def test_bad_charclass3(self): r = Regex.get_parse_tree(r"[\010-\020]") print("\n".join(fmttree(r))) print(r.children[0].chars) errs = [] check_charclass_homogeneous_ranges(r, errs) print(errs) self.assertEqual(len(errs), 1)
def test_good_unicode_charclass(self): r = Regex.get_parse_tree(u"[\u1000-\uffff]") print("\n".join(fmttree(r))) print(r.children[0].chars) errs = [] check_charclass_homogeneous_ranges(r, errs) print(errs) self.assertEqual(len(errs), 0)
def test_dash_ends_charclass(self): r = Regex.get_parse_tree(r"[_-]") print("\n".join(fmttree(r))) print(r.children[0].chars) errs = [] check_charclass_homogeneous_ranges(r, errs) print(errs) self.assertEqual(len(errs), 0) self.assertEqual(len(r.children[0].chars), 2) self.assertEqual(r.children[0].chars[0].data, "_") self.assertEqual(r.children[0].chars[1].data, "-")
def test_dash_after_range_charclass(self): r = Regex.get_parse_tree(r"[0-9-_]") print("\n".join(fmttree(r))) print(r.children[0].chars) errs = [] check_charclass_homogeneous_ranges(r, errs) print(errs) self.assertEqual(len(errs), 0) self.assertEqual(len(r.children[0].chars), 3) self.assertEqual(r.children[0].chars[0].a.data, "0") self.assertEqual(r.children[0].chars[0].b.data, "9") self.assertEqual(r.children[0].chars[1].data, "-") self.assertEqual(r.children[0].chars[2].data, "_")
def test_good_charclass_hex(self): r = Regex.get_parse_tree(r"[\x00-\xff]") print("\n".join(fmttree(r))) errs = [] check_charclass_homogeneous_ranges(r, errs) self.assertEqual(len(errs), 0)