lix/tests/lang/eval-okay-replacestrings.nix
Tuomas Tynkkynen 4ea9707591 libexpr: Fix prim_replaceStrings() to work on an empty source string
Otherwise, running e.g.

nix-instantiate --eval -E --strict 'builtins.replaceStrings [""] ["X"] "abc"'

would just hang in an infinite loop.

Found by afl-fuzz.
2018-02-19 23:20:26 +02:00

11 lines
307 B
Nix

with builtins;
[ (replaceStrings ["o"] ["a"] "foobar")
(replaceStrings ["o"] [""] "foobar")
(replaceStrings ["oo"] ["u"] "foobar")
(replaceStrings ["oo" "a"] ["a" "oo"] "foobar")
(replaceStrings ["oo" "oo"] ["u" "i"] "foobar")
(replaceStrings [""] ["X"] "abc")
(replaceStrings [""] ["X"] "")
]