MCPcopy Create free account
hub / github.com/idank/explainshell / test_nested_option

Method test_nested_option

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

Source from the content-addressed store, hash-verified

427 self.assertEqual(groups[2].results, matchedresult[1])
428
429 def test_nested_option(self):
430 cmd = "withargs -b arg -exec bar -a EOF -b arg"
431
432 matchedresult = [
433 [
434 MR(0, 8, "withargs synopsis", "withargs"),
435 MR(9, 15, "-b <arg> desc", "-b arg"),
436 MR(16, 21, "-exec nest", "-exec"),
437 MR(29, 32, "-exec nest", "EOF"),
438 MR(33, 39, "-b <arg> desc", "-b arg"),
439 ],
440 [MR(22, 25, "bar synopsis", "bar"), MR(26, 28, "-a desc", "-a")],
441 ]
442
443 groups = matcher.Matcher(cmd, s).match()
444 self.assertEqual(len(groups), 3)
445 self.assertEqual(groups[0].results, [])
446 self.assertEqual(groups[1].results, matchedresult[0])
447 self.assertEqual(groups[2].results, matchedresult[1])
448
449 cmd = "withargs -b arg -exec bar -a ';' -a"
450
451 matchedresult = [
452 [
453 MR(0, 8, "withargs synopsis", "withargs"),
454 MR(9, 15, "-b <arg> desc", "-b arg"),
455 MR(16, 21, "-exec nest", "-exec"),
456 MR(29, 32, "-exec nest", "';'"),
457 MR(33, 35, "-a desc", "-a"),
458 ],
459 [MR(22, 25, "bar synopsis", "bar"), MR(26, 28, "-a desc", "-a")],
460 ]
461
462 groups = matcher.Matcher(cmd, s).match()
463 self.assertEqual(len(groups), 3)
464 self.assertEqual(groups[0].results, [])
465 self.assertEqual(groups[1].results, matchedresult[0])
466 self.assertEqual(groups[2].results, matchedresult[1])
467
468 cmd = "withargs -b arg -exec bar -a \\; -a"
469
470 matchedresult = [
471 [
472 MR(0, 8, "withargs synopsis", "withargs"),
473 MR(9, 15, "-b <arg> desc", "-b arg"),
474 MR(16, 21, "-exec nest", "-exec"),
475 MR(29, 31, "-exec nest", "\\;"),
476 MR(32, 34, "-a desc", "-a"),
477 ],
478 [MR(22, 25, "bar synopsis", "bar"), MR(26, 28, "-a desc", "-a")],
479 ]
480
481 groups = matcher.Matcher(cmd, s).match()
482 self.assertEqual(len(groups), 3)
483 self.assertEqual(groups[0].results, [])
484 self.assertEqual(groups[1].results, matchedresult[0])
485 self.assertEqual(groups[2].results, matchedresult[1])
486

Callers

nothing calls this directly

Calls 1

matchMethod · 0.80

Tested by

no test coverage detected