| 721 | ) |
| 722 | |
| 723 | def test_if(self): |
| 724 | cmd = "if bar -a; then b; fi" |
| 725 | shellresults = [ |
| 726 | MR(0, 2, help_constants._if, "if"), |
| 727 | MR(9, 15, help_constants._if, "; then"), |
| 728 | MR(17, 21, help_constants._if, "; fi"), |
| 729 | ] |
| 730 | |
| 731 | matchresults = [ |
| 732 | [MR(3, 6, "bar synopsis", "bar"), MR(7, 9, "-a desc", "-a")], |
| 733 | [MR(16, 17, None, "b")], |
| 734 | ] |
| 735 | |
| 736 | groups = matcher.Matcher(cmd, s).match() |
| 737 | self.assertEqual(len(groups), 3) |
| 738 | self.assertEqual(groups[0].results, shellresults) |
| 739 | self.assertEqual(groups[1].results, matchresults[0]) |
| 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" |