aboutsummaryrefslogtreecommitdiff
path: root/tests/functional/lang/eval-okay-substring-context.nix
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-04 08:06:36 +0100
committereldritch horrors <pennae@lix.systems>2024-03-04 08:06:36 +0100
commit2c85fcce875404f07ce29f7a2bb2ed970d2d5840 (patch)
tree9acac9daa113e8c98720bb10e59a6eacec2b25da /tests/functional/lang/eval-okay-substring-context.nix
parent64b077cdaa325d7ae3bd7fe5f84e1247f1298a4d (diff)
Merge pull request #9747 from awakesecurity/mz/fix-quadratic-splitString
Fix performance of builtins.substring for empty substrings (cherry picked from commit b2deff1947c2fe57fdbf1a472eb9003eb407f8d3) Change-Id: I4ddfc8d26a4781c9520fff9807849a073ee7bed8
Diffstat (limited to 'tests/functional/lang/eval-okay-substring-context.nix')
-rw-r--r--tests/functional/lang/eval-okay-substring-context.nix11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/functional/lang/eval-okay-substring-context.nix b/tests/functional/lang/eval-okay-substring-context.nix
new file mode 100644
index 000000000..d0ef70d4e
--- /dev/null
+++ b/tests/functional/lang/eval-okay-substring-context.nix
@@ -0,0 +1,11 @@
+with builtins;
+
+let
+
+ s = "${builtins.derivation { name = "test"; builder = "/bin/sh"; system = "x86_64-linux"; }}";
+
+in
+
+if getContext s == getContext "${substring 0 0 s + unsafeDiscardStringContext s}"
+then "okay"
+else throw "empty substring should preserve context"