MCPcopy
hub / github.com/idank/explainshell / test_functions

Method test_functions

tests/test_matcher.py:825–855  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

823 self.assertEqual(v.maxdepth, 1)
824
825 def test_functions(self):
826 cmd = "function a() { bar; }"
827 shellresults = [
828 MR(0, 14, help_constants._function, "function a() {"),
829 MR(18, 19, help_constants.OPSEMICOLON, ";"),
830 MR(20, 21, help_constants._function, "}"),
831 ]
832
833 matchresults = [MR(15, 18, "bar synopsis", "bar")]
834
835 groups = matcher.Matcher(cmd, s).match()
836 self.assertEqual(len(groups), 2)
837 self.assertEqual(groups[0].results, shellresults)
838 self.assertEqual(groups[1].results, matchresults)
839
840 cmd = 'function a() { bar "$(a)"; }'
841 shellresults = [
842 MR(0, 14, help_constants._function, "function a() {"),
843 MR(25, 26, help_constants.OPSEMICOLON, ";"),
844 MR(27, 28, help_constants._function, "}"),
845 ]
846
847 matchresults = [MR(15, 18, "bar synopsis", "bar"), MR(19, 25, None, '"$(a)"')]
848
849 m = matcher.Matcher(cmd, s)
850 groups = m.match()
851
852 self.assertEqual(len(groups), 2)
853 self.assertEqual(groups[0].results, shellresults)
854 self.assertEqual(groups[1].results, matchresults)
855 self.assertEqual(m.expansions, [(22, 23, "substitution")])
856
857 def test_function_reference(self):
858 cmd = "function a() { bar; a b; }; a"

Callers

nothing calls this directly

Calls 1

matchMethod · 0.95

Tested by

no test coverage detected