MCPcopy Index your code
hub / github.com/idank/explainshell / test_comsub

Method test_comsub

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

Source from the content-addressed store, hash-verified

634 self.assertEqual(groups[1].results, matchedresult[1])
635
636 def test_comsub(self):
637 cmd = "bar $(a) -b \"b $(c) `c`\" '$(d)' >$(e) `f`"
638
639 matchedresult = [
640 MR(0, 3, "bar synopsis", "bar"),
641 MR(4, 8, None, "$(a)"),
642 MR(9, 24, "-b <arg> desc", '-b "b $(c) `c`"'),
643 MR(25, 31, None, "'$(d)'"),
644 MR(38, 41, None, "`f`"),
645 ]
646 shellresult = [
647 MR(
648 32,
649 37,
650 help_constants.REDIRECTION
651 + "\n\n"
652 + help_constants.REDIRECTION_KIND[">"],
653 ">$(e)",
654 )
655 ]
656
657 m = matcher.Matcher(cmd, s)
658 groups = m.match()
659 self.assertEqual(groups[0].results, shellresult)
660 self.assertEqual(groups[1].results, matchedresult)
661
662 # check expansions
663 self.assertEqual(
664 m.expansions,
665 [
666 (6, 7, "substitution"),
667 (17, 18, "substitution"),
668 (21, 22, "substitution"),
669 (35, 36, "substitution"),
670 (39, 40, "substitution"),
671 ],
672 )
673
674 def test_comsub_as_arg(self):
675 cmd = "withargs $(a) $0"

Callers

nothing calls this directly

Calls 1

matchMethod · 0.95

Tested by

no test coverage detected