def test_out_of_order_alternation_with_anchor_after(self): r = Regex.get_parse_tree(r"(a|ab)\b") print("\n".join(fmttree(r))) errs = [] check_prefix_ordering(r, errs) print(errs) self.assertEqual(len(errs), 0)
def test_out_of_order_crazy_complicated(self): r = Regex.get_parse_tree(r"""(!=|#|&&|&|\(|\)|\*|\+|,|-|-\.)""") # |->|\.|\.\.|::|:=|:>|:|;;|;|<|<-|=|>|>]|>}|\?|\?\?|\[|\[<|\[>|\[\||]|_|`|{|{<|\||\|]|}|~)''') print("\n".join(fmttree(r))) errs = [] check_prefix_ordering(r, errs) self.assertEqual(len(errs), 1)
def test_out_of_order_alternation_location(self): r = Regex.get_parse_tree(r"(foo|bar|@|@@)") print("\n".join(fmttree(r))) errs = [] check_prefix_ordering(r, errs) self.assertEqual(len(errs), 1) # location of the second one. self.assertEqual(errs[0][2], 11)
def test_out_of_order_alternation_longer(self): r = Regex.get_parse_tree(r"(a|ab|c)") print("\n".join(fmttree(r))) errs = [] check_prefix_ordering(r, errs) self.assertEqual(len(errs), 1)