about summary refs log blame commit diff
path: root/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-replace-strings-propagate-catchable.nix
blob: ad9734ba9aee6c4af80dbba8bd3c6b26dbec3853 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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"))
]