@@ -61,6 +61,18 @@ def test_walk_fsm(function):
61
61
res = tuple (function (regex_fsm , "0" , 1 , full_match = True ))
62
62
assert res == tuple ()
63
63
64
+ regex_pattern = interegular .parse_pattern ("0|[1-9][2-9]+" )
65
+ regex_fsm , _ = make_deterministic_fsm (regex_pattern .to_fsm ().reduce ())
66
+
67
+ res = tuple (function (regex_fsm , "1" , regex_fsm .initial , full_match = True ))
68
+ assert res == tuple ()
69
+
70
+ res = tuple (function (regex_fsm , "1" , regex_fsm .initial , full_match = False ))
71
+ assert res == (2 ,)
72
+
73
+ res = tuple (function (regex_fsm , "12" , regex_fsm .initial , full_match = True ))
74
+ assert res == (2 , 3 )
75
+
64
76
pattern = interegular .parse_pattern (r"(?:[^\W\d]\w*|[\t \x0c]+)" )
65
77
fsm , _ = make_deterministic_fsm (pattern .to_fsm ().reduce ())
66
78
@@ -90,19 +102,19 @@ def to_python(res):
90
102
91
103
res = to_python (find_partial_matches (def_fsm , "def" ))
92
104
assert res == {(2 , (0 , 1 , 2 , 3 ))}
93
- res = to_python (find_partial_matches (def_fsm , "de" ))
105
+ res = to_python (find_partial_matches (def_fsm , "de" , full_match = False ))
94
106
assert res == {(1 , (0 , 1 , 2 ))}
95
- res = to_python (find_partial_matches (def_fsm , "d" ))
107
+ res = to_python (find_partial_matches (def_fsm , "d" , full_match = False ))
96
108
assert res == {(0 , (0 , 1 ))}
97
109
res = to_python (find_partial_matches (def_fsm , "" ))
98
110
assert res == set ()
99
111
res = to_python (find_partial_matches (def_fsm , "df" ))
100
112
assert res == set ()
101
- res = to_python (find_partial_matches (def_fsm , "ef" ))
113
+ res = to_python (find_partial_matches (def_fsm , "ef" , full_match = False ))
102
114
assert res == {(1 , (1 , 2 , 3 ))}
103
- res = to_python (find_partial_matches (def_fsm , "e" ))
115
+ res = to_python (find_partial_matches (def_fsm , "e" , full_match = False ))
104
116
assert res == {(0 , (1 , 2 ))}
105
- res = to_python (find_partial_matches (def_fsm , "f" ))
117
+ res = to_python (find_partial_matches (def_fsm , "f" , full_match = False ))
106
118
assert res == {(0 , (2 , 3 ))}
107
119
res = to_python (find_partial_matches (def_fsm , "ef foo" , full_match = False ))
108
120
assert res == {(1 , (1 , 2 , 3 ))}
@@ -112,7 +124,7 @@ def to_python(res):
112
124
assert res == {(2 , (0 , 1 , 2 , 3 ))}
113
125
114
126
# `NAME` can have multiple start states for this input
115
- res = to_python (find_partial_matches (name_fsm , "d" ))
127
+ res = to_python (find_partial_matches (name_fsm , "d" , full_match = False ))
116
128
assert res == {(0 , (0 , 1 )), (0 , (1 , 1 ))}
117
129
# Not this case
118
130
res = to_python (find_partial_matches (name_fsm , "1d" ))
@@ -133,7 +145,7 @@ def to_python(res):
133
145
134
146
float_fsm = float_fsm .fsm_info
135
147
136
- res = to_python (find_partial_matches (float_fsm , "." ))
148
+ res = to_python (find_partial_matches (float_fsm , "." , full_match = False ))
137
149
assert res == {(0 , (3 , 5 )), (0 , (4 , 5 )), (0 , (0 , 2 ))}
138
150
139
151
joins_fsm , _ = make_deterministic_fsm (
0 commit comments