Skip to content

Commit 8029c5b

Browse files
committed
Add test
1 parent 376ebcb commit 8029c5b

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests/test_type_eval.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,24 @@ def test_type_strings_6():
221221
assert d == Literal["bcd"]
222222

223223

224+
type ReplacePrefix[S: str, P: str, N: str] = If[
225+
Equals[StrSlice[S, 0, Length[P]], P],
226+
StrConcat[N, StrSlice[S, 2, Literal[None]]],
227+
S,
228+
]
229+
230+
231+
def test_type_strings_7():
232+
d = eval_typing(
233+
ReplacePrefix[Literal["x_a"], Literal["x_"], Literal["hi_"]]
234+
)
235+
assert d == Literal["hi_a"]
236+
d = eval_typing(
237+
ReplacePrefix[Literal["x_a"], Literal["y_"], Literal["hi_"]]
238+
)
239+
assert d == Literal["x_a"]
240+
241+
224242
def _is_generic_permutation(t1, t2):
225243
return t1.__origin__ == t2.__origin__ and collections.Counter(
226244
t1.__args__

0 commit comments

Comments
 (0)