| 740 | self.assertEqual(groups[2].results, matchresults[1]) |
| 741 | |
| 742 | def test_nested_controlflows(self): |
| 743 | cmd = "for a; do while bar; do baz; done; done" |
| 744 | shellresults = [ |
| 745 | MR(0, 9, help_constants._for, "for a; do"), |
| 746 | MR(10, 15, help_constants._whileuntil, "while"), |
| 747 | MR(19, 23, help_constants._whileuntil, "; do"), |
| 748 | MR(27, 33, help_constants._whileuntil, "; done"), |
| 749 | MR(33, 39, help_constants._for, "; done"), |
| 750 | ] |
| 751 | |
| 752 | matchresults = [ |
| 753 | [MR(16, 19, "bar synopsis", "bar")], |
| 754 | [MR(24, 27, "baz synopsis", "baz")], |
| 755 | ] |
| 756 | |
| 757 | groups = matcher.Matcher(cmd, s).match() |
| 758 | self.assertEqual(len(groups), 3) |
| 759 | self.assertEqual(groups[0].results, shellresults) |
| 760 | self.assertEqual(groups[1].results, matchresults[0]) |
| 761 | self.assertEqual(groups[2].results, matchresults[1]) |
| 762 | |
| 763 | def test_for_expansion(self): |
| 764 | cmd = "for a in $(bar); do baz; done" |