From 7b1632ec71cc56dffa6eeca90fdf122331a5065f Mon Sep 17 00:00:00 2001 From: Ryan Lahfa Date: Sun, 14 Jan 2024 04:07:33 +0100 Subject: feat(tvix/eval): strengthen significantly catchable test suite Adds a bunch (notably certain overlapping) tests for catchable situations. This should cover many scenarios, argument is catchable, element in argument is catchable, function returns catchable in the middle of the processing, etc. Co-authored-by: Aspen Smith Change-Id: Icd722cf8dbc91a24f45cd540a328711e5826f76c Reviewed-on: https://cl.tvl.fyi/c/depot/+/10621 Reviewed-by: aspen Tested-by: BuildkiteCI --- ...okay-builtins-replace-strings-propagate-catchable.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-builtins-replace-strings-propagate-catchable.nix (limited to 'tvix/eval/src/tests/tvix_tests/eval-okay-builtins-replace-strings-propagate-catchable.nix') 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")) +] -- cgit 1.4.1