about summary refs log tree commit diff
path: root/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-replace-strings-propagate-catchable.nix
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/tests/tvix_tests/eval-okay-builtins-replace-strings-propagate-catchable.nix')
-rw-r--r--tvix/eval/src/tests/tvix_tests/eval-okay-builtins-replace-strings-propagate-catchable.nix16
1 files changed, 16 insertions, 0 deletions
diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-replace-strings-propagate-catchable.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-replace-strings-propagate-catchable.nix
new file mode 100644
index 0000000000..ad9734ba9a
--- /dev/null
+++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-replace-strings-propagate-catchable.nix
@@ -0,0 +1,16 @@
+map (e: (builtins.tryEval e).success) [
+  # This one may be hard to read for non-experts.
+  # Replace strings is a special built-in compared to others in the sense
+  # it might attempt to lazily evaluate things upon successful replacements,
+  # so it would not be surprising that some of the non-replacements which could throw
+  # could be ignored by laziness. It is not the case though.
+  (builtins.replaceStrings [ "a" (builtins.throw "b") ] [ "c" "d" ] "ab")
+  (builtins.replaceStrings [ "a" (builtins.throw "b") ] [ "c" "d" ] "a")
+  (builtins.replaceStrings [ "a" "b" ] [ "c" (builtins.throw "d") ] "a")
+  (builtins.replaceStrings [ "a" "b" ] [ "c" (builtins.throw "d") ] "ab")
+  (builtins.replaceStrings [ "" ] [ (builtins.throw "d") ] "ab")
+  (builtins.replaceStrings [ "a" "" ] [ "b" (builtins.throw "d") ] "ab")
+  (builtins.replaceStrings (builtins.throw "z") [ ] "ab")
+  (builtins.replaceStrings [ ] (builtins.throw "z") "ab")
+  (builtins.replaceStrings [ ] [ ] (builtins.throw "z"))
+]