diff options
Diffstat (limited to 'test/testdata')
460 files changed, 4363 insertions, 0 deletions
diff --git a/test/testdata/binary-data b/test/testdata/binary-data new file mode 100644 index 0000000..06d7405 --- /dev/null +++ b/test/testdata/binary-data | |||
Binary files differ | |||
diff --git a/test/testdata/data b/test/testdata/data new file mode 100644 index 0000000..257cc56 --- /dev/null +++ b/test/testdata/data | |||
@@ -0,0 +1 @@ | |||
foo | |||
diff --git a/test/testdata/dir1/a.nix b/test/testdata/dir1/a.nix new file mode 100644 index 0000000..231f150 --- /dev/null +++ b/test/testdata/dir1/a.nix | |||
@@ -0,0 +1 @@ | |||
"a" | |||
diff --git a/test/testdata/dir2/a.nix b/test/testdata/dir2/a.nix new file mode 100644 index 0000000..170df52 --- /dev/null +++ b/test/testdata/dir2/a.nix | |||
@@ -0,0 +1 @@ | |||
"X" | |||
diff --git a/test/testdata/dir2/b.nix b/test/testdata/dir2/b.nix new file mode 100644 index 0000000..19010cc --- /dev/null +++ b/test/testdata/dir2/b.nix | |||
@@ -0,0 +1 @@ | |||
"b" | |||
diff --git a/test/testdata/dir3/a.nix b/test/testdata/dir3/a.nix new file mode 100644 index 0000000..170df52 --- /dev/null +++ b/test/testdata/dir3/a.nix | |||
@@ -0,0 +1 @@ | |||
"X" | |||
diff --git a/test/testdata/dir3/b.nix b/test/testdata/dir3/b.nix new file mode 100644 index 0000000..170df52 --- /dev/null +++ b/test/testdata/dir3/b.nix | |||
@@ -0,0 +1 @@ | |||
"X" | |||
diff --git a/test/testdata/dir3/c.nix b/test/testdata/dir3/c.nix new file mode 100644 index 0000000..cdf1585 --- /dev/null +++ b/test/testdata/dir3/c.nix | |||
@@ -0,0 +1 @@ | |||
"c" | |||
diff --git a/test/testdata/dir4/a.nix b/test/testdata/dir4/a.nix new file mode 100644 index 0000000..170df52 --- /dev/null +++ b/test/testdata/dir4/a.nix | |||
@@ -0,0 +1 @@ | |||
"X" | |||
diff --git a/test/testdata/dir4/c.nix b/test/testdata/dir4/c.nix new file mode 100644 index 0000000..170df52 --- /dev/null +++ b/test/testdata/dir4/c.nix | |||
@@ -0,0 +1 @@ | |||
"X" | |||
diff --git a/test/testdata/eval-fail-abort.err.exp b/test/testdata/eval-fail-abort.err.exp new file mode 100644 index 0000000..20e7b9e --- /dev/null +++ b/test/testdata/eval-fail-abort.err.exp | |||
@@ -0,0 +1,8 @@ | |||
1 | error: | ||
2 | … while calling the 'abort' builtin | ||
3 | at /pwd/lang/eval-fail-abort.nix:1:14: | ||
4 | 1| if true then abort "this should fail" else 1 | ||
5 | | ^ | ||
6 | 2| | ||
7 | |||
8 | error: evaluation aborted with the following error message: 'this should fail' | ||
diff --git a/test/testdata/eval-fail-abort.nix b/test/testdata/eval-fail-abort.nix new file mode 100644 index 0000000..75c51bc --- /dev/null +++ b/test/testdata/eval-fail-abort.nix | |||
@@ -0,0 +1 @@ | |||
if true then abort "this should fail" else 1 | |||
diff --git a/test/testdata/eval-fail-addDrvOutputDependencies-empty-context.err.exp b/test/testdata/eval-fail-addDrvOutputDependencies-empty-context.err.exp new file mode 100644 index 0000000..37e0bd9 --- /dev/null +++ b/test/testdata/eval-fail-addDrvOutputDependencies-empty-context.err.exp | |||
@@ -0,0 +1,8 @@ | |||
1 | error: | ||
2 | … while calling the 'addDrvOutputDependencies' builtin | ||
3 | at /pwd/lang/eval-fail-addDrvOutputDependencies-empty-context.nix:1:1: | ||
4 | 1| builtins.addDrvOutputDependencies "" | ||
5 | | ^ | ||
6 | 2| | ||
7 | |||
8 | error: context of string '' must have exactly one element, but has 0 | ||
diff --git a/test/testdata/eval-fail-addDrvOutputDependencies-empty-context.nix b/test/testdata/eval-fail-addDrvOutputDependencies-empty-context.nix new file mode 100644 index 0000000..dc9ee3b --- /dev/null +++ b/test/testdata/eval-fail-addDrvOutputDependencies-empty-context.nix | |||
@@ -0,0 +1 @@ | |||
builtins.addDrvOutputDependencies "" | |||
diff --git a/test/testdata/eval-fail-addDrvOutputDependencies-multi-elem-context.err.exp b/test/testdata/eval-fail-addDrvOutputDependencies-multi-elem-context.err.exp new file mode 100644 index 0000000..6828e03 --- /dev/null +++ b/test/testdata/eval-fail-addDrvOutputDependencies-multi-elem-context.err.exp | |||
@@ -0,0 +1,9 @@ | |||
1 | error: | ||
2 | … while calling the 'addDrvOutputDependencies' builtin | ||
3 | at /pwd/lang/eval-fail-addDrvOutputDependencies-multi-elem-context.nix:18:4: | ||
4 | 17| | ||
5 | 18| in builtins.addDrvOutputDependencies combo-path | ||
6 | | ^ | ||
7 | 19| | ||
8 | |||
9 | error: context of string '/nix/store/pg9yqs4yd85yhdm3f4i5dyaqp5jahrsz-fail.drv/nix/store/2dxd5frb715z451vbf7s8birlf3argbk-fail-2.drv' must have exactly one element, but has 2 | ||
diff --git a/test/testdata/eval-fail-addDrvOutputDependencies-multi-elem-context.nix b/test/testdata/eval-fail-addDrvOutputDependencies-multi-elem-context.nix new file mode 100644 index 0000000..dbde264 --- /dev/null +++ b/test/testdata/eval-fail-addDrvOutputDependencies-multi-elem-context.nix | |||
@@ -0,0 +1,18 @@ | |||
1 | let | ||
2 | drv0 = derivation { | ||
3 | name = "fail"; | ||
4 | builder = "/bin/false"; | ||
5 | system = "x86_64-linux"; | ||
6 | outputs = [ "out" "foo" ]; | ||
7 | }; | ||
8 | |||
9 | drv1 = derivation { | ||
10 | name = "fail-2"; | ||
11 | builder = "/bin/false"; | ||
12 | system = "x86_64-linux"; | ||
13 | outputs = [ "out" "foo" ]; | ||
14 | }; | ||
15 | |||
16 | combo-path = "${drv0.drvPath}${drv1.drvPath}"; | ||
17 | |||
18 | in builtins.addDrvOutputDependencies combo-path | ||
diff --git a/test/testdata/eval-fail-addDrvOutputDependencies-wrong-element-kind.err.exp b/test/testdata/eval-fail-addDrvOutputDependencies-wrong-element-kind.err.exp new file mode 100644 index 0000000..72b5e63 --- /dev/null +++ b/test/testdata/eval-fail-addDrvOutputDependencies-wrong-element-kind.err.exp | |||
@@ -0,0 +1,9 @@ | |||
1 | error: | ||
2 | … while calling the 'addDrvOutputDependencies' builtin | ||
3 | at /pwd/lang/eval-fail-addDrvOutputDependencies-wrong-element-kind.nix:9:4: | ||
4 | 8| | ||
5 | 9| in builtins.addDrvOutputDependencies drv.outPath | ||
6 | | ^ | ||
7 | 10| | ||
8 | |||
9 | error: `addDrvOutputDependencies` can only act on derivations, not on a derivation output such as 'out' | ||
diff --git a/test/testdata/eval-fail-addDrvOutputDependencies-wrong-element-kind.nix b/test/testdata/eval-fail-addDrvOutputDependencies-wrong-element-kind.nix new file mode 100644 index 0000000..e379e1d --- /dev/null +++ b/test/testdata/eval-fail-addDrvOutputDependencies-wrong-element-kind.nix | |||
@@ -0,0 +1,9 @@ | |||
1 | let | ||
2 | drv = derivation { | ||
3 | name = "fail"; | ||
4 | builder = "/bin/false"; | ||
5 | system = "x86_64-linux"; | ||
6 | outputs = [ "out" "foo" ]; | ||
7 | }; | ||
8 | |||
9 | in builtins.addDrvOutputDependencies drv.outPath | ||
diff --git a/test/testdata/eval-fail-addErrorContext-example.err.exp b/test/testdata/eval-fail-addErrorContext-example.err.exp new file mode 100644 index 0000000..4fad8f5 --- /dev/null +++ b/test/testdata/eval-fail-addErrorContext-example.err.exp | |||
@@ -0,0 +1,24 @@ | |||
1 | error: | ||
2 | … while counting down; n = 10 | ||
3 | |||
4 | … while counting down; n = 9 | ||
5 | |||
6 | … while counting down; n = 8 | ||
7 | |||
8 | … while counting down; n = 7 | ||
9 | |||
10 | … while counting down; n = 6 | ||
11 | |||
12 | … while counting down; n = 5 | ||
13 | |||
14 | … while counting down; n = 4 | ||
15 | |||
16 | … while counting down; n = 3 | ||
17 | |||
18 | … while counting down; n = 2 | ||
19 | |||
20 | … while counting down; n = 1 | ||
21 | |||
22 | (stack trace truncated; use '--show-trace' to show the full, detailed trace) | ||
23 | |||
24 | error: kaboom | ||
diff --git a/test/testdata/eval-fail-addErrorContext-example.flags b/test/testdata/eval-fail-addErrorContext-example.flags new file mode 100644 index 0000000..9b1f645 --- /dev/null +++ b/test/testdata/eval-fail-addErrorContext-example.flags | |||
@@ -0,0 +1 @@ | |||
--eval --strict --no-show-trace | |||
diff --git a/test/testdata/eval-fail-addErrorContext-example.nix b/test/testdata/eval-fail-addErrorContext-example.nix new file mode 100644 index 0000000..996b246 --- /dev/null +++ b/test/testdata/eval-fail-addErrorContext-example.nix | |||
@@ -0,0 +1,9 @@ | |||
1 | let | ||
2 | countDown = n: | ||
3 | if n == 0 | ||
4 | then throw "kaboom" | ||
5 | else | ||
6 | builtins.addErrorContext | ||
7 | "while counting down; n = ${toString n}" | ||
8 | ("x" + countDown (n - 1)); | ||
9 | in countDown 10 | ||
diff --git a/test/testdata/eval-fail-assert-equal-attrs-names-2.err.exp b/test/testdata/eval-fail-assert-equal-attrs-names-2.err.exp new file mode 100644 index 0000000..4b68d97 --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-attrs-names-2.err.exp | |||
@@ -0,0 +1,8 @@ | |||
1 | error: | ||
2 | … while evaluating the condition of the assertion '({ a = true; } == { a = true; b = true; })' | ||
3 | at /pwd/lang/eval-fail-assert-equal-attrs-names-2.nix:1:1: | ||
4 | 1| assert { a = true; } == { a = true; b = true; }; | ||
5 | | ^ | ||
6 | 2| throw "unreachable" | ||
7 | |||
8 | error: attribute names of attribute set '{ a = true; }' differs from attribute set '{ a = true; b = true; }' | ||
diff --git a/test/testdata/eval-fail-assert-equal-attrs-names-2.nix b/test/testdata/eval-fail-assert-equal-attrs-names-2.nix new file mode 100644 index 0000000..8e7ac9c --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-attrs-names-2.nix | |||
@@ -0,0 +1,2 @@ | |||
1 | assert { a = true; } == { a = true; b = true; }; | ||
2 | throw "unreachable" | ||
diff --git a/test/testdata/eval-fail-assert-equal-attrs-names.err.exp b/test/testdata/eval-fail-assert-equal-attrs-names.err.exp new file mode 100644 index 0000000..bc61ca6 --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-attrs-names.err.exp | |||
@@ -0,0 +1,8 @@ | |||
1 | error: | ||
2 | … while evaluating the condition of the assertion '({ a = true; b = true; } == { a = true; })' | ||
3 | at /pwd/lang/eval-fail-assert-equal-attrs-names.nix:1:1: | ||
4 | 1| assert { a = true; b = true; } == { a = true; }; | ||
5 | | ^ | ||
6 | 2| throw "unreachable" | ||
7 | |||
8 | error: attribute names of attribute set '{ a = true; b = true; }' differs from attribute set '{ a = true; }' | ||
diff --git a/test/testdata/eval-fail-assert-equal-attrs-names.nix b/test/testdata/eval-fail-assert-equal-attrs-names.nix new file mode 100644 index 0000000..e2f53a8 --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-attrs-names.nix | |||
@@ -0,0 +1,2 @@ | |||
1 | assert { a = true; b = true; } == { a = true; }; | ||
2 | throw "unreachable" | ||
diff --git a/test/testdata/eval-fail-assert-equal-derivations-extra.err.exp b/test/testdata/eval-fail-assert-equal-derivations-extra.err.exp new file mode 100644 index 0000000..7f49240 --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-derivations-extra.err.exp | |||
@@ -0,0 +1,26 @@ | |||
1 | error: | ||
2 | … while evaluating the condition of the assertion '({ foo = { outPath = "/nix/store/0"; type = "derivation"; }; } == { foo = { devious = true; outPath = "/nix/store/1"; type = "derivation"; }; })' | ||
3 | at /pwd/lang/eval-fail-assert-equal-derivations-extra.nix:1:1: | ||
4 | 1| assert | ||
5 | | ^ | ||
6 | 2| { foo = { type = "derivation"; outPath = "/nix/store/0"; }; } | ||
7 | |||
8 | … while comparing attribute 'foo' | ||
9 | |||
10 | … where left hand side is | ||
11 | at /pwd/lang/eval-fail-assert-equal-derivations-extra.nix:2:5: | ||
12 | 1| assert | ||
13 | 2| { foo = { type = "derivation"; outPath = "/nix/store/0"; }; } | ||
14 | | ^ | ||
15 | 3| == | ||
16 | |||
17 | … where right hand side is | ||
18 | at /pwd/lang/eval-fail-assert-equal-derivations-extra.nix:4:5: | ||
19 | 3| == | ||
20 | 4| { foo = { type = "derivation"; outPath = "/nix/store/1"; devious = true; }; }; | ||
21 | | ^ | ||
22 | 5| throw "unreachable" | ||
23 | |||
24 | … while comparing a derivation by its 'outPath' attribute | ||
25 | |||
26 | error: string '"/nix/store/0"' is not equal to string '"/nix/store/1"' | ||
diff --git a/test/testdata/eval-fail-assert-equal-derivations-extra.nix b/test/testdata/eval-fail-assert-equal-derivations-extra.nix new file mode 100644 index 0000000..fd8bc3f --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-derivations-extra.nix | |||
@@ -0,0 +1,5 @@ | |||
1 | assert | ||
2 | { foo = { type = "derivation"; outPath = "/nix/store/0"; }; } | ||
3 | == | ||
4 | { foo = { type = "derivation"; outPath = "/nix/store/1"; devious = true; }; }; | ||
5 | throw "unreachable" \ No newline at end of file | ||
diff --git a/test/testdata/eval-fail-assert-equal-derivations.err.exp b/test/testdata/eval-fail-assert-equal-derivations.err.exp new file mode 100644 index 0000000..d7f0fac --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-derivations.err.exp | |||
@@ -0,0 +1,26 @@ | |||
1 | error: | ||
2 | … while evaluating the condition of the assertion '({ foo = { ignored = (abort "not ignored"); outPath = "/nix/store/0"; type = "derivation"; }; } == { foo = { ignored = (abort "not ignored"); outPath = "/nix/store/1"; type = "derivation"; }; })' | ||
3 | at /pwd/lang/eval-fail-assert-equal-derivations.nix:1:1: | ||
4 | 1| assert | ||
5 | | ^ | ||
6 | 2| { foo = { type = "derivation"; outPath = "/nix/store/0"; ignored = abort "not ignored"; }; } | ||
7 | |||
8 | … while comparing attribute 'foo' | ||
9 | |||
10 | … where left hand side is | ||
11 | at /pwd/lang/eval-fail-assert-equal-derivations.nix:2:5: | ||
12 | 1| assert | ||
13 | 2| { foo = { type = "derivation"; outPath = "/nix/store/0"; ignored = abort "not ignored"; }; } | ||
14 | | ^ | ||
15 | 3| == | ||
16 | |||
17 | … where right hand side is | ||
18 | at /pwd/lang/eval-fail-assert-equal-derivations.nix:4:5: | ||
19 | 3| == | ||
20 | 4| { foo = { type = "derivation"; outPath = "/nix/store/1"; ignored = abort "not ignored"; }; }; | ||
21 | | ^ | ||
22 | 5| throw "unreachable" | ||
23 | |||
24 | … while comparing a derivation by its 'outPath' attribute | ||
25 | |||
26 | error: string '"/nix/store/0"' is not equal to string '"/nix/store/1"' | ||
diff --git a/test/testdata/eval-fail-assert-equal-derivations.nix b/test/testdata/eval-fail-assert-equal-derivations.nix new file mode 100644 index 0000000..c648eae --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-derivations.nix | |||
@@ -0,0 +1,5 @@ | |||
1 | assert | ||
2 | { foo = { type = "derivation"; outPath = "/nix/store/0"; ignored = abort "not ignored"; }; } | ||
3 | == | ||
4 | { foo = { type = "derivation"; outPath = "/nix/store/1"; ignored = abort "not ignored"; }; }; | ||
5 | throw "unreachable" \ No newline at end of file | ||
diff --git a/test/testdata/eval-fail-assert-equal-floats.err.exp b/test/testdata/eval-fail-assert-equal-floats.err.exp new file mode 100644 index 0000000..d8545e2 --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-floats.err.exp | |||
@@ -0,0 +1,22 @@ | |||
1 | error: | ||
2 | … while evaluating the condition of the assertion '({ b = 1; } == { b = 1.01; })' | ||
3 | at /pwd/lang/eval-fail-assert-equal-floats.nix:1:1: | ||
4 | 1| assert { b = 1.0; } == { b = 1.01; }; | ||
5 | | ^ | ||
6 | 2| abort "unreachable" | ||
7 | |||
8 | … while comparing attribute 'b' | ||
9 | |||
10 | … where left hand side is | ||
11 | at /pwd/lang/eval-fail-assert-equal-floats.nix:1:10: | ||
12 | 1| assert { b = 1.0; } == { b = 1.01; }; | ||
13 | | ^ | ||
14 | 2| abort "unreachable" | ||
15 | |||
16 | … where right hand side is | ||
17 | at /pwd/lang/eval-fail-assert-equal-floats.nix:1:26: | ||
18 | 1| assert { b = 1.0; } == { b = 1.01; }; | ||
19 | | ^ | ||
20 | 2| abort "unreachable" | ||
21 | |||
22 | error: a float with value '1' is not equal to a float with value '1.01' | ||
diff --git a/test/testdata/eval-fail-assert-equal-floats.nix b/test/testdata/eval-fail-assert-equal-floats.nix new file mode 100644 index 0000000..438e85a --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-floats.nix | |||
@@ -0,0 +1,2 @@ | |||
1 | assert { b = 1.0; } == { b = 1.01; }; | ||
2 | abort "unreachable" | ||
diff --git a/test/testdata/eval-fail-assert-equal-function-direct.err.exp b/test/testdata/eval-fail-assert-equal-function-direct.err.exp new file mode 100644 index 0000000..f06d796 --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-function-direct.err.exp | |||
@@ -0,0 +1,9 @@ | |||
1 | error: | ||
2 | … while evaluating the condition of the assertion '((x: x) == (x: x))' | ||
3 | at /pwd/lang/eval-fail-assert-equal-function-direct.nix:3:1: | ||
4 | 2| # This only compares a direct comparison and makes no claims about functions in nested structures. | ||
5 | 3| assert | ||
6 | | ^ | ||
7 | 4| (x: x) | ||
8 | |||
9 | error: distinct functions and immediate comparisons of identical functions compare as unequal | ||
diff --git a/test/testdata/eval-fail-assert-equal-function-direct.nix b/test/testdata/eval-fail-assert-equal-function-direct.nix new file mode 100644 index 0000000..68e5e39 --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-function-direct.nix | |||
@@ -0,0 +1,7 @@ | |||
1 | # Note: functions in nested structures, e.g. attributes, may be optimized away by pointer identity optimization. | ||
2 | # This only compares a direct comparison and makes no claims about functions in nested structures. | ||
3 | assert | ||
4 | (x: x) | ||
5 | == | ||
6 | (x: x); | ||
7 | abort "unreachable" \ No newline at end of file | ||
diff --git a/test/testdata/eval-fail-assert-equal-int-float.err.exp b/test/testdata/eval-fail-assert-equal-int-float.err.exp new file mode 100644 index 0000000..c927e38 --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-int-float.err.exp | |||
@@ -0,0 +1,8 @@ | |||
1 | error: | ||
2 | … while evaluating the condition of the assertion '(1 == 1.1)' | ||
3 | at /pwd/lang/eval-fail-assert-equal-int-float.nix:1:1: | ||
4 | 1| assert 1 == 1.1; | ||
5 | | ^ | ||
6 | 2| throw "unreachable" | ||
7 | |||
8 | error: an integer with value '1' is not equal to a float with value '1.1' | ||
diff --git a/test/testdata/eval-fail-assert-equal-int-float.nix b/test/testdata/eval-fail-assert-equal-int-float.nix new file mode 100644 index 0000000..1dfdf2b --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-int-float.nix | |||
@@ -0,0 +1,2 @@ | |||
1 | assert 1 == 1.1; | ||
2 | throw "unreachable" | ||
diff --git a/test/testdata/eval-fail-assert-equal-ints.err.exp b/test/testdata/eval-fail-assert-equal-ints.err.exp new file mode 100644 index 0000000..d6219e2 --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-ints.err.exp | |||
@@ -0,0 +1,22 @@ | |||
1 | error: | ||
2 | … while evaluating the condition of the assertion '({ b = 1; } == { b = 2; })' | ||
3 | at /pwd/lang/eval-fail-assert-equal-ints.nix:1:1: | ||
4 | 1| assert { b = 1; } == { b = 2; }; | ||
5 | | ^ | ||
6 | 2| abort "unreachable" | ||
7 | |||
8 | … while comparing attribute 'b' | ||
9 | |||
10 | … where left hand side is | ||
11 | at /pwd/lang/eval-fail-assert-equal-ints.nix:1:10: | ||
12 | 1| assert { b = 1; } == { b = 2; }; | ||
13 | | ^ | ||
14 | 2| abort "unreachable" | ||
15 | |||
16 | … where right hand side is | ||
17 | at /pwd/lang/eval-fail-assert-equal-ints.nix:1:24: | ||
18 | 1| assert { b = 1; } == { b = 2; }; | ||
19 | | ^ | ||
20 | 2| abort "unreachable" | ||
21 | |||
22 | error: an integer with value '1' is not equal to an integer with value '2' | ||
diff --git a/test/testdata/eval-fail-assert-equal-ints.nix b/test/testdata/eval-fail-assert-equal-ints.nix new file mode 100644 index 0000000..645258e --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-ints.nix | |||
@@ -0,0 +1,2 @@ | |||
1 | assert { b = 1; } == { b = 2; }; | ||
2 | abort "unreachable" | ||
diff --git a/test/testdata/eval-fail-assert-equal-list-length.err.exp b/test/testdata/eval-fail-assert-equal-list-length.err.exp new file mode 100644 index 0000000..9010855 --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-list-length.err.exp | |||
@@ -0,0 +1,8 @@ | |||
1 | error: | ||
2 | … while evaluating the condition of the assertion '([ (1) (0) ] == [ (10) ])' | ||
3 | at /pwd/lang/eval-fail-assert-equal-list-length.nix:1:1: | ||
4 | 1| assert [ 1 0 ] == [ 10 ]; | ||
5 | | ^ | ||
6 | 2| throw "unreachable" | ||
7 | |||
8 | error: list of size '2' is not equal to list of size '1', left hand side is '[ 1 0 ]', right hand side is '[ 10 ]' | ||
diff --git a/test/testdata/eval-fail-assert-equal-list-length.nix b/test/testdata/eval-fail-assert-equal-list-length.nix new file mode 100644 index 0000000..6d40f4d --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-list-length.nix | |||
@@ -0,0 +1,2 @@ | |||
1 | assert [ 1 0 ] == [ 10 ]; | ||
2 | throw "unreachable" \ No newline at end of file | ||
diff --git a/test/testdata/eval-fail-assert-equal-paths.err.exp b/test/testdata/eval-fail-assert-equal-paths.err.exp new file mode 100644 index 0000000..66c34e9 --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-paths.err.exp | |||
@@ -0,0 +1,8 @@ | |||
1 | error: | ||
2 | … while evaluating the condition of the assertion '(/pwd/lang/foo == /pwd/lang/bar)' | ||
3 | at /pwd/lang/eval-fail-assert-equal-paths.nix:1:1: | ||
4 | 1| assert ./foo == ./bar; | ||
5 | | ^ | ||
6 | 2| throw "unreachable" | ||
7 | |||
8 | error: path '/pwd/lang/foo' is not equal to path '/pwd/lang/bar' | ||
diff --git a/test/testdata/eval-fail-assert-equal-paths.nix b/test/testdata/eval-fail-assert-equal-paths.nix new file mode 100644 index 0000000..ef0b670 --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-paths.nix | |||
@@ -0,0 +1,2 @@ | |||
1 | assert ./foo == ./bar; | ||
2 | throw "unreachable" \ No newline at end of file | ||
diff --git a/test/testdata/eval-fail-assert-equal-type-nested.err.exp b/test/testdata/eval-fail-assert-equal-type-nested.err.exp new file mode 100644 index 0000000..f78badd --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-type-nested.err.exp | |||
@@ -0,0 +1,22 @@ | |||
1 | error: | ||
2 | … while evaluating the condition of the assertion '({ ding = false; } == { ding = null; })' | ||
3 | at /pwd/lang/eval-fail-assert-equal-type-nested.nix:1:1: | ||
4 | 1| assert { ding = false; } == { ding = null; }; | ||
5 | | ^ | ||
6 | 2| abort "unreachable" | ||
7 | |||
8 | … while comparing attribute 'ding' | ||
9 | |||
10 | … where left hand side is | ||
11 | at /pwd/lang/eval-fail-assert-equal-type-nested.nix:1:10: | ||
12 | 1| assert { ding = false; } == { ding = null; }; | ||
13 | | ^ | ||
14 | 2| abort "unreachable" | ||
15 | |||
16 | … where right hand side is | ||
17 | at /pwd/lang/eval-fail-assert-equal-type-nested.nix:1:31: | ||
18 | 1| assert { ding = false; } == { ding = null; }; | ||
19 | | ^ | ||
20 | 2| abort "unreachable" | ||
21 | |||
22 | error: a Boolean of value 'false' is not equal to null of value 'null' | ||
diff --git a/test/testdata/eval-fail-assert-equal-type-nested.nix b/test/testdata/eval-fail-assert-equal-type-nested.nix new file mode 100644 index 0000000..3fbd14c --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-type-nested.nix | |||
@@ -0,0 +1,2 @@ | |||
1 | assert { ding = false; } == { ding = null; }; | ||
2 | abort "unreachable" | ||
diff --git a/test/testdata/eval-fail-assert-equal-type.err.exp b/test/testdata/eval-fail-assert-equal-type.err.exp new file mode 100644 index 0000000..4dc3f2e --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-type.err.exp | |||
@@ -0,0 +1,8 @@ | |||
1 | error: | ||
2 | … while evaluating the condition of the assertion '(false == null)' | ||
3 | at /pwd/lang/eval-fail-assert-equal-type.nix:1:1: | ||
4 | 1| assert false == null; | ||
5 | | ^ | ||
6 | 2| abort "unreachable" | ||
7 | |||
8 | error: a Boolean of value 'false' is not equal to null of value 'null' | ||
diff --git a/test/testdata/eval-fail-assert-equal-type.nix b/test/testdata/eval-fail-assert-equal-type.nix new file mode 100644 index 0000000..7023ea0 --- /dev/null +++ b/test/testdata/eval-fail-assert-equal-type.nix | |||
@@ -0,0 +1,2 @@ | |||
1 | assert false == null; | ||
2 | abort "unreachable" | ||
diff --git a/test/testdata/eval-fail-assert-nested-bool.err.exp b/test/testdata/eval-fail-assert-nested-bool.err.exp new file mode 100644 index 0000000..1debb66 --- /dev/null +++ b/test/testdata/eval-fail-assert-nested-bool.err.exp | |||
@@ -0,0 +1,74 @@ | |||
1 | error: | ||
2 | … while evaluating the condition of the assertion '({ a = { b = [ ({ c = { d = true; }; }) ]; }; } == { a = { b = [ ({ c = { d = false; }; }) ]; }; })' | ||
3 | at /pwd/lang/eval-fail-assert-nested-bool.nix:1:1: | ||
4 | 1| assert | ||
5 | | ^ | ||
6 | 2| { a.b = [ { c.d = true; } ]; } | ||
7 | |||
8 | … while comparing attribute 'a' | ||
9 | |||
10 | … where left hand side is | ||
11 | at /pwd/lang/eval-fail-assert-nested-bool.nix:2:5: | ||
12 | 1| assert | ||
13 | 2| { a.b = [ { c.d = true; } ]; } | ||
14 | | ^ | ||
15 | 3| == | ||
16 | |||
17 | … where right hand side is | ||
18 | at /pwd/lang/eval-fail-assert-nested-bool.nix:4:5: | ||
19 | 3| == | ||
20 | 4| { a.b = [ { c.d = false; } ]; }; | ||
21 | | ^ | ||
22 | 5| | ||
23 | |||
24 | … while comparing attribute 'b' | ||
25 | |||
26 | … where left hand side is | ||
27 | at /pwd/lang/eval-fail-assert-nested-bool.nix:2:5: | ||
28 | 1| assert | ||
29 | 2| { a.b = [ { c.d = true; } ]; } | ||
30 | | ^ | ||
31 | 3| == | ||
32 | |||
33 | … where right hand side is | ||
34 | at /pwd/lang/eval-fail-assert-nested-bool.nix:4:5: | ||
35 | 3| == | ||
36 | 4| { a.b = [ { c.d = false; } ]; }; | ||
37 | | ^ | ||
38 | 5| | ||
39 | |||
40 | … while comparing list element 0 | ||
41 | |||
42 | … while comparing attribute 'c' | ||
43 | |||
44 | … where left hand side is | ||
45 | at /pwd/lang/eval-fail-assert-nested-bool.nix:2:15: | ||
46 | 1| assert | ||
47 | 2| { a.b = [ { c.d = true; } ]; } | ||
48 | | ^ | ||
49 | 3| == | ||
50 | |||
51 | … where right hand side is | ||
52 | at /pwd/lang/eval-fail-assert-nested-bool.nix:4:15: | ||
53 | 3| == | ||
54 | 4| { a.b = [ { c.d = false; } ]; }; | ||
55 | | ^ | ||
56 | 5| | ||
57 | |||
58 | … while comparing attribute 'd' | ||
59 | |||
60 | … where left hand side is | ||
61 | at /pwd/lang/eval-fail-assert-nested-bool.nix:2:15: | ||
62 | 1| assert | ||
63 | 2| { a.b = [ { c.d = true; } ]; } | ||
64 | | ^ | ||
65 | 3| == | ||
66 | |||
67 | … where right hand side is | ||
68 | at /pwd/lang/eval-fail-assert-nested-bool.nix:4:15: | ||
69 | 3| == | ||
70 | 4| { a.b = [ { c.d = false; } ]; }; | ||
71 | | ^ | ||
72 | 5| | ||
73 | |||
74 | error: boolean 'true' is not equal to boolean 'false' | ||
diff --git a/test/testdata/eval-fail-assert-nested-bool.nix b/test/testdata/eval-fail-assert-nested-bool.nix new file mode 100644 index 0000000..2285769 --- /dev/null +++ b/test/testdata/eval-fail-assert-nested-bool.nix | |||
@@ -0,0 +1,6 @@ | |||
1 | assert | ||
2 | { a.b = [ { c.d = true; } ]; } | ||
3 | == | ||
4 | { a.b = [ { c.d = false; } ]; }; | ||
5 | |||
6 | abort "unreachable" \ No newline at end of file | ||
diff --git a/test/testdata/eval-fail-assert.err.exp b/test/testdata/eval-fail-assert.err.exp new file mode 100644 index 0000000..7be9e23 --- /dev/null +++ b/test/testdata/eval-fail-assert.err.exp | |||
@@ -0,0 +1,30 @@ | |||
1 | error: | ||
2 | … while evaluating the attribute 'body' | ||
3 | at /pwd/lang/eval-fail-assert.nix:4:3: | ||
4 | 3| | ||
5 | 4| body = x "x"; | ||
6 | | ^ | ||
7 | 5| } | ||
8 | |||
9 | … from call site | ||
10 | at /pwd/lang/eval-fail-assert.nix:4:10: | ||
11 | 3| | ||
12 | 4| body = x "x"; | ||
13 | | ^ | ||
14 | 5| } | ||
15 | |||
16 | … while calling 'x' | ||
17 | at /pwd/lang/eval-fail-assert.nix:2:7: | ||
18 | 1| let { | ||
19 | 2| x = arg: assert arg == "y"; 123; | ||
20 | | ^ | ||
21 | 3| | ||
22 | |||
23 | … while evaluating the condition of the assertion '(arg == "y")' | ||
24 | at /pwd/lang/eval-fail-assert.nix:2:12: | ||
25 | 1| let { | ||
26 | 2| x = arg: assert arg == "y"; 123; | ||
27 | | ^ | ||
28 | 3| | ||
29 | |||
30 | error: string '"x"' is not equal to string '"y"' | ||
diff --git a/test/testdata/eval-fail-assert.nix b/test/testdata/eval-fail-assert.nix new file mode 100644 index 0000000..3b7a1e8 --- /dev/null +++ b/test/testdata/eval-fail-assert.nix | |||
@@ -0,0 +1,5 @@ | |||
1 | let { | ||
2 | x = arg: assert arg == "y"; 123; | ||
3 | |||
4 | body = x "x"; | ||
5 | } \ No newline at end of file | ||
diff --git a/test/testdata/eval-fail-attr-name-type.err.exp b/test/testdata/eval-fail-attr-name-type.err.exp new file mode 100644 index 0000000..6848a35 --- /dev/null +++ b/test/testdata/eval-fail-attr-name-type.err.exp | |||
@@ -0,0 +1,21 @@ | |||
1 | error: | ||
2 | … while evaluating the attribute 'puppy."${key}"' | ||
3 | at /pwd/lang/eval-fail-attr-name-type.nix:3:5: | ||
4 | 2| attrs = { | ||
5 | 3| puppy.doggy = {}; | ||
6 | | ^ | ||
7 | 4| }; | ||
8 | |||
9 | … while evaluating an attribute name | ||
10 | at /pwd/lang/eval-fail-attr-name-type.nix:7:17: | ||
11 | 6| in | ||
12 | 7| attrs.puppy.${key} | ||
13 | | ^ | ||
14 | 8| | ||
15 | |||
16 | error: expected a string but found an integer: 1 | ||
17 | at /pwd/lang/eval-fail-attr-name-type.nix:7:17: | ||
18 | 6| in | ||
19 | 7| attrs.puppy.${key} | ||
20 | | ^ | ||
21 | 8| | ||
diff --git a/test/testdata/eval-fail-attr-name-type.nix b/test/testdata/eval-fail-attr-name-type.nix new file mode 100644 index 0000000..a0e7600 --- /dev/null +++ b/test/testdata/eval-fail-attr-name-type.nix | |||
@@ -0,0 +1,7 @@ | |||
1 | let | ||
2 | attrs = { | ||
3 | puppy.doggy = {}; | ||
4 | }; | ||
5 | key = 1; | ||
6 | in | ||
7 | attrs.puppy.${key} | ||
diff --git a/test/testdata/eval-fail-bad-string-interpolation-1.err.exp b/test/testdata/eval-fail-bad-string-interpolation-1.err.exp new file mode 100644 index 0000000..5ae5303 --- /dev/null +++ b/test/testdata/eval-fail-bad-string-interpolation-1.err.exp | |||
@@ -0,0 +1,8 @@ | |||
1 | error: | ||
2 | … while evaluating a path segment | ||
3 | at /pwd/lang/eval-fail-bad-string-interpolation-1.nix:1:2: | ||
4 | 1| "${x: x}" | ||
5 | | ^ | ||
6 | 2| | ||
7 | |||
8 | error: cannot coerce a function to a string: «lambda @ /pwd/lang/eval-fail-bad-string-interpolation-1.nix:1:4» | ||
diff --git a/test/testdata/eval-fail-bad-string-interpolation-1.nix b/test/testdata/eval-fail-bad-string-interpolation-1.nix new file mode 100644 index 0000000..ffe9c98 --- /dev/null +++ b/test/testdata/eval-fail-bad-string-interpolation-1.nix | |||
@@ -0,0 +1 @@ | |||
"${x: x}" | |||
diff --git a/test/testdata/eval-fail-bad-string-interpolation-2.err.exp b/test/testdata/eval-fail-bad-string-interpolation-2.err.exp new file mode 100644 index 0000000..a287067 --- /dev/null +++ b/test/testdata/eval-fail-bad-string-interpolation-2.err.exp | |||
@@ -0,0 +1 @@ | |||
error: path '/pwd/lang/fnord' does not exist | |||
diff --git a/test/testdata/eval-fail-bad-string-interpolation-2.nix b/test/testdata/eval-fail-bad-string-interpolation-2.nix new file mode 100644 index 0000000..3745235 --- /dev/null +++ b/test/testdata/eval-fail-bad-string-interpolation-2.nix | |||
@@ -0,0 +1 @@ | |||
"${./fnord}" | |||
diff --git a/test/testdata/eval-fail-bad-string-interpolation-3.err.exp b/test/testdata/eval-fail-bad-string-interpolation-3.err.exp new file mode 100644 index 0000000..170a3d1 --- /dev/null +++ b/test/testdata/eval-fail-bad-string-interpolation-3.err.exp | |||
@@ -0,0 +1,8 @@ | |||
1 | error: | ||
2 | … while evaluating a path segment | ||
3 | at /pwd/lang/eval-fail-bad-string-interpolation-3.nix:1:3: | ||
4 | 1| ''${x: x}'' | ||
5 | | ^ | ||
6 | 2| | ||
7 | |||
8 | error: cannot coerce a function to a string: «lambda @ /pwd/lang/eval-fail-bad-string-interpolation-3.nix:1:5» | ||
diff --git a/test/testdata/eval-fail-bad-string-interpolation-3.nix b/test/testdata/eval-fail-bad-string-interpolation-3.nix new file mode 100644 index 0000000..65b9d4f --- /dev/null +++ b/test/testdata/eval-fail-bad-string-interpolation-3.nix | |||
@@ -0,0 +1 @@ | |||
''${x: x}'' | |||
diff --git a/test/testdata/eval-fail-bad-string-interpolation-4.err.exp b/test/testdata/eval-fail-bad-string-interpolation-4.err.exp new file mode 100644 index 0000000..b262e81 --- /dev/null +++ b/test/testdata/eval-fail-bad-string-interpolation-4.err.exp | |||
@@ -0,0 +1,9 @@ | |||
1 | error: | ||
2 | … while evaluating a path segment | ||
3 | at /pwd/lang/eval-fail-bad-string-interpolation-4.nix:9:3: | ||
4 | 8| # The error message should not be too long. | ||
5 | 9| ''${pkgs}'' | ||
6 | | ^ | ||
7 | 10| | ||
8 | |||
9 | error: cannot coerce a set to a string: { a = { a = { a = { a = "ha"; b = "ha"; c = "ha"; d = "ha"; e = "ha"; f = "ha"; g = "ha"; h = "ha"; j = "ha"; }; «8 attributes elided» }; «8 attributes elided» }; «8 attributes elided» } | ||
diff --git a/test/testdata/eval-fail-bad-string-interpolation-4.nix b/test/testdata/eval-fail-bad-string-interpolation-4.nix new file mode 100644 index 0000000..457b5f0 --- /dev/null +++ b/test/testdata/eval-fail-bad-string-interpolation-4.nix | |||
@@ -0,0 +1,9 @@ | |||
1 | let | ||
2 | # Basically a "billion laughs" attack, but toned down to simulated `pkgs`. | ||
3 | ha = x: y: { a = x y; b = x y; c = x y; d = x y; e = x y; f = x y; g = x y; h = x y; j = x y; }; | ||
4 | has = ha (ha (ha (ha (x: x)))) "ha"; | ||
5 | # A large structure that has already been evaluated. | ||
6 | pkgs = builtins.deepSeq has has; | ||
7 | in | ||
8 | # The error message should not be too long. | ||
9 | ''${pkgs}'' | ||
diff --git a/test/testdata/eval-fail-blackhole.err.exp b/test/testdata/eval-fail-blackhole.err.exp new file mode 100644 index 0000000..95e33a5 --- /dev/null +++ b/test/testdata/eval-fail-blackhole.err.exp | |||
@@ -0,0 +1,14 @@ | |||
1 | error: | ||
2 | … while evaluating the attribute 'body' | ||
3 | at /pwd/lang/eval-fail-blackhole.nix:2:3: | ||
4 | 1| let { | ||
5 | 2| body = x; | ||
6 | | ^ | ||
7 | 3| x = y; | ||
8 | |||
9 | error: infinite recursion encountered | ||
10 | at /pwd/lang/eval-fail-blackhole.nix:3:7: | ||
11 | 2| body = x; | ||
12 | 3| x = y; | ||
13 | | ^ | ||
14 | 4| y = x; | ||
diff --git a/test/testdata/eval-fail-blackhole.nix b/test/testdata/eval-fail-blackhole.nix new file mode 100644 index 0000000..81133b5 --- /dev/null +++ b/test/testdata/eval-fail-blackhole.nix | |||
@@ -0,0 +1,5 @@ | |||
1 | let { | ||
2 | body = x; | ||
3 | x = y; | ||
4 | y = x; | ||
5 | } | ||
diff --git a/test/testdata/eval-fail-call-primop.err.exp b/test/testdata/eval-fail-call-primop.err.exp new file mode 100644 index 0000000..0c6f614 --- /dev/null +++ b/test/testdata/eval-fail-call-primop.err.exp | |||
@@ -0,0 +1,10 @@ | |||
1 | error: | ||
2 | … while calling the 'length' builtin | ||
3 | at /pwd/lang/eval-fail-call-primop.nix:1:1: | ||
4 | 1| builtins.length 1 | ||
5 | | ^ | ||
6 | 2| | ||
7 | |||
8 | … while evaluating the first argument passed to builtins.length | ||
9 | |||
10 | error: expected a list but found an integer: 1 | ||
diff --git a/test/testdata/eval-fail-call-primop.nix b/test/testdata/eval-fail-call-primop.nix new file mode 100644 index 0000000..972eb72 --- /dev/null +++ b/test/testdata/eval-fail-call-primop.nix | |||
@@ -0,0 +1 @@ | |||
builtins.length 1 | |||
diff --git a/test/testdata/eval-fail-deepseq.err.exp b/test/testdata/eval-fail-deepseq.err.exp new file mode 100644 index 0000000..11b6234 --- /dev/null +++ b/test/testdata/eval-fail-deepseq.err.exp | |||
@@ -0,0 +1,20 @@ | |||
1 | error: | ||
2 | … while calling the 'deepSeq' builtin | ||
3 | at /pwd/lang/eval-fail-deepseq.nix:1:1: | ||
4 | 1| builtins.deepSeq { x = abort "foo"; } 456 | ||
5 | | ^ | ||
6 | 2| | ||
7 | |||
8 | … while evaluating the attribute 'x' | ||
9 | at /pwd/lang/eval-fail-deepseq.nix:1:20: | ||
10 | 1| builtins.deepSeq { x = abort "foo"; } 456 | ||
11 | | ^ | ||
12 | 2| | ||
13 | |||
14 | … while calling the 'abort' builtin | ||
15 | at /pwd/lang/eval-fail-deepseq.nix:1:24: | ||
16 | 1| builtins.deepSeq { x = abort "foo"; } 456 | ||
17 | | ^ | ||
18 | 2| | ||
19 | |||
20 | error: evaluation aborted with the following error message: 'foo' | ||
diff --git a/test/testdata/eval-fail-deepseq.nix b/test/testdata/eval-fail-deepseq.nix new file mode 100644 index 0000000..9baa49b --- /dev/null +++ b/test/testdata/eval-fail-deepseq.nix | |||
@@ -0,0 +1 @@ | |||
builtins.deepSeq { x = abort "foo"; } 456 | |||
diff --git a/test/testdata/eval-fail-derivation-name.err.exp b/test/testdata/eval-fail-derivation-name.err.exp new file mode 100644 index 0000000..0ef9867 --- /dev/null +++ b/test/testdata/eval-fail-derivation-name.err.exp | |||
@@ -0,0 +1,26 @@ | |||
1 | error: | ||
2 | … while evaluating the attribute 'outPath' | ||
3 | at <nix/derivation-internal.nix>:<number>:<number>: | ||
4 | <number>| value = commonAttrs // { | ||
5 | <number>| outPath = builtins.getAttr outputName strict; | ||
6 | | ^ | ||
7 | <number>| drvPath = strict.drvPath; | ||
8 | |||
9 | … while calling the 'getAttr' builtin | ||
10 | at <nix/derivation-internal.nix>:<number>:<number>: | ||
11 | <number>| value = commonAttrs // { | ||
12 | <number>| outPath = builtins.getAttr outputName strict; | ||
13 | | ^ | ||
14 | <number>| drvPath = strict.drvPath; | ||
15 | |||
16 | … while calling the 'derivationStrict' builtin | ||
17 | at <nix/derivation-internal.nix>:<number>:<number>: | ||
18 | <number>| | ||
19 | <number>| strict = derivationStrict drvAttrs; | ||
20 | | ^ | ||
21 | <number>| | ||
22 | |||
23 | … while evaluating derivation '~jiggle~' | ||
24 | whose name attribute is located at /pwd/lang/eval-fail-derivation-name.nix:<number>:<number> | ||
25 | |||
26 | error: invalid derivation name: name '~jiggle~' contains illegal character '~'. Please pass a different 'name'. | ||
diff --git a/test/testdata/eval-fail-derivation-name.nix b/test/testdata/eval-fail-derivation-name.nix new file mode 100644 index 0000000..e779ad6 --- /dev/null +++ b/test/testdata/eval-fail-derivation-name.nix | |||
@@ -0,0 +1,5 @@ | |||
1 | derivation { | ||
2 | name = "~jiggle~"; | ||
3 | system = "some-system"; | ||
4 | builder = "/dontcare"; | ||
5 | } | ||
diff --git a/test/testdata/eval-fail-derivation-name.postprocess b/test/testdata/eval-fail-derivation-name.postprocess new file mode 100644 index 0000000..ffbc2b5 --- /dev/null +++ b/test/testdata/eval-fail-derivation-name.postprocess | |||
@@ -0,0 +1,9 @@ | |||
1 | # shellcheck shell=bash | ||
2 | set -euo pipefail | ||
3 | testcaseBasename=$1 | ||
4 | |||
5 | # Line numbers change when derivation.nix docs are updated. | ||
6 | sed -i "$testcaseBasename.err" \ | ||
7 | -e 's/[0-9 ][0-9 ][0-9 ][0-9 ][0-9 ][0-9 ][0-9 ][0-9]\([^0-9]\)/<number>\1/g' \ | ||
8 | -e 's/[0-9][0-9]*/<number>/g' \ | ||
9 | ; | ||
diff --git a/test/testdata/eval-fail-dup-dynamic-attrs.err.exp b/test/testdata/eval-fail-dup-dynamic-attrs.err.exp new file mode 100644 index 0000000..834f9c6 --- /dev/null +++ b/test/testdata/eval-fail-dup-dynamic-attrs.err.exp | |||
@@ -0,0 +1,14 @@ | |||
1 | error: | ||
2 | … while evaluating the attribute 'set' | ||
3 | at /pwd/lang/eval-fail-dup-dynamic-attrs.nix:2:3: | ||
4 | 1| { | ||
5 | 2| set = { "${"" + "b"}" = 1; }; | ||
6 | | ^ | ||
7 | 3| set = { "${"b" + ""}" = 2; }; | ||
8 | |||
9 | error: dynamic attribute 'b' already defined at /pwd/lang/eval-fail-dup-dynamic-attrs.nix:2:11 | ||
10 | at /pwd/lang/eval-fail-dup-dynamic-attrs.nix:3:11: | ||
11 | 2| set = { "${"" + "b"}" = 1; }; | ||
12 | 3| set = { "${"b" + ""}" = 2; }; | ||
13 | | ^ | ||
14 | 4| } | ||
diff --git a/test/testdata/eval-fail-dup-dynamic-attrs.nix b/test/testdata/eval-fail-dup-dynamic-attrs.nix new file mode 100644 index 0000000..7ea17f6 --- /dev/null +++ b/test/testdata/eval-fail-dup-dynamic-attrs.nix | |||
@@ -0,0 +1,4 @@ | |||
1 | { | ||
2 | set = { "${"" + "b"}" = 1; }; | ||
3 | set = { "${"b" + ""}" = 2; }; | ||
4 | } | ||
diff --git a/test/testdata/eval-fail-duplicate-traces.err.exp b/test/testdata/eval-fail-duplicate-traces.err.exp new file mode 100644 index 0000000..cedaebd --- /dev/null +++ b/test/testdata/eval-fail-duplicate-traces.err.exp | |||
@@ -0,0 +1,51 @@ | |||
1 | error: | ||
2 | … from call site | ||
3 | at /pwd/lang/eval-fail-duplicate-traces.nix:9:3: | ||
4 | 8| in | ||
5 | 9| throwAfter 2 | ||
6 | | ^ | ||
7 | 10| | ||
8 | |||
9 | … while calling 'throwAfter' | ||
10 | at /pwd/lang/eval-fail-duplicate-traces.nix:4:16: | ||
11 | 3| let | ||
12 | 4| throwAfter = n: | ||
13 | | ^ | ||
14 | 5| if n > 0 | ||
15 | |||
16 | … from call site | ||
17 | at /pwd/lang/eval-fail-duplicate-traces.nix:6:10: | ||
18 | 5| if n > 0 | ||
19 | 6| then throwAfter (n - 1) | ||
20 | | ^ | ||
21 | 7| else throw "Uh oh!"; | ||
22 | |||
23 | … while calling 'throwAfter' | ||
24 | at /pwd/lang/eval-fail-duplicate-traces.nix:4:16: | ||
25 | 3| let | ||
26 | 4| throwAfter = n: | ||
27 | | ^ | ||
28 | 5| if n > 0 | ||
29 | |||
30 | … from call site | ||
31 | at /pwd/lang/eval-fail-duplicate-traces.nix:6:10: | ||
32 | 5| if n > 0 | ||
33 | 6| then throwAfter (n - 1) | ||
34 | | ^ | ||
35 | 7| else throw "Uh oh!"; | ||
36 | |||
37 | … while calling 'throwAfter' | ||
38 | at /pwd/lang/eval-fail-duplicate-traces.nix:4:16: | ||
39 | 3| let | ||
40 | 4| throwAfter = n: | ||
41 | | ^ | ||
42 | 5| if n > 0 | ||
43 | |||
44 | … while calling the 'throw' builtin | ||
45 | at /pwd/lang/eval-fail-duplicate-traces.nix:7:10: | ||
46 | 6| then throwAfter (n - 1) | ||
47 | 7| else throw "Uh oh!"; | ||
48 | | ^ | ||
49 | 8| in | ||
50 | |||
51 | error: Uh oh! | ||
diff --git a/test/testdata/eval-fail-duplicate-traces.nix b/test/testdata/eval-fail-duplicate-traces.nix new file mode 100644 index 0000000..17ce374 --- /dev/null +++ b/test/testdata/eval-fail-duplicate-traces.nix | |||
@@ -0,0 +1,9 @@ | |||
1 | # Check that we only omit duplicate stack traces when there's a bunch of them. | ||
2 | # Here, there's only a couple duplicate entries, so we output them all. | ||
3 | let | ||
4 | throwAfter = n: | ||
5 | if n > 0 | ||
6 | then throwAfter (n - 1) | ||
7 | else throw "Uh oh!"; | ||
8 | in | ||
9 | throwAfter 2 | ||
diff --git a/test/testdata/eval-fail-eol-1.err.exp b/test/testdata/eval-fail-eol-1.err.exp new file mode 100644 index 0000000..3f5a5c2 --- /dev/null +++ b/test/testdata/eval-fail-eol-1.err.exp | |||
@@ -0,0 +1,6 @@ | |||
1 | error: undefined variable 'invalid' | ||
2 | at /pwd/lang/eval-fail-eol-1.nix:2:1: | ||
3 | 1| # foo | ||
4 | 2| invalid | ||
5 | | ^ | ||
6 | 3| # bar | ||
diff --git a/test/testdata/eval-fail-eol-1.nix b/test/testdata/eval-fail-eol-1.nix new file mode 100644 index 0000000..4762239 --- /dev/null +++ b/test/testdata/eval-fail-eol-1.nix | |||
@@ -0,0 +1,3 @@ | |||
1 | # foo | ||
2 | invalid | ||
3 | # bar | ||
diff --git a/test/testdata/eval-fail-eol-2.err.exp b/test/testdata/eval-fail-eol-2.err.exp new file mode 100644 index 0000000..ff13e2d --- /dev/null +++ b/test/testdata/eval-fail-eol-2.err.exp | |||
@@ -0,0 +1,6 @@ | |||
1 | error: undefined variable 'invalid' | ||
2 | at /pwd/lang/eval-fail-eol-2.nix:2:1: | ||
3 | 1| # foo | ||
4 | 2| invalid | ||
5 | | ^ | ||
6 | 3| # bar | ||
diff --git a/test/testdata/eval-fail-eol-2.nix b/test/testdata/eval-fail-eol-2.nix new file mode 100644 index 0000000..0cf92a4 --- /dev/null +++ b/test/testdata/eval-fail-eol-2.nix | |||
@@ -0,0 +1,2 @@ | |||
1 | # foo invalid | ||
2 | # bar | ||
diff --git a/test/testdata/eval-fail-eol-3.err.exp b/test/testdata/eval-fail-eol-3.err.exp new file mode 100644 index 0000000..ada3c5e --- /dev/null +++ b/test/testdata/eval-fail-eol-3.err.exp | |||
@@ -0,0 +1,6 @@ | |||
1 | error: undefined variable 'invalid' | ||
2 | at /pwd/lang/eval-fail-eol-3.nix:2:1: | ||
3 | 1| # foo | ||
4 | 2| invalid | ||
5 | | ^ | ||
6 | 3| # bar | ||
diff --git a/test/testdata/eval-fail-eol-3.nix b/test/testdata/eval-fail-eol-3.nix new file mode 100644 index 0000000..4762239 --- /dev/null +++ b/test/testdata/eval-fail-eol-3.nix | |||
@@ -0,0 +1,3 @@ | |||
1 | # foo | ||
2 | invalid | ||
3 | # bar | ||
diff --git a/test/testdata/eval-fail-fetchTree-negative.err.exp b/test/testdata/eval-fail-fetchTree-negative.err.exp new file mode 100644 index 0000000..d9ba1f0 --- /dev/null +++ b/test/testdata/eval-fail-fetchTree-negative.err.exp | |||
@@ -0,0 +1,8 @@ | |||
1 | error: | ||
2 | … while calling the 'fetchTree' builtin | ||
3 | at /pwd/lang/eval-fail-fetchTree-negative.nix:1:1: | ||
4 | 1| builtins.fetchTree { | ||
5 | | ^ | ||
6 | 2| type = "file"; | ||
7 | |||
8 | error: negative value given for fetchTree attr owner: -1 | ||
diff --git a/test/testdata/eval-fail-fetchTree-negative.nix b/test/testdata/eval-fail-fetchTree-negative.nix new file mode 100644 index 0000000..90bcab5 --- /dev/null +++ b/test/testdata/eval-fail-fetchTree-negative.nix | |||
@@ -0,0 +1,5 @@ | |||
1 | builtins.fetchTree { | ||
2 | type = "file"; | ||
3 | url = "file://eval-fail-fetchTree-negative.nix"; | ||
4 | owner = -1; | ||
5 | } | ||
diff --git a/test/testdata/eval-fail-fetchurl-baseName-attrs-name.err.exp b/test/testdata/eval-fail-fetchurl-baseName-attrs-name.err.exp new file mode 100644 index 0000000..30f8b6a --- /dev/null +++ b/test/testdata/eval-fail-fetchurl-baseName-attrs-name.err.exp | |||
@@ -0,0 +1,8 @@ | |||
1 | error: | ||
2 | … while calling the 'fetchurl' builtin | ||
3 | at /pwd/lang/eval-fail-fetchurl-baseName-attrs-name.nix:1:1: | ||
4 | 1| builtins.fetchurl { url = "https://example.com/foo.tar.gz"; name = "~wobble~"; } | ||
5 | | ^ | ||
6 | 2| | ||
7 | |||
8 | error: invalid store path name when fetching URL 'https://example.com/foo.tar.gz': name '~wobble~' contains illegal character '~'. Please change the value for the 'name' attribute passed to 'fetchurl', so that it can create a valid store path. | ||
diff --git a/test/testdata/eval-fail-fetchurl-baseName-attrs-name.nix b/test/testdata/eval-fail-fetchurl-baseName-attrs-name.nix new file mode 100644 index 0000000..5838055 --- /dev/null +++ b/test/testdata/eval-fail-fetchurl-baseName-attrs-name.nix | |||
@@ -0,0 +1 @@ | |||
builtins.fetchurl { url = "https://example.com/foo.tar.gz"; name = "~wobble~"; } | |||
diff --git a/test/testdata/eval-fail-fetchurl-baseName-attrs.err.exp b/test/testdata/eval-fail-fetchurl-baseName-attrs.err.exp new file mode 100644 index 0000000..cef532e --- /dev/null +++ b/test/testdata/eval-fail-fetchurl-baseName-attrs.err.exp | |||
@@ -0,0 +1,8 @@ | |||
1 | error: | ||
2 | … while calling the 'fetchurl' builtin | ||
3 | at /pwd/lang/eval-fail-fetchurl-baseName-attrs.nix:1:1: | ||
4 | 1| builtins.fetchurl { url = "https://example.com/~wiggle~"; } | ||
5 | | ^ | ||
6 | 2| | ||
7 | |||
8 | error: invalid store path name when fetching URL 'https://example.com/~wiggle~': name '~wiggle~' contains illegal character '~'. Please add a valid 'name' attribute to the argument for 'fetchurl', so that it can create a valid store path. | ||
diff --git a/test/testdata/eval-fail-fetchurl-baseName-attrs.nix b/test/testdata/eval-fail-fetchurl-baseName-attrs.nix new file mode 100644 index 0000000..068120e --- /dev/null +++ b/test/testdata/eval-fail-fetchurl-baseName-attrs.nix | |||
@@ -0,0 +1 @@ | |||
builtins.fetchurl { url = "https://example.com/~wiggle~"; } | |||
diff --git a/test/testdata/eval-fail-fetchurl-baseName.err.exp b/test/testdata/eval-fail-fetchurl-baseName.err.exp new file mode 100644 index 0000000..0950e8e --- /dev/null +++ b/test/testdata/eval-fail-fetchurl-baseName.err.exp | |||
@@ -0,0 +1,8 @@ | |||
1 | error: | ||
2 | … while calling the 'fetchurl' builtin | ||
3 | at /pwd/lang/eval-fail-fetchurl-baseName.nix:1:1: | ||
4 | 1| builtins.fetchurl "https://example.com/~wiggle~" | ||
5 | | ^ | ||
6 | 2| | ||
7 | |||
8 | error: invalid store path name when fetching URL 'https://example.com/~wiggle~': name '~wiggle~' contains illegal character '~'. Please pass an attribute set with 'url' and 'name' attributes to 'fetchurl', so that it can create a valid store path. | ||
diff --git a/test/testdata/eval-fail-fetchurl-baseName.nix b/test/testdata/eval-fail-fetchurl-baseName.nix new file mode 100644 index 0000000..9650938 --- /dev/null +++ b/test/testdata/eval-fail-fetchurl-baseName.nix | |||
@@ -0,0 +1 @@ | |||
builtins.fetchurl "https://example.com/~wiggle~" | |||
diff --git a/test/testdata/eval-fail-flake-ref-to-string-negative-integer.err.exp b/test/testdata/eval-fail-flake-ref-to-string-negative-integer.err.exp new file mode 100644 index 0000000..25c8d7e --- /dev/null +++ b/test/testdata/eval-fail-flake-ref-to-string-negative-integer.err.exp | |||
@@ -0,0 +1,14 @@ | |||
1 | error: | ||
2 | … while calling the 'seq' builtin | ||
3 | at /pwd/lang/eval-fail-flake-ref-to-string-negative-integer.nix:1:16: | ||
4 | 1| let n = -1; in builtins.seq n (builtins.flakeRefToString { | ||
5 | | ^ | ||
6 | 2| type = "github"; | ||
7 | |||
8 | … while calling the 'flakeRefToString' builtin | ||
9 | at /pwd/lang/eval-fail-flake-ref-to-string-negative-integer.nix:1:32: | ||
10 | 1| let n = -1; in builtins.seq n (builtins.flakeRefToString { | ||
11 | | ^ | ||
12 | 2| type = "github"; | ||
13 | |||
14 | error: negative value given for flake ref attr repo: -1 | ||
diff --git a/test/testdata/eval-fail-flake-ref-to-string-negative-integer.nix b/test/testdata/eval-fail-flake-ref-to-string-negative-integer.nix new file mode 100644 index 0000000..e0208eb --- /dev/null +++ b/test/testdata/eval-fail-flake-ref-to-string-negative-integer.nix | |||
@@ -0,0 +1,7 @@ | |||
1 | let n = -1; in builtins.seq n (builtins.flakeRefToString { | ||
2 | type = "github"; | ||
3 | owner = "NixOS"; | ||
4 | repo = n; | ||
5 | ref = "23.05"; | ||
6 | dir = "lib"; | ||
7 | }) | ||
diff --git a/test/testdata/eval-fail-foldlStrict-strict-op-application.err.exp b/test/testdata/eval-fail-foldlStrict-strict-op-application.err.exp new file mode 100644 index 0000000..4903bc8 --- /dev/null +++ b/test/testdata/eval-fail-foldlStrict-strict-op-application.err.exp | |||
@@ -0,0 +1,37 @@ | |||
1 | error: | ||
2 | … while calling the 'foldl'' builtin | ||
3 | at /pwd/lang/eval-fail-foldlStrict-strict-op-application.nix:2:1: | ||
4 | 1| # Tests that the result of applying op is forced even if the value is never used | ||
5 | 2| builtins.foldl' | ||
6 | | ^ | ||
7 | 3| (_: f: f null) | ||
8 | |||
9 | … while calling anonymous lambda | ||
10 | at /pwd/lang/eval-fail-foldlStrict-strict-op-application.nix:3:7: | ||
11 | 2| builtins.foldl' | ||
12 | 3| (_: f: f null) | ||
13 | | ^ | ||
14 | 4| null | ||
15 | |||
16 | … from call site | ||
17 | at /pwd/lang/eval-fail-foldlStrict-strict-op-application.nix:3:10: | ||
18 | 2| builtins.foldl' | ||
19 | 3| (_: f: f null) | ||
20 | | ^ | ||
21 | 4| null | ||
22 | |||
23 | … while calling anonymous lambda | ||
24 | at /pwd/lang/eval-fail-foldlStrict-strict-op-application.nix:5:6: | ||
25 | 4| null | ||
26 | 5| [ (_: throw "Not the final value, but is still forced!") (_: 23) ] | ||
27 | | ^ | ||
28 | 6| | ||
29 | |||
30 | … while calling the 'throw' builtin | ||
31 | at /pwd/lang/eval-fail-foldlStrict-strict-op-application.nix:5:9: | ||
32 | 4| null | ||
33 | 5| [ (_: throw "Not the final value, but is still forced!") (_: 23) ] | ||
34 | | ^ | ||
35 | 6| | ||
36 | |||
37 | error: Not the final value, but is still forced! | ||
diff --git a/test/testdata/eval-fail-foldlStrict-strict-op-application.nix b/test/testdata/eval-fail-foldlStrict-strict-op-application.nix new file mode 100644 index 0000000..1620cc7 --- /dev/null +++ b/test/testdata/eval-fail-foldlStrict-strict-op-application.nix | |||
@@ -0,0 +1,5 @@ | |||
1 | # Tests that the result of applying op is forced even if the value is never used | ||
2 | builtins.foldl' | ||
3 | (_: f: f null) | ||
4 | null | ||
5 | [ (_: throw "Not the final value, but is still forced!") (_: 23) ] | ||
diff --git a/test/testdata/eval-fail-fromJSON-overflowing.err.exp b/test/testdata/eval-fail-fromJSON-overflowing.err.exp new file mode 100644 index 0000000..a39082b --- /dev/null +++ b/test/testdata/eval-fail-fromJSON-overflowing.err.exp | |||
@@ -0,0 +1,8 @@ | |||
1 | error: | ||
2 | … while calling the 'fromJSON' builtin | ||
3 | at /pwd/lang/eval-fail-fromJSON-overflowing.nix:1:1: | ||
4 | 1| builtins.fromJSON ''{"attr": 18446744073709551615}'' | ||
5 | | ^ | ||
6 | 2| | ||
7 | |||
8 | error: unsigned json number 18446744073709551615 outside of Nix integer range | ||
diff --git a/test/testdata/eval-fail-fromJSON-overflowing.nix b/test/testdata/eval-fail-fromJSON-overflowing.nix new file mode 100644 index 0000000..6dfbce3 --- /dev/null +++ b/test/testdata/eval-fail-fromJSON-overflowing.nix | |||
@@ -0,0 +1 @@ | |||
builtins.fromJSON ''{"attr": 18446744073709551615}'' | |||
diff --git a/test/testdata/eval-fail-fromTOML-timestamps.err.exp b/test/testdata/eval-fail-fromTOML-timestamps.err.exp new file mode 100644 index 0000000..9bbb251 --- /dev/null +++ b/test/testdata/eval-fail-fromTOML-timestamps.err.exp | |||
@@ -0,0 +1,8 @@ | |||
1 | error: | ||
2 | … while calling the 'fromTOML' builtin | ||
3 | at /pwd/lang/eval-fail-fromTOML-timestamps.nix:1:1: | ||
4 | 1| builtins.fromTOML '' | ||
5 | | ^ | ||
6 | 2| key = "value" | ||
7 | |||
8 | error: while parsing TOML: Dates and times are not supported | ||
diff --git a/test/testdata/eval-fail-fromTOML-timestamps.nix b/test/testdata/eval-fail-fromTOML-timestamps.nix new file mode 100644 index 0000000..74cff94 --- /dev/null +++ b/test/testdata/eval-fail-fromTOML-timestamps.nix | |||
@@ -0,0 +1,130 @@ | |||
1 | builtins.fromTOML '' | ||
2 | key = "value" | ||
3 | bare_key = "value" | ||
4 | bare-key = "value" | ||
5 | 1234 = "value" | ||
6 | |||
7 | "127.0.0.1" = "value" | ||
8 | "character encoding" = "value" | ||
9 | "ʎǝʞ" = "value" | ||
10 | 'key2' = "value" | ||
11 | 'quoted "value"' = "value" | ||
12 | |||
13 | name = "Orange" | ||
14 | |||
15 | physical.color = "orange" | ||
16 | physical.shape = "round" | ||
17 | site."google.com" = true | ||
18 | |||
19 | # This is legal according to the spec, but cpptoml doesn't handle it. | ||
20 | #a.b.c = 1 | ||
21 | #a.d = 2 | ||
22 | |||
23 | str = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF." | ||
24 | |||
25 | int1 = +99 | ||
26 | int2 = 42 | ||
27 | int3 = 0 | ||
28 | int4 = -17 | ||
29 | int5 = 1_000 | ||
30 | int6 = 5_349_221 | ||
31 | int7 = 1_2_3_4_5 | ||
32 | |||
33 | hex1 = 0xDEADBEEF | ||
34 | hex2 = 0xdeadbeef | ||
35 | hex3 = 0xdead_beef | ||
36 | |||
37 | oct1 = 0o01234567 | ||
38 | oct2 = 0o755 | ||
39 | |||
40 | bin1 = 0b11010110 | ||
41 | |||
42 | flt1 = +1.0 | ||
43 | flt2 = 3.1415 | ||
44 | flt3 = -0.01 | ||
45 | flt4 = 5e+22 | ||
46 | flt5 = 1e6 | ||
47 | flt6 = -2E-2 | ||
48 | flt7 = 6.626e-34 | ||
49 | flt8 = 9_224_617.445_991_228_313 | ||
50 | |||
51 | bool1 = true | ||
52 | bool2 = false | ||
53 | |||
54 | odt1 = 1979-05-27T07:32:00Z | ||
55 | odt2 = 1979-05-27T00:32:00-07:00 | ||
56 | odt3 = 1979-05-27T00:32:00.999999-07:00 | ||
57 | odt4 = 1979-05-27 07:32:00Z | ||
58 | ldt1 = 1979-05-27T07:32:00 | ||
59 | ldt2 = 1979-05-27T00:32:00.999999 | ||
60 | ld1 = 1979-05-27 | ||
61 | lt1 = 07:32:00 | ||
62 | lt2 = 00:32:00.999999 | ||
63 | |||
64 | arr1 = [ 1, 2, 3 ] | ||
65 | arr2 = [ "red", "yellow", "green" ] | ||
66 | arr3 = [ [ 1, 2 ], [3, 4, 5] ] | ||
67 | arr4 = [ "all", 'strings', """are the same""", ''''type''''] | ||
68 | arr5 = [ [ 1, 2 ], ["a", "b", "c"] ] | ||
69 | |||
70 | arr7 = [ | ||
71 | 1, 2, 3 | ||
72 | ] | ||
73 | |||
74 | arr8 = [ | ||
75 | 1, | ||
76 | 2, # this is ok | ||
77 | ] | ||
78 | |||
79 | [table-1] | ||
80 | key1 = "some string" | ||
81 | key2 = 123 | ||
82 | |||
83 | |||
84 | [table-2] | ||
85 | key1 = "another string" | ||
86 | key2 = 456 | ||
87 | |||
88 | [dog."tater.man"] | ||
89 | type.name = "pug" | ||
90 | |||
91 | [a.b.c] | ||
92 | [ d.e.f ] | ||
93 | [ g . h . i ] | ||
94 | [ j . "ʞ" . 'l' ] | ||
95 | [x.y.z.w] | ||
96 | |||
97 | name = { first = "Tom", last = "Preston-Werner" } | ||
98 | point = { x = 1, y = 2 } | ||
99 | animal = { type.name = "pug" } | ||
100 | |||
101 | [[products]] | ||
102 | name = "Hammer" | ||
103 | sku = 738594937 | ||
104 | |||
105 | [[products]] | ||
106 | |||
107 | [[products]] | ||
108 | name = "Nail" | ||
109 | sku = 284758393 | ||
110 | color = "gray" | ||
111 | |||
112 | [[fruit]] | ||
113 | name = "apple" | ||
114 | |||
115 | [fruit.physical] | ||
116 | color = "red" | ||
117 | shape = "round" | ||
118 | |||
119 | [[fruit.variety]] | ||
120 | name = "red delicious" | ||
121 | |||
122 | [[fruit.variety]] | ||
123 | name = "granny smith" | ||
124 | |||
125 | [[fruit]] | ||
126 | name = "banana" | ||
127 | |||
128 | [[fruit.variety]] | ||
129 | name = "plantain" | ||
130 | '' | ||
diff --git a/test/testdata/eval-fail-hashfile-missing.err.exp b/test/testdata/eval-fail-hashfile-missing.err.exp new file mode 100644 index 0000000..1e46539 --- /dev/null +++ b/test/testdata/eval-fail-hashfile-missing.err.exp | |||
@@ -0,0 +1,13 @@ | |||
1 | error: | ||
2 | … while calling the 'toString' builtin | ||
3 | at /pwd/lang/eval-fail-hashfile-missing.nix:4:3: | ||
4 | 3| in | ||
5 | 4| toString (builtins.concatLists (map (hash: map (builtins.hashFile hash) paths) ["md5" "sha1" "sha256" "sha512"])) | ||
6 | | ^ | ||
7 | 5| | ||
8 | |||
9 | … while evaluating the first argument passed to builtins.toString | ||
10 | |||
11 | … while calling the 'hashFile' builtin | ||
12 | |||
13 | error: opening file '/pwd/lang/this-file-is-definitely-not-there-7392097': No such file or directory | ||
diff --git a/test/testdata/eval-fail-hashfile-missing.nix b/test/testdata/eval-fail-hashfile-missing.nix new file mode 100644 index 0000000..ce098b8 --- /dev/null +++ b/test/testdata/eval-fail-hashfile-missing.nix | |||
@@ -0,0 +1,5 @@ | |||
1 | let | ||
2 | paths = [ ./this-file-is-definitely-not-there-7392097 "/and/neither/is/this/37293620" ]; | ||
3 | in | ||
4 | toString (builtins.concatLists (map (hash: map (builtins.hashFile hash) paths) ["md5" "sha1" "sha256" "sha512"])) | ||
5 | |||
diff --git a/test/testdata/eval-fail-infinite-recursion-lambda.err.exp b/test/testdata/eval-fail-infinite-recursion-lambda.err.exp new file mode 100644 index 0000000..712dd75 --- /dev/null +++ b/test/testdata/eval-fail-infinite-recursion-lambda.err.exp | |||
@@ -0,0 +1,38 @@ | |||
1 | error: | ||
2 | … from call site | ||
3 | at /pwd/lang/eval-fail-infinite-recursion-lambda.nix:1:1: | ||
4 | 1| (x: x x) (x: x x) | ||
5 | | ^ | ||
6 | 2| | ||
7 | |||
8 | … while calling anonymous lambda | ||
9 | at /pwd/lang/eval-fail-infinite-recursion-lambda.nix:1:2: | ||
10 | 1| (x: x x) (x: x x) | ||
11 | | ^ | ||
12 | 2| | ||
13 | |||
14 | … from call site | ||
15 | at /pwd/lang/eval-fail-infinite-recursion-lambda.nix:1:5: | ||
16 | 1| (x: x x) (x: x x) | ||
17 | | ^ | ||
18 | 2| | ||
19 | |||
20 | … while calling anonymous lambda | ||
21 | at /pwd/lang/eval-fail-infinite-recursion-lambda.nix:1:11: | ||
22 | 1| (x: x x) (x: x x) | ||
23 | | ^ | ||
24 | 2| | ||
25 | |||
26 | … from call site | ||
27 | at /pwd/lang/eval-fail-infinite-recursion-lambda.nix:1:14: | ||
28 | 1| (x: x x) (x: x x) | ||
29 | | ^ | ||
30 | 2| | ||
31 | |||
32 | (197 duplicate frames omitted) | ||
33 | |||
34 | error: stack overflow; max-call-depth exceeded | ||
35 | at /pwd/lang/eval-fail-infinite-recursion-lambda.nix:1:14: | ||
36 | 1| (x: x x) (x: x x) | ||
37 | | ^ | ||
38 | 2| | ||
diff --git a/test/testdata/eval-fail-infinite-recursion-lambda.flags b/test/testdata/eval-fail-infinite-recursion-lambda.flags new file mode 100644 index 0000000..59e20ec --- /dev/null +++ b/test/testdata/eval-fail-infinite-recursion-lambda.flags | |||
@@ -0,0 +1 @@ | |||
--max-call-depth 100 \ No newline at end of file | |||
diff --git a/test/testdata/eval-fail-infinite-recursion-lambda.nix b/test/testdata/eval-fail-infinite-recursion-lambda.nix new file mode 100644 index 0000000..dd0a8bf --- /dev/null +++ b/test/testdata/eval-fail-infinite-recursion-lambda.nix | |||
@@ -0,0 +1 @@ | |||
(x: x x) (x: x x) | |||
diff --git a/test/testdata/eval-fail-list.err.exp b/test/testdata/eval-fail-list.err.exp new file mode 100644 index 0000000..d492f8b --- /dev/null +++ b/test/testdata/eval-fail-list.err.exp | |||
@@ -0,0 +1,8 @@ | |||
1 | error: | ||
2 | … while evaluating one of the elements to concatenate | ||
3 | at /pwd/lang/eval-fail-list.nix:1:2: | ||
4 | 1| 8++1 | ||
5 | | ^ | ||
6 | 2| | ||
7 | |||
8 | error: expected a list but found an integer: 8 | ||
diff --git a/test/testdata/eval-fail-list.nix b/test/testdata/eval-fail-list.nix new file mode 100644 index 0000000..fa749f2 --- /dev/null +++ b/test/testdata/eval-fail-list.nix | |||
@@ -0,0 +1 @@ | |||
8++1 | |||
diff --git a/test/testdata/eval-fail-missing-arg.err.exp b/test/testdata/eval-fail-missing-arg.err.exp new file mode 100644 index 0000000..3b162fe --- /dev/null +++ b/test/testdata/eval-fail-missing-arg.err.exp | |||
@@ -0,0 +1,12 @@ | |||
1 | error: | ||
2 | … from call site | ||
3 | at /pwd/lang/eval-fail-missing-arg.nix:1:1: | ||
4 | 1| ({x, y, z}: x + y + z) {x = "foo"; z = "bar";} | ||
5 | | ^ | ||
6 | 2| | ||
7 | |||
8 | error: function 'anonymous lambda' called without required argument 'y' | ||
9 | at /pwd/lang/eval-fail-missing-arg.nix:1:2: | ||
10 | 1| ({x, y, z}: x + y + z) {x = "foo"; z = "bar";} | ||
11 | | ^ | ||
12 | 2| | ||
diff --git a/test/testdata/eval-fail-missing-arg.nix b/test/testdata/eval-fail-missing-arg.nix new file mode 100644 index 0000000..c4be979 --- /dev/null +++ b/test/testdata/eval-fail-missing-arg.nix | |||
@@ -0,0 +1 @@ | |||
({x, y, z}: x + y + z) {x = "foo"; z = "bar";} | |||
diff --git a/test/testdata/eval-fail-mutual-recursion.err.exp b/test/testdata/eval-fail-mutual-recursion.err.exp new file mode 100644 index 0000000..c034afc --- /dev/null +++ b/test/testdata/eval-fail-mutual-recursion.err.exp | |||
@@ -0,0 +1,64 @@ | |||
1 | error: | ||
2 | … from call site | ||
3 | at /pwd/lang/eval-fail-mutual-recursion.nix:36:3: | ||
4 | 35| in | ||
5 | 36| throwAfterA true 10 | ||
6 | | ^ | ||
7 | 37| | ||
8 | |||
9 | … while calling 'throwAfterA' | ||
10 | at /pwd/lang/eval-fail-mutual-recursion.nix:29:26: | ||
11 | 28| | ||
12 | 29| throwAfterA = recurse: n: | ||
13 | | ^ | ||
14 | 30| if n > 0 | ||
15 | |||
16 | … from call site | ||
17 | at /pwd/lang/eval-fail-mutual-recursion.nix:31:10: | ||
18 | 30| if n > 0 | ||
19 | 31| then throwAfterA recurse (n - 1) | ||
20 | | ^ | ||
21 | 32| else if recurse | ||
22 | |||
23 | (19 duplicate frames omitted) | ||
24 | |||
25 | … from call site | ||
26 | at /pwd/lang/eval-fail-mutual-recursion.nix:33:10: | ||
27 | 32| else if recurse | ||
28 | 33| then throwAfterB true 10 | ||
29 | | ^ | ||
30 | 34| else throw "Uh oh!"; | ||
31 | |||
32 | … while calling 'throwAfterB' | ||
33 | at /pwd/lang/eval-fail-mutual-recursion.nix:22:26: | ||
34 | 21| let | ||
35 | 22| throwAfterB = recurse: n: | ||
36 | | ^ | ||
37 | 23| if n > 0 | ||
38 | |||
39 | … from call site | ||
40 | at /pwd/lang/eval-fail-mutual-recursion.nix:24:10: | ||
41 | 23| if n > 0 | ||
42 | 24| then throwAfterB recurse (n - 1) | ||
43 | | ^ | ||
44 | 25| else if recurse | ||
45 | |||
46 | (19 duplicate frames omitted) | ||
47 | |||
48 | … from call site | ||
49 | at /pwd/lang/eval-fail-mutual-recursion.nix:26:10: | ||
50 | 25| else if recurse | ||
51 | 26| then throwAfterA false 10 | ||
52 | | ^ | ||
53 | 27| else throw "Uh oh!"; | ||
54 | |||
55 | (21 duplicate frames omitted) | ||
56 | |||
57 | … while calling the 'throw' builtin | ||
58 | at /pwd/lang/eval-fail-mutual-recursion.nix:34:10: | ||
59 | 33| then throwAfterB true 10 | ||
60 | 34| else throw "Uh oh!"; | ||
61 | | ^ | ||
62 | 35| in | ||
63 | |||
64 | error: Uh oh! | ||
diff --git a/test/testdata/eval-fail-mutual-recursion.nix b/test/testdata/eval-fail-mutual-recursion.nix new file mode 100644 index 0000000..d090d31 --- /dev/null +++ b/test/testdata/eval-fail-mutual-recursion.nix | |||
@@ -0,0 +1,36 @@ | |||
1 | # Check that stack frame deduplication only affects consecutive intervals, and | ||
2 | # that they are reported independently of any preceding sections, even if | ||
3 | # they're indistinguishable. | ||
4 | # | ||
5 | # In terms of the current implementation, we check that we clear the set of | ||
6 | # "seen frames" after eliding a group of frames. | ||
7 | # | ||
8 | # Suppose we have: | ||
9 | # - 10 frames in a function A | ||
10 | # - 10 frames in a function B | ||
11 | # - 10 frames in a function A | ||
12 | # | ||
13 | # We want to output: | ||
14 | # - a few frames of A (skip the rest) | ||
15 | # - a few frames of B (skip the rest) | ||
16 | # - a few frames of A (skip the rest) | ||
17 | # | ||
18 | # If we implemented this in the naive manner, we'd instead get: | ||
19 | # - a few frames of A (skip the rest) | ||
20 | # - a few frames of B (skip the rest, _and_ skip the remaining frames of A) | ||
21 | let | ||
22 | throwAfterB = recurse: n: | ||
23 | if n > 0 | ||
24 | then throwAfterB recurse (n - 1) | ||
25 | else if recurse | ||
26 | then throwAfterA false 10 | ||
27 | else throw "Uh oh!"; | ||
28 | |||
29 | throwAfterA = recurse: n: | ||
30 | if n > 0 | ||
31 | then throwAfterA recurse (n - 1) | ||
32 | else if recurse | ||
33 | then throwAfterB true 10 | ||
34 | else throw "Uh oh!"; | ||
35 | in | ||
36 | throwAfterA true 10 | ||
diff --git a/test/testdata/eval-fail-nested-list-items.err.exp b/test/testdata/eval-fail-nested-list-items.err.exp new file mode 100644 index 0000000..90d4390 --- /dev/null +++ b/test/testdata/eval-fail-nested-list-items.err.exp | |||
@@ -0,0 +1,9 @@ | |||
1 | error: | ||
2 | … while evaluating a path segment | ||
3 | at /pwd/lang/eval-fail-nested-list-items.nix:11:6: | ||
4 | 10| | ||
5 | 11| "" + (let v = [ [ 1 2 3 4 5 6 7 8 ] [1 2 3 4]]; in builtins.deepSeq v v) | ||
6 | | ^ | ||
7 | 12| | ||
8 | |||
9 | error: cannot coerce a list to a string: [ [ 1 2 3 4 5 6 7 8 ] [ 1 «3 items elided» ] ] | ||
diff --git a/test/testdata/eval-fail-nested-list-items.nix b/test/testdata/eval-fail-nested-list-items.nix new file mode 100644 index 0000000..af45b1d --- /dev/null +++ b/test/testdata/eval-fail-nested-list-items.nix | |||
@@ -0,0 +1,11 @@ | |||
1 | # This reproduces https://github.com/NixOS/nix/issues/10993, for lists | ||
2 | # $ nix run nix/2.23.1 -- eval --expr '"" + (let v = [ [ 1 2 3 4 5 6 7 8 ] [1 2 3 4]]; in builtins.deepSeq v v)' | ||
3 | # error: | ||
4 | # … while evaluating a path segment | ||
5 | # at «string»:1:6: | ||
6 | # 1| "" + (let v = [ [ 1 2 3 4 5 6 7 8 ] [1 2 3 4]]; in builtins.deepSeq v v) | ||
7 | # | ^ | ||
8 | # | ||
9 | # error: cannot coerce a list to a string: [ [ 1 2 3 4 5 6 7 8 ] [ 1 «4294967290 items elided» ] ] | ||
10 | |||
11 | "" + (let v = [ [ 1 2 3 4 5 6 7 8 ] [1 2 3 4]]; in builtins.deepSeq v v) | ||
diff --git a/test/testdata/eval-fail-nonexist-path.err.exp b/test/testdata/eval-fail-nonexist-path.err.exp new file mode 100644 index 0000000..a287067 --- /dev/null +++ b/test/testdata/eval-fail-nonexist-path.err.exp | |||
@@ -0,0 +1 @@ | |||
error: path '/pwd/lang/fnord' does not exist | |||
diff --git a/test/testdata/eval-fail-nonexist-path.nix b/test/testdata/eval-fail-nonexist-path.nix new file mode 100644 index 0000000..f2f0810 --- /dev/null +++ b/test/testdata/eval-fail-nonexist-path.nix | |||
@@ -0,0 +1,4 @@ | |||
1 | # This must fail to evaluate, since ./fnord doesn't exist. If it did | ||
2 | # exist, it would produce "/nix/store/<hash>-fnord/xyzzy" (with an | ||
3 | # appropriate context). | ||
4 | "${./fnord}/xyzzy" | ||
diff --git a/test/testdata/eval-fail-not-throws.err.exp b/test/testdata/eval-fail-not-throws.err.exp new file mode 100644 index 0000000..fc81f72 --- /dev/null +++ b/test/testdata/eval-fail-not-throws.err.exp | |||
@@ -0,0 +1,14 @@ | |||
1 | error: | ||
2 | … in the argument of the not operator | ||
3 | at /pwd/lang/eval-fail-not-throws.nix:1:4: | ||
4 | 1| ! (throw "uh oh!") | ||
5 | | ^ | ||
6 | 2| | ||
7 | |||
8 | … while calling the 'throw' builtin | ||
9 | at /pwd/lang/eval-fail-not-throws.nix:1:4: | ||
10 | 1| ! (throw "uh oh!") | ||
11 | | ^ | ||
12 | 2| | ||
13 | |||
14 | error: uh oh! | ||
diff --git a/test/testdata/eval-fail-not-throws.nix b/test/testdata/eval-fail-not-throws.nix new file mode 100644 index 0000000..a74ce4e --- /dev/null +++ b/test/testdata/eval-fail-not-throws.nix | |||
@@ -0,0 +1 @@ | |||
! (throw "uh oh!") | |||
diff --git a/test/testdata/eval-fail-overflowing-add.err.exp b/test/testdata/eval-fail-overflowing-add.err.exp new file mode 100644 index 0000000..6458cf1 --- /dev/null +++ b/test/testdata/eval-fail-overflowing-add.err.exp | |||
@@ -0,0 +1,6 @@ | |||
1 | error: integer overflow in adding 9223372036854775807 + 1 | ||
2 | at /pwd/lang/eval-fail-overflowing-add.nix:4:8: | ||
3 | 3| b = 1; | ||
4 | 4| in a + b | ||
5 | | ^ | ||
6 | 5| | ||
diff --git a/test/testdata/eval-fail-overflowing-add.nix b/test/testdata/eval-fail-overflowing-add.nix new file mode 100644 index 0000000..24258fc --- /dev/null +++ b/test/testdata/eval-fail-overflowing-add.nix | |||
@@ -0,0 +1,4 @@ | |||
1 | let | ||
2 | a = 9223372036854775807; | ||
3 | b = 1; | ||
4 | in a + b | ||
diff --git a/test/testdata/eval-fail-overflowing-div.err.exp b/test/testdata/eval-fail-overflowing-div.err.exp new file mode 100644 index 0000000..8ce07d4 --- /dev/null +++ b/test/testdata/eval-fail-overflowing-div.err.exp | |||
@@ -0,0 +1,23 @@ | |||
1 | error: | ||
2 | … while calling the 'seq' builtin | ||
3 | at /pwd/lang/eval-fail-overflowing-div.nix:7:4: | ||
4 | 6| b = -1; | ||
5 | 7| in builtins.seq intMin (builtins.seq b (intMin / b)) | ||
6 | | ^ | ||
7 | 8| | ||
8 | |||
9 | … while calling the 'seq' builtin | ||
10 | at /pwd/lang/eval-fail-overflowing-div.nix:7:25: | ||
11 | 6| b = -1; | ||
12 | 7| in builtins.seq intMin (builtins.seq b (intMin / b)) | ||
13 | | ^ | ||
14 | 8| | ||
15 | |||
16 | … while calling the 'div' builtin | ||
17 | at /pwd/lang/eval-fail-overflowing-div.nix:7:48: | ||
18 | 6| b = -1; | ||
19 | 7| in builtins.seq intMin (builtins.seq b (intMin / b)) | ||
20 | | ^ | ||
21 | 8| | ||
22 | |||
23 | error: integer overflow in dividing -9223372036854775808 / -1 | ||
diff --git a/test/testdata/eval-fail-overflowing-div.nix b/test/testdata/eval-fail-overflowing-div.nix new file mode 100644 index 0000000..44fbe9d --- /dev/null +++ b/test/testdata/eval-fail-overflowing-div.nix | |||
@@ -0,0 +1,7 @@ | |||
1 | let | ||
2 | # lol, this has to be written as an expression like this because negative | ||
3 | # numbers use unary negation rather than parsing directly, and 2**63 is out | ||
4 | # of range | ||
5 | intMin = -9223372036854775807 - 1; | ||
6 | b = -1; | ||
7 | in builtins.seq intMin (builtins.seq b (intMin / b)) | ||
diff --git a/test/testdata/eval-fail-overflowing-mul.err.exp b/test/testdata/eval-fail-overflowing-mul.err.exp new file mode 100644 index 0000000..f42b39d --- /dev/null +++ b/test/testdata/eval-fail-overflowing-mul.err.exp | |||
@@ -0,0 +1,16 @@ | |||
1 | error: | ||
2 | … while calling the 'mul' builtin | ||
3 | at /pwd/lang/eval-fail-overflowing-mul.nix:3:10: | ||
4 | 2| a = 4294967297; | ||
5 | 3| in a * a * a | ||
6 | | ^ | ||
7 | 4| | ||
8 | |||
9 | … while calling the 'mul' builtin | ||
10 | at /pwd/lang/eval-fail-overflowing-mul.nix:3:6: | ||
11 | 2| a = 4294967297; | ||
12 | 3| in a * a * a | ||
13 | | ^ | ||
14 | 4| | ||
15 | |||
16 | error: integer overflow in multiplying 4294967297 * 4294967297 | ||
diff --git a/test/testdata/eval-fail-overflowing-mul.nix b/test/testdata/eval-fail-overflowing-mul.nix new file mode 100644 index 0000000..6081d9c --- /dev/null +++ b/test/testdata/eval-fail-overflowing-mul.nix | |||
@@ -0,0 +1,3 @@ | |||
1 | let | ||
2 | a = 4294967297; | ||
3 | in a * a * a | ||
diff --git a/test/testdata/eval-fail-overflowing-sub.err.exp b/test/testdata/eval-fail-overflowing-sub.err.exp new file mode 100644 index 0000000..66a3a03 --- /dev/null +++ b/test/testdata/eval-fail-overflowing-sub.err.exp | |||
@@ -0,0 +1,9 @@ | |||
1 | error: | ||
2 | … while calling the 'sub' builtin | ||
3 | at /pwd/lang/eval-fail-overflowing-sub.nix:4:6: | ||
4 | 3| b = 2; | ||
5 | 4| in a - b | ||
6 | | ^ | ||
7 | 5| | ||
8 | |||
9 | error: integer overflow in subtracting -9223372036854775807 - 2 | ||
diff --git a/test/testdata/eval-fail-overflowing-sub.nix b/test/testdata/eval-fail-overflowing-sub.nix new file mode 100644 index 0000000..229b8c6 --- /dev/null +++ b/test/testdata/eval-fail-overflowing-sub.nix | |||
@@ -0,0 +1,4 @@ | |||
1 | let | ||
2 | a = -9223372036854775807; | ||
3 | b = 2; | ||
4 | in a - b | ||
diff --git a/test/testdata/eval-fail-path-slash.err.exp b/test/testdata/eval-fail-path-slash.err.exp new file mode 100644 index 0000000..e3531d3 --- /dev/null +++ b/test/testdata/eval-fail-path-slash.err.exp | |||
@@ -0,0 +1,6 @@ | |||
1 | error: path has a trailing slash | ||
2 | at /pwd/lang/eval-fail-path-slash.nix:6:12: | ||
3 | 5| # and https://nixos.org/nix-dev/2016-June/020829.html | ||
4 | 6| /nix/store/ | ||
5 | | ^ | ||
6 | 7| | ||
diff --git a/test/testdata/eval-fail-path-slash.nix b/test/testdata/eval-fail-path-slash.nix new file mode 100644 index 0000000..8c2e104 --- /dev/null +++ b/test/testdata/eval-fail-path-slash.nix | |||
@@ -0,0 +1,6 @@ | |||
1 | # Trailing slashes in paths are not allowed. | ||
2 | # This restriction could be lifted sometime, | ||
3 | # for example if we make '/' a path concatenation operator. | ||
4 | # See https://github.com/NixOS/nix/issues/1138 | ||
5 | # and https://nixos.org/nix-dev/2016-June/020829.html | ||
6 | /nix/store/ | ||
diff --git a/test/testdata/eval-fail-pipe-operators.err.exp b/test/testdata/eval-fail-pipe-operators.err.exp new file mode 100644 index 0000000..49f3fa8 --- /dev/null +++ b/test/testdata/eval-fail-pipe-operators.err.exp | |||
@@ -0,0 +1,5 @@ | |||
1 | error: experimental Nix feature 'pipe-operators' is disabled; add '--extra-experimental-features pipe-operators' to enable it | ||
2 | at /pwd/lang/eval-fail-pipe-operators.nix:1:3: | ||
3 | 1| 1 |> 2 | ||
4 | | ^ | ||
5 | 2| | ||
diff --git a/test/testdata/eval-fail-pipe-operators.nix b/test/testdata/eval-fail-pipe-operators.nix new file mode 100644 index 0000000..433e0fd --- /dev/null +++ b/test/testdata/eval-fail-pipe-operators.nix | |||
@@ -0,0 +1 @@ | |||
1 |> 2 | |||
diff --git a/test/testdata/eval-fail-recursion.err.exp b/test/testdata/eval-fail-recursion.err.exp new file mode 100644 index 0000000..19380dc --- /dev/null +++ b/test/testdata/eval-fail-recursion.err.exp | |||
@@ -0,0 +1,12 @@ | |||
1 | error: | ||
2 | … in the right operand of the update (//) operator | ||
3 | at /pwd/lang/eval-fail-recursion.nix:1:12: | ||
4 | 1| let a = {} // a; in a.foo | ||
5 | | ^ | ||
6 | 2| | ||
7 | |||
8 | error: infinite recursion encountered | ||
9 | at /pwd/lang/eval-fail-recursion.nix:1:15: | ||
10 | 1| let a = {} // a; in a.foo | ||
11 | | ^ | ||
12 | 2| | ||
diff --git a/test/testdata/eval-fail-recursion.nix b/test/testdata/eval-fail-recursion.nix new file mode 100644 index 0000000..075b5ed --- /dev/null +++ b/test/testdata/eval-fail-recursion.nix | |||
@@ -0,0 +1 @@ | |||
let a = {} // a; in a.foo | |||
diff --git a/test/testdata/eval-fail-remove.err.exp b/test/testdata/eval-fail-remove.err.exp new file mode 100644 index 0000000..292b3c3 --- /dev/null +++ b/test/testdata/eval-fail-remove.err.exp | |||
@@ -0,0 +1,15 @@ | |||
1 | error: | ||
2 | … while evaluating the attribute 'body' | ||
3 | at /pwd/lang/eval-fail-remove.nix:4:3: | ||
4 | 3| | ||
5 | 4| body = (removeAttrs attrs ["x"]).x; | ||
6 | | ^ | ||
7 | 5| } | ||
8 | |||
9 | error: attribute 'x' missing | ||
10 | at /pwd/lang/eval-fail-remove.nix:4:10: | ||
11 | 3| | ||
12 | 4| body = (removeAttrs attrs ["x"]).x; | ||
13 | | ^ | ||
14 | 5| } | ||
15 | Did you mean y? | ||
diff --git a/test/testdata/eval-fail-remove.nix b/test/testdata/eval-fail-remove.nix new file mode 100644 index 0000000..539e0eb --- /dev/null +++ b/test/testdata/eval-fail-remove.nix | |||
@@ -0,0 +1,5 @@ | |||
1 | let { | ||
2 | attrs = {x = 123; y = 456;}; | ||
3 | |||
4 | body = (removeAttrs attrs ["x"]).x; | ||
5 | } \ No newline at end of file | ||
diff --git a/test/testdata/eval-fail-scope-5.err.exp b/test/testdata/eval-fail-scope-5.err.exp new file mode 100644 index 0000000..b0b05ca --- /dev/null +++ b/test/testdata/eval-fail-scope-5.err.exp | |||
@@ -0,0 +1,28 @@ | |||
1 | error: | ||
2 | … while evaluating the attribute 'body' | ||
3 | at /pwd/lang/eval-fail-scope-5.nix:8:3: | ||
4 | 7| | ||
5 | 8| body = f {}; | ||
6 | | ^ | ||
7 | 9| | ||
8 | |||
9 | … from call site | ||
10 | at /pwd/lang/eval-fail-scope-5.nix:8:10: | ||
11 | 7| | ||
12 | 8| body = f {}; | ||
13 | | ^ | ||
14 | 9| | ||
15 | |||
16 | … while calling 'f' | ||
17 | at /pwd/lang/eval-fail-scope-5.nix:6:7: | ||
18 | 5| | ||
19 | 6| f = {x ? y, y ? x}: x + y; | ||
20 | | ^ | ||
21 | 7| | ||
22 | |||
23 | error: infinite recursion encountered | ||
24 | at /pwd/lang/eval-fail-scope-5.nix:6:12: | ||
25 | 5| | ||
26 | 6| f = {x ? y, y ? x}: x + y; | ||
27 | | ^ | ||
28 | 7| | ||
diff --git a/test/testdata/eval-fail-scope-5.nix b/test/testdata/eval-fail-scope-5.nix new file mode 100644 index 0000000..f89a65a --- /dev/null +++ b/test/testdata/eval-fail-scope-5.nix | |||
@@ -0,0 +1,10 @@ | |||
1 | let { | ||
2 | |||
3 | x = "a"; | ||
4 | y = "b"; | ||
5 | |||
6 | f = {x ? y, y ? x}: x + y; | ||
7 | |||
8 | body = f {}; | ||
9 | |||
10 | } | ||
diff --git a/test/testdata/eval-fail-seq.err.exp b/test/testdata/eval-fail-seq.err.exp new file mode 100644 index 0000000..3e3d71b --- /dev/null +++ b/test/testdata/eval-fail-seq.err.exp | |||
@@ -0,0 +1,14 @@ | |||
1 | error: | ||
2 | … while calling the 'seq' builtin | ||
3 | at /pwd/lang/eval-fail-seq.nix:1:1: | ||
4 | 1| builtins.seq (abort "foo") 2 | ||
5 | | ^ | ||
6 | 2| | ||
7 | |||
8 | … while calling the 'abort' builtin | ||
9 | at /pwd/lang/eval-fail-seq.nix:1:15: | ||
10 | 1| builtins.seq (abort "foo") 2 | ||
11 | | ^ | ||
12 | 2| | ||
13 | |||
14 | error: evaluation aborted with the following error message: 'foo' | ||
diff --git a/test/testdata/eval-fail-seq.nix b/test/testdata/eval-fail-seq.nix new file mode 100644 index 0000000..cddbbfd --- /dev/null +++ b/test/testdata/eval-fail-seq.nix | |||
@@ -0,0 +1 @@ | |||
builtins.seq (abort "foo") 2 | |||
diff --git a/test/testdata/eval-fail-set-override.err.exp b/test/testdata/eval-fail-set-override.err.exp new file mode 100644 index 0000000..9006ca4 --- /dev/null +++ b/test/testdata/eval-fail-set-override.err.exp | |||
@@ -0,0 +1,4 @@ | |||
1 | error: | ||
2 | … while evaluating the `__overrides` attribute | ||
3 | |||
4 | error: expected a set but found an integer: 1 | ||
diff --git a/test/testdata/eval-fail-set-override.nix b/test/testdata/eval-fail-set-override.nix new file mode 100644 index 0000000..03551c1 --- /dev/null +++ b/test/testdata/eval-fail-set-override.nix | |||
@@ -0,0 +1 @@ | |||
rec { __overrides = 1; } | |||
diff --git a/test/testdata/eval-fail-set.err.exp b/test/testdata/eval-fail-set.err.exp new file mode 100644 index 0000000..6dd646e --- /dev/null +++ b/test/testdata/eval-fail-set.err.exp | |||
@@ -0,0 +1,5 @@ | |||
1 | error: undefined variable 'x' | ||
2 | at /pwd/lang/eval-fail-set.nix:1:3: | ||
3 | 1| 8.x | ||
4 | | ^ | ||
5 | 2| | ||
diff --git a/test/testdata/eval-fail-set.nix b/test/testdata/eval-fail-set.nix new file mode 100644 index 0000000..c6b7980 --- /dev/null +++ b/test/testdata/eval-fail-set.nix | |||
@@ -0,0 +1 @@ | |||
8.x | |||
diff --git a/test/testdata/eval-fail-substring.err.exp b/test/testdata/eval-fail-substring.err.exp new file mode 100644 index 0000000..0457a82 --- /dev/null +++ b/test/testdata/eval-fail-substring.err.exp | |||
@@ -0,0 +1,8 @@ | |||
1 | error: | ||
2 | … while calling the 'substring' builtin | ||
3 | at /pwd/lang/eval-fail-substring.nix:1:1: | ||
4 | 1| builtins.substring (builtins.sub 0 1) 1 "x" | ||
5 | | ^ | ||
6 | 2| | ||
7 | |||
8 | error: negative start position in 'substring' | ||
diff --git a/test/testdata/eval-fail-substring.nix b/test/testdata/eval-fail-substring.nix new file mode 100644 index 0000000..f37c2bc --- /dev/null +++ b/test/testdata/eval-fail-substring.nix | |||
@@ -0,0 +1 @@ | |||
builtins.substring (builtins.sub 0 1) 1 "x" | |||
diff --git a/test/testdata/eval-fail-to-path.err.exp b/test/testdata/eval-fail-to-path.err.exp new file mode 100644 index 0000000..d6b17be --- /dev/null +++ b/test/testdata/eval-fail-to-path.err.exp | |||
@@ -0,0 +1,10 @@ | |||
1 | error: | ||
2 | … while calling the 'toPath' builtin | ||
3 | at /pwd/lang/eval-fail-to-path.nix:1:1: | ||
4 | 1| builtins.toPath "foo/bar" | ||
5 | | ^ | ||
6 | 2| | ||
7 | |||
8 | … while evaluating the first argument passed to builtins.toPath | ||
9 | |||
10 | error: string 'foo/bar' doesn't represent an absolute path | ||
diff --git a/test/testdata/eval-fail-to-path.nix b/test/testdata/eval-fail-to-path.nix new file mode 100644 index 0000000..5e322bc --- /dev/null +++ b/test/testdata/eval-fail-to-path.nix | |||
@@ -0,0 +1 @@ | |||
builtins.toPath "foo/bar" | |||
diff --git a/test/testdata/eval-fail-toJSON.err.exp b/test/testdata/eval-fail-toJSON.err.exp new file mode 100644 index 0000000..ad26771 --- /dev/null +++ b/test/testdata/eval-fail-toJSON.err.exp | |||
@@ -0,0 +1,50 @@ | |||
1 | error: | ||
2 | … while calling the 'toJSON' builtin | ||
3 | at /pwd/lang/eval-fail-toJSON.nix:1:1: | ||
4 | 1| builtins.toJSON { | ||
5 | | ^ | ||
6 | 2| a.b = [ | ||
7 | |||
8 | … while evaluating attribute 'a' | ||
9 | at /pwd/lang/eval-fail-toJSON.nix:2:3: | ||
10 | 1| builtins.toJSON { | ||
11 | 2| a.b = [ | ||
12 | | ^ | ||
13 | 3| true | ||
14 | |||
15 | … while evaluating attribute 'b' | ||
16 | at /pwd/lang/eval-fail-toJSON.nix:2:3: | ||
17 | 1| builtins.toJSON { | ||
18 | 2| a.b = [ | ||
19 | | ^ | ||
20 | 3| true | ||
21 | |||
22 | … while evaluating list element at index 3 | ||
23 | at /pwd/lang/eval-fail-toJSON.nix:2:3: | ||
24 | 1| builtins.toJSON { | ||
25 | 2| a.b = [ | ||
26 | | ^ | ||
27 | 3| true | ||
28 | |||
29 | … while evaluating attribute 'c' | ||
30 | at /pwd/lang/eval-fail-toJSON.nix:7:7: | ||
31 | 6| { | ||
32 | 7| c.d = throw "hah no"; | ||
33 | | ^ | ||
34 | 8| } | ||
35 | |||
36 | … while evaluating attribute 'd' | ||
37 | at /pwd/lang/eval-fail-toJSON.nix:7:7: | ||
38 | 6| { | ||
39 | 7| c.d = throw "hah no"; | ||
40 | | ^ | ||
41 | 8| } | ||
42 | |||
43 | … while calling the 'throw' builtin | ||
44 | at /pwd/lang/eval-fail-toJSON.nix:7:13: | ||
45 | 6| { | ||
46 | 7| c.d = throw "hah no"; | ||
47 | | ^ | ||
48 | 8| } | ||
49 | |||
50 | error: hah no | ||
diff --git a/test/testdata/eval-fail-toJSON.nix b/test/testdata/eval-fail-toJSON.nix new file mode 100644 index 0000000..8112e1c --- /dev/null +++ b/test/testdata/eval-fail-toJSON.nix | |||
@@ -0,0 +1,10 @@ | |||
1 | builtins.toJSON { | ||
2 | a.b = [ | ||
3 | true | ||
4 | false | ||
5 | "it's a bird" | ||
6 | { | ||
7 | c.d = throw "hah no"; | ||
8 | } | ||
9 | ]; | ||
10 | } | ||
diff --git a/test/testdata/eval-fail-undeclared-arg.err.exp b/test/testdata/eval-fail-undeclared-arg.err.exp new file mode 100644 index 0000000..6e13a13 --- /dev/null +++ b/test/testdata/eval-fail-undeclared-arg.err.exp | |||
@@ -0,0 +1,13 @@ | |||
1 | error: | ||
2 | … from call site | ||
3 | at /pwd/lang/eval-fail-undeclared-arg.nix:1:1: | ||
4 | 1| ({x, z}: x + z) {x = "foo"; y = "bla"; z = "bar";} | ||
5 | | ^ | ||
6 | 2| | ||
7 | |||
8 | error: function 'anonymous lambda' called with unexpected argument 'y' | ||
9 | at /pwd/lang/eval-fail-undeclared-arg.nix:1:2: | ||
10 | 1| ({x, z}: x + z) {x = "foo"; y = "bla"; z = "bar";} | ||
11 | | ^ | ||
12 | 2| | ||
13 | Did you mean one of x or z? | ||
diff --git a/test/testdata/eval-fail-undeclared-arg.nix b/test/testdata/eval-fail-undeclared-arg.nix new file mode 100644 index 0000000..cafdf16 --- /dev/null +++ b/test/testdata/eval-fail-undeclared-arg.nix | |||
@@ -0,0 +1 @@ | |||
({x, z}: x + z) {x = "foo"; y = "bla"; z = "bar";} | |||
diff --git a/test/testdata/eval-fail-using-set-as-attr-name.err.exp b/test/testdata/eval-fail-using-set-as-attr-name.err.exp new file mode 100644 index 0000000..4326c96 --- /dev/null +++ b/test/testdata/eval-fail-using-set-as-attr-name.err.exp | |||
@@ -0,0 +1,14 @@ | |||
1 | error: | ||
2 | … while evaluating an attribute name | ||
3 | at /pwd/lang/eval-fail-using-set-as-attr-name.nix:5:10: | ||
4 | 4| in | ||
5 | 5| attr.${key} | ||
6 | | ^ | ||
7 | 6| | ||
8 | |||
9 | error: expected a string but found a set: { } | ||
10 | at /pwd/lang/eval-fail-using-set-as-attr-name.nix:5:10: | ||
11 | 4| in | ||
12 | 5| attr.${key} | ||
13 | | ^ | ||
14 | 6| | ||
diff --git a/test/testdata/eval-fail-using-set-as-attr-name.nix b/test/testdata/eval-fail-using-set-as-attr-name.nix new file mode 100644 index 0000000..48e071a --- /dev/null +++ b/test/testdata/eval-fail-using-set-as-attr-name.nix | |||
@@ -0,0 +1,5 @@ | |||
1 | let | ||
2 | attr = {foo = "bar";}; | ||
3 | key = {}; | ||
4 | in | ||
5 | attr.${key} | ||
diff --git a/test/testdata/eval-okay-any-all.exp b/test/testdata/eval-okay-any-all.exp new file mode 100644 index 0000000..eb273f4 --- /dev/null +++ b/test/testdata/eval-okay-any-all.exp | |||
@@ -0,0 +1 @@ | |||
[ false false true true true true false true ] | |||
diff --git a/test/testdata/eval-okay-any-all.nix b/test/testdata/eval-okay-any-all.nix new file mode 100644 index 0000000..a3f26ea --- /dev/null +++ b/test/testdata/eval-okay-any-all.nix | |||
@@ -0,0 +1,11 @@ | |||
1 | with builtins; | ||
2 | |||
3 | [ (any (x: x == 1) []) | ||
4 | (any (x: x == 1) [2 3 4]) | ||
5 | (any (x: x == 1) [1 2 3 4]) | ||
6 | (any (x: x == 1) [4 3 2 1]) | ||
7 | (all (x: x == 1) []) | ||
8 | (all (x: x == 1) [1]) | ||
9 | (all (x: x == 1) [1 2 3]) | ||
10 | (all (x: x == 1) [1 1 1]) | ||
11 | ] | ||
diff --git a/test/testdata/eval-okay-arithmetic.exp b/test/testdata/eval-okay-arithmetic.exp new file mode 100644 index 0000000..5c54d10 --- /dev/null +++ b/test/testdata/eval-okay-arithmetic.exp | |||
@@ -0,0 +1 @@ | |||
2216 | |||
diff --git a/test/testdata/eval-okay-arithmetic.nix b/test/testdata/eval-okay-arithmetic.nix new file mode 100644 index 0000000..7e9e6a0 --- /dev/null +++ b/test/testdata/eval-okay-arithmetic.nix | |||
@@ -0,0 +1,59 @@ | |||
1 | with import ./lib.nix; | ||
2 | |||
3 | let { | ||
4 | |||
5 | /* Supposedly tail recursive version: | ||
6 | |||
7 | range_ = accum: first: last: | ||
8 | if first == last then ([first] ++ accum) | ||
9 | else range_ ([first] ++ accum) (builtins.add first 1) last; | ||
10 | |||
11 | range = range_ []; | ||
12 | */ | ||
13 | |||
14 | x = 12; | ||
15 | |||
16 | err = abort "urgh"; | ||
17 | |||
18 | body = sum | ||
19 | [ (sum (range 1 50)) | ||
20 | (123 + 456) | ||
21 | (0 + -10 + -(-11) + -x) | ||
22 | (10 - 7 - -2) | ||
23 | (10 - (6 - -1)) | ||
24 | (10 - 1 + 2) | ||
25 | (3 * 4 * 5) | ||
26 | (56088 / 123 / 2) | ||
27 | (3 + 4 * const 5 0 - 6 / id 2) | ||
28 | |||
29 | (builtins.bitAnd 12 10) # 0b1100 & 0b1010 = 8 | ||
30 | (builtins.bitOr 12 10) # 0b1100 | 0b1010 = 14 | ||
31 | (builtins.bitXor 12 10) # 0b1100 ^ 0b1010 = 6 | ||
32 | |||
33 | (if 3 < 7 then 1 else err) | ||
34 | (if 7 < 3 then err else 1) | ||
35 | (if 3 < 3 then err else 1) | ||
36 | |||
37 | (if 3 <= 7 then 1 else err) | ||
38 | (if 7 <= 3 then err else 1) | ||
39 | (if 3 <= 3 then 1 else err) | ||
40 | |||
41 | (if 3 > 7 then err else 1) | ||
42 | (if 7 > 3 then 1 else err) | ||
43 | (if 3 > 3 then err else 1) | ||
44 | |||
45 | (if 3 >= 7 then err else 1) | ||
46 | (if 7 >= 3 then 1 else err) | ||
47 | (if 3 >= 3 then 1 else err) | ||
48 | |||
49 | (if 2 > 1 == 1 < 2 then 1 else err) | ||
50 | (if 1 + 2 * 3 >= 7 then 1 else err) | ||
51 | (if 1 + 2 * 3 < 7 then err else 1) | ||
52 | |||
53 | # Not integer, but so what. | ||
54 | (if "aa" < "ab" then 1 else err) | ||
55 | (if "aa" < "aa" then err else 1) | ||
56 | (if "foo" < "foobar" then 1 else err) | ||
57 | ]; | ||
58 | |||
59 | } | ||
diff --git a/test/testdata/eval-okay-attrnames.exp b/test/testdata/eval-okay-attrnames.exp new file mode 100644 index 0000000..b4aa387 --- /dev/null +++ b/test/testdata/eval-okay-attrnames.exp | |||
@@ -0,0 +1 @@ | |||
"newxfoonewxy" | |||
diff --git a/test/testdata/eval-okay-attrnames.nix b/test/testdata/eval-okay-attrnames.nix new file mode 100644 index 0000000..e5b26e9 --- /dev/null +++ b/test/testdata/eval-okay-attrnames.nix | |||
@@ -0,0 +1,11 @@ | |||
1 | with import ./lib.nix; | ||
2 | |||
3 | let | ||
4 | |||
5 | attrs = {y = "y"; x = "x"; foo = "foo";} // rec {x = "newx"; bar = x;}; | ||
6 | |||
7 | names = builtins.attrNames attrs; | ||
8 | |||
9 | values = map (name: builtins.getAttr name attrs) names; | ||
10 | |||
11 | in assert values == builtins.attrValues attrs; concat values | ||
diff --git a/test/testdata/eval-okay-attrs.exp b/test/testdata/eval-okay-attrs.exp new file mode 100644 index 0000000..45b0f82 --- /dev/null +++ b/test/testdata/eval-okay-attrs.exp | |||
@@ -0,0 +1 @@ | |||
987 | |||
diff --git a/test/testdata/eval-okay-attrs.nix b/test/testdata/eval-okay-attrs.nix new file mode 100644 index 0000000..810b31a --- /dev/null +++ b/test/testdata/eval-okay-attrs.nix | |||
@@ -0,0 +1,5 @@ | |||
1 | let { | ||
2 | as = { x = 123; y = 456; } // { z = 789; } // { z = 987; }; | ||
3 | |||
4 | body = if as ? a then as.a else assert as ? z; as.z; | ||
5 | } | ||
diff --git a/test/testdata/eval-okay-attrs2.exp b/test/testdata/eval-okay-attrs2.exp new file mode 100644 index 0000000..45b0f82 --- /dev/null +++ b/test/testdata/eval-okay-attrs2.exp | |||
@@ -0,0 +1 @@ | |||
987 | |||
diff --git a/test/testdata/eval-okay-attrs2.nix b/test/testdata/eval-okay-attrs2.nix new file mode 100644 index 0000000..9e06b83 --- /dev/null +++ b/test/testdata/eval-okay-attrs2.nix | |||
@@ -0,0 +1,10 @@ | |||
1 | let { | ||
2 | as = { x = 123; y = 456; } // { z = 789; } // { z = 987; }; | ||
3 | |||
4 | A = "a"; | ||
5 | Z = "z"; | ||
6 | |||
7 | body = if builtins.hasAttr A as | ||
8 | then builtins.getAttr A as | ||
9 | else assert builtins.hasAttr Z as; builtins.getAttr Z as; | ||
10 | } | ||
diff --git a/test/testdata/eval-okay-attrs3.exp b/test/testdata/eval-okay-attrs3.exp new file mode 100644 index 0000000..19de4fd --- /dev/null +++ b/test/testdata/eval-okay-attrs3.exp | |||
@@ -0,0 +1 @@ | |||
"foo 22 80 itchyxac" | |||
diff --git a/test/testdata/eval-okay-attrs3.nix b/test/testdata/eval-okay-attrs3.nix new file mode 100644 index 0000000..f29de11 --- /dev/null +++ b/test/testdata/eval-okay-attrs3.nix | |||
@@ -0,0 +1,22 @@ | |||
1 | let | ||
2 | |||
3 | config = | ||
4 | { | ||
5 | services.sshd.enable = true; | ||
6 | services.sshd.port = 22; | ||
7 | services.httpd.port = 80; | ||
8 | hostName = "itchy"; | ||
9 | a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z = "x"; | ||
10 | foo = { | ||
11 | a = "a"; | ||
12 | b.c = "c"; | ||
13 | }; | ||
14 | }; | ||
15 | |||
16 | in | ||
17 | if config.services.sshd.enable | ||
18 | then "foo ${toString config.services.sshd.port} ${toString config.services.httpd.port} ${config.hostName}" | ||
19 | + "${config.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z}" | ||
20 | + "${config.foo.a}" | ||
21 | + "${config.foo.b.c}" | ||
22 | else "bar" | ||
diff --git a/test/testdata/eval-okay-attrs4.exp b/test/testdata/eval-okay-attrs4.exp new file mode 100644 index 0000000..1851731 --- /dev/null +++ b/test/testdata/eval-okay-attrs4.exp | |||
@@ -0,0 +1 @@ | |||
[ true false true false false true false false ] | |||
diff --git a/test/testdata/eval-okay-attrs4.nix b/test/testdata/eval-okay-attrs4.nix new file mode 100644 index 0000000..43ec812 --- /dev/null +++ b/test/testdata/eval-okay-attrs4.nix | |||
@@ -0,0 +1,7 @@ | |||
1 | let | ||
2 | |||
3 | as = { x.y.z = 123; a.b.c = 456; }; | ||
4 | |||
5 | bs = null; | ||
6 | |||
7 | in [ (as ? x) (as ? y) (as ? x.y.z) (as ? x.y.z.a) (as ? x.y.a) (as ? a.b.c) (bs ? x) (bs ? x.y.z) ] | ||
diff --git a/test/testdata/eval-okay-attrs5.exp b/test/testdata/eval-okay-attrs5.exp new file mode 100644 index 0000000..ce0430d --- /dev/null +++ b/test/testdata/eval-okay-attrs5.exp | |||
@@ -0,0 +1 @@ | |||
[ 123 "foo" 456 456 "foo" "xyzzy" "xyzzy" true ] | |||
diff --git a/test/testdata/eval-okay-attrs5.nix b/test/testdata/eval-okay-attrs5.nix new file mode 100644 index 0000000..a4584cd --- /dev/null +++ b/test/testdata/eval-okay-attrs5.nix | |||
@@ -0,0 +1,21 @@ | |||
1 | with import ./lib.nix; | ||
2 | |||
3 | let | ||
4 | |||
5 | as = { x.y.z = 123; a.b.c = 456; }; | ||
6 | |||
7 | bs = { f-o-o.bar = "foo"; }; | ||
8 | |||
9 | or = x: y: x || y; | ||
10 | |||
11 | in | ||
12 | [ as.x.y.z | ||
13 | as.foo or "foo" | ||
14 | as.x.y.bla or as.a.b.c | ||
15 | as.a.b.c or as.x.y.z | ||
16 | as.x.y.bla or bs.f-o-o.bar or "xyzzy" | ||
17 | as.x.y.bla or bs.bar.foo or "xyzzy" | ||
18 | (123).bla or null.foo or "xyzzy" | ||
19 | # Backwards compatibility test. | ||
20 | (fold or [] [true false false]) | ||
21 | ] | ||
diff --git a/test/testdata/eval-okay-attrs6.exp b/test/testdata/eval-okay-attrs6.exp new file mode 100644 index 0000000..b469380 --- /dev/null +++ b/test/testdata/eval-okay-attrs6.exp | |||
@@ -0,0 +1 @@ | |||
{ __overrides = { bar = "qux"; }; bar = "qux"; foo = "bar"; } | |||
diff --git a/test/testdata/eval-okay-attrs6.nix b/test/testdata/eval-okay-attrs6.nix new file mode 100644 index 0000000..2e5c854 --- /dev/null +++ b/test/testdata/eval-okay-attrs6.nix | |||
@@ -0,0 +1,4 @@ | |||
1 | rec { | ||
2 | "${"foo"}" = "bar"; | ||
3 | __overrides = { bar = "qux"; }; | ||
4 | } | ||
diff --git a/test/testdata/eval-okay-autoargs.exp b/test/testdata/eval-okay-autoargs.exp new file mode 100644 index 0000000..7a83917 --- /dev/null +++ b/test/testdata/eval-okay-autoargs.exp | |||
@@ -0,0 +1 @@ | |||
"xyzzy!xyzzy!foobar" | |||
diff --git a/test/testdata/eval-okay-autoargs.flags b/test/testdata/eval-okay-autoargs.flags new file mode 100644 index 0000000..ae37622 --- /dev/null +++ b/test/testdata/eval-okay-autoargs.flags | |||
@@ -0,0 +1 @@ | |||
--arg lib import(lang/lib.nix) --argstr xyzzy xyzzy! -A result | |||
diff --git a/test/testdata/eval-okay-autoargs.nix b/test/testdata/eval-okay-autoargs.nix new file mode 100644 index 0000000..815f51b --- /dev/null +++ b/test/testdata/eval-okay-autoargs.nix | |||
@@ -0,0 +1,15 @@ | |||
1 | let | ||
2 | |||
3 | foobar = "foobar"; | ||
4 | |||
5 | in | ||
6 | |||
7 | { xyzzy2 ? xyzzy # mutually recursive args | ||
8 | , xyzzy ? "blaat" # will be overridden by --argstr | ||
9 | , fb ? foobar | ||
10 | , lib # will be set by --arg | ||
11 | }: | ||
12 | |||
13 | { | ||
14 | result = lib.concat [xyzzy xyzzy2 fb]; | ||
15 | } | ||
diff --git a/test/testdata/eval-okay-backslash-newline-1.exp b/test/testdata/eval-okay-backslash-newline-1.exp new file mode 100644 index 0000000..3e75436 --- /dev/null +++ b/test/testdata/eval-okay-backslash-newline-1.exp | |||
@@ -0,0 +1 @@ | |||
"a\nb" | |||
diff --git a/test/testdata/eval-okay-backslash-newline-1.nix b/test/testdata/eval-okay-backslash-newline-1.nix new file mode 100644 index 0000000..7fef3dd --- /dev/null +++ b/test/testdata/eval-okay-backslash-newline-1.nix | |||
@@ -0,0 +1,2 @@ | |||
1 | "a\ | ||
2 | b" | ||
diff --git a/test/testdata/eval-okay-backslash-newline-2.exp b/test/testdata/eval-okay-backslash-newline-2.exp new file mode 100644 index 0000000..3e75436 --- /dev/null +++ b/test/testdata/eval-okay-backslash-newline-2.exp | |||
@@ -0,0 +1 @@ | |||
"a\nb" | |||
diff --git a/test/testdata/eval-okay-backslash-newline-2.nix b/test/testdata/eval-okay-backslash-newline-2.nix new file mode 100644 index 0000000..35ddf49 --- /dev/null +++ b/test/testdata/eval-okay-backslash-newline-2.nix | |||
@@ -0,0 +1,2 @@ | |||
1 | ''a''\ | ||
2 | b'' | ||
diff --git a/test/testdata/eval-okay-baseNameOf.exp b/test/testdata/eval-okay-baseNameOf.exp new file mode 100644 index 0000000..52c33a5 --- /dev/null +++ b/test/testdata/eval-okay-baseNameOf.exp | |||
@@ -0,0 +1 @@ | |||
"ok" | |||
diff --git a/test/testdata/eval-okay-baseNameOf.nix b/test/testdata/eval-okay-baseNameOf.nix new file mode 100644 index 0000000..a7afdd8 --- /dev/null +++ b/test/testdata/eval-okay-baseNameOf.nix | |||
@@ -0,0 +1,32 @@ | |||
1 | assert baseNameOf "" == ""; | ||
2 | assert baseNameOf "." == "."; | ||
3 | assert baseNameOf ".." == ".."; | ||
4 | assert baseNameOf "a" == "a"; | ||
5 | assert baseNameOf "a." == "a."; | ||
6 | assert baseNameOf "a.." == "a.."; | ||
7 | assert baseNameOf "a.b" == "a.b"; | ||
8 | assert baseNameOf "a.b." == "a.b."; | ||
9 | assert baseNameOf "a.b.." == "a.b.."; | ||
10 | assert baseNameOf "a/" == "a"; | ||
11 | assert baseNameOf "a/." == "."; | ||
12 | assert baseNameOf "a/.." == ".."; | ||
13 | assert baseNameOf "a/b" == "b"; | ||
14 | assert baseNameOf "a/b." == "b."; | ||
15 | assert baseNameOf "a/b.." == "b.."; | ||
16 | assert baseNameOf "a/b/c" == "c"; | ||
17 | assert baseNameOf "a/b/c." == "c."; | ||
18 | assert baseNameOf "a/b/c.." == "c.."; | ||
19 | assert baseNameOf "a/b/c/d" == "d"; | ||
20 | assert baseNameOf "a/b/c/d." == "d."; | ||
21 | assert baseNameOf "a\\b" == "a\\b"; | ||
22 | assert baseNameOf "C:a" == "C:a"; | ||
23 | assert baseNameOf "a//b" == "b"; | ||
24 | |||
25 | # It's been like this for close to a decade. We ought to commit to it. | ||
26 | # https://github.com/NixOS/nix/pull/582#issuecomment-121014450 | ||
27 | assert baseNameOf "a//" == ""; | ||
28 | |||
29 | assert baseNameOf ./foo == "foo"; | ||
30 | assert baseNameOf ./foo/bar == "bar"; | ||
31 | |||
32 | "ok" | ||
diff --git a/test/testdata/eval-okay-builtins-add.exp b/test/testdata/eval-okay-builtins-add.exp new file mode 100644 index 0000000..0350b51 --- /dev/null +++ b/test/testdata/eval-okay-builtins-add.exp | |||
@@ -0,0 +1 @@ | |||
[ 5 4 "int" "tt" "float" 4 ] | |||
diff --git a/test/testdata/eval-okay-builtins-add.nix b/test/testdata/eval-okay-builtins-add.nix new file mode 100644 index 0000000..c841816 --- /dev/null +++ b/test/testdata/eval-okay-builtins-add.nix | |||
@@ -0,0 +1,8 @@ | |||
1 | [ | ||
2 | (builtins.add 2 3) | ||
3 | (builtins.add 2 2) | ||
4 | (builtins.typeOf (builtins.add 2 2)) | ||
5 | ("t" + "t") | ||
6 | (builtins.typeOf (builtins.add 2.0 2)) | ||
7 | (builtins.add 2.0 2) | ||
8 | ] | ||
diff --git a/test/testdata/eval-okay-builtins.exp b/test/testdata/eval-okay-builtins.exp new file mode 100644 index 0000000..0661686 --- /dev/null +++ b/test/testdata/eval-okay-builtins.exp | |||
@@ -0,0 +1 @@ | |||
/foo | |||
diff --git a/test/testdata/eval-okay-builtins.nix b/test/testdata/eval-okay-builtins.nix new file mode 100644 index 0000000..e9d65e8 --- /dev/null +++ b/test/testdata/eval-okay-builtins.nix | |||
@@ -0,0 +1,12 @@ | |||
1 | assert builtins ? currentSystem; | ||
2 | assert !builtins ? __currentSystem; | ||
3 | |||
4 | let { | ||
5 | |||
6 | x = if builtins ? dirOf then builtins.dirOf /foo/bar else ""; | ||
7 | |||
8 | y = if builtins ? fnord then builtins.fnord "foo" else ""; | ||
9 | |||
10 | body = x + y; | ||
11 | |||
12 | } | ||
diff --git a/test/testdata/eval-okay-callable-attrs.exp b/test/testdata/eval-okay-callable-attrs.exp new file mode 100644 index 0000000..27ba77d --- /dev/null +++ b/test/testdata/eval-okay-callable-attrs.exp | |||
@@ -0,0 +1 @@ | |||
true | |||
diff --git a/test/testdata/eval-okay-callable-attrs.nix b/test/testdata/eval-okay-callable-attrs.nix new file mode 100644 index 0000000..310a030 --- /dev/null +++ b/test/testdata/eval-okay-callable-attrs.nix | |||
@@ -0,0 +1 @@ | |||
({ __functor = self: x: self.foo && x; foo = false; } // { foo = true; }) true | |||
diff --git a/test/testdata/eval-okay-catattrs.exp b/test/testdata/eval-okay-catattrs.exp new file mode 100644 index 0000000..b4a1e66 --- /dev/null +++ b/test/testdata/eval-okay-catattrs.exp | |||
@@ -0,0 +1 @@ | |||
[ 1 2 ] | |||
diff --git a/test/testdata/eval-okay-catattrs.nix b/test/testdata/eval-okay-catattrs.nix new file mode 100644 index 0000000..2c3dc10 --- /dev/null +++ b/test/testdata/eval-okay-catattrs.nix | |||
@@ -0,0 +1 @@ | |||
builtins.catAttrs "a" [ { a = 1; } { b = 0; } { a = 2; } ] | |||
diff --git a/test/testdata/eval-okay-closure.exp b/test/testdata/eval-okay-closure.exp new file mode 100644 index 0000000..e7dbf97 --- /dev/null +++ b/test/testdata/eval-okay-closure.exp | |||
@@ -0,0 +1 @@ | |||
[ { foo = true; key = -13; } { foo = true; key = -12; } { foo = true; key = -11; } { foo = true; key = -9; } { foo = true; key = -8; } { foo = true; key = -7; } { foo = true; key = -5; } { foo = true; key = -4; } { foo = true; key = -3; } { key = -1; } { foo = true; key = 0; } { foo = true; key = 1; } { foo = true; key = 2; } { foo = true; key = 4; } { foo = true; key = 5; } { foo = true; key = 6; } { key = 8; } { foo = true; key = 9; } { foo = true; key = 10; } { foo = true; key = 13; } { foo = true; key = 14; } { foo = true; key = 15; } { key = 17; } { foo = true; key = 18; } { foo = true; key = 19; } { foo = true; key = 22; } { foo = true; key = 23; } { key = 26; } { foo = true; key = 27; } { foo = true; key = 28; } { foo = true; key = 31; } { foo = true; key = 32; } { key = 35; } { foo = true; key = 36; } { foo = true; key = 40; } { foo = true; key = 41; } { key = 44; } { foo = true; key = 45; } { foo = true; key = 49; } { key = 53; } { foo = true; key = 54; } { foo = true; key = 58; } { key = 62; } { foo = true; key = 67; } { key = 71; } { key = 80; } ] | |||
diff --git a/test/testdata/eval-okay-closure.exp.xml b/test/testdata/eval-okay-closure.exp.xml new file mode 100644 index 0000000..dffc03a --- /dev/null +++ b/test/testdata/eval-okay-closure.exp.xml | |||
@@ -0,0 +1,343 @@ | |||
1 | <?xml version='1.0' encoding='utf-8'?> | ||
2 | <expr> | ||
3 | <list> | ||
4 | <attrs> | ||
5 | <attr name="foo"> | ||
6 | <bool value="true" /> | ||
7 | </attr> | ||
8 | <attr name="key"> | ||
9 | <int value="-13" /> | ||
10 | </attr> | ||
11 | </attrs> | ||
12 | <attrs> | ||
13 | <attr name="foo"> | ||
14 | <bool value="true" /> | ||
15 | </attr> | ||
16 | <attr name="key"> | ||
17 | <int value="-12" /> | ||
18 | </attr> | ||
19 | </attrs> | ||
20 | <attrs> | ||
21 | <attr name="foo"> | ||
22 | <bool value="true" /> | ||
23 | </attr> | ||
24 | <attr name="key"> | ||
25 | <int value="-11" /> | ||
26 | </attr> | ||
27 | </attrs> | ||
28 | <attrs> | ||
29 | <attr name="foo"> | ||
30 | <bool value="true" /> | ||
31 | </attr> | ||
32 | <attr name="key"> | ||
33 | <int value="-9" /> | ||
34 | </attr> | ||
35 | </attrs> | ||
36 | <attrs> | ||
37 | <attr name="foo"> | ||
38 | <bool value="true" /> | ||
39 | </attr> | ||
40 | <attr name="key"> | ||
41 | <int value="-8" /> | ||
42 | </attr> | ||
43 | </attrs> | ||
44 | <attrs> | ||
45 | <attr name="foo"> | ||
46 | <bool value="true" /> | ||
47 | </attr> | ||
48 | <attr name="key"> | ||
49 | <int value="-7" /> | ||
50 | </attr> | ||
51 | </attrs> | ||
52 | <attrs> | ||
53 | <attr name="foo"> | ||
54 | <bool value="true" /> | ||
55 | </attr> | ||
56 | <attr name="key"> | ||
57 | <int value="-5" /> | ||
58 | </attr> | ||
59 | </attrs> | ||
60 | <attrs> | ||
61 | <attr name="foo"> | ||
62 | <bool value="true" /> | ||
63 | </attr> | ||
64 | <attr name="key"> | ||
65 | <int value="-4" /> | ||
66 | </attr> | ||
67 | </attrs> | ||
68 | <attrs> | ||
69 | <attr name="foo"> | ||
70 | <bool value="true" /> | ||
71 | </attr> | ||
72 | <attr name="key"> | ||
73 | <int value="-3" /> | ||
74 | </attr> | ||
75 | </attrs> | ||
76 | <attrs> | ||
77 | <attr name="key"> | ||
78 | <int value="-1" /> | ||
79 | </attr> | ||
80 | </attrs> | ||
81 | <attrs> | ||
82 | <attr name="foo"> | ||
83 | <bool value="true" /> | ||
84 | </attr> | ||
85 | <attr name="key"> | ||
86 | <int value="0" /> | ||
87 | </attr> | ||
88 | </attrs> | ||
89 | <attrs> | ||
90 | <attr name="foo"> | ||
91 | <bool value="true" /> | ||
92 | </attr> | ||
93 | <attr name="key"> | ||
94 | <int value="1" /> | ||
95 | </attr> | ||
96 | </attrs> | ||
97 | <attrs> | ||
98 | <attr name="foo"> | ||
99 | <bool value="true" /> | ||
100 | </attr> | ||
101 | <attr name="key"> | ||
102 | <int value="2" /> | ||
103 | </attr> | ||
104 | </attrs> | ||
105 | <attrs> | ||
106 | <attr name="foo"> | ||
107 | <bool value="true" /> | ||
108 | </attr> | ||
109 | <attr name="key"> | ||
110 | <int value="4" /> | ||
111 | </attr> | ||
112 | </attrs> | ||
113 | <attrs> | ||
114 | <attr name="foo"> | ||
115 | <bool value="true" /> | ||
116 | </attr> | ||
117 | <attr name="key"> | ||
118 | <int value="5" /> | ||
119 | </attr> | ||
120 | </attrs> | ||
121 | <attrs> | ||
122 | <attr name="foo"> | ||
123 | <bool value="true" /> | ||
124 | </attr> | ||
125 | <attr name="key"> | ||
126 | <int value="6" /> | ||
127 | </attr> | ||
128 | </attrs> | ||
129 | <attrs> | ||
130 | <attr name="key"> | ||
131 | <int value="8" /> | ||
132 | </attr> | ||
133 | </attrs> | ||
134 | <attrs> | ||
135 | <attr name="foo"> | ||
136 | <bool value="true" /> | ||
137 | </attr> | ||
138 | <attr name="key"> | ||
139 | <int value="9" /> | ||
140 | </attr> | ||
141 | </attrs> | ||
142 | <attrs> | ||
143 | <attr name="foo"> | ||
144 | <bool value="true" /> | ||
145 | </attr> | ||
146 | <attr name="key"> | ||
147 | <int value="10" /> | ||
148 | </attr> | ||
149 | </attrs> | ||
150 | <attrs> | ||
151 | <attr name="foo"> | ||
152 | <bool value="true" /> | ||
153 | </attr> | ||
154 | <attr name="key"> | ||
155 | <int value="13" /> | ||
156 | </attr> | ||
157 | </attrs> | ||
158 | <attrs> | ||
159 | <attr name="foo"> | ||
160 | <bool value="true" /> | ||
161 | </attr> | ||
162 | <attr name="key"> | ||
163 | <int value="14" /> | ||
164 | </attr> | ||
165 | </attrs> | ||
166 | <attrs> | ||
167 | <attr name="foo"> | ||
168 | <bool value="true" /> | ||
169 | </attr> | ||
170 | <attr name="key"> | ||
171 | <int value="15" /> | ||
172 | </attr> | ||
173 | </attrs> | ||
174 | <attrs> | ||
175 | <attr name="key"> | ||
176 | <int value="17" /> | ||
177 | </attr> | ||
178 | </attrs> | ||
179 | <attrs> | ||
180 | <attr name="foo"> | ||
181 | <bool value="true" /> | ||
182 | </attr> | ||
183 | <attr name="key"> | ||
184 | <int value="18" /> | ||
185 | </attr> | ||
186 | </attrs> | ||
187 | <attrs> | ||
188 | <attr name="foo"> | ||
189 | <bool value="true" /> | ||
190 | </attr> | ||
191 | <attr name="key"> | ||
192 | <int value="19" /> | ||
193 | </attr> | ||
194 | </attrs> | ||
195 | <attrs> | ||
196 | <attr name="foo"> | ||
197 | <bool value="true" /> | ||
198 | </attr> | ||
199 | <attr name="key"> | ||
200 | <int value="22" /> | ||
201 | </attr> | ||
202 | </attrs> | ||
203 | <attrs> | ||
204 | <attr name="foo"> | ||
205 | <bool value="true" /> | ||
206 | </attr> | ||
207 | <attr name="key"> | ||
208 | <int value="23" /> | ||
209 | </attr> | ||
210 | </attrs> | ||
211 | <attrs> | ||
212 | <attr name="key"> | ||
213 | <int value="26" /> | ||
214 | </attr> | ||
215 | </attrs> | ||
216 | <attrs> | ||
217 | <attr name="foo"> | ||
218 | <bool value="true" /> | ||
219 | </attr> | ||
220 | <attr name="key"> | ||
221 | <int value="27" /> | ||
222 | </attr> | ||
223 | </attrs> | ||
224 | <attrs> | ||
225 | <attr name="foo"> | ||
226 | <bool value="true" /> | ||
227 | </attr> | ||
228 | <attr name="key"> | ||
229 | <int value="28" /> | ||
230 | </attr> | ||
231 | </attrs> | ||
232 | <attrs> | ||
233 | <attr name="foo"> | ||
234 | <bool value="true" /> | ||
235 | </attr> | ||
236 | <attr name="key"> | ||
237 | <int value="31" /> | ||
238 | </attr> | ||
239 | </attrs> | ||
240 | <attrs> | ||
241 | <attr name="foo"> | ||
242 | <bool value="true" /> | ||
243 | </attr> | ||
244 | <attr name="key"> | ||
245 | <int value="32" /> | ||
246 | </attr> | ||
247 | </attrs> | ||
248 | <attrs> | ||
249 | <attr name="key"> | ||
250 | <int value="35" /> | ||
251 | </attr> | ||
252 | </attrs> | ||
253 | <attrs> | ||
254 | <attr name="foo"> | ||
255 | <bool value="true" /> | ||
256 | </attr> | ||
257 | <attr name="key"> | ||
258 | <int value="36" /> | ||
259 | </attr> | ||
260 | </attrs> | ||
261 | <attrs> | ||
262 | <attr name="foo"> | ||
263 | <bool value="true" /> | ||
264 | </attr> | ||
265 | <attr name="key"> | ||
266 | <int value="40" /> | ||
267 | </attr> | ||
268 | </attrs> | ||
269 | <attrs> | ||
270 | <attr name="foo"> | ||
271 | <bool value="true" /> | ||
272 | </attr> | ||
273 | <attr name="key"> | ||
274 | <int value="41" /> | ||
275 | </attr> | ||
276 | </attrs> | ||
277 | <attrs> | ||
278 | <attr name="key"> | ||
279 | <int value="44" /> | ||
280 | </attr> | ||
281 | </attrs> | ||
282 | <attrs> | ||
283 | <attr name="foo"> | ||
284 | <bool value="true" /> | ||
285 | </attr> | ||
286 | <attr name="key"> | ||
287 | <int value="45" /> | ||
288 | </attr> | ||
289 | </attrs> | ||
290 | <attrs> | ||
291 | <attr name="foo"> | ||
292 | <bool value="true" /> | ||
293 | </attr> | ||
294 | <attr name="key"> | ||
295 | <int value="49" /> | ||
296 | </attr> | ||
297 | </attrs> | ||
298 | <attrs> | ||
299 | <attr name="key"> | ||
300 | <int value="53" /> | ||
301 | </attr> | ||
302 | </attrs> | ||
303 | <attrs> | ||
304 | <attr name="foo"> | ||
305 | <bool value="true" /> | ||
306 | </attr> | ||
307 | <attr name="key"> | ||
308 | <int value="54" /> | ||
309 | </attr> | ||
310 | </attrs> | ||
311 | <attrs> | ||
312 | <attr name="foo"> | ||
313 | <bool value="true" /> | ||
314 | </attr> | ||
315 | <attr name="key"> | ||
316 | <int value="58" /> | ||
317 | </attr> | ||
318 | </attrs> | ||
319 | <attrs> | ||
320 | <attr name="key"> | ||
321 | <int value="62" /> | ||
322 | </attr> | ||
323 | </attrs> | ||
324 | <attrs> | ||
325 | <attr name="foo"> | ||
326 | <bool value="true" /> | ||
327 | </attr> | ||
328 | <attr name="key"> | ||
329 | <int value="67" /> | ||
330 | </attr> | ||
331 | </attrs> | ||
332 | <attrs> | ||
333 | <attr name="key"> | ||
334 | <int value="71" /> | ||
335 | </attr> | ||
336 | </attrs> | ||
337 | <attrs> | ||
338 | <attr name="key"> | ||
339 | <int value="80" /> | ||
340 | </attr> | ||
341 | </attrs> | ||
342 | </list> | ||
343 | </expr> | ||
diff --git a/test/testdata/eval-okay-closure.nix b/test/testdata/eval-okay-closure.nix new file mode 100644 index 0000000..cccd4dc --- /dev/null +++ b/test/testdata/eval-okay-closure.nix | |||
@@ -0,0 +1,13 @@ | |||
1 | let | ||
2 | |||
3 | closure = builtins.genericClosure { | ||
4 | startSet = [{key = 80;}]; | ||
5 | operator = {key, foo ? false}: | ||
6 | if builtins.lessThan key 0 | ||
7 | then [] | ||
8 | else [{key = builtins.sub key 9;} {key = builtins.sub key 13; foo = true;}]; | ||
9 | }; | ||
10 | |||
11 | sort = (import ./lib.nix).sortBy (a: b: builtins.lessThan a.key b.key); | ||
12 | |||
13 | in sort closure | ||
diff --git a/test/testdata/eval-okay-comments.exp b/test/testdata/eval-okay-comments.exp new file mode 100644 index 0000000..7182dc2 --- /dev/null +++ b/test/testdata/eval-okay-comments.exp | |||
@@ -0,0 +1 @@ | |||
"abcdefghijklmnopqrstuvwxyz" | |||
diff --git a/test/testdata/eval-okay-comments.nix b/test/testdata/eval-okay-comments.nix new file mode 100644 index 0000000..cb2cce2 --- /dev/null +++ b/test/testdata/eval-okay-comments.nix | |||
@@ -0,0 +1,59 @@ | |||
1 | # A simple comment | ||
2 | "a"+ # And another | ||
3 | ## A double comment | ||
4 | "b"+ ## And another | ||
5 | # Nested # comments # | ||
6 | "c"+ # and # some # other # | ||
7 | # An empty line, following here: | ||
8 | |||
9 | "d"+ # and a comment not starting the line ! | ||
10 | |||
11 | "e"+ | ||
12 | /* multiline comments */ | ||
13 | "f" + | ||
14 | /* multiline | ||
15 | comments, | ||
16 | on | ||
17 | multiple | ||
18 | lines | ||
19 | */ | ||
20 | "g" + | ||
21 | # Small, tricky comments | ||
22 | /**/ "h"+ /*/*/ "i"+ /***/ "j"+ /* /*/ "k"+ /*/* /*/ "l"+ | ||
23 | # Comments with an even number of ending '*' used to fail: | ||
24 | "m"+ | ||
25 | /* */ /* **/ /* ***/ /* ****/ "n"+ | ||
26 | /* */ /** */ /*** */ /**** */ "o"+ | ||
27 | /** **/ /*** ***/ /**** ****/ "p"+ | ||
28 | /* * ** *** **** ***** */ "q"+ | ||
29 | # Random comments | ||
30 | /* ***** ////// * / * / /* */ "r"+ | ||
31 | # Mixed comments | ||
32 | /* # */ | ||
33 | "s"+ | ||
34 | # /* # | ||
35 | "t"+ | ||
36 | # /* # */ | ||
37 | "u"+ | ||
38 | # /*********/ | ||
39 | "v"+ | ||
40 | ## */* | ||
41 | "w"+ | ||
42 | /* | ||
43 | * Multiline, decorated comments | ||
44 | * # This ain't a nest'd comm'nt | ||
45 | */ | ||
46 | "x"+ | ||
47 | ''${/** with **/"y" | ||
48 | # real | ||
49 | /* comments | ||
50 | inside ! # */ | ||
51 | |||
52 | # (and empty lines) | ||
53 | |||
54 | }''+ /* And a multiline comment, | ||
55 | on the same line, | ||
56 | after some spaces | ||
57 | */ # followed by a one-line comment | ||
58 | "z" | ||
59 | /* EOF */ | ||
diff --git a/test/testdata/eval-okay-concat.exp b/test/testdata/eval-okay-concat.exp new file mode 100644 index 0000000..bb4bbd5 --- /dev/null +++ b/test/testdata/eval-okay-concat.exp | |||
@@ -0,0 +1 @@ | |||
[ 1 2 3 4 5 6 7 8 9 ] | |||
diff --git a/test/testdata/eval-okay-concat.nix b/test/testdata/eval-okay-concat.nix new file mode 100644 index 0000000..d158a9b --- /dev/null +++ b/test/testdata/eval-okay-concat.nix | |||
@@ -0,0 +1 @@ | |||
[1 2 3] ++ [4 5 6] ++ [7 8 9] | |||
diff --git a/test/testdata/eval-okay-concatmap.exp b/test/testdata/eval-okay-concatmap.exp new file mode 100644 index 0000000..3b8be77 --- /dev/null +++ b/test/testdata/eval-okay-concatmap.exp | |||
@@ -0,0 +1 @@ | |||
[ [ 1 3 5 7 9 ] [ "a" "z" "b" "z" ] ] | |||
diff --git a/test/testdata/eval-okay-concatmap.nix b/test/testdata/eval-okay-concatmap.nix new file mode 100644 index 0000000..97da5d3 --- /dev/null +++ b/test/testdata/eval-okay-concatmap.nix | |||
@@ -0,0 +1,5 @@ | |||
1 | with import ./lib.nix; | ||
2 | |||
3 | [ (builtins.concatMap (x: if x / 2 * 2 == x then [] else [ x ]) (range 0 10)) | ||
4 | (builtins.concatMap (x: [x] ++ ["z"]) ["a" "b"]) | ||
5 | ] | ||
diff --git a/test/testdata/eval-okay-concatstringssep.exp b/test/testdata/eval-okay-concatstringssep.exp new file mode 100644 index 0000000..9398764 --- /dev/null +++ b/test/testdata/eval-okay-concatstringssep.exp | |||
@@ -0,0 +1 @@ | |||
[ "" "foobarxyzzy" "foo, bar, xyzzy" "foo" "" ] | |||
diff --git a/test/testdata/eval-okay-concatstringssep.nix b/test/testdata/eval-okay-concatstringssep.nix new file mode 100644 index 0000000..adc4c41 --- /dev/null +++ b/test/testdata/eval-okay-concatstringssep.nix | |||
@@ -0,0 +1,8 @@ | |||
1 | with builtins; | ||
2 | |||
3 | [ (concatStringsSep "" []) | ||
4 | (concatStringsSep "" ["foo" "bar" "xyzzy"]) | ||
5 | (concatStringsSep ", " ["foo" "bar" "xyzzy"]) | ||
6 | (concatStringsSep ", " ["foo"]) | ||
7 | (concatStringsSep ", " []) | ||
8 | ] | ||
diff --git a/test/testdata/eval-okay-context-introspection.exp b/test/testdata/eval-okay-context-introspection.exp new file mode 100644 index 0000000..a136b00 --- /dev/null +++ b/test/testdata/eval-okay-context-introspection.exp | |||
@@ -0,0 +1 @@ | |||
[ true true true true true true true true true true true true true ] | |||
diff --git a/test/testdata/eval-okay-context-introspection.nix b/test/testdata/eval-okay-context-introspection.nix new file mode 100644 index 0000000..8886cf3 --- /dev/null +++ b/test/testdata/eval-okay-context-introspection.nix | |||
@@ -0,0 +1,59 @@ | |||
1 | let | ||
2 | drv = derivation { | ||
3 | name = "fail"; | ||
4 | builder = "/bin/false"; | ||
5 | system = "x86_64-linux"; | ||
6 | outputs = [ "out" "foo" ]; | ||
7 | }; | ||
8 | |||
9 | path = "${./eval-okay-context-introspection.nix}"; | ||
10 | |||
11 | desired-context = { | ||
12 | "${builtins.unsafeDiscardStringContext path}" = { | ||
13 | path = true; | ||
14 | }; | ||
15 | "${builtins.unsafeDiscardStringContext drv.drvPath}" = { | ||
16 | outputs = [ "foo" "out" ]; | ||
17 | allOutputs = true; | ||
18 | }; | ||
19 | }; | ||
20 | |||
21 | combo-path = "${path}${drv.outPath}${drv.foo.outPath}${drv.drvPath}"; | ||
22 | legit-context = builtins.getContext combo-path; | ||
23 | |||
24 | reconstructed-path = builtins.appendContext | ||
25 | (builtins.unsafeDiscardStringContext combo-path) | ||
26 | desired-context; | ||
27 | |||
28 | # Eta rule for strings with context. | ||
29 | etaRule = str: | ||
30 | str == builtins.appendContext | ||
31 | (builtins.unsafeDiscardStringContext str) | ||
32 | (builtins.getContext str); | ||
33 | |||
34 | # Only holds true if string context contains both a `DrvDeep` and | ||
35 | # `Opaque` element. | ||
36 | almostEtaRule = str: | ||
37 | str == builtins.addDrvOutputDependencies | ||
38 | (builtins.unsafeDiscardOutputDependency str); | ||
39 | |||
40 | addDrvOutputDependencies_idempotent = str: | ||
41 | builtins.addDrvOutputDependencies str == | ||
42 | builtins.addDrvOutputDependencies (builtins.addDrvOutputDependencies str); | ||
43 | |||
44 | rules = str: [ | ||
45 | (etaRule str) | ||
46 | (almostEtaRule str) | ||
47 | (addDrvOutputDependencies_idempotent str) | ||
48 | ]; | ||
49 | |||
50 | in [ | ||
51 | (legit-context == desired-context) | ||
52 | (reconstructed-path == combo-path) | ||
53 | (etaRule "foo") | ||
54 | (etaRule drv.foo.outPath) | ||
55 | ] ++ builtins.concatMap rules [ | ||
56 | drv.drvPath | ||
57 | (builtins.addDrvOutputDependencies drv.drvPath) | ||
58 | (builtins.unsafeDiscardOutputDependency drv.drvPath) | ||
59 | ] | ||
diff --git a/test/testdata/eval-okay-context.exp b/test/testdata/eval-okay-context.exp new file mode 100644 index 0000000..2f535bd --- /dev/null +++ b/test/testdata/eval-okay-context.exp | |||
@@ -0,0 +1 @@ | |||
"foo eval-okay-context.nix bar" | |||
diff --git a/test/testdata/eval-okay-context.nix b/test/testdata/eval-okay-context.nix new file mode 100644 index 0000000..7b9531c --- /dev/null +++ b/test/testdata/eval-okay-context.nix | |||
@@ -0,0 +1,6 @@ | |||
1 | let s = "foo ${builtins.substring 33 100 (baseNameOf "${./eval-okay-context.nix}")} bar"; | ||
2 | in | ||
3 | if s != "foo eval-okay-context.nix bar" | ||
4 | then abort "context not discarded" | ||
5 | else builtins.unsafeDiscardStringContext s | ||
6 | |||
diff --git a/test/testdata/eval-okay-convertHash.err.exp b/test/testdata/eval-okay-convertHash.err.exp new file mode 100644 index 0000000..41d7467 --- /dev/null +++ b/test/testdata/eval-okay-convertHash.err.exp | |||
@@ -0,0 +1,108 @@ | |||
1 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
2 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
3 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
4 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
5 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
6 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
7 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
8 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
9 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
10 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
11 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
12 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
13 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
14 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
15 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
16 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
17 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
18 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
19 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
20 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
21 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
22 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
23 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
24 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
25 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
26 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
27 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
28 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
29 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
30 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
31 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
32 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
33 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
34 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
35 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
36 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
37 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
38 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
39 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
40 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
41 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
42 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
43 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
44 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
45 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
46 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
47 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
48 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
49 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
50 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
51 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
52 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
53 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
54 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
55 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
56 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
57 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
58 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
59 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
60 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
61 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
62 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
63 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
64 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
65 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
66 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
67 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
68 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
69 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
70 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
71 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
72 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
73 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
74 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
75 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
76 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
77 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
78 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
79 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
80 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
81 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
82 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
83 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
84 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
85 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
86 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
87 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
88 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
89 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
90 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
91 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
92 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
93 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
94 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
95 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
96 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
97 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
98 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
99 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
100 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
101 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
102 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
103 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
104 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
105 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
106 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
107 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
108 | warning: "base32" is a deprecated alias for hash format "nix32". | ||
diff --git a/test/testdata/eval-okay-convertHash.exp b/test/testdata/eval-okay-convertHash.exp new file mode 100644 index 0000000..16b0240 --- /dev/null +++ b/test/testdata/eval-okay-convertHash.exp | |||
@@ -0,0 +1 @@ | |||
{ hashesBase16 = [ "d41d8cd98f00b204e9800998ecf8427e" "6c69ee7f211c640419d5366cc076ae46" "bb3438fbabd460ea6dbd27d153e2233b" "da39a3ee5e6b4b0d3255bfef95601890afd80709" "cd54e8568c1b37cf1e5badb0779bcbf382212189" "6d12e10b1d331dad210e47fd25d4f260802b7e77" "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" "900a4469df00ccbfd0c145c6d1e4b7953dd0afafadd7534e3a4019e8d38fc663" "ad0387b3bd8652f730ca46d25f9c170af0fd589f42e7f23f5a9e6412d97d7e56" "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" "9d0886f8c6b389398a16257bc79780fab9831c7fc11c8ab07fa732cb7b348feade382f92617c9c5305fefba0af02ab5fd39a587d330997ff5bd0db19f7666653" "21644b72aa259e5a588cd3afbafb1d4310f4889680f6c83b9d531596a5a284f34dbebff409d23bcc86aee6bad10c891606f075c6f4755cb536da27db5693f3a7" ]; hashesBase32 = [ "3y8bwfr609h3lh9ch0izcqq7fl" "26mrvc0v1nslch8r0w45zywsbc" "1v4gi57l97pmnylq6lmgxkhd5v" "143xibwh31h9bvxzalr0sjvbbvpa6ffs" "i4hj30pkrfdpgc5dbcgcydqviibfhm6d" "fxz2p030yba2bza71qhss79k3l5y24kd" "0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73" "0qy6iz9yh6a079757mxdmypx0gcmnzjd3ij5q78bzk00vxll82lh" "0mkygpci4r4yb8zz5rs2kxcgvw0a2yf5zlj6r8qgfll6pnrqf0xd" "0zdl9zrg8r3i9c1g90lgg9ip5ijzv3yhz91i0zzn3r8ap9ws784gkp9dk9j3aglhgf1amqb0pj21mh7h1nxcl18akqvvf7ggqsy30yg" "19ncrpp37dx0nzzjw4k6zaqkb9mzaq2myhgpzh5aff7qqcj5wwdxslg6ixwncm7gyq8l761gwf87fgsh2bwfyr52s53k2dkqvw8c24x" "2kz74snvckxldmmbisz9ikmy031d28cs6xfdbl6rhxx42glpyz4vww4lajrc5akklxwixl0js4g84233pxvmbykiic5m7i5m9r4nr11" ]; hashesBase64 = [ "1B2M2Y8AsgTpgAmY7PhCfg==" "bGnufyEcZAQZ1TZswHauRg==" "uzQ4+6vUYOptvSfRU+IjOw==" "2jmj7l5rSw0yVb/vlWAYkK/YBwk=" "zVToVowbN88eW62wd5vL84IhIYk=" "bRLhCx0zHa0hDkf9JdTyYIArfnc=" "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=" "kApEad8AzL/QwUXG0eS3lT3Qr6+t11NOOkAZ6NOPxmM=" "rQOHs72GUvcwykbSX5wXCvD9WJ9C5/I/Wp5kEtl9flY=" "z4PhNX7vuL3xVChQ1m2AB9Yg5AULVxXcg/SpIdNs6c5H0NE8XYXysP+DGNKHfuwvY7kxvUdBeoGlODJ6+SfaPg==" "nQiG+MaziTmKFiV7x5eA+rmDHH/BHIqwf6cyy3s0j+reOC+SYXycUwX++6CvAqtf05pYfTMJl/9b0NsZ92ZmUw==" "IWRLcqolnlpYjNOvuvsdQxD0iJaA9sg7nVMVlqWihPNNvr/0CdI7zIau5rrRDIkWBvB1xvR1XLU22ifbVpPzpw==" ]; hashesNix32 = [ "3y8bwfr609h3lh9ch0izcqq7fl" "26mrvc0v1nslch8r0w45zywsbc" "1v4gi57l97pmnylq6lmgxkhd5v" "143xibwh31h9bvxzalr0sjvbbvpa6ffs" "i4hj30pkrfdpgc5dbcgcydqviibfhm6d" "fxz2p030yba2bza71qhss79k3l5y24kd" "0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73" "0qy6iz9yh6a079757mxdmypx0gcmnzjd3ij5q78bzk00vxll82lh" "0mkygpci4r4yb8zz5rs2kxcgvw0a2yf5zlj6r8qgfll6pnrqf0xd" "0zdl9zrg8r3i9c1g90lgg9ip5ijzv3yhz91i0zzn3r8ap9ws784gkp9dk9j3aglhgf1amqb0pj21mh7h1nxcl18akqvvf7ggqsy30yg" "19ncrpp37dx0nzzjw4k6zaqkb9mzaq2myhgpzh5aff7qqcj5wwdxslg6ixwncm7gyq8l761gwf87fgsh2bwfyr52s53k2dkqvw8c24x" "2kz74snvckxldmmbisz9ikmy031d28cs6xfdbl6rhxx42glpyz4vww4lajrc5akklxwixl0js4g84233pxvmbykiic5m7i5m9r4nr11" ]; hashesSRI = [ "md5-1B2M2Y8AsgTpgAmY7PhCfg==" "md5-bGnufyEcZAQZ1TZswHauRg==" "md5-uzQ4+6vUYOptvSfRU+IjOw==" "sha1-2jmj7l5rSw0yVb/vlWAYkK/YBwk=" "sha1-zVToVowbN88eW62wd5vL84IhIYk=" "sha1-bRLhCx0zHa0hDkf9JdTyYIArfnc=" "sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=" "sha256-kApEad8AzL/QwUXG0eS3lT3Qr6+t11NOOkAZ6NOPxmM=" "sha256-rQOHs72GUvcwykbSX5wXCvD9WJ9C5/I/Wp5kEtl9flY=" "sha512-z4PhNX7vuL3xVChQ1m2AB9Yg5AULVxXcg/SpIdNs6c5H0NE8XYXysP+DGNKHfuwvY7kxvUdBeoGlODJ6+SfaPg==" "sha512-nQiG+MaziTmKFiV7x5eA+rmDHH/BHIqwf6cyy3s0j+reOC+SYXycUwX++6CvAqtf05pYfTMJl/9b0NsZ92ZmUw==" "sha512-IWRLcqolnlpYjNOvuvsdQxD0iJaA9sg7nVMVlqWihPNNvr/0CdI7zIau5rrRDIkWBvB1xvR1XLU22ifbVpPzpw==" ]; } | |||
diff --git a/test/testdata/eval-okay-convertHash.nix b/test/testdata/eval-okay-convertHash.nix new file mode 100644 index 0000000..a0191ee --- /dev/null +++ b/test/testdata/eval-okay-convertHash.nix | |||
@@ -0,0 +1,33 @@ | |||
1 | let | ||
2 | hashAlgos = [ "md5" "md5" "md5" "sha1" "sha1" "sha1" "sha256" "sha256" "sha256" "sha512" "sha512" "sha512" ]; | ||
3 | hashesBase16 = import ./eval-okay-hashstring.exp; | ||
4 | map2 = f: { fsts, snds }: if fsts == [ ] then [ ] else [ (f (builtins.head fsts) (builtins.head snds)) ] ++ map2 f { fsts = builtins.tail fsts; snds = builtins.tail snds; }; | ||
5 | map2' = f: fsts: snds: map2 f { inherit fsts snds; }; | ||
6 | getOutputHashes = hashes: { | ||
7 | hashesBase16 = map2' (hashAlgo: hash: builtins.convertHash { inherit hash hashAlgo; toHashFormat = "base16";}) hashAlgos hashes; | ||
8 | hashesNix32 = map2' (hashAlgo: hash: builtins.convertHash { inherit hash hashAlgo; toHashFormat = "nix32";}) hashAlgos hashes; | ||
9 | hashesBase32 = map2' (hashAlgo: hash: builtins.convertHash { inherit hash hashAlgo; toHashFormat = "base32";}) hashAlgos hashes; | ||
10 | hashesBase64 = map2' (hashAlgo: hash: builtins.convertHash { inherit hash hashAlgo; toHashFormat = "base64";}) hashAlgos hashes; | ||
11 | hashesSRI = map2' (hashAlgo: hash: builtins.convertHash { inherit hash hashAlgo; toHashFormat = "sri" ;}) hashAlgos hashes; | ||
12 | }; | ||
13 | getOutputHashesColon = hashes: { | ||
14 | hashesBase16 = map2' (hashAlgo: hashBody: builtins.convertHash { hash = hashAlgo + ":" + hashBody; toHashFormat = "base16";}) hashAlgos hashes; | ||
15 | hashesNix32 = map2' (hashAlgo: hashBody: builtins.convertHash { hash = hashAlgo + ":" + hashBody; toHashFormat = "nix32";}) hashAlgos hashes; | ||
16 | hashesBase32 = map2' (hashAlgo: hashBody: builtins.convertHash { hash = hashAlgo + ":" + hashBody; toHashFormat = "base32";}) hashAlgos hashes; | ||
17 | hashesBase64 = map2' (hashAlgo: hashBody: builtins.convertHash { hash = hashAlgo + ":" + hashBody; toHashFormat = "base64";}) hashAlgos hashes; | ||
18 | hashesSRI = map2' (hashAlgo: hashBody: builtins.convertHash { hash = hashAlgo + ":" + hashBody; toHashFormat = "sri" ;}) hashAlgos hashes; | ||
19 | }; | ||
20 | outputHashes = getOutputHashes hashesBase16; | ||
21 | in | ||
22 | # map2'` | ||
23 | assert map2' (s1: s2: s1 + s2) [ "a" "b" ] [ "c" "d" ] == [ "ac" "bd" ]; | ||
24 | # hashesBase16 | ||
25 | assert outputHashes.hashesBase16 == hashesBase16; | ||
26 | # standard SRI hashes | ||
27 | assert outputHashes.hashesSRI == (map2' (hashAlgo: hashBody: hashAlgo + "-" + hashBody) hashAlgos outputHashes.hashesBase64); | ||
28 | # without prefix | ||
29 | assert builtins.all (x: getOutputHashes x == outputHashes) (builtins.attrValues outputHashes); | ||
30 | # colon-separated. | ||
31 | # Note that colon prefix must not be applied to the standard SRI. e.g. "sha256:sha256-..." is illegal. | ||
32 | assert builtins.all (x: getOutputHashesColon x == outputHashes) (with outputHashes; [ hashesBase16 hashesBase32 hashesBase64 ]); | ||
33 | outputHashes | ||
diff --git a/test/testdata/eval-okay-curpos.exp b/test/testdata/eval-okay-curpos.exp new file mode 100644 index 0000000..65fd65b --- /dev/null +++ b/test/testdata/eval-okay-curpos.exp | |||
@@ -0,0 +1 @@ | |||
[ 3 7 4 9 ] | |||
diff --git a/test/testdata/eval-okay-curpos.nix b/test/testdata/eval-okay-curpos.nix new file mode 100644 index 0000000..b79553d --- /dev/null +++ b/test/testdata/eval-okay-curpos.nix | |||
@@ -0,0 +1,5 @@ | |||
1 | # Bla | ||
2 | let | ||
3 | x = __curPos; | ||
4 | y = __curPos; | ||
5 | in [ x.line x.column y.line y.column ] | ||
diff --git a/test/testdata/eval-okay-deepseq.exp b/test/testdata/eval-okay-deepseq.exp new file mode 100644 index 0000000..8d38505 --- /dev/null +++ b/test/testdata/eval-okay-deepseq.exp | |||
@@ -0,0 +1 @@ | |||
456 | |||
diff --git a/test/testdata/eval-okay-deepseq.nix b/test/testdata/eval-okay-deepseq.nix new file mode 100644 index 0000000..53aa4b1 --- /dev/null +++ b/test/testdata/eval-okay-deepseq.nix | |||
@@ -0,0 +1 @@ | |||
builtins.deepSeq (let as = { x = 123; y = as; }; in as) 456 | |||
diff --git a/test/testdata/eval-okay-delayed-with-inherit.exp b/test/testdata/eval-okay-delayed-with-inherit.exp new file mode 100644 index 0000000..eaacb55 --- /dev/null +++ b/test/testdata/eval-okay-delayed-with-inherit.exp | |||
@@ -0,0 +1 @@ | |||
"b-overridden" | |||
diff --git a/test/testdata/eval-okay-delayed-with-inherit.nix b/test/testdata/eval-okay-delayed-with-inherit.nix new file mode 100644 index 0000000..84b388c --- /dev/null +++ b/test/testdata/eval-okay-delayed-with-inherit.nix | |||
@@ -0,0 +1,24 @@ | |||
1 | let | ||
2 | pkgs_ = with pkgs; { | ||
3 | a = derivation { | ||
4 | name = "a"; | ||
5 | system = builtins.currentSystem; | ||
6 | builder = "/bin/sh"; | ||
7 | args = [ "-c" "touch $out" ]; | ||
8 | inherit b; | ||
9 | }; | ||
10 | |||
11 | inherit b; | ||
12 | }; | ||
13 | |||
14 | packageOverrides = p: { | ||
15 | b = derivation { | ||
16 | name = "b-overridden"; | ||
17 | system = builtins.currentSystem; | ||
18 | builder = "/bin/sh"; | ||
19 | args = [ "-c" "touch $out" ]; | ||
20 | }; | ||
21 | }; | ||
22 | |||
23 | pkgs = pkgs_ // (packageOverrides pkgs_); | ||
24 | in pkgs.a.b.name | ||
diff --git a/test/testdata/eval-okay-delayed-with.exp b/test/testdata/eval-okay-delayed-with.exp new file mode 100644 index 0000000..8e7c61a --- /dev/null +++ b/test/testdata/eval-okay-delayed-with.exp | |||
@@ -0,0 +1 @@ | |||
"b-overridden b-overridden a" | |||
diff --git a/test/testdata/eval-okay-delayed-with.nix b/test/testdata/eval-okay-delayed-with.nix new file mode 100644 index 0000000..3fb023e --- /dev/null +++ b/test/testdata/eval-okay-delayed-with.nix | |||
@@ -0,0 +1,29 @@ | |||
1 | let | ||
2 | |||
3 | pkgs_ = with pkgs; { | ||
4 | a = derivation { | ||
5 | name = "a"; | ||
6 | system = builtins.currentSystem; | ||
7 | builder = "/bin/sh"; | ||
8 | args = [ "-c" "touch $out" ]; | ||
9 | inherit b; | ||
10 | }; | ||
11 | |||
12 | b = derivation { | ||
13 | name = "b"; | ||
14 | system = builtins.currentSystem; | ||
15 | builder = "/bin/sh"; | ||
16 | args = [ "-c" "touch $out" ]; | ||
17 | inherit a; | ||
18 | }; | ||
19 | |||
20 | c = b; | ||
21 | }; | ||
22 | |||
23 | packageOverrides = pkgs: with pkgs; { | ||
24 | b = derivation (b.drvAttrs // { name = "${b.name}-overridden"; }); | ||
25 | }; | ||
26 | |||
27 | pkgs = pkgs_ // (packageOverrides pkgs_); | ||
28 | |||
29 | in "${pkgs.a.b.name} ${pkgs.c.name} ${pkgs.b.a.name}" | ||
diff --git a/test/testdata/eval-okay-derivation-legacy.err.exp b/test/testdata/eval-okay-derivation-legacy.err.exp new file mode 100644 index 0000000..94f0854 --- /dev/null +++ b/test/testdata/eval-okay-derivation-legacy.err.exp | |||
@@ -0,0 +1,6 @@ | |||
1 | warning: In a derivation named 'eval-okay-derivation-legacy', 'structuredAttrs' disables the effect of the derivation attribute 'allowedReferences'; use 'outputChecks.<output>.allowedReferences' instead | ||
2 | warning: In a derivation named 'eval-okay-derivation-legacy', 'structuredAttrs' disables the effect of the derivation attribute 'allowedRequisites'; use 'outputChecks.<output>.allowedRequisites' instead | ||
3 | warning: In a derivation named 'eval-okay-derivation-legacy', 'structuredAttrs' disables the effect of the derivation attribute 'disallowedReferences'; use 'outputChecks.<output>.disallowedReferences' instead | ||
4 | warning: In a derivation named 'eval-okay-derivation-legacy', 'structuredAttrs' disables the effect of the derivation attribute 'disallowedRequisites'; use 'outputChecks.<output>.disallowedRequisites' instead | ||
5 | warning: In a derivation named 'eval-okay-derivation-legacy', 'structuredAttrs' disables the effect of the derivation attribute 'maxClosureSize'; use 'outputChecks.<output>.maxClosureSize' instead | ||
6 | warning: In a derivation named 'eval-okay-derivation-legacy', 'structuredAttrs' disables the effect of the derivation attribute 'maxSize'; use 'outputChecks.<output>.maxSize' instead | ||
diff --git a/test/testdata/eval-okay-derivation-legacy.exp b/test/testdata/eval-okay-derivation-legacy.exp new file mode 100644 index 0000000..4f374a1 --- /dev/null +++ b/test/testdata/eval-okay-derivation-legacy.exp | |||
@@ -0,0 +1 @@ | |||
"/nix/store/mzgwvrjjir216ra58mwwizi8wj6y9ddr-eval-okay-derivation-legacy" | |||
diff --git a/test/testdata/eval-okay-derivation-legacy.nix b/test/testdata/eval-okay-derivation-legacy.nix new file mode 100644 index 0000000..b529cdf --- /dev/null +++ b/test/testdata/eval-okay-derivation-legacy.nix | |||
@@ -0,0 +1,12 @@ | |||
1 | (builtins.derivationStrict { | ||
2 | name = "eval-okay-derivation-legacy"; | ||
3 | system = "x86_64-linux"; | ||
4 | builder = "/dontcare"; | ||
5 | __structuredAttrs = true; | ||
6 | allowedReferences = [ ]; | ||
7 | disallowedReferences = [ ]; | ||
8 | allowedRequisites = [ ]; | ||
9 | disallowedRequisites = [ ]; | ||
10 | maxSize = 1234; | ||
11 | maxClosureSize = 12345; | ||
12 | }).out | ||
diff --git a/test/testdata/eval-okay-dynamic-attrs-2.exp b/test/testdata/eval-okay-dynamic-attrs-2.exp new file mode 100644 index 0000000..27ba77d --- /dev/null +++ b/test/testdata/eval-okay-dynamic-attrs-2.exp | |||
@@ -0,0 +1 @@ | |||
true | |||
diff --git a/test/testdata/eval-okay-dynamic-attrs-2.nix b/test/testdata/eval-okay-dynamic-attrs-2.nix new file mode 100644 index 0000000..6d57bf8 --- /dev/null +++ b/test/testdata/eval-okay-dynamic-attrs-2.nix | |||
@@ -0,0 +1 @@ | |||
{ a."${"b"}" = true; a."${"c"}" = false; }.a.b | |||
diff --git a/test/testdata/eval-okay-dynamic-attrs-bare.exp b/test/testdata/eval-okay-dynamic-attrs-bare.exp new file mode 100644 index 0000000..df8750a --- /dev/null +++ b/test/testdata/eval-okay-dynamic-attrs-bare.exp | |||
@@ -0,0 +1 @@ | |||
{ binds = true; hasAttrs = true; multiAttrs = true; recBinds = true; selectAttrs = true; selectOrAttrs = true; } | |||
diff --git a/test/testdata/eval-okay-dynamic-attrs-bare.nix b/test/testdata/eval-okay-dynamic-attrs-bare.nix new file mode 100644 index 0000000..0dbe15e --- /dev/null +++ b/test/testdata/eval-okay-dynamic-attrs-bare.nix | |||
@@ -0,0 +1,17 @@ | |||
1 | let | ||
2 | aString = "a"; | ||
3 | |||
4 | bString = "b"; | ||
5 | in { | ||
6 | hasAttrs = { a.b = null; } ? ${aString}.b; | ||
7 | |||
8 | selectAttrs = { a.b = true; }.a.${bString}; | ||
9 | |||
10 | selectOrAttrs = { }.${aString} or true; | ||
11 | |||
12 | binds = { ${aString}."${bString}c" = true; }.a.bc; | ||
13 | |||
14 | recBinds = rec { ${bString} = a; a = true; }.b; | ||
15 | |||
16 | multiAttrs = { ${aString} = true; ${bString} = false; }.a; | ||
17 | } | ||
diff --git a/test/testdata/eval-okay-dynamic-attrs.exp b/test/testdata/eval-okay-dynamic-attrs.exp new file mode 100644 index 0000000..df8750a --- /dev/null +++ b/test/testdata/eval-okay-dynamic-attrs.exp | |||
@@ -0,0 +1 @@ | |||
{ binds = true; hasAttrs = true; multiAttrs = true; recBinds = true; selectAttrs = true; selectOrAttrs = true; } | |||
diff --git a/test/testdata/eval-okay-dynamic-attrs.nix b/test/testdata/eval-okay-dynamic-attrs.nix new file mode 100644 index 0000000..ee02ac7 --- /dev/null +++ b/test/testdata/eval-okay-dynamic-attrs.nix | |||
@@ -0,0 +1,17 @@ | |||
1 | let | ||
2 | aString = "a"; | ||
3 | |||
4 | bString = "b"; | ||
5 | in { | ||
6 | hasAttrs = { a.b = null; } ? "${aString}".b; | ||
7 | |||
8 | selectAttrs = { a.b = true; }.a."${bString}"; | ||
9 | |||
10 | selectOrAttrs = { }."${aString}" or true; | ||
11 | |||
12 | binds = { "${aString}"."${bString}c" = true; }.a.bc; | ||
13 | |||
14 | recBinds = rec { "${bString}" = a; a = true; }.b; | ||
15 | |||
16 | multiAttrs = { "${aString}" = true; "${bString}" = false; }.a; | ||
17 | } | ||
diff --git a/test/testdata/eval-okay-elem.exp b/test/testdata/eval-okay-elem.exp new file mode 100644 index 0000000..3cf6c0e --- /dev/null +++ b/test/testdata/eval-okay-elem.exp | |||
@@ -0,0 +1 @@ | |||
[ true false 30 ] | |||
diff --git a/test/testdata/eval-okay-elem.nix b/test/testdata/eval-okay-elem.nix new file mode 100644 index 0000000..71ea7a4 --- /dev/null +++ b/test/testdata/eval-okay-elem.nix | |||
@@ -0,0 +1,6 @@ | |||
1 | with import ./lib.nix; | ||
2 | |||
3 | let xs = range 10 40; in | ||
4 | |||
5 | [ (builtins.elem 23 xs) (builtins.elem 42 xs) (builtins.elemAt xs 20) ] | ||
6 | |||
diff --git a/test/testdata/eval-okay-empty-args.exp b/test/testdata/eval-okay-empty-args.exp new file mode 100644 index 0000000..cb5537d --- /dev/null +++ b/test/testdata/eval-okay-empty-args.exp | |||
@@ -0,0 +1 @@ | |||
"ab" | |||
diff --git a/test/testdata/eval-okay-empty-args.nix b/test/testdata/eval-okay-empty-args.nix new file mode 100644 index 0000000..78c133a --- /dev/null +++ b/test/testdata/eval-okay-empty-args.nix | |||
@@ -0,0 +1 @@ | |||
({}: {x,y,}: "${x}${y}") {} {x = "a"; y = "b";} | |||
diff --git a/test/testdata/eval-okay-eq-derivations.exp b/test/testdata/eval-okay-eq-derivations.exp new file mode 100644 index 0000000..ec04aab --- /dev/null +++ b/test/testdata/eval-okay-eq-derivations.exp | |||
@@ -0,0 +1 @@ | |||
[ true true true false ] | |||
diff --git a/test/testdata/eval-okay-eq-derivations.nix b/test/testdata/eval-okay-eq-derivations.nix new file mode 100644 index 0000000..d526cb4 --- /dev/null +++ b/test/testdata/eval-okay-eq-derivations.nix | |||
@@ -0,0 +1,10 @@ | |||
1 | let | ||
2 | |||
3 | drvA1 = derivation { name = "a"; builder = "/foo"; system = "i686-linux"; }; | ||
4 | drvA2 = derivation { name = "a"; builder = "/foo"; system = "i686-linux"; }; | ||
5 | drvA3 = derivation { name = "a"; builder = "/foo"; system = "i686-linux"; } // { dummy = 1; }; | ||
6 | |||
7 | drvC1 = derivation { name = "c"; builder = "/foo"; system = "i686-linux"; }; | ||
8 | drvC2 = derivation { name = "c"; builder = "/bar"; system = "i686-linux"; }; | ||
9 | |||
10 | in [ (drvA1 == drvA1) (drvA1 == drvA2) (drvA1 == drvA3) (drvC1 == drvC2) ] | ||
diff --git a/test/testdata/eval-okay-eq.exp b/test/testdata/eval-okay-eq.exp new file mode 100644 index 0000000..27ba77d --- /dev/null +++ b/test/testdata/eval-okay-eq.exp | |||
@@ -0,0 +1 @@ | |||
true | |||
diff --git a/test/testdata/eval-okay-eq.nix b/test/testdata/eval-okay-eq.nix new file mode 100644 index 0000000..73d200b --- /dev/null +++ b/test/testdata/eval-okay-eq.nix | |||
@@ -0,0 +1,3 @@ | |||
1 | ["foobar" (rec {x = 1; y = x;})] | ||
2 | == | ||
3 | [("foo" + "bar") ({x = 1; y = 1;})] | ||
diff --git a/test/testdata/eval-okay-filter.exp b/test/testdata/eval-okay-filter.exp new file mode 100644 index 0000000..355d51c --- /dev/null +++ b/test/testdata/eval-okay-filter.exp | |||
@@ -0,0 +1 @@ | |||
[ 0 2 4 6 8 10 100 102 104 106 108 110 ] | |||
diff --git a/test/testdata/eval-okay-filter.nix b/test/testdata/eval-okay-filter.nix new file mode 100644 index 0000000..85109b0 --- /dev/null +++ b/test/testdata/eval-okay-filter.nix | |||
@@ -0,0 +1,5 @@ | |||
1 | with import ./lib.nix; | ||
2 | |||
3 | builtins.filter | ||
4 | (x: x / 2 * 2 == x) | ||
5 | (builtins.concatLists [ (range 0 10) (range 100 110) ]) | ||
diff --git a/test/testdata/eval-okay-flake-ref-to-string.exp b/test/testdata/eval-okay-flake-ref-to-string.exp new file mode 100644 index 0000000..110f844 --- /dev/null +++ b/test/testdata/eval-okay-flake-ref-to-string.exp | |||
@@ -0,0 +1 @@ | |||
"github:NixOS/nixpkgs/23.05?dir=lib" | |||
diff --git a/test/testdata/eval-okay-flake-ref-to-string.nix b/test/testdata/eval-okay-flake-ref-to-string.nix new file mode 100644 index 0000000..dbb4e5b --- /dev/null +++ b/test/testdata/eval-okay-flake-ref-to-string.nix | |||
@@ -0,0 +1,7 @@ | |||
1 | builtins.flakeRefToString { | ||
2 | type = "github"; | ||
3 | owner = "NixOS"; | ||
4 | repo = "nixpkgs"; | ||
5 | ref = "23.05"; | ||
6 | dir = "lib"; | ||
7 | } | ||
diff --git a/test/testdata/eval-okay-flatten.exp b/test/testdata/eval-okay-flatten.exp new file mode 100644 index 0000000..b979b2b --- /dev/null +++ b/test/testdata/eval-okay-flatten.exp | |||
@@ -0,0 +1 @@ | |||
"1234567" | |||
diff --git a/test/testdata/eval-okay-flatten.nix b/test/testdata/eval-okay-flatten.nix new file mode 100644 index 0000000..fe911e9 --- /dev/null +++ b/test/testdata/eval-okay-flatten.nix | |||
@@ -0,0 +1,8 @@ | |||
1 | with import ./lib.nix; | ||
2 | |||
3 | let { | ||
4 | |||
5 | l = ["1" "2" ["3" ["4"] ["5" "6"]] "7"]; | ||
6 | |||
7 | body = concat (flatten l); | ||
8 | } | ||
diff --git a/test/testdata/eval-okay-float.exp b/test/testdata/eval-okay-float.exp new file mode 100644 index 0000000..3c50a8a --- /dev/null +++ b/test/testdata/eval-okay-float.exp | |||
@@ -0,0 +1 @@ | |||
[ 3.4 3.5 2.5 1.5 ] | |||
diff --git a/test/testdata/eval-okay-float.nix b/test/testdata/eval-okay-float.nix new file mode 100644 index 0000000..b2702c7 --- /dev/null +++ b/test/testdata/eval-okay-float.nix | |||
@@ -0,0 +1,6 @@ | |||
1 | [ | ||
2 | (1.1 + 2.3) | ||
3 | (builtins.add (0.5 + 0.5) (2.0 + 0.5)) | ||
4 | ((0.5 + 0.5) * (2.0 + 0.5)) | ||
5 | ((1.5 + 1.5) / (0.5 * 4.0)) | ||
6 | ] | ||
diff --git a/test/testdata/eval-okay-floor-ceil.exp b/test/testdata/eval-okay-floor-ceil.exp new file mode 100644 index 0000000..81f8042 --- /dev/null +++ b/test/testdata/eval-okay-floor-ceil.exp | |||
@@ -0,0 +1 @@ | |||
"23;24;23;23" | |||
diff --git a/test/testdata/eval-okay-floor-ceil.nix b/test/testdata/eval-okay-floor-ceil.nix new file mode 100644 index 0000000..d76a0d8 --- /dev/null +++ b/test/testdata/eval-okay-floor-ceil.nix | |||
@@ -0,0 +1,9 @@ | |||
1 | with import ./lib.nix; | ||
2 | |||
3 | let | ||
4 | n1 = builtins.floor 23.5; | ||
5 | n2 = builtins.ceil 23.5; | ||
6 | n3 = builtins.floor 23; | ||
7 | n4 = builtins.ceil 23; | ||
8 | in | ||
9 | builtins.concatStringsSep ";" (map toString [ n1 n2 n3 n4 ]) | ||
diff --git a/test/testdata/eval-okay-foldlStrict-lazy-elements.exp b/test/testdata/eval-okay-foldlStrict-lazy-elements.exp new file mode 100644 index 0000000..d81cc07 --- /dev/null +++ b/test/testdata/eval-okay-foldlStrict-lazy-elements.exp | |||
@@ -0,0 +1 @@ | |||
42 | |||
diff --git a/test/testdata/eval-okay-foldlStrict-lazy-elements.nix b/test/testdata/eval-okay-foldlStrict-lazy-elements.nix new file mode 100644 index 0000000..c666e07 --- /dev/null +++ b/test/testdata/eval-okay-foldlStrict-lazy-elements.nix | |||
@@ -0,0 +1,9 @@ | |||
1 | # Tests that the rhs argument of op is not forced unconditionally | ||
2 | let | ||
3 | lst = builtins.foldl' | ||
4 | (acc: x: acc ++ [ x ]) | ||
5 | [ ] | ||
6 | [ 42 (throw "this shouldn't be evaluated") ]; | ||
7 | in | ||
8 | |||
9 | builtins.head lst | ||
diff --git a/test/testdata/eval-okay-foldlStrict-lazy-initial-accumulator.exp b/test/testdata/eval-okay-foldlStrict-lazy-initial-accumulator.exp new file mode 100644 index 0000000..d81cc07 --- /dev/null +++ b/test/testdata/eval-okay-foldlStrict-lazy-initial-accumulator.exp | |||
@@ -0,0 +1 @@ | |||
42 | |||
diff --git a/test/testdata/eval-okay-foldlStrict-lazy-initial-accumulator.nix b/test/testdata/eval-okay-foldlStrict-lazy-initial-accumulator.nix new file mode 100644 index 0000000..abcd536 --- /dev/null +++ b/test/testdata/eval-okay-foldlStrict-lazy-initial-accumulator.nix | |||
@@ -0,0 +1,6 @@ | |||
1 | # Checks that the nul value for the accumulator is not forced unconditionally. | ||
2 | # Some languages provide a foldl' that is strict in this argument, but Nix does not. | ||
3 | builtins.foldl' | ||
4 | (_: x: x) | ||
5 | (throw "This is never forced") | ||
6 | [ "but the results of applying op are" 42 ] | ||
diff --git a/test/testdata/eval-okay-foldlStrict.exp b/test/testdata/eval-okay-foldlStrict.exp new file mode 100644 index 0000000..837e12b --- /dev/null +++ b/test/testdata/eval-okay-foldlStrict.exp | |||
@@ -0,0 +1 @@ | |||
500500 | |||
diff --git a/test/testdata/eval-okay-foldlStrict.nix b/test/testdata/eval-okay-foldlStrict.nix new file mode 100644 index 0000000..3b87188 --- /dev/null +++ b/test/testdata/eval-okay-foldlStrict.nix | |||
@@ -0,0 +1,3 @@ | |||
1 | with import ./lib.nix; | ||
2 | |||
3 | builtins.foldl' (x: y: x + y) 0 (range 1 1000) | ||
diff --git a/test/testdata/eval-okay-fromTOML-timestamps.exp b/test/testdata/eval-okay-fromTOML-timestamps.exp new file mode 100644 index 0000000..08b3c69 --- /dev/null +++ b/test/testdata/eval-okay-fromTOML-timestamps.exp | |||
@@ -0,0 +1 @@ | |||
{ "1234" = "value"; "127.0.0.1" = "value"; a = { b = { c = { }; }; }; arr1 = [ 1 2 3 ]; arr2 = [ "red" "yellow" "green" ]; arr3 = [ [ 1 2 ] [ 3 4 5 ] ]; arr4 = [ "all" "strings" "are the same" "type" ]; arr5 = [ [ 1 2 ] [ "a" "b" "c" ] ]; arr7 = [ 1 2 3 ]; arr8 = [ 1 2 ]; bare-key = "value"; bare_key = "value"; bin1 = 214; bool1 = true; bool2 = false; "character encoding" = "value"; d = { e = { f = { }; }; }; dog = { "tater.man" = { type = { name = "pug"; }; }; }; flt1 = 1; flt2 = 3.1415; flt3 = -0.01; flt4 = 5e+22; flt5 = 1e+06; flt6 = -0.02; flt7 = 6.626e-34; flt8 = 9.22462e+06; fruit = [ { name = "apple"; physical = { color = "red"; shape = "round"; }; variety = [ { name = "red delicious"; } { name = "granny smith"; } ]; } { name = "banana"; variety = [ { name = "plantain"; } ]; } ]; g = { h = { i = { }; }; }; hex1 = 3735928559; hex2 = 3735928559; hex3 = 3735928559; int1 = 99; int2 = 42; int3 = 0; int4 = -17; int5 = 1000; int6 = 5349221; int7 = 12345; j = { "ʞ" = { l = { }; }; }; key = "value"; key2 = "value"; ld1 = { _type = "timestamp"; value = "1979-05-27"; }; ldt1 = { _type = "timestamp"; value = "1979-05-27T07:32:00"; }; ldt2 = { _type = "timestamp"; value = "1979-05-27T00:32:00.999999"; }; lt1 = { _type = "timestamp"; value = "07:32:00"; }; lt2 = { _type = "timestamp"; value = "00:32:00.999999"; }; name = "Orange"; oct1 = 342391; oct2 = 493; odt1 = { _type = "timestamp"; value = "1979-05-27T07:32:00Z"; }; odt2 = { _type = "timestamp"; value = "1979-05-27T00:32:00-07:00"; }; odt3 = { _type = "timestamp"; value = "1979-05-27T00:32:00.999999-07:00"; }; odt4 = { _type = "timestamp"; value = "1979-05-27T07:32:00Z"; }; physical = { color = "orange"; shape = "round"; }; products = [ { name = "Hammer"; sku = 738594937; } { } { color = "gray"; name = "Nail"; sku = 284758393; } ]; "quoted \"value\"" = "value"; site = { "google.com" = true; }; str = "I'm a string. \"You can quote me\". Name\tJosé\nLocation\tSF."; table-1 = { key1 = "some string"; key2 = 123; }; table-2 = { key1 = "another string"; key2 = 456; }; x = { y = { z = { w = { animal = { type = { name = "pug"; }; }; name = { first = "Tom"; last = "Preston-Werner"; }; point = { x = 1; y = 2; }; }; }; }; }; "ʎǝʞ" = "value"; } | |||
diff --git a/test/testdata/eval-okay-fromTOML-timestamps.flags b/test/testdata/eval-okay-fromTOML-timestamps.flags new file mode 100644 index 0000000..9ed39dc --- /dev/null +++ b/test/testdata/eval-okay-fromTOML-timestamps.flags | |||
@@ -0,0 +1 @@ | |||
--extra-experimental-features parse-toml-timestamps | |||
diff --git a/test/testdata/eval-okay-fromTOML-timestamps.nix b/test/testdata/eval-okay-fromTOML-timestamps.nix new file mode 100644 index 0000000..74cff94 --- /dev/null +++ b/test/testdata/eval-okay-fromTOML-timestamps.nix | |||
@@ -0,0 +1,130 @@ | |||
1 | builtins.fromTOML '' | ||
2 | key = "value" | ||
3 | bare_key = "value" | ||
4 | bare-key = "value" | ||
5 | 1234 = "value" | ||
6 | |||
7 | "127.0.0.1" = "value" | ||
8 | "character encoding" = "value" | ||
9 | "ʎǝʞ" = "value" | ||
10 | 'key2' = "value" | ||
11 | 'quoted "value"' = "value" | ||
12 | |||
13 | name = "Orange" | ||
14 | |||
15 | physical.color = "orange" | ||
16 | physical.shape = "round" | ||
17 | site."google.com" = true | ||
18 | |||
19 | # This is legal according to the spec, but cpptoml doesn't handle it. | ||
20 | #a.b.c = 1 | ||
21 | #a.d = 2 | ||
22 | |||
23 | str = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF." | ||
24 | |||
25 | int1 = +99 | ||
26 | int2 = 42 | ||
27 | int3 = 0 | ||
28 | int4 = -17 | ||
29 | int5 = 1_000 | ||
30 | int6 = 5_349_221 | ||
31 | int7 = 1_2_3_4_5 | ||
32 | |||
33 | hex1 = 0xDEADBEEF | ||
34 | hex2 = 0xdeadbeef | ||
35 | hex3 = 0xdead_beef | ||
36 | |||
37 | oct1 = 0o01234567 | ||
38 | oct2 = 0o755 | ||
39 | |||
40 | bin1 = 0b11010110 | ||
41 | |||
42 | flt1 = +1.0 | ||
43 | flt2 = 3.1415 | ||
44 | flt3 = -0.01 | ||
45 | flt4 = 5e+22 | ||
46 | flt5 = 1e6 | ||
47 | flt6 = -2E-2 | ||
48 | flt7 = 6.626e-34 | ||
49 | flt8 = 9_224_617.445_991_228_313 | ||
50 | |||
51 | bool1 = true | ||
52 | bool2 = false | ||
53 | |||
54 | odt1 = 1979-05-27T07:32:00Z | ||
55 | odt2 = 1979-05-27T00:32:00-07:00 | ||
56 | odt3 = 1979-05-27T00:32:00.999999-07:00 | ||
57 | odt4 = 1979-05-27 07:32:00Z | ||
58 | ldt1 = 1979-05-27T07:32:00 | ||
59 | ldt2 = 1979-05-27T00:32:00.999999 | ||
60 | ld1 = 1979-05-27 | ||
61 | lt1 = 07:32:00 | ||
62 | lt2 = 00:32:00.999999 | ||
63 | |||
64 | arr1 = [ 1, 2, 3 ] | ||
65 | arr2 = [ "red", "yellow", "green" ] | ||
66 | arr3 = [ [ 1, 2 ], [3, 4, 5] ] | ||
67 | arr4 = [ "all", 'strings', """are the same""", ''''type''''] | ||
68 | arr5 = [ [ 1, 2 ], ["a", "b", "c"] ] | ||
69 | |||
70 | arr7 = [ | ||
71 | 1, 2, 3 | ||
72 | ] | ||
73 | |||
74 | arr8 = [ | ||
75 | 1, | ||
76 | 2, # this is ok | ||
77 | ] | ||
78 | |||
79 | [table-1] | ||
80 | key1 = "some string" | ||
81 | key2 = 123 | ||
82 | |||
83 | |||
84 | [table-2] | ||
85 | key1 = "another string" | ||
86 | key2 = 456 | ||
87 | |||
88 | [dog."tater.man"] | ||
89 | type.name = "pug" | ||
90 | |||
91 | [a.b.c] | ||
92 | [ d.e.f ] | ||
93 | [ g . h . i ] | ||
94 | [ j . "ʞ" . 'l' ] | ||
95 | [x.y.z.w] | ||
96 | |||
97 | name = { first = "Tom", last = "Preston-Werner" } | ||
98 | point = { x = 1, y = 2 } | ||
99 | animal = { type.name = "pug" } | ||
100 | |||
101 | [[products]] | ||
102 | name = "Hammer" | ||
103 | sku = 738594937 | ||
104 | |||
105 | [[products]] | ||
106 | |||
107 | [[products]] | ||
108 | name = "Nail" | ||
109 | sku = 284758393 | ||
110 | color = "gray" | ||
111 | |||
112 | [[fruit]] | ||
113 | name = "apple" | ||
114 | |||
115 | [fruit.physical] | ||
116 | color = "red" | ||
117 | shape = "round" | ||
118 | |||
119 | [[fruit.variety]] | ||
120 | name = "red delicious" | ||
121 | |||
122 | [[fruit.variety]] | ||
123 | name = "granny smith" | ||
124 | |||
125 | [[fruit]] | ||
126 | name = "banana" | ||
127 | |||
128 | [[fruit.variety]] | ||
129 | name = "plantain" | ||
130 | '' | ||
diff --git a/test/testdata/eval-okay-fromTOML.exp b/test/testdata/eval-okay-fromTOML.exp new file mode 100644 index 0000000..d0dd3af --- /dev/null +++ b/test/testdata/eval-okay-fromTOML.exp | |||
@@ -0,0 +1 @@ | |||
[ { clients = { data = [ [ "gamma" "delta" ] [ 1 2 ] ]; hosts = [ "alpha" "omega" ]; }; database = { connection_max = 5000; enabled = true; ports = [ 8001 8001 8002 ]; server = "192.168.1.1"; }; owner = { name = "Tom Preston-Werner"; }; servers = { alpha = { dc = "eqdc10"; ip = "10.0.0.1"; }; beta = { dc = "eqdc10"; ip = "10.0.0.2"; }; }; title = "TOML Example"; } { "1234" = "value"; "127.0.0.1" = "value"; a = { b = { c = { }; }; }; arr1 = [ 1 2 3 ]; arr2 = [ "red" "yellow" "green" ]; arr3 = [ [ 1 2 ] [ 3 4 5 ] ]; arr4 = [ "all" "strings" "are the same" "type" ]; arr5 = [ [ 1 2 ] [ "a" "b" "c" ] ]; arr7 = [ 1 2 3 ]; arr8 = [ 1 2 ]; bare-key = "value"; bare_key = "value"; bin1 = 214; bool1 = true; bool2 = false; "character encoding" = "value"; d = { e = { f = { }; }; }; dog = { "tater.man" = { type = { name = "pug"; }; }; }; flt1 = 1; flt2 = 3.1415; flt3 = -0.01; flt4 = 5e+22; flt5 = 1e+06; flt6 = -0.02; flt7 = 6.626e-34; flt8 = 9.22462e+06; fruit = [ { name = "apple"; physical = { color = "red"; shape = "round"; }; variety = [ { name = "red delicious"; } { name = "granny smith"; } ]; } { name = "banana"; variety = [ { name = "plantain"; } ]; } ]; g = { h = { i = { }; }; }; hex1 = 3735928559; hex2 = 3735928559; hex3 = 3735928559; int1 = 99; int2 = 42; int3 = 0; int4 = -17; int5 = 1000; int6 = 5349221; int7 = 12345; j = { "ʞ" = { l = { }; }; }; key = "value"; key2 = "value"; name = "Orange"; oct1 = 342391; oct2 = 493; physical = { color = "orange"; shape = "round"; }; products = [ { name = "Hammer"; sku = 738594937; } { } { color = "gray"; name = "Nail"; sku = 284758393; } ]; "quoted \"value\"" = "value"; site = { "google.com" = true; }; str = "I'm a string. \"You can quote me\". Name\tJosé\nLocation\tSF."; table-1 = { key1 = "some string"; key2 = 123; }; table-2 = { key1 = "another string"; key2 = 456; }; x = { y = { z = { w = { animal = { type = { name = "pug"; }; }; name = { first = "Tom"; last = "Preston-Werner"; }; point = { x = 1; y = 2; }; }; }; }; }; "ʎǝʞ" = "value"; } { metadata = { "checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4"; "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"; "checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6"; "checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef"; }; package = [ { dependencies = [ "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" ]; name = "aho-corasick"; source = "registry+https://github.com/rust-lang/crates.io-index"; version = "0.6.4"; } { name = "ansi_term"; source = "registry+https://github.com/rust-lang/crates.io-index"; version = "0.9.0"; } { dependencies = [ "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" ]; name = "atty"; source = "registry+https://github.com/rust-lang/crates.io-index"; version = "0.2.10"; } ]; } { a = [ [ { b = true; } ] ]; c = [ [ { d = true; } ] ]; e = [ [ 123 ] ]; } ] | |||
diff --git a/test/testdata/eval-okay-fromTOML.nix b/test/testdata/eval-okay-fromTOML.nix new file mode 100644 index 0000000..9639326 --- /dev/null +++ b/test/testdata/eval-okay-fromTOML.nix | |||
@@ -0,0 +1,208 @@ | |||
1 | [ | ||
2 | |||
3 | (builtins.fromTOML '' | ||
4 | # This is a TOML document. | ||
5 | |||
6 | title = "TOML Example" | ||
7 | |||
8 | [owner] | ||
9 | name = "Tom Preston-Werner" | ||
10 | #dob = 1979-05-27T07:32:00-08:00 # First class dates | ||
11 | |||
12 | [database] | ||
13 | server = "192.168.1.1" | ||
14 | ports = [ 8001, 8001, 8002 ] | ||
15 | connection_max = 5000 | ||
16 | enabled = true | ||
17 | |||
18 | [servers] | ||
19 | |||
20 | # Indentation (tabs and/or spaces) is allowed but not required | ||
21 | [servers.alpha] | ||
22 | ip = "10.0.0.1" | ||
23 | dc = "eqdc10" | ||
24 | |||
25 | [servers.beta] | ||
26 | ip = "10.0.0.2" | ||
27 | dc = "eqdc10" | ||
28 | |||
29 | [clients] | ||
30 | data = [ ["gamma", "delta"], [1, 2] ] | ||
31 | |||
32 | # Line breaks are OK when inside arrays | ||
33 | hosts = [ | ||
34 | "alpha", | ||
35 | "omega" | ||
36 | ] | ||
37 | '') | ||
38 | |||
39 | (builtins.fromTOML '' | ||
40 | key = "value" | ||
41 | bare_key = "value" | ||
42 | bare-key = "value" | ||
43 | 1234 = "value" | ||
44 | |||
45 | "127.0.0.1" = "value" | ||
46 | "character encoding" = "value" | ||
47 | "ʎǝʞ" = "value" | ||
48 | 'key2' = "value" | ||
49 | 'quoted "value"' = "value" | ||
50 | |||
51 | name = "Orange" | ||
52 | |||
53 | physical.color = "orange" | ||
54 | physical.shape = "round" | ||
55 | site."google.com" = true | ||
56 | |||
57 | # This is legal according to the spec, but cpptoml doesn't handle it. | ||
58 | #a.b.c = 1 | ||
59 | #a.d = 2 | ||
60 | |||
61 | str = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF." | ||
62 | |||
63 | int1 = +99 | ||
64 | int2 = 42 | ||
65 | int3 = 0 | ||
66 | int4 = -17 | ||
67 | int5 = 1_000 | ||
68 | int6 = 5_349_221 | ||
69 | int7 = 1_2_3_4_5 | ||
70 | |||
71 | hex1 = 0xDEADBEEF | ||
72 | hex2 = 0xdeadbeef | ||
73 | hex3 = 0xdead_beef | ||
74 | |||
75 | oct1 = 0o01234567 | ||
76 | oct2 = 0o755 | ||
77 | |||
78 | bin1 = 0b11010110 | ||
79 | |||
80 | flt1 = +1.0 | ||
81 | flt2 = 3.1415 | ||
82 | flt3 = -0.01 | ||
83 | flt4 = 5e+22 | ||
84 | flt5 = 1e6 | ||
85 | flt6 = -2E-2 | ||
86 | flt7 = 6.626e-34 | ||
87 | flt8 = 9_224_617.445_991_228_313 | ||
88 | |||
89 | bool1 = true | ||
90 | bool2 = false | ||
91 | |||
92 | # FIXME: not supported because Nix doesn't have a date/time type. | ||
93 | #odt1 = 1979-05-27T07:32:00Z | ||
94 | #odt2 = 1979-05-27T00:32:00-07:00 | ||
95 | #odt3 = 1979-05-27T00:32:00.999999-07:00 | ||
96 | #odt4 = 1979-05-27 07:32:00Z | ||
97 | #ldt1 = 1979-05-27T07:32:00 | ||
98 | #ldt2 = 1979-05-27T00:32:00.999999 | ||
99 | #ld1 = 1979-05-27 | ||
100 | #lt1 = 07:32:00 | ||
101 | #lt2 = 00:32:00.999999 | ||
102 | |||
103 | arr1 = [ 1, 2, 3 ] | ||
104 | arr2 = [ "red", "yellow", "green" ] | ||
105 | arr3 = [ [ 1, 2 ], [3, 4, 5] ] | ||
106 | arr4 = [ "all", 'strings', """are the same""", ''''type''''] | ||
107 | arr5 = [ [ 1, 2 ], ["a", "b", "c"] ] | ||
108 | |||
109 | arr7 = [ | ||
110 | 1, 2, 3 | ||
111 | ] | ||
112 | |||
113 | arr8 = [ | ||
114 | 1, | ||
115 | 2, # this is ok | ||
116 | ] | ||
117 | |||
118 | [table-1] | ||
119 | key1 = "some string" | ||
120 | key2 = 123 | ||
121 | |||
122 | |||
123 | [table-2] | ||
124 | key1 = "another string" | ||
125 | key2 = 456 | ||
126 | |||
127 | [dog."tater.man"] | ||
128 | type.name = "pug" | ||
129 | |||
130 | [a.b.c] | ||
131 | [ d.e.f ] | ||
132 | [ g . h . i ] | ||
133 | [ j . "ʞ" . 'l' ] | ||
134 | [x.y.z.w] | ||
135 | |||
136 | name = { first = "Tom", last = "Preston-Werner" } | ||
137 | point = { x = 1, y = 2 } | ||
138 | animal = { type.name = "pug" } | ||
139 | |||
140 | [[products]] | ||
141 | name = "Hammer" | ||
142 | sku = 738594937 | ||
143 | |||
144 | [[products]] | ||
145 | |||
146 | [[products]] | ||
147 | name = "Nail" | ||
148 | sku = 284758393 | ||
149 | color = "gray" | ||
150 | |||
151 | [[fruit]] | ||
152 | name = "apple" | ||
153 | |||
154 | [fruit.physical] | ||
155 | color = "red" | ||
156 | shape = "round" | ||
157 | |||
158 | [[fruit.variety]] | ||
159 | name = "red delicious" | ||
160 | |||
161 | [[fruit.variety]] | ||
162 | name = "granny smith" | ||
163 | |||
164 | [[fruit]] | ||
165 | name = "banana" | ||
166 | |||
167 | [[fruit.variety]] | ||
168 | name = "plantain" | ||
169 | '') | ||
170 | |||
171 | (builtins.fromTOML '' | ||
172 | [[package]] | ||
173 | name = "aho-corasick" | ||
174 | version = "0.6.4" | ||
175 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
176 | dependencies = [ | ||
177 | "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | ||
178 | ] | ||
179 | |||
180 | [[package]] | ||
181 | name = "ansi_term" | ||
182 | version = "0.9.0" | ||
183 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
184 | |||
185 | [[package]] | ||
186 | name = "atty" | ||
187 | version = "0.2.10" | ||
188 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
189 | dependencies = [ | ||
190 | "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", | ||
191 | "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", | ||
192 | "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", | ||
193 | ] | ||
194 | |||
195 | [metadata] | ||
196 | "checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4" | ||
197 | "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" | ||
198 | "checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6" | ||
199 | "checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" | ||
200 | '') | ||
201 | |||
202 | (builtins.fromTOML '' | ||
203 | a = [[{ b = true }]] | ||
204 | c = [ [ { d = true } ] ] | ||
205 | e = [[123]] | ||
206 | '') | ||
207 | |||
208 | ] | ||
diff --git a/test/testdata/eval-okay-fromjson-escapes.exp b/test/testdata/eval-okay-fromjson-escapes.exp new file mode 100644 index 0000000..add5505 --- /dev/null +++ b/test/testdata/eval-okay-fromjson-escapes.exp | |||
@@ -0,0 +1 @@ | |||
"quote \" reverse solidus \\ solidus / backspace formfeed newline \n carriage return \r horizontal tab \t 1 char unicode encoded backspace 1 char unicode encoded e with accent é 2 char unicode encoded s with caron š 3 char unicode encoded rightwards arrow →" | |||
diff --git a/test/testdata/eval-okay-fromjson-escapes.nix b/test/testdata/eval-okay-fromjson-escapes.nix new file mode 100644 index 0000000..f007135 --- /dev/null +++ b/test/testdata/eval-okay-fromjson-escapes.nix | |||
@@ -0,0 +1,3 @@ | |||
1 | # This string contains all supported escapes in a JSON string, per json.org | ||
2 | # \b and \f are not supported by Nix | ||
3 | builtins.fromJSON ''"quote \" reverse solidus \\ solidus \/ backspace \b formfeed \f newline \n carriage return \r horizontal tab \t 1 char unicode encoded backspace \u0008 1 char unicode encoded e with accent \u00e9 2 char unicode encoded s with caron \u0161 3 char unicode encoded rightwards arrow \u2192"'' | ||
diff --git a/test/testdata/eval-okay-fromjson.exp b/test/testdata/eval-okay-fromjson.exp new file mode 100644 index 0000000..27ba77d --- /dev/null +++ b/test/testdata/eval-okay-fromjson.exp | |||
@@ -0,0 +1 @@ | |||
true | |||
diff --git a/test/testdata/eval-okay-fromjson.nix b/test/testdata/eval-okay-fromjson.nix new file mode 100644 index 0000000..4c526b9 --- /dev/null +++ b/test/testdata/eval-okay-fromjson.nix | |||
@@ -0,0 +1,41 @@ | |||
1 | builtins.fromJSON | ||
2 | '' | ||
3 | { | ||
4 | "Video": { | ||
5 | "Title": "The Penguin Chronicles", | ||
6 | "Width": 1920, | ||
7 | "Height": 1080, | ||
8 | "EmbeddedData": [3.14159, 23493,null, true ,false, -10], | ||
9 | "Thumb": { | ||
10 | "Url": "http://www.example.com/video/5678931", | ||
11 | "Width": 200, | ||
12 | "Height": 250 | ||
13 | }, | ||
14 | "Animated" : false, | ||
15 | "IDs": [116, 943, 234, 38793, true ,false,null, -100], | ||
16 | "Escapes": "\"\\\/\t\n\r\t", | ||
17 | "Subtitle" : false, | ||
18 | "Latitude": 37.7668, | ||
19 | "Longitude": -122.3959 | ||
20 | } | ||
21 | } | ||
22 | '' | ||
23 | == | ||
24 | { Video = | ||
25 | { Title = "The Penguin Chronicles"; | ||
26 | Width = 1920; | ||
27 | Height = 1080; | ||
28 | EmbeddedData = [ 3.14159 23493 null true false (0-10) ]; | ||
29 | Thumb = | ||
30 | { Url = "http://www.example.com/video/5678931"; | ||
31 | Width = 200; | ||
32 | Height = 250; | ||
33 | }; | ||
34 | Animated = false; | ||
35 | IDs = [ 116 943 234 38793 true false null (0-100) ]; | ||
36 | Escapes = "\"\\\/\t\n\r\t"; # supported in JSON but not Nix: \b\f | ||
37 | Subtitle = false; | ||
38 | Latitude = 37.7668; | ||
39 | Longitude = -122.3959; | ||
40 | }; | ||
41 | } | ||
diff --git a/test/testdata/eval-okay-functionargs.exp b/test/testdata/eval-okay-functionargs.exp new file mode 100644 index 0000000..c1c9f8f --- /dev/null +++ b/test/testdata/eval-okay-functionargs.exp | |||
@@ -0,0 +1 @@ | |||
[ "stdenv" "fetchurl" "aterm-stdenv" "aterm-stdenv2" "libX11" "libXv" "mplayer-stdenv2.libXv-libX11" "mplayer-stdenv2.libXv-libX11_2" "nix-stdenv-aterm-stdenv" "nix-stdenv2-aterm2-stdenv2" ] | |||
diff --git a/test/testdata/eval-okay-functionargs.exp.xml b/test/testdata/eval-okay-functionargs.exp.xml new file mode 100644 index 0000000..651f54c --- /dev/null +++ b/test/testdata/eval-okay-functionargs.exp.xml | |||
@@ -0,0 +1,15 @@ | |||
1 | <?xml version='1.0' encoding='utf-8'?> | ||
2 | <expr> | ||
3 | <list> | ||
4 | <string value="stdenv" /> | ||
5 | <string value="fetchurl" /> | ||
6 | <string value="aterm-stdenv" /> | ||
7 | <string value="aterm-stdenv2" /> | ||
8 | <string value="libX11" /> | ||
9 | <string value="libXv" /> | ||
10 | <string value="mplayer-stdenv2.libXv-libX11" /> | ||
11 | <string value="mplayer-stdenv2.libXv-libX11_2" /> | ||
12 | <string value="nix-stdenv-aterm-stdenv" /> | ||
13 | <string value="nix-stdenv2-aterm2-stdenv2" /> | ||
14 | </list> | ||
15 | </expr> | ||
diff --git a/test/testdata/eval-okay-functionargs.nix b/test/testdata/eval-okay-functionargs.nix new file mode 100644 index 0000000..68dca62 --- /dev/null +++ b/test/testdata/eval-okay-functionargs.nix | |||
@@ -0,0 +1,80 @@ | |||
1 | let | ||
2 | |||
3 | stdenvFun = { }: { name = "stdenv"; }; | ||
4 | stdenv2Fun = { }: { name = "stdenv2"; }; | ||
5 | fetchurlFun = { stdenv }: assert stdenv.name == "stdenv"; { name = "fetchurl"; }; | ||
6 | atermFun = { stdenv, fetchurl }: { name = "aterm-${stdenv.name}"; }; | ||
7 | aterm2Fun = { stdenv, fetchurl }: { name = "aterm2-${stdenv.name}"; }; | ||
8 | nixFun = { stdenv, fetchurl, aterm }: { name = "nix-${stdenv.name}-${aterm.name}"; }; | ||
9 | |||
10 | mplayerFun = | ||
11 | { stdenv, fetchurl, enableX11 ? false, xorg ? null, enableFoo ? true, foo ? null }: | ||
12 | assert stdenv.name == "stdenv2"; | ||
13 | assert enableX11 -> xorg.libXv.name == "libXv"; | ||
14 | assert enableFoo -> foo != null; | ||
15 | { name = "mplayer-${stdenv.name}.${xorg.libXv.name}-${xorg.libX11.name}"; }; | ||
16 | |||
17 | makeOverridable = f: origArgs: f origArgs // | ||
18 | { override = newArgs: | ||
19 | makeOverridable f (origArgs // (if builtins.isFunction newArgs then newArgs origArgs else newArgs)); | ||
20 | }; | ||
21 | |||
22 | callPackage_ = pkgs: f: args: | ||
23 | makeOverridable f ((builtins.intersectAttrs (builtins.functionArgs f) pkgs) // args); | ||
24 | |||
25 | allPackages = | ||
26 | { overrides ? (pkgs: pkgsPrev: { }) }: | ||
27 | let | ||
28 | callPackage = callPackage_ pkgs; | ||
29 | pkgs = pkgsStd // (overrides pkgs pkgsStd); | ||
30 | pkgsStd = { | ||
31 | inherit pkgs; | ||
32 | stdenv = callPackage stdenvFun { }; | ||
33 | stdenv2 = callPackage stdenv2Fun { }; | ||
34 | fetchurl = callPackage fetchurlFun { }; | ||
35 | aterm = callPackage atermFun { }; | ||
36 | xorg = callPackage xorgFun { }; | ||
37 | mplayer = callPackage mplayerFun { stdenv = pkgs.stdenv2; enableFoo = false; }; | ||
38 | nix = callPackage nixFun { }; | ||
39 | }; | ||
40 | in pkgs; | ||
41 | |||
42 | libX11Fun = { stdenv, fetchurl }: { name = "libX11"; }; | ||
43 | libX11_2Fun = { stdenv, fetchurl }: { name = "libX11_2"; }; | ||
44 | libXvFun = { stdenv, fetchurl, libX11 }: { name = "libXv"; }; | ||
45 | |||
46 | xorgFun = | ||
47 | { pkgs }: | ||
48 | let callPackage = callPackage_ (pkgs // pkgs.xorg); in | ||
49 | { | ||
50 | libX11 = callPackage libX11Fun { }; | ||
51 | libXv = callPackage libXvFun { }; | ||
52 | }; | ||
53 | |||
54 | in | ||
55 | |||
56 | let | ||
57 | |||
58 | pkgs = allPackages { }; | ||
59 | |||
60 | pkgs2 = allPackages { | ||
61 | overrides = pkgs: pkgsPrev: { | ||
62 | stdenv = pkgs.stdenv2; | ||
63 | nix = pkgsPrev.nix.override { aterm = aterm2Fun { inherit (pkgs) stdenv fetchurl; }; }; | ||
64 | xorg = pkgsPrev.xorg // { libX11 = libX11_2Fun { inherit (pkgs) stdenv fetchurl; }; }; | ||
65 | }; | ||
66 | }; | ||
67 | |||
68 | in | ||
69 | |||
70 | [ pkgs.stdenv.name | ||
71 | pkgs.fetchurl.name | ||
72 | pkgs.aterm.name | ||
73 | pkgs2.aterm.name | ||
74 | pkgs.xorg.libX11.name | ||
75 | pkgs.xorg.libXv.name | ||
76 | pkgs.mplayer.name | ||
77 | pkgs2.mplayer.name | ||
78 | pkgs.nix.name | ||
79 | pkgs2.nix.name | ||
80 | ] | ||
diff --git a/test/testdata/eval-okay-getattrpos-functionargs.exp b/test/testdata/eval-okay-getattrpos-functionargs.exp new file mode 100644 index 0000000..7f9ac40 --- /dev/null +++ b/test/testdata/eval-okay-getattrpos-functionargs.exp | |||
@@ -0,0 +1 @@ | |||
{ column = 11; file = "eval-okay-getattrpos-functionargs.nix"; line = 2; } | |||
diff --git a/test/testdata/eval-okay-getattrpos-functionargs.nix b/test/testdata/eval-okay-getattrpos-functionargs.nix new file mode 100644 index 0000000..11d6bb0 --- /dev/null +++ b/test/testdata/eval-okay-getattrpos-functionargs.nix | |||
@@ -0,0 +1,4 @@ | |||
1 | let | ||
2 | fun = { foo }: {}; | ||
3 | pos = builtins.unsafeGetAttrPos "foo" (builtins.functionArgs fun); | ||
4 | in { inherit (pos) column line; file = baseNameOf pos.file; } | ||
diff --git a/test/testdata/eval-okay-getattrpos-undefined.exp b/test/testdata/eval-okay-getattrpos-undefined.exp new file mode 100644 index 0000000..19765bd --- /dev/null +++ b/test/testdata/eval-okay-getattrpos-undefined.exp | |||
@@ -0,0 +1 @@ | |||
null | |||
diff --git a/test/testdata/eval-okay-getattrpos-undefined.nix b/test/testdata/eval-okay-getattrpos-undefined.nix new file mode 100644 index 0000000..14dd38f --- /dev/null +++ b/test/testdata/eval-okay-getattrpos-undefined.nix | |||
@@ -0,0 +1 @@ | |||
builtins.unsafeGetAttrPos "abort" builtins | |||
diff --git a/test/testdata/eval-okay-getattrpos.exp b/test/testdata/eval-okay-getattrpos.exp new file mode 100644 index 0000000..469249b --- /dev/null +++ b/test/testdata/eval-okay-getattrpos.exp | |||
@@ -0,0 +1 @@ | |||
{ column = 5; file = "eval-okay-getattrpos.nix"; line = 3; } | |||
diff --git a/test/testdata/eval-okay-getattrpos.nix b/test/testdata/eval-okay-getattrpos.nix new file mode 100644 index 0000000..ca6b079 --- /dev/null +++ b/test/testdata/eval-okay-getattrpos.nix | |||
@@ -0,0 +1,6 @@ | |||
1 | let | ||
2 | as = { | ||
3 | foo = "bar"; | ||
4 | }; | ||
5 | pos = builtins.unsafeGetAttrPos "foo" as; | ||
6 | in { inherit (pos) column line; file = baseNameOf pos.file; } | ||
diff --git a/test/testdata/eval-okay-getenv.exp b/test/testdata/eval-okay-getenv.exp new file mode 100644 index 0000000..14e24d4 --- /dev/null +++ b/test/testdata/eval-okay-getenv.exp | |||
@@ -0,0 +1 @@ | |||
"foobar" | |||
diff --git a/test/testdata/eval-okay-getenv.nix b/test/testdata/eval-okay-getenv.nix new file mode 100644 index 0000000..4cfec5f --- /dev/null +++ b/test/testdata/eval-okay-getenv.nix | |||
@@ -0,0 +1 @@ | |||
builtins.getEnv "TEST_VAR" + (if builtins.getEnv "NO_SUCH_VAR" == "" then "bar" else "bla") | |||
diff --git a/test/testdata/eval-okay-groupBy.exp b/test/testdata/eval-okay-groupBy.exp new file mode 100644 index 0000000..bfca565 --- /dev/null +++ b/test/testdata/eval-okay-groupBy.exp | |||
@@ -0,0 +1 @@ | |||
{ "1" = [ 9 ]; "2" = [ 8 ]; "3" = [ 13 29 ]; "4" = [ 3 4 10 11 17 18 ]; "5" = [ 0 23 26 28 ]; "6" = [ 1 12 21 27 30 ]; "7" = [ 7 22 ]; "8" = [ 14 ]; "9" = [ 19 ]; b = [ 16 25 ]; c = [ 24 ]; d = [ 2 ]; e = [ 5 6 15 31 ]; f = [ 20 ]; } | |||
diff --git a/test/testdata/eval-okay-groupBy.nix b/test/testdata/eval-okay-groupBy.nix new file mode 100644 index 0000000..862d89d --- /dev/null +++ b/test/testdata/eval-okay-groupBy.nix | |||
@@ -0,0 +1,5 @@ | |||
1 | with import ./lib.nix; | ||
2 | |||
3 | builtins.groupBy (n: | ||
4 | builtins.substring 0 1 (builtins.hashString "sha256" (toString n)) | ||
5 | ) (range 0 31) | ||
diff --git a/test/testdata/eval-okay-hash.exp b/test/testdata/eval-okay-hash.exp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/testdata/eval-okay-hash.exp | |||
diff --git a/test/testdata/eval-okay-hashfile.exp b/test/testdata/eval-okay-hashfile.exp new file mode 100644 index 0000000..ff1e829 --- /dev/null +++ b/test/testdata/eval-okay-hashfile.exp | |||
@@ -0,0 +1 @@ | |||
[ "d3b07384d113edec49eaa6238ad5ff00" "0f343b0931126a20f133d67c2b018a3b" "f1d2d2f924e986ac86fdf7b36c94bcdf32beec15" "60cacbf3d72e1e7834203da608037b1bf83b40e8" "b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c" "5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef" "0cf9180a764aba863a67b6d72f0918bc131c6772642cb2dce5a34f0a702f9470ddc2bf125c12198b1995c233c34b4afd346c54a2334c350a948a51b6e8b4e6b6" "8efb4f73c5655351c444eb109230c556d39e2c7624e9c11abc9e3fb4b9b9254218cc5085b454a9698d085cfa92198491f07a723be4574adc70617b73eb0b6461" ] | |||
diff --git a/test/testdata/eval-okay-hashfile.nix b/test/testdata/eval-okay-hashfile.nix new file mode 100644 index 0000000..aff5a18 --- /dev/null +++ b/test/testdata/eval-okay-hashfile.nix | |||
@@ -0,0 +1,4 @@ | |||
1 | let | ||
2 | paths = [ ./data ./binary-data ]; | ||
3 | in | ||
4 | builtins.concatLists (map (hash: map (builtins.hashFile hash) paths) ["md5" "sha1" "sha256" "sha512"]) | ||
diff --git a/test/testdata/eval-okay-hashstring.exp b/test/testdata/eval-okay-hashstring.exp new file mode 100644 index 0000000..d720a08 --- /dev/null +++ b/test/testdata/eval-okay-hashstring.exp | |||
@@ -0,0 +1 @@ | |||
[ "d41d8cd98f00b204e9800998ecf8427e" "6c69ee7f211c640419d5366cc076ae46" "bb3438fbabd460ea6dbd27d153e2233b" "da39a3ee5e6b4b0d3255bfef95601890afd80709" "cd54e8568c1b37cf1e5badb0779bcbf382212189" "6d12e10b1d331dad210e47fd25d4f260802b7e77" "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" "900a4469df00ccbfd0c145c6d1e4b7953dd0afafadd7534e3a4019e8d38fc663" "ad0387b3bd8652f730ca46d25f9c170af0fd589f42e7f23f5a9e6412d97d7e56" "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" "9d0886f8c6b389398a16257bc79780fab9831c7fc11c8ab07fa732cb7b348feade382f92617c9c5305fefba0af02ab5fd39a587d330997ff5bd0db19f7666653" "21644b72aa259e5a588cd3afbafb1d4310f4889680f6c83b9d531596a5a284f34dbebff409d23bcc86aee6bad10c891606f075c6f4755cb536da27db5693f3a7" ] | |||
diff --git a/test/testdata/eval-okay-hashstring.nix b/test/testdata/eval-okay-hashstring.nix new file mode 100644 index 0000000..b0f62b2 --- /dev/null +++ b/test/testdata/eval-okay-hashstring.nix | |||
@@ -0,0 +1,4 @@ | |||
1 | let | ||
2 | strings = [ "" "text 1" "text 2" ]; | ||
3 | in | ||
4 | builtins.concatLists (map (hash: map (builtins.hashString hash) strings) ["md5" "sha1" "sha256" "sha512"]) | ||
diff --git a/test/testdata/eval-okay-if.exp b/test/testdata/eval-okay-if.exp new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/test/testdata/eval-okay-if.exp | |||
@@ -0,0 +1 @@ | |||
3 | |||
diff --git a/test/testdata/eval-okay-if.nix b/test/testdata/eval-okay-if.nix new file mode 100644 index 0000000..23e4c74 --- /dev/null +++ b/test/testdata/eval-okay-if.nix | |||
@@ -0,0 +1 @@ | |||
if "foo" != "f" + "oo" then 1 else if false then 2 else 3 | |||
diff --git a/test/testdata/eval-okay-import.exp b/test/testdata/eval-okay-import.exp new file mode 100644 index 0000000..c508125 --- /dev/null +++ b/test/testdata/eval-okay-import.exp | |||
@@ -0,0 +1 @@ | |||
[ 1 2 3 4 5 6 7 8 9 10 ] | |||
diff --git a/test/testdata/eval-okay-import.nix b/test/testdata/eval-okay-import.nix new file mode 100644 index 0000000..0b18d94 --- /dev/null +++ b/test/testdata/eval-okay-import.nix | |||
@@ -0,0 +1,11 @@ | |||
1 | let | ||
2 | |||
3 | overrides = { | ||
4 | import = fn: scopedImport overrides fn; | ||
5 | |||
6 | scopedImport = attrs: fn: scopedImport (overrides // attrs) fn; | ||
7 | |||
8 | builtins = builtins // overrides; | ||
9 | } // import ./lib.nix; | ||
10 | |||
11 | in scopedImport overrides ./imported.nix | ||
diff --git a/test/testdata/eval-okay-ind-string.exp b/test/testdata/eval-okay-ind-string.exp new file mode 100644 index 0000000..7862331 --- /dev/null +++ b/test/testdata/eval-okay-ind-string.exp | |||
@@ -0,0 +1 @@ | |||
"This is an indented multi-line string\nliteral. An amount of whitespace at\nthe start of each line matching the minimum\nindentation of all lines in the string\nliteral together will be removed. Thus,\nin this case four spaces will be\nstripped from each line, even though\n THIS LINE is indented six spaces.\n\nAlso, empty lines don't count in the\ndetermination of the indentation level (the\nprevious empty line has indentation 0, but\nit doesn't matter).\nIf the string starts with whitespace\n followed by a newline, it's stripped, but\n that's not the case here. Two spaces are\n stripped because of the \" \" at the start. \nThis line is indented\na bit further.\nAnti-quotations, like so, are\nalso allowed.\n The \\ is not special here.\n' can be followed by any character except another ', e.g. 'x'.\nLikewise for $, e.g. $$ or $varName.\nBut ' followed by ' is special, as is $ followed by {.\nIf you want them, use anti-quotations: '', \${.\n Tabs are not interpreted as whitespace (since we can't guess\n what tab settings are intended), so don't use them.\n\tThis line starts with a space and a tab, so only one\n space will be stripped from each line.\nAlso note that if the last line (just before the closing ' ')\nconsists only of whitespace, it's ignored. But here there is\nsome non-whitespace stuff, so the line isn't removed. \nThis shows a hacky way to preserve an empty line after the start.\nBut there's no reason to do so: you could just repeat the empty\nline.\n Similarly you can force an indentation level,\n in this case to 2 spaces. This works because the anti-quote\n is significant (not whitespace).\nstart on network-interfaces\n\nstart script\n\n rm -f /var/run/opengl-driver\n ln -sf 123 /var/run/opengl-driver\n\n rm -f /var/log/slim.log\n \nend script\n\nenv SLIM_CFGFILE=abc\nenv SLIM_THEMESDIR=def\nenv FONTCONFIG_FILE=/etc/fonts/fonts.conf \t\t\t\t# !!! cleanup\nenv XKB_BINDIR=foo/bin \t\t\t\t# Needed for the Xkb extension.\nenv LD_LIBRARY_PATH=libX11/lib:libXext/lib:/usr/lib/ # related to xorg-sys-opengl - needed to load libglx for (AI)GLX support (for compiz)\n\nenv XORG_DRI_DRIVER_PATH=nvidiaDrivers/X11R6/lib/modules/drivers/ \n\nexec slim/bin/slim\nEscaping of ' followed by ': ''\nEscaping of $ followed by {: \${\nAnd finally to interpret \\n etc. as in a string: \n, \r, \t.\nfoo\n'bla'\nbar\ncut -d $'\\t' -f 1\nending dollar $$\n" | |||
diff --git a/test/testdata/eval-okay-ind-string.nix b/test/testdata/eval-okay-ind-string.nix new file mode 100644 index 0000000..95d59b5 --- /dev/null +++ b/test/testdata/eval-okay-ind-string.nix | |||
@@ -0,0 +1,128 @@ | |||
1 | let | ||
2 | |||
3 | s1 = '' | ||
4 | This is an indented multi-line string | ||
5 | literal. An amount of whitespace at | ||
6 | the start of each line matching the minimum | ||
7 | indentation of all lines in the string | ||
8 | literal together will be removed. Thus, | ||
9 | in this case four spaces will be | ||
10 | stripped from each line, even though | ||
11 | THIS LINE is indented six spaces. | ||
12 | |||
13 | Also, empty lines don't count in the | ||
14 | determination of the indentation level (the | ||
15 | previous empty line has indentation 0, but | ||
16 | it doesn't matter). | ||
17 | ''; | ||
18 | |||
19 | s2 = '' If the string starts with whitespace | ||
20 | followed by a newline, it's stripped, but | ||
21 | that's not the case here. Two spaces are | ||
22 | stripped because of the " " at the start. | ||
23 | ''; | ||
24 | |||
25 | s3 = '' | ||
26 | This line is indented | ||
27 | a bit further. | ||
28 | ''; # indentation of last line doesn't count if it's empty | ||
29 | |||
30 | s4 = '' | ||
31 | Anti-quotations, like ${if true then "so" else "not so"}, are | ||
32 | also allowed. | ||
33 | ''; | ||
34 | |||
35 | s5 = '' | ||
36 | The \ is not special here. | ||
37 | ' can be followed by any character except another ', e.g. 'x'. | ||
38 | Likewise for $, e.g. $$ or $varName. | ||
39 | But ' followed by ' is special, as is $ followed by {. | ||
40 | If you want them, use anti-quotations: ${"''"}, ${"\${"}. | ||
41 | ''; | ||
42 | |||
43 | s6 = '' | ||
44 | Tabs are not interpreted as whitespace (since we can't guess | ||
45 | what tab settings are intended), so don't use them. | ||
46 | This line starts with a space and a tab, so only one | ||
47 | space will be stripped from each line. | ||
48 | ''; | ||
49 | |||
50 | s7 = '' | ||
51 | Also note that if the last line (just before the closing ' ') | ||
52 | consists only of whitespace, it's ignored. But here there is | ||
53 | some non-whitespace stuff, so the line isn't removed. ''; | ||
54 | |||
55 | s8 = '' ${""} | ||
56 | This shows a hacky way to preserve an empty line after the start. | ||
57 | But there's no reason to do so: you could just repeat the empty | ||
58 | line. | ||
59 | ''; | ||
60 | |||
61 | s9 = '' | ||
62 | ${""} Similarly you can force an indentation level, | ||
63 | in this case to 2 spaces. This works because the anti-quote | ||
64 | is significant (not whitespace). | ||
65 | ''; | ||
66 | |||
67 | s10 = '' | ||
68 | ''; | ||
69 | |||
70 | s11 = ''''; | ||
71 | |||
72 | s12 = '' ''; | ||
73 | |||
74 | s13 = '' | ||
75 | start on network-interfaces | ||
76 | |||
77 | start script | ||
78 | |||
79 | rm -f /var/run/opengl-driver | ||
80 | ${if true | ||
81 | then "ln -sf 123 /var/run/opengl-driver" | ||
82 | else if true | ||
83 | then "ln -sf 456 /var/run/opengl-driver" | ||
84 | else "" | ||
85 | } | ||
86 | |||
87 | rm -f /var/log/slim.log | ||
88 | |||
89 | end script | ||
90 | |||
91 | env SLIM_CFGFILE=${"abc"} | ||
92 | env SLIM_THEMESDIR=${"def"} | ||
93 | env FONTCONFIG_FILE=/etc/fonts/fonts.conf # !!! cleanup | ||
94 | env XKB_BINDIR=${"foo"}/bin # Needed for the Xkb extension. | ||
95 | env LD_LIBRARY_PATH=${"libX11"}/lib:${"libXext"}/lib:/usr/lib/ # related to xorg-sys-opengl - needed to load libglx for (AI)GLX support (for compiz) | ||
96 | |||
97 | ${if true | ||
98 | then "env XORG_DRI_DRIVER_PATH=${"nvidiaDrivers"}/X11R6/lib/modules/drivers/" | ||
99 | else if true | ||
100 | then "env XORG_DRI_DRIVER_PATH=${"mesa"}/lib/modules/dri" | ||
101 | else "" | ||
102 | } | ||
103 | |||
104 | exec ${"slim"}/bin/slim | ||
105 | ''; | ||
106 | |||
107 | s14 = '' | ||
108 | Escaping of ' followed by ': ''' | ||
109 | Escaping of $ followed by {: ''${ | ||
110 | And finally to interpret \n etc. as in a string: ''\n, ''\r, ''\t. | ||
111 | ''; | ||
112 | |||
113 | # Regression test: string interpolation in '${x}' should work, but didn't. | ||
114 | s15 = let x = "bla"; in '' | ||
115 | foo | ||
116 | '${x}' | ||
117 | bar | ||
118 | ''; | ||
119 | |||
120 | # Regression test: accept $'. | ||
121 | s16 = '' | ||
122 | cut -d $'\t' -f 1 | ||
123 | ''; | ||
124 | |||
125 | # Accept dollars at end of strings | ||
126 | s17 = ''ending dollar $'' + ''$'' + "\n"; | ||
127 | |||
128 | in s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10 + s11 + s12 + s13 + s14 + s15 + s16 + s17 | ||
diff --git a/test/testdata/eval-okay-inherit-attr-pos.exp b/test/testdata/eval-okay-inherit-attr-pos.exp new file mode 100644 index 0000000..e87d037 --- /dev/null +++ b/test/testdata/eval-okay-inherit-attr-pos.exp | |||
@@ -0,0 +1 @@ | |||
[ { column = 17; file = "/pwd/lang/eval-okay-inherit-attr-pos.nix"; line = 4; } { column = 19; file = "/pwd/lang/eval-okay-inherit-attr-pos.nix"; line = 4; } { column = 21; file = "/pwd/lang/eval-okay-inherit-attr-pos.nix"; line = 5; } { column = 23; file = "/pwd/lang/eval-okay-inherit-attr-pos.nix"; line = 5; } ] | |||
diff --git a/test/testdata/eval-okay-inherit-attr-pos.nix b/test/testdata/eval-okay-inherit-attr-pos.nix new file mode 100644 index 0000000..017ab1d --- /dev/null +++ b/test/testdata/eval-okay-inherit-attr-pos.nix | |||
@@ -0,0 +1,12 @@ | |||
1 | let | ||
2 | d = 0; | ||
3 | x = 1; | ||
4 | y = { inherit d x; }; | ||
5 | z = { inherit (y) d x; }; | ||
6 | in | ||
7 | [ | ||
8 | (builtins.unsafeGetAttrPos "d" y) | ||
9 | (builtins.unsafeGetAttrPos "x" y) | ||
10 | (builtins.unsafeGetAttrPos "d" z) | ||
11 | (builtins.unsafeGetAttrPos "x" z) | ||
12 | ] | ||
diff --git a/test/testdata/eval-okay-inherit-from.err.exp b/test/testdata/eval-okay-inherit-from.err.exp new file mode 100644 index 0000000..3227501 --- /dev/null +++ b/test/testdata/eval-okay-inherit-from.err.exp | |||
@@ -0,0 +1 @@ | |||
trace: used | |||
diff --git a/test/testdata/eval-okay-inherit-from.exp b/test/testdata/eval-okay-inherit-from.exp new file mode 100644 index 0000000..024daff --- /dev/null +++ b/test/testdata/eval-okay-inherit-from.exp | |||
@@ -0,0 +1 @@ | |||
[ 1 2 { __overrides = { y = { d = [ ]; }; }; c = [ ]; d = 4; x = { c = [ ]; }; y = «repeated»; } { inner = { c = 3; d = 4; }; } ] | |||
diff --git a/test/testdata/eval-okay-inherit-from.nix b/test/testdata/eval-okay-inherit-from.nix new file mode 100644 index 0000000..b72a1c6 --- /dev/null +++ b/test/testdata/eval-okay-inherit-from.nix | |||
@@ -0,0 +1,16 @@ | |||
1 | let | ||
2 | inherit (builtins.trace "used" { a = 1; b = 2; }) a b; | ||
3 | x.c = 3; | ||
4 | y.d = 4; | ||
5 | |||
6 | merged = { | ||
7 | inner = { | ||
8 | inherit (y) d; | ||
9 | }; | ||
10 | |||
11 | inner = { | ||
12 | inherit (x) c; | ||
13 | }; | ||
14 | }; | ||
15 | in | ||
16 | [ a b rec { x.c = []; inherit (x) c; inherit (y) d; __overrides.y.d = []; } merged ] | ||
diff --git a/test/testdata/eval-okay-intersectAttrs.exp b/test/testdata/eval-okay-intersectAttrs.exp new file mode 100644 index 0000000..50445bc --- /dev/null +++ b/test/testdata/eval-okay-intersectAttrs.exp | |||
@@ -0,0 +1 @@ | |||
[ { } { a = 1; } { a = 1; } { a = "a"; } { m = 1; } { m = "m"; } { n = 1; } { n = "n"; } { n = 1; p = 2; } { n = "n"; p = "p"; } { n = 1; p = 2; } { n = "n"; p = "p"; } { a = "a"; b = "b"; c = "c"; d = "d"; e = "e"; f = "f"; g = "g"; h = "h"; i = "i"; j = "j"; k = "k"; l = "l"; m = "m"; n = "n"; o = "o"; p = "p"; q = "q"; r = "r"; s = "s"; t = "t"; u = "u"; v = "v"; w = "w"; x = "x"; y = "y"; z = "z"; } true ] | |||
diff --git a/test/testdata/eval-okay-intersectAttrs.nix b/test/testdata/eval-okay-intersectAttrs.nix new file mode 100644 index 0000000..39d4993 --- /dev/null +++ b/test/testdata/eval-okay-intersectAttrs.nix | |||
@@ -0,0 +1,50 @@ | |||
1 | let | ||
2 | alphabet = | ||
3 | { a = "a"; | ||
4 | b = "b"; | ||
5 | c = "c"; | ||
6 | d = "d"; | ||
7 | e = "e"; | ||
8 | f = "f"; | ||
9 | g = "g"; | ||
10 | h = "h"; | ||
11 | i = "i"; | ||
12 | j = "j"; | ||
13 | k = "k"; | ||
14 | l = "l"; | ||
15 | m = "m"; | ||
16 | n = "n"; | ||
17 | o = "o"; | ||
18 | p = "p"; | ||
19 | q = "q"; | ||
20 | r = "r"; | ||
21 | s = "s"; | ||
22 | t = "t"; | ||
23 | u = "u"; | ||
24 | v = "v"; | ||
25 | w = "w"; | ||
26 | x = "x"; | ||
27 | y = "y"; | ||
28 | z = "z"; | ||
29 | }; | ||
30 | foo = { | ||
31 | inherit (alphabet) f o b a r z q u x; | ||
32 | aa = throw "aa"; | ||
33 | }; | ||
34 | alphabetFail = builtins.mapAttrs throw alphabet; | ||
35 | in | ||
36 | [ (builtins.intersectAttrs { a = abort "l1"; } { b = abort "r1"; }) | ||
37 | (builtins.intersectAttrs { a = abort "l2"; } { a = 1; }) | ||
38 | (builtins.intersectAttrs alphabetFail { a = 1; }) | ||
39 | (builtins.intersectAttrs { a = abort "laa"; } alphabet) | ||
40 | (builtins.intersectAttrs alphabetFail { m = 1; }) | ||
41 | (builtins.intersectAttrs { m = abort "lam"; } alphabet) | ||
42 | (builtins.intersectAttrs alphabetFail { n = 1; }) | ||
43 | (builtins.intersectAttrs { n = abort "lan"; } alphabet) | ||
44 | (builtins.intersectAttrs alphabetFail { n = 1; p = 2; }) | ||
45 | (builtins.intersectAttrs { n = abort "lan2"; p = abort "lap"; } alphabet) | ||
46 | (builtins.intersectAttrs alphabetFail { n = 1; p = 2; }) | ||
47 | (builtins.intersectAttrs { n = abort "lan2"; p = abort "lap"; } alphabet) | ||
48 | (builtins.intersectAttrs alphabetFail alphabet) | ||
49 | (builtins.intersectAttrs alphabet foo == builtins.intersectAttrs foo alphabet) | ||
50 | ] | ||
diff --git a/test/testdata/eval-okay-let.exp b/test/testdata/eval-okay-let.exp new file mode 100644 index 0000000..14e24d4 --- /dev/null +++ b/test/testdata/eval-okay-let.exp | |||
@@ -0,0 +1 @@ | |||
"foobar" | |||
diff --git a/test/testdata/eval-okay-let.nix b/test/testdata/eval-okay-let.nix new file mode 100644 index 0000000..fe118c5 --- /dev/null +++ b/test/testdata/eval-okay-let.nix | |||
@@ -0,0 +1,5 @@ | |||
1 | let { | ||
2 | x = "foo"; | ||
3 | y = "bar"; | ||
4 | body = x + y; | ||
5 | } | ||
diff --git a/test/testdata/eval-okay-list.exp b/test/testdata/eval-okay-list.exp new file mode 100644 index 0000000..f784f26 --- /dev/null +++ b/test/testdata/eval-okay-list.exp | |||
@@ -0,0 +1 @@ | |||
"foobarblatest" | |||
diff --git a/test/testdata/eval-okay-list.nix b/test/testdata/eval-okay-list.nix new file mode 100644 index 0000000..d433bcf --- /dev/null +++ b/test/testdata/eval-okay-list.nix | |||
@@ -0,0 +1,7 @@ | |||
1 | with import ./lib.nix; | ||
2 | |||
3 | let { | ||
4 | |||
5 | body = concat ["foo" "bar" "bla" "test"]; | ||
6 | |||
7 | } \ No newline at end of file | ||
diff --git a/test/testdata/eval-okay-listtoattrs.exp b/test/testdata/eval-okay-listtoattrs.exp new file mode 100644 index 0000000..74abef7 --- /dev/null +++ b/test/testdata/eval-okay-listtoattrs.exp | |||
@@ -0,0 +1 @@ | |||
"AAbar" | |||
diff --git a/test/testdata/eval-okay-listtoattrs.nix b/test/testdata/eval-okay-listtoattrs.nix new file mode 100644 index 0000000..4186e02 --- /dev/null +++ b/test/testdata/eval-okay-listtoattrs.nix | |||
@@ -0,0 +1,11 @@ | |||
1 | # this test shows how to use listToAttrs and that evaluation is still lazy (throw isn't called) | ||
2 | with import ./lib.nix; | ||
3 | |||
4 | let | ||
5 | asi = name: value : { inherit name value; }; | ||
6 | list = [ ( asi "a" "A" ) ( asi "b" "B" ) ]; | ||
7 | a = builtins.listToAttrs list; | ||
8 | b = builtins.listToAttrs ( list ++ list ); | ||
9 | r = builtins.listToAttrs [ (asi "result" [ a b ]) ( asi "throw" (throw "this should not be thrown")) ]; | ||
10 | x = builtins.listToAttrs [ (asi "foo" "bar") (asi "foo" "bla") ]; | ||
11 | in concat (map (x: x.a) r.result) + x.foo | ||
diff --git a/test/testdata/eval-okay-logic.exp b/test/testdata/eval-okay-logic.exp new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/test/testdata/eval-okay-logic.exp | |||
@@ -0,0 +1 @@ | |||
1 | |||
diff --git a/test/testdata/eval-okay-logic.nix b/test/testdata/eval-okay-logic.nix new file mode 100644 index 0000000..fbb1279 --- /dev/null +++ b/test/testdata/eval-okay-logic.nix | |||
@@ -0,0 +1 @@ | |||
assert !false && (true || false) -> true; 1 | |||
diff --git a/test/testdata/eval-okay-map.exp b/test/testdata/eval-okay-map.exp new file mode 100644 index 0000000..dbb64f7 --- /dev/null +++ b/test/testdata/eval-okay-map.exp | |||
@@ -0,0 +1 @@ | |||
"foobarblabarxyzzybar" | |||
diff --git a/test/testdata/eval-okay-map.nix b/test/testdata/eval-okay-map.nix new file mode 100644 index 0000000..a76c1d8 --- /dev/null +++ b/test/testdata/eval-okay-map.nix | |||
@@ -0,0 +1,3 @@ | |||
1 | with import ./lib.nix; | ||
2 | |||
3 | concat (map (x: x + "bar") [ "foo" "bla" "xyzzy" ]) \ No newline at end of file | ||
diff --git a/test/testdata/eval-okay-mapattrs.exp b/test/testdata/eval-okay-mapattrs.exp new file mode 100644 index 0000000..3f113f1 --- /dev/null +++ b/test/testdata/eval-okay-mapattrs.exp | |||
@@ -0,0 +1 @@ | |||
{ x = "x-foo"; y = "y-bar"; } | |||
diff --git a/test/testdata/eval-okay-mapattrs.nix b/test/testdata/eval-okay-mapattrs.nix new file mode 100644 index 0000000..f075b62 --- /dev/null +++ b/test/testdata/eval-okay-mapattrs.nix | |||
@@ -0,0 +1,3 @@ | |||
1 | with import ./lib.nix; | ||
2 | |||
3 | builtins.mapAttrs (name: value: name + "-" + value) { x = "foo"; y = "bar"; } | ||
diff --git a/test/testdata/eval-okay-merge-dynamic-attrs.exp b/test/testdata/eval-okay-merge-dynamic-attrs.exp new file mode 100644 index 0000000..157d677 --- /dev/null +++ b/test/testdata/eval-okay-merge-dynamic-attrs.exp | |||
@@ -0,0 +1 @@ | |||
{ set1 = { a = 1; b = 2; }; set2 = { a = 1; b = 2; }; set3 = { a = 1; b = 2; }; set4 = { a = 1; b = 2; }; } | |||
diff --git a/test/testdata/eval-okay-merge-dynamic-attrs.nix b/test/testdata/eval-okay-merge-dynamic-attrs.nix new file mode 100644 index 0000000..f459a55 --- /dev/null +++ b/test/testdata/eval-okay-merge-dynamic-attrs.nix | |||
@@ -0,0 +1,13 @@ | |||
1 | { | ||
2 | set1 = { a = 1; }; | ||
3 | set1 = { "${"b" + ""}" = 2; }; | ||
4 | |||
5 | set2 = { "${"b" + ""}" = 2; }; | ||
6 | set2 = { a = 1; }; | ||
7 | |||
8 | set3.a = 1; | ||
9 | set3."${"b" + ""}" = 2; | ||
10 | |||
11 | set4."${"b" + ""}" = 2; | ||
12 | set4.a = 1; | ||
13 | } | ||
diff --git a/test/testdata/eval-okay-nested-with.exp b/test/testdata/eval-okay-nested-with.exp new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/test/testdata/eval-okay-nested-with.exp | |||
@@ -0,0 +1 @@ | |||
2 | |||
diff --git a/test/testdata/eval-okay-nested-with.nix b/test/testdata/eval-okay-nested-with.nix new file mode 100644 index 0000000..ba9d79a --- /dev/null +++ b/test/testdata/eval-okay-nested-with.nix | |||
@@ -0,0 +1,3 @@ | |||
1 | with { x = 1; }; | ||
2 | with { x = 2; }; | ||
3 | x | ||
diff --git a/test/testdata/eval-okay-new-let.exp b/test/testdata/eval-okay-new-let.exp new file mode 100644 index 0000000..f98b388 --- /dev/null +++ b/test/testdata/eval-okay-new-let.exp | |||
@@ -0,0 +1 @@ | |||
"xyzzyfoobar" | |||
diff --git a/test/testdata/eval-okay-new-let.nix b/test/testdata/eval-okay-new-let.nix new file mode 100644 index 0000000..7381231 --- /dev/null +++ b/test/testdata/eval-okay-new-let.nix | |||
@@ -0,0 +1,14 @@ | |||
1 | let | ||
2 | |||
3 | f = z: | ||
4 | |||
5 | let | ||
6 | x = "foo"; | ||
7 | y = "bar"; | ||
8 | body = 1; # compat test | ||
9 | in | ||
10 | z + x + y; | ||
11 | |||
12 | arg = "xyzzy"; | ||
13 | |||
14 | in f arg | ||
diff --git a/test/testdata/eval-okay-null-dynamic-attrs.exp b/test/testdata/eval-okay-null-dynamic-attrs.exp new file mode 100644 index 0000000..27ba77d --- /dev/null +++ b/test/testdata/eval-okay-null-dynamic-attrs.exp | |||
@@ -0,0 +1 @@ | |||
true | |||
diff --git a/test/testdata/eval-okay-null-dynamic-attrs.nix b/test/testdata/eval-okay-null-dynamic-attrs.nix new file mode 100644 index 0000000..b060c0b --- /dev/null +++ b/test/testdata/eval-okay-null-dynamic-attrs.nix | |||
@@ -0,0 +1 @@ | |||
{ ${null} = true; } == {} | |||
diff --git a/test/testdata/eval-okay-overrides.exp b/test/testdata/eval-okay-overrides.exp new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/test/testdata/eval-okay-overrides.exp | |||
@@ -0,0 +1 @@ | |||
2 | |||
diff --git a/test/testdata/eval-okay-overrides.nix b/test/testdata/eval-okay-overrides.nix new file mode 100644 index 0000000..719bdc9 --- /dev/null +++ b/test/testdata/eval-okay-overrides.nix | |||
@@ -0,0 +1,9 @@ | |||
1 | let | ||
2 | |||
3 | overrides = { a = 2; b = 3; }; | ||
4 | |||
5 | in (rec { | ||
6 | __overrides = overrides; | ||
7 | x = a; | ||
8 | a = 1; | ||
9 | }).x | ||
diff --git a/test/testdata/eval-okay-parse-flake-ref.exp b/test/testdata/eval-okay-parse-flake-ref.exp new file mode 100644 index 0000000..fc17ba0 --- /dev/null +++ b/test/testdata/eval-okay-parse-flake-ref.exp | |||
@@ -0,0 +1 @@ | |||
{ dir = "lib"; owner = "NixOS"; ref = "23.05"; repo = "nixpkgs"; type = "github"; } | |||
diff --git a/test/testdata/eval-okay-parse-flake-ref.nix b/test/testdata/eval-okay-parse-flake-ref.nix new file mode 100644 index 0000000..db4ed27 --- /dev/null +++ b/test/testdata/eval-okay-parse-flake-ref.nix | |||
@@ -0,0 +1 @@ | |||
builtins.parseFlakeRef "github:NixOS/nixpkgs/23.05?dir=lib" | |||
diff --git a/test/testdata/eval-okay-partition.exp b/test/testdata/eval-okay-partition.exp new file mode 100644 index 0000000..cd8b8b0 --- /dev/null +++ b/test/testdata/eval-okay-partition.exp | |||
@@ -0,0 +1 @@ | |||
{ right = [ 0 2 4 6 8 10 100 102 104 106 108 110 ]; wrong = [ 1 3 5 7 9 101 103 105 107 109 ]; } | |||
diff --git a/test/testdata/eval-okay-partition.nix b/test/testdata/eval-okay-partition.nix new file mode 100644 index 0000000..846d2ce --- /dev/null +++ b/test/testdata/eval-okay-partition.nix | |||
@@ -0,0 +1,5 @@ | |||
1 | with import ./lib.nix; | ||
2 | |||
3 | builtins.partition | ||
4 | (x: x / 2 * 2 == x) | ||
5 | (builtins.concatLists [ (range 0 10) (range 100 110) ]) | ||
diff --git a/test/testdata/eval-okay-path-string-interpolation.exp b/test/testdata/eval-okay-path-string-interpolation.exp new file mode 100644 index 0000000..5b8ea02 --- /dev/null +++ b/test/testdata/eval-okay-path-string-interpolation.exp | |||
@@ -0,0 +1 @@ | |||
{ absolute = /foo; expr = /pwd/lang/foo/bar; home = /fake-home/foo; notfirst = /pwd/lang/bar/foo; simple = /pwd/lang/foo; slashes = /foo/bar; surrounded = /pwd/lang/a-foo-b; } | |||
diff --git a/test/testdata/eval-okay-path-string-interpolation.nix b/test/testdata/eval-okay-path-string-interpolation.nix new file mode 100644 index 0000000..497d7c1 --- /dev/null +++ b/test/testdata/eval-okay-path-string-interpolation.nix | |||
@@ -0,0 +1,12 @@ | |||
1 | let | ||
2 | foo = "foo"; | ||
3 | in | ||
4 | { | ||
5 | simple = ./${foo}; | ||
6 | surrounded = ./a-${foo}-b; | ||
7 | absolute = /${foo}; | ||
8 | expr = ./${foo + "/bar"}; | ||
9 | home = ~/${foo}; | ||
10 | notfirst = ./bar/${foo}; | ||
11 | slashes = /${foo}/${"bar"}; | ||
12 | } | ||
diff --git a/test/testdata/eval-okay-path.exp b/test/testdata/eval-okay-path.exp new file mode 100644 index 0000000..635e224 --- /dev/null +++ b/test/testdata/eval-okay-path.exp | |||
@@ -0,0 +1 @@ | |||
[ "/nix/store/ya937r4ydw0l6kayq8jkyqaips9c75jm-output" "/nix/store/m7y372g6jb0g4hh1dzmj847rd356fhnz-output" ] | |||
diff --git a/test/testdata/eval-okay-path.nix b/test/testdata/eval-okay-path.nix new file mode 100644 index 0000000..599b335 --- /dev/null +++ b/test/testdata/eval-okay-path.nix | |||
@@ -0,0 +1,15 @@ | |||
1 | [ | ||
2 | (builtins.path | ||
3 | { path = ./.; | ||
4 | filter = path: _: baseNameOf path == "data"; | ||
5 | recursive = true; | ||
6 | sha256 = "1yhm3gwvg5a41yylymgblsclk95fs6jy72w0wv925mmidlhcq4sw"; | ||
7 | name = "output"; | ||
8 | }) | ||
9 | (builtins.path | ||
10 | { path = ./data; | ||
11 | recursive = false; | ||
12 | sha256 = "0k4lwj58f2w5yh92ilrwy9917pycipbrdrr13vbb3yd02j09vfxm"; | ||
13 | name = "output"; | ||
14 | }) | ||
15 | ] | ||
diff --git a/test/testdata/eval-okay-pathexists.exp b/test/testdata/eval-okay-pathexists.exp new file mode 100644 index 0000000..27ba77d --- /dev/null +++ b/test/testdata/eval-okay-pathexists.exp | |||
@@ -0,0 +1 @@ | |||
true | |||
diff --git a/test/testdata/eval-okay-pathexists.nix b/test/testdata/eval-okay-pathexists.nix new file mode 100644 index 0000000..022b22f --- /dev/null +++ b/test/testdata/eval-okay-pathexists.nix | |||
@@ -0,0 +1,34 @@ | |||
1 | builtins.pathExists (./lib.nix) | ||
2 | && builtins.pathExists (builtins.toPath ./lib.nix) | ||
3 | && builtins.pathExists (builtins.toString ./lib.nix) | ||
4 | && !builtins.pathExists (builtins.toString ./lib.nix + "/") | ||
5 | && !builtins.pathExists (builtins.toString ./lib.nix + "/.") | ||
6 | # FIXME | ||
7 | # && !builtins.pathExists (builtins.toString ./lib.nix + "/..") | ||
8 | # && !builtins.pathExists (builtins.toString ./lib.nix + "/a/..") | ||
9 | # && !builtins.pathExists (builtins.toString ./lib.nix + "/../lib.nix") | ||
10 | && !builtins.pathExists (builtins.toString ./lib.nix + "/./") | ||
11 | && !builtins.pathExists (builtins.toString ./lib.nix + "/./.") | ||
12 | && builtins.pathExists (builtins.toString ./.. + "/lang/lib.nix") | ||
13 | && !builtins.pathExists (builtins.toString ./.. + "lang/lib.nix") | ||
14 | && builtins.pathExists (builtins.toString ./. + "/../lang/lib.nix") | ||
15 | && builtins.pathExists (builtins.toString ./. + "/../lang/./lib.nix") | ||
16 | && builtins.pathExists (builtins.toString ./.) | ||
17 | && builtins.pathExists (builtins.toString ./. + "/") | ||
18 | && builtins.pathExists (builtins.toString ./. + "/../lang") | ||
19 | && builtins.pathExists (builtins.toString ./. + "/../lang/") | ||
20 | && builtins.pathExists (builtins.toString ./. + "/../lang/.") | ||
21 | && builtins.pathExists (builtins.toString ./. + "/../lang/./") | ||
22 | && builtins.pathExists (builtins.toString ./. + "/../lang//./") | ||
23 | && builtins.pathExists (builtins.toString ./. + "/../lang/..") | ||
24 | && builtins.pathExists (builtins.toString ./. + "/../lang/../") | ||
25 | && builtins.pathExists (builtins.toString ./. + "/../lang/..//") | ||
26 | && builtins.pathExists (builtins.toPath (builtins.toString ./lib.nix)) | ||
27 | && !builtins.pathExists (builtins.toPath (builtins.toString ./bla.nix)) | ||
28 | && builtins.pathExists (builtins.toPath { __toString = x: builtins.toString ./lib.nix; }) | ||
29 | && builtins.pathExists (builtins.toPath { outPath = builtins.toString ./lib.nix; }) | ||
30 | && builtins.pathExists ./lib.nix | ||
31 | && !builtins.pathExists ./bla.nix | ||
32 | && builtins.pathExists ./symlink-resolution/foo/overlays/overlay.nix | ||
33 | && builtins.pathExists ./symlink-resolution/broken | ||
34 | && builtins.pathExists (builtins.toString ./symlink-resolution/foo/overlays + "/.") | ||
diff --git a/test/testdata/eval-okay-patterns.exp b/test/testdata/eval-okay-patterns.exp new file mode 100644 index 0000000..a430401 --- /dev/null +++ b/test/testdata/eval-okay-patterns.exp | |||
@@ -0,0 +1 @@ | |||
"abcxyzDDDDEFijk" | |||
diff --git a/test/testdata/eval-okay-patterns.nix b/test/testdata/eval-okay-patterns.nix new file mode 100644 index 0000000..96fd25a --- /dev/null +++ b/test/testdata/eval-okay-patterns.nix | |||
@@ -0,0 +1,16 @@ | |||
1 | let | ||
2 | |||
3 | f = args@{x, y, z}: x + args.y + z; | ||
4 | |||
5 | g = {x, y, z}@args: f args; | ||
6 | |||
7 | h = {x ? "d", y ? x, z ? args.x}@args: x + y + z; | ||
8 | |||
9 | j = {x, y, z, ...}: x + y + z; | ||
10 | |||
11 | in | ||
12 | f {x = "a"; y = "b"; z = "c";} + | ||
13 | g {x = "x"; y = "y"; z = "z";} + | ||
14 | h {x = "D";} + | ||
15 | h {x = "D"; y = "E"; z = "F";} + | ||
16 | j {x = "i"; y = "j"; z = "k"; bla = "bla"; foo = "bar";} | ||
diff --git a/test/testdata/eval-okay-print.err.exp b/test/testdata/eval-okay-print.err.exp new file mode 100644 index 0000000..80aa17c --- /dev/null +++ b/test/testdata/eval-okay-print.err.exp | |||
@@ -0,0 +1 @@ | |||
trace: [ «thunk» ] | |||
diff --git a/test/testdata/eval-okay-print.exp b/test/testdata/eval-okay-print.exp new file mode 100644 index 0000000..0d960fb --- /dev/null +++ b/test/testdata/eval-okay-print.exp | |||
@@ -0,0 +1 @@ | |||
[ null <PRIMOP> <PRIMOP-APP> <LAMBDA> [ [ «repeated» ] ] ] | |||
diff --git a/test/testdata/eval-okay-print.nix b/test/testdata/eval-okay-print.nix new file mode 100644 index 0000000..d36ba4d --- /dev/null +++ b/test/testdata/eval-okay-print.nix | |||
@@ -0,0 +1 @@ | |||
with builtins; trace [(1+1)] [ null toString (deepSeq "x") (a: a) (let x=[x]; in x) ] | |||
diff --git a/test/testdata/eval-okay-readDir.exp b/test/testdata/eval-okay-readDir.exp new file mode 100644 index 0000000..6413f6d --- /dev/null +++ b/test/testdata/eval-okay-readDir.exp | |||
@@ -0,0 +1 @@ | |||
{ bar = "regular"; foo = "directory"; ldir = "symlink"; linked = "symlink"; } | |||
diff --git a/test/testdata/eval-okay-readDir.nix b/test/testdata/eval-okay-readDir.nix new file mode 100644 index 0000000..a7ec929 --- /dev/null +++ b/test/testdata/eval-okay-readDir.nix | |||
@@ -0,0 +1 @@ | |||
builtins.readDir ./readDir | |||
diff --git a/test/testdata/eval-okay-readFileType.exp b/test/testdata/eval-okay-readFileType.exp new file mode 100644 index 0000000..6413f6d --- /dev/null +++ b/test/testdata/eval-okay-readFileType.exp | |||
@@ -0,0 +1 @@ | |||
{ bar = "regular"; foo = "directory"; ldir = "symlink"; linked = "symlink"; } | |||
diff --git a/test/testdata/eval-okay-readFileType.nix b/test/testdata/eval-okay-readFileType.nix new file mode 100644 index 0000000..174fb6c --- /dev/null +++ b/test/testdata/eval-okay-readFileType.nix | |||
@@ -0,0 +1,6 @@ | |||
1 | { | ||
2 | bar = builtins.readFileType ./readDir/bar; | ||
3 | foo = builtins.readFileType ./readDir/foo; | ||
4 | linked = builtins.readFileType ./readDir/linked; | ||
5 | ldir = builtins.readFileType ./readDir/ldir; | ||
6 | } | ||
diff --git a/test/testdata/eval-okay-readfile.exp b/test/testdata/eval-okay-readfile.exp new file mode 100644 index 0000000..a2c87d0 --- /dev/null +++ b/test/testdata/eval-okay-readfile.exp | |||
@@ -0,0 +1 @@ | |||
"builtins.readFile ./eval-okay-readfile.nix\n" | |||
diff --git a/test/testdata/eval-okay-readfile.nix b/test/testdata/eval-okay-readfile.nix new file mode 100644 index 0000000..82f7cb1 --- /dev/null +++ b/test/testdata/eval-okay-readfile.nix | |||
@@ -0,0 +1 @@ | |||
builtins.readFile ./eval-okay-readfile.nix | |||
diff --git a/test/testdata/eval-okay-redefine-builtin.exp b/test/testdata/eval-okay-redefine-builtin.exp new file mode 100644 index 0000000..c508d53 --- /dev/null +++ b/test/testdata/eval-okay-redefine-builtin.exp | |||
@@ -0,0 +1 @@ | |||
false | |||
diff --git a/test/testdata/eval-okay-redefine-builtin.nix b/test/testdata/eval-okay-redefine-builtin.nix new file mode 100644 index 0000000..df9fc3f --- /dev/null +++ b/test/testdata/eval-okay-redefine-builtin.nix | |||
@@ -0,0 +1,3 @@ | |||
1 | let | ||
2 | throw = abort "Error!"; | ||
3 | in (builtins.tryEval <foobaz>).success | ||
diff --git a/test/testdata/eval-okay-regex-match.exp b/test/testdata/eval-okay-regex-match.exp new file mode 100644 index 0000000..27ba77d --- /dev/null +++ b/test/testdata/eval-okay-regex-match.exp | |||
@@ -0,0 +1 @@ | |||
true | |||
diff --git a/test/testdata/eval-okay-regex-match.nix b/test/testdata/eval-okay-regex-match.nix new file mode 100644 index 0000000..273e259 --- /dev/null +++ b/test/testdata/eval-okay-regex-match.nix | |||
@@ -0,0 +1,29 @@ | |||
1 | with builtins; | ||
2 | |||
3 | let | ||
4 | |||
5 | matches = pat: s: match pat s != null; | ||
6 | |||
7 | splitFN = match "((.*)/)?([^/]*)\\.(nix|cc)"; | ||
8 | |||
9 | in | ||
10 | |||
11 | assert matches "foobar" "foobar"; | ||
12 | assert matches "fo*" "f"; | ||
13 | assert !matches "fo+" "f"; | ||
14 | assert matches "fo*" "fo"; | ||
15 | assert matches "fo*" "foo"; | ||
16 | assert matches "fo+" "foo"; | ||
17 | assert matches "fo{1,2}" "foo"; | ||
18 | assert !matches "fo{1,2}" "fooo"; | ||
19 | assert !matches "fo*" "foobar"; | ||
20 | assert matches "[[:space:]]+([^[:space:]]+)[[:space:]]+" " foo "; | ||
21 | assert !matches "[[:space:]]+([[:upper:]]+)[[:space:]]+" " foo "; | ||
22 | |||
23 | assert match "(.*)\\.nix" "foobar.nix" == [ "foobar" ]; | ||
24 | assert match "[[:space:]]+([[:upper:]]+)[[:space:]]+" " FOO " == [ "FOO" ]; | ||
25 | |||
26 | assert splitFN "/path/to/foobar.nix" == [ "/path/to/" "/path/to" "foobar" "nix" ]; | ||
27 | assert splitFN "foobar.cc" == [ null null "foobar" "cc" ]; | ||
28 | |||
29 | true | ||
diff --git a/test/testdata/eval-okay-regex-split.exp b/test/testdata/eval-okay-regex-split.exp new file mode 100644 index 0000000..27ba77d --- /dev/null +++ b/test/testdata/eval-okay-regex-split.exp | |||
@@ -0,0 +1 @@ | |||
true | |||
diff --git a/test/testdata/eval-okay-regex-split.nix b/test/testdata/eval-okay-regex-split.nix new file mode 100644 index 0000000..0073e05 --- /dev/null +++ b/test/testdata/eval-okay-regex-split.nix | |||
@@ -0,0 +1,48 @@ | |||
1 | with builtins; | ||
2 | |||
3 | # Non capturing regex returns empty lists | ||
4 | assert split "foobar" "foobar" == ["" [] ""]; | ||
5 | assert split "fo*" "f" == ["" [] ""]; | ||
6 | assert split "fo+" "f" == ["f"]; | ||
7 | assert split "fo*" "fo" == ["" [] ""]; | ||
8 | assert split "fo*" "foo" == ["" [] ""]; | ||
9 | assert split "fo+" "foo" == ["" [] ""]; | ||
10 | assert split "fo{1,2}" "foo" == ["" [] ""]; | ||
11 | assert split "fo{1,2}" "fooo" == ["" [] "o"]; | ||
12 | assert split "fo*" "foobar" == ["" [] "bar"]; | ||
13 | |||
14 | # Capturing regex returns a list of sub-matches | ||
15 | assert split "(fo*)" "f" == ["" ["f"] ""]; | ||
16 | assert split "(fo+)" "f" == ["f"]; | ||
17 | assert split "(fo*)" "fo" == ["" ["fo"] ""]; | ||
18 | assert split "(f)(o*)" "f" == ["" ["f" ""] ""]; | ||
19 | assert split "(f)(o*)" "foo" == ["" ["f" "oo"] ""]; | ||
20 | assert split "(fo+)" "foo" == ["" ["foo"] ""]; | ||
21 | assert split "(fo{1,2})" "foo" == ["" ["foo"] ""]; | ||
22 | assert split "(fo{1,2})" "fooo" == ["" ["foo"] "o"]; | ||
23 | assert split "(fo*)" "foobar" == ["" ["foo"] "bar"]; | ||
24 | |||
25 | # Matches are greedy. | ||
26 | assert split "(o+)" "oooofoooo" == ["" ["oooo"] "f" ["oooo"] ""]; | ||
27 | |||
28 | # Matches multiple times. | ||
29 | assert split "(b)" "foobarbaz" == ["foo" ["b"] "ar" ["b"] "az"]; | ||
30 | |||
31 | # Split large strings containing newlines. null are inserted when a | ||
32 | # pattern within the current did not match anything. | ||
33 | assert split "[[:space:]]+|([',.!?])" '' | ||
34 | Nix Rocks! | ||
35 | That's why I use it. | ||
36 | '' == [ | ||
37 | "Nix" [ null ] "Rocks" ["!"] "" [ null ] | ||
38 | "That" ["'"] "s" [ null ] "why" [ null ] "I" [ null ] "use" [ null ] "it" ["."] "" [ null ] | ||
39 | "" | ||
40 | ]; | ||
41 | |||
42 | # Documentation examples | ||
43 | assert split "(a)b" "abc" == [ "" [ "a" ] "c" ]; | ||
44 | assert split "([ac])" "abc" == [ "" [ "a" ] "b" [ "c" ] "" ]; | ||
45 | assert split "(a)|(c)" "abc" == [ "" [ "a" null ] "b" [ null "c" ] "" ]; | ||
46 | assert split "([[:upper:]]+)" " FOO " == [ " " [ "FOO" ] " " ]; | ||
47 | |||
48 | true | ||
diff --git a/test/testdata/eval-okay-regression-20220122.exp b/test/testdata/eval-okay-regression-20220122.exp new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/test/testdata/eval-okay-regression-20220122.exp | |||
@@ -0,0 +1 @@ | |||
3 | |||
diff --git a/test/testdata/eval-okay-regression-20220122.nix b/test/testdata/eval-okay-regression-20220122.nix new file mode 100644 index 0000000..694e9a1 --- /dev/null +++ b/test/testdata/eval-okay-regression-20220122.nix | |||
@@ -0,0 +1 @@ | |||
((_: _) 1) + ((__: __) 2) | |||
diff --git a/test/testdata/eval-okay-regression-20220125.exp b/test/testdata/eval-okay-regression-20220125.exp new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/test/testdata/eval-okay-regression-20220125.exp | |||
@@ -0,0 +1 @@ | |||
3 | |||
diff --git a/test/testdata/eval-okay-regression-20220125.nix b/test/testdata/eval-okay-regression-20220125.nix new file mode 100644 index 0000000..4855023 --- /dev/null +++ b/test/testdata/eval-okay-regression-20220125.nix | |||
@@ -0,0 +1,2 @@ | |||
1 | ((__curPosFoo: __curPosFoo) 1) + ((__curPosBar: __curPosBar) 2) | ||
2 | |||
diff --git a/test/testdata/eval-okay-remove.exp b/test/testdata/eval-okay-remove.exp new file mode 100644 index 0000000..8d38505 --- /dev/null +++ b/test/testdata/eval-okay-remove.exp | |||
@@ -0,0 +1 @@ | |||
456 | |||
diff --git a/test/testdata/eval-okay-remove.nix b/test/testdata/eval-okay-remove.nix new file mode 100644 index 0000000..4ad5ba8 --- /dev/null +++ b/test/testdata/eval-okay-remove.nix | |||
@@ -0,0 +1,5 @@ | |||
1 | let { | ||
2 | attrs = {x = 123; y = 456;}; | ||
3 | |||
4 | body = (removeAttrs attrs ["x"]).y; | ||
5 | } \ No newline at end of file | ||
diff --git a/test/testdata/eval-okay-repeated-empty-attrs.exp b/test/testdata/eval-okay-repeated-empty-attrs.exp new file mode 100644 index 0000000..d21e6db --- /dev/null +++ b/test/testdata/eval-okay-repeated-empty-attrs.exp | |||
@@ -0,0 +1 @@ | |||
[ { } { } ] | |||
diff --git a/test/testdata/eval-okay-repeated-empty-attrs.nix b/test/testdata/eval-okay-repeated-empty-attrs.nix new file mode 100644 index 0000000..030a3b8 --- /dev/null +++ b/test/testdata/eval-okay-repeated-empty-attrs.nix | |||
@@ -0,0 +1,2 @@ | |||
1 | # Tests that empty attribute sets are not printed as `«repeated»`. | ||
2 | [ {} {} ] | ||
diff --git a/test/testdata/eval-okay-repeated-empty-list.exp b/test/testdata/eval-okay-repeated-empty-list.exp new file mode 100644 index 0000000..701fc7e --- /dev/null +++ b/test/testdata/eval-okay-repeated-empty-list.exp | |||
@@ -0,0 +1 @@ | |||
[ [ ] [ ] ] | |||
diff --git a/test/testdata/eval-okay-repeated-empty-list.nix b/test/testdata/eval-okay-repeated-empty-list.nix new file mode 100644 index 0000000..376c51b --- /dev/null +++ b/test/testdata/eval-okay-repeated-empty-list.nix | |||
@@ -0,0 +1 @@ | |||
[ [] [] ] | |||
diff --git a/test/testdata/eval-okay-replacestrings.exp b/test/testdata/eval-okay-replacestrings.exp new file mode 100644 index 0000000..eac67c5 --- /dev/null +++ b/test/testdata/eval-okay-replacestrings.exp | |||
@@ -0,0 +1 @@ | |||
[ "faabar" "fbar" "fubar" "faboor" "fubar" "XaXbXcX" "X" "a_b" "fubar" ] | |||
diff --git a/test/testdata/eval-okay-replacestrings.nix b/test/testdata/eval-okay-replacestrings.nix new file mode 100644 index 0000000..a803e65 --- /dev/null +++ b/test/testdata/eval-okay-replacestrings.nix | |||
@@ -0,0 +1,12 @@ | |||
1 | with builtins; | ||
2 | |||
3 | [ (replaceStrings ["o"] ["a"] "foobar") | ||
4 | (replaceStrings ["o"] [""] "foobar") | ||
5 | (replaceStrings ["oo"] ["u"] "foobar") | ||
6 | (replaceStrings ["oo" "a"] ["a" "oo"] "foobar") | ||
7 | (replaceStrings ["oo" "oo"] ["u" "i"] "foobar") | ||
8 | (replaceStrings [""] ["X"] "abc") | ||
9 | (replaceStrings [""] ["X"] "") | ||
10 | (replaceStrings ["-"] ["_"] "a-b") | ||
11 | (replaceStrings ["oo" "XX"] ["u" (throw "unreachable")] "foobar") | ||
12 | ] | ||
diff --git a/test/testdata/eval-okay-scope-1.exp b/test/testdata/eval-okay-scope-1.exp new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/test/testdata/eval-okay-scope-1.exp | |||
@@ -0,0 +1 @@ | |||
3 | |||
diff --git a/test/testdata/eval-okay-scope-1.nix b/test/testdata/eval-okay-scope-1.nix new file mode 100644 index 0000000..fa38a71 --- /dev/null +++ b/test/testdata/eval-okay-scope-1.nix | |||
@@ -0,0 +1,6 @@ | |||
1 | (({x}: x: | ||
2 | |||
3 | { x = 1; | ||
4 | y = x; | ||
5 | } | ||
6 | ) {x = 2;} 3).y | ||
diff --git a/test/testdata/eval-okay-scope-2.exp b/test/testdata/eval-okay-scope-2.exp new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/test/testdata/eval-okay-scope-2.exp | |||
@@ -0,0 +1 @@ | |||
1 | |||
diff --git a/test/testdata/eval-okay-scope-2.nix b/test/testdata/eval-okay-scope-2.nix new file mode 100644 index 0000000..eb8b02b --- /dev/null +++ b/test/testdata/eval-okay-scope-2.nix | |||
@@ -0,0 +1,6 @@ | |||
1 | ((x: {x}: | ||
2 | rec { | ||
3 | x = 1; | ||
4 | y = x; | ||
5 | } | ||
6 | ) 2 {x = 3;}).y | ||
diff --git a/test/testdata/eval-okay-scope-3.exp b/test/testdata/eval-okay-scope-3.exp new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/test/testdata/eval-okay-scope-3.exp | |||
@@ -0,0 +1 @@ | |||
4 | |||
diff --git a/test/testdata/eval-okay-scope-3.nix b/test/testdata/eval-okay-scope-3.nix new file mode 100644 index 0000000..10d6bc0 --- /dev/null +++ b/test/testdata/eval-okay-scope-3.nix | |||
@@ -0,0 +1,6 @@ | |||
1 | ((x: as: {x}: | ||
2 | rec { | ||
3 | inherit (as) x; | ||
4 | y = x; | ||
5 | } | ||
6 | ) 2 {x = 4;} {x = 3;}).y | ||
diff --git a/test/testdata/eval-okay-scope-4.exp b/test/testdata/eval-okay-scope-4.exp new file mode 100644 index 0000000..00ff03a --- /dev/null +++ b/test/testdata/eval-okay-scope-4.exp | |||
@@ -0,0 +1 @@ | |||
"ccdd" | |||
diff --git a/test/testdata/eval-okay-scope-4.nix b/test/testdata/eval-okay-scope-4.nix new file mode 100644 index 0000000..dc8243b --- /dev/null +++ b/test/testdata/eval-okay-scope-4.nix | |||
@@ -0,0 +1,10 @@ | |||
1 | let { | ||
2 | |||
3 | x = "a"; | ||
4 | y = "b"; | ||
5 | |||
6 | f = {x ? y, y ? x}: x + y; | ||
7 | |||
8 | body = f {x = "c";} + f {y = "d";}; | ||
9 | |||
10 | } | ||
diff --git a/test/testdata/eval-okay-scope-6.exp b/test/testdata/eval-okay-scope-6.exp new file mode 100644 index 0000000..00ff03a --- /dev/null +++ b/test/testdata/eval-okay-scope-6.exp | |||
@@ -0,0 +1 @@ | |||
"ccdd" | |||
diff --git a/test/testdata/eval-okay-scope-6.nix b/test/testdata/eval-okay-scope-6.nix new file mode 100644 index 0000000..0995d4e --- /dev/null +++ b/test/testdata/eval-okay-scope-6.nix | |||
@@ -0,0 +1,7 @@ | |||
1 | let { | ||
2 | |||
3 | f = {x ? y, y ? x}: x + y; | ||
4 | |||
5 | body = f {x = "c";} + f {y = "d";}; | ||
6 | |||
7 | } | ||
diff --git a/test/testdata/eval-okay-scope-7.exp b/test/testdata/eval-okay-scope-7.exp new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/test/testdata/eval-okay-scope-7.exp | |||
@@ -0,0 +1 @@ | |||
1 | |||
diff --git a/test/testdata/eval-okay-scope-7.nix b/test/testdata/eval-okay-scope-7.nix new file mode 100644 index 0000000..4da0296 --- /dev/null +++ b/test/testdata/eval-okay-scope-7.nix | |||
@@ -0,0 +1,6 @@ | |||
1 | rec { | ||
2 | inherit (x) y; | ||
3 | x = { | ||
4 | y = 1; | ||
5 | }; | ||
6 | }.y | ||
diff --git a/test/testdata/eval-okay-search-path.exp b/test/testdata/eval-okay-search-path.exp new file mode 100644 index 0000000..4519bc4 --- /dev/null +++ b/test/testdata/eval-okay-search-path.exp | |||
@@ -0,0 +1 @@ | |||
"abccX" | |||
diff --git a/test/testdata/eval-okay-search-path.flags b/test/testdata/eval-okay-search-path.flags new file mode 100644 index 0000000..dfad1c6 --- /dev/null +++ b/test/testdata/eval-okay-search-path.flags | |||
@@ -0,0 +1 @@ | |||
-I lang/dir1 -I lang/dir2 -I dir5=lang/dir3 | |||
diff --git a/test/testdata/eval-okay-search-path.nix b/test/testdata/eval-okay-search-path.nix new file mode 100644 index 0000000..6fe33de --- /dev/null +++ b/test/testdata/eval-okay-search-path.nix | |||
@@ -0,0 +1,10 @@ | |||
1 | with import ./lib.nix; | ||
2 | with builtins; | ||
3 | |||
4 | assert isFunction (import <nix/fetchurl.nix>); | ||
5 | |||
6 | assert length __nixPath == 5; | ||
7 | assert length (filter (x: baseNameOf x.path == "dir4") __nixPath) == 1; | ||
8 | |||
9 | import <a.nix> + import <b.nix> + import <c.nix> + import <dir5/c.nix> | ||
10 | + (let __nixPath = [ { path = ./dir2; } { path = ./dir1; } ]; in import <a.nix>) | ||
diff --git a/test/testdata/eval-okay-seq.exp b/test/testdata/eval-okay-seq.exp new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/test/testdata/eval-okay-seq.exp | |||
@@ -0,0 +1 @@ | |||
2 | |||
diff --git a/test/testdata/eval-okay-seq.nix b/test/testdata/eval-okay-seq.nix new file mode 100644 index 0000000..0a9a21c --- /dev/null +++ b/test/testdata/eval-okay-seq.nix | |||
@@ -0,0 +1 @@ | |||
builtins.seq 1 2 | |||
diff --git a/test/testdata/eval-okay-sort.exp b/test/testdata/eval-okay-sort.exp new file mode 100644 index 0000000..899119e --- /dev/null +++ b/test/testdata/eval-okay-sort.exp | |||
@@ -0,0 +1 @@ | |||
[ [ 42 77 147 249 483 526 ] [ 526 483 249 147 77 42 ] [ "bar" "fnord" "foo" "xyzzy" ] [ { key = 1; value = "foo"; } { key = 1; value = "fnord"; } { key = 2; value = "bar"; } ] [ [ ] [ ] [ 1 ] [ 1 4 ] [ 1 5 ] [ 1 6 ] [ 2 ] [ 2 3 ] [ 3 ] [ 3 ] ] ] | |||
diff --git a/test/testdata/eval-okay-sort.nix b/test/testdata/eval-okay-sort.nix new file mode 100644 index 0000000..50aa78e --- /dev/null +++ b/test/testdata/eval-okay-sort.nix | |||
@@ -0,0 +1,20 @@ | |||
1 | with builtins; | ||
2 | |||
3 | [ (sort lessThan [ 483 249 526 147 42 77 ]) | ||
4 | (sort (x: y: y < x) [ 483 249 526 147 42 77 ]) | ||
5 | (sort lessThan [ "foo" "bar" "xyzzy" "fnord" ]) | ||
6 | (sort (x: y: x.key < y.key) | ||
7 | [ { key = 1; value = "foo"; } { key = 2; value = "bar"; } { key = 1; value = "fnord"; } ]) | ||
8 | (sort lessThan [ | ||
9 | [ 1 6 ] | ||
10 | [ ] | ||
11 | [ 2 3 ] | ||
12 | [ 3 ] | ||
13 | [ 1 5 ] | ||
14 | [ 2 ] | ||
15 | [ 1 ] | ||
16 | [ ] | ||
17 | [ 1 4 ] | ||
18 | [ 3 ] | ||
19 | ]) | ||
20 | ] | ||
diff --git a/test/testdata/eval-okay-splitversion.exp b/test/testdata/eval-okay-splitversion.exp new file mode 100644 index 0000000..153ceb8 --- /dev/null +++ b/test/testdata/eval-okay-splitversion.exp | |||
@@ -0,0 +1 @@ | |||
[ "1" "2" "3" ] | |||
diff --git a/test/testdata/eval-okay-splitversion.nix b/test/testdata/eval-okay-splitversion.nix new file mode 100644 index 0000000..9e5c99d --- /dev/null +++ b/test/testdata/eval-okay-splitversion.nix | |||
@@ -0,0 +1 @@ | |||
builtins.splitVersion "1.2.3" | |||
diff --git a/test/testdata/eval-okay-string.exp b/test/testdata/eval-okay-string.exp new file mode 100644 index 0000000..63f650f --- /dev/null +++ b/test/testdata/eval-okay-string.exp | |||
@@ -0,0 +1 @@ | |||
"foobar/a/b/c/d/foo/xyzzy/foo.txt/../foo/x/yescape: \"quote\" \n \\end\nof\nlinefoobarblaatfoo$bar$\"$\"$" | |||
diff --git a/test/testdata/eval-okay-string.nix b/test/testdata/eval-okay-string.nix new file mode 100644 index 0000000..47cc989 --- /dev/null +++ b/test/testdata/eval-okay-string.nix | |||
@@ -0,0 +1,12 @@ | |||
1 | "foo" + "bar" | ||
2 | + toString (/a/b + /c/d) | ||
3 | + toString (/foo/bar + "/../xyzzy/." + "/foo.txt") | ||
4 | + ("/../foo" + toString /x/y) | ||
5 | + "escape: \"quote\" \n \\" | ||
6 | + "end | ||
7 | of | ||
8 | line" | ||
9 | + "foo${if true then "b${"a" + "r"}" else "xyzzy"}blaat" | ||
10 | + "foo$bar" | ||
11 | + "$\"$\"" | ||
12 | + "$" | ||
diff --git a/test/testdata/eval-okay-strings-as-attrs-names.exp b/test/testdata/eval-okay-strings-as-attrs-names.exp new file mode 100644 index 0000000..27ba77d --- /dev/null +++ b/test/testdata/eval-okay-strings-as-attrs-names.exp | |||
@@ -0,0 +1 @@ | |||
true | |||
diff --git a/test/testdata/eval-okay-strings-as-attrs-names.nix b/test/testdata/eval-okay-strings-as-attrs-names.nix new file mode 100644 index 0000000..5e40928 --- /dev/null +++ b/test/testdata/eval-okay-strings-as-attrs-names.nix | |||
@@ -0,0 +1,20 @@ | |||
1 | let | ||
2 | |||
3 | attr = { | ||
4 | "key 1" = "test"; | ||
5 | "key 2" = "caseok"; | ||
6 | }; | ||
7 | |||
8 | t1 = builtins.getAttr "key 1" attr; | ||
9 | t2 = attr."key 2"; | ||
10 | t3 = attr ? "key 1"; | ||
11 | t4 = builtins.attrNames { inherit (attr) "key 1"; }; | ||
12 | |||
13 | # This is permitted, but there is currently no way to reference this | ||
14 | # variable. | ||
15 | "foo bar" = 1; | ||
16 | |||
17 | in t1 == "test" | ||
18 | && t2 == "caseok" | ||
19 | && t3 == true | ||
20 | && t4 == ["key 1"] | ||
diff --git a/test/testdata/eval-okay-substring-context.exp b/test/testdata/eval-okay-substring-context.exp new file mode 100644 index 0000000..2fe7f71 --- /dev/null +++ b/test/testdata/eval-okay-substring-context.exp | |||
@@ -0,0 +1 @@ | |||
"okay" | |||
diff --git a/test/testdata/eval-okay-substring-context.nix b/test/testdata/eval-okay-substring-context.nix new file mode 100644 index 0000000..d0ef70d --- /dev/null +++ b/test/testdata/eval-okay-substring-context.nix | |||
@@ -0,0 +1,11 @@ | |||
1 | with builtins; | ||
2 | |||
3 | let | ||
4 | |||
5 | s = "${builtins.derivation { name = "test"; builder = "/bin/sh"; system = "x86_64-linux"; }}"; | ||
6 | |||
7 | in | ||
8 | |||
9 | if getContext s == getContext "${substring 0 0 s + unsafeDiscardStringContext s}" | ||
10 | then "okay" | ||
11 | else throw "empty substring should preserve context" | ||
diff --git a/test/testdata/eval-okay-substring.exp b/test/testdata/eval-okay-substring.exp new file mode 100644 index 0000000..f48b462 --- /dev/null +++ b/test/testdata/eval-okay-substring.exp | |||
@@ -0,0 +1 @@ | |||
"ooxfoobarybarzobaabbc_bad" | |||
diff --git a/test/testdata/eval-okay-substring.nix b/test/testdata/eval-okay-substring.nix new file mode 100644 index 0000000..54c97e1 --- /dev/null +++ b/test/testdata/eval-okay-substring.nix | |||
@@ -0,0 +1,23 @@ | |||
1 | with builtins; | ||
2 | |||
3 | let | ||
4 | |||
5 | s = "foobar"; | ||
6 | |||
7 | in | ||
8 | |||
9 | substring 1 2 s | ||
10 | + "x" | ||
11 | + substring 0 (stringLength s) s | ||
12 | + "y" | ||
13 | + substring 3 100 s | ||
14 | + "z" | ||
15 | + substring 2 (sub (stringLength s) 3) s | ||
16 | + "a" | ||
17 | + substring 3 0 s | ||
18 | + "b" | ||
19 | + substring 3 1 s | ||
20 | + "c" | ||
21 | + substring 5 10 "perl" | ||
22 | + "_" | ||
23 | + substring 3 (-1) "tebbad" | ||
diff --git a/test/testdata/eval-okay-symlink-resolution.exp b/test/testdata/eval-okay-symlink-resolution.exp new file mode 100644 index 0000000..8b8441b --- /dev/null +++ b/test/testdata/eval-okay-symlink-resolution.exp | |||
@@ -0,0 +1 @@ | |||
"test" | |||
diff --git a/test/testdata/eval-okay-symlink-resolution.nix b/test/testdata/eval-okay-symlink-resolution.nix new file mode 100644 index 0000000..ffb1818 --- /dev/null +++ b/test/testdata/eval-okay-symlink-resolution.nix | |||
@@ -0,0 +1 @@ | |||
import symlink-resolution/foo/overlays/overlay.nix | |||
diff --git a/test/testdata/eval-okay-tail-call-1.exp-disabled b/test/testdata/eval-okay-tail-call-1.exp-disabled new file mode 100644 index 0000000..f7393e8 --- /dev/null +++ b/test/testdata/eval-okay-tail-call-1.exp-disabled | |||
@@ -0,0 +1 @@ | |||
100000 | |||
diff --git a/test/testdata/eval-okay-tail-call-1.nix b/test/testdata/eval-okay-tail-call-1.nix new file mode 100644 index 0000000..a3962ce --- /dev/null +++ b/test/testdata/eval-okay-tail-call-1.nix | |||
@@ -0,0 +1,3 @@ | |||
1 | let | ||
2 | f = n: if n == 100000 then n else f (n + 1); | ||
3 | in f 0 | ||
diff --git a/test/testdata/eval-okay-tojson.exp b/test/testdata/eval-okay-tojson.exp new file mode 100644 index 0000000..e92aae3 --- /dev/null +++ b/test/testdata/eval-okay-tojson.exp | |||
@@ -0,0 +1 @@ | |||
"{\"a\":123,\"b\":-456,\"c\":\"foo\",\"d\":\"foo\\n\\\"bar\\\"\",\"e\":true,\"f\":false,\"g\":[1,2,3],\"h\":[\"a\",[\"b\",{\"foo\\nbar\":{}}]],\"i\":3,\"j\":1.44,\"k\":\"foo\"}" | |||
diff --git a/test/testdata/eval-okay-tojson.nix b/test/testdata/eval-okay-tojson.nix new file mode 100644 index 0000000..ce67943 --- /dev/null +++ b/test/testdata/eval-okay-tojson.nix | |||
@@ -0,0 +1,13 @@ | |||
1 | builtins.toJSON | ||
2 | { a = 123; | ||
3 | b = -456; | ||
4 | c = "foo"; | ||
5 | d = "foo\n\"bar\""; | ||
6 | e = true; | ||
7 | f = false; | ||
8 | g = [ 1 2 3 ]; | ||
9 | h = [ "a" [ "b" { "foo\nbar" = {}; } ] ]; | ||
10 | i = 1 + 2; | ||
11 | j = 1.44; | ||
12 | k = { __toString = self: self.a; a = "foo"; }; | ||
13 | } | ||
diff --git a/test/testdata/eval-okay-toxml.exp b/test/testdata/eval-okay-toxml.exp new file mode 100644 index 0000000..8282208 --- /dev/null +++ b/test/testdata/eval-okay-toxml.exp | |||
@@ -0,0 +1 @@ | |||
"<?xml version='1.0' encoding='utf-8'?>\n<expr>\n <attrs>\n <attr name=\"a\">\n <string value=\"s\" />\n </attr>\n </attrs>\n</expr>\n" | |||
diff --git a/test/testdata/eval-okay-toxml.nix b/test/testdata/eval-okay-toxml.nix new file mode 100644 index 0000000..068c97a --- /dev/null +++ b/test/testdata/eval-okay-toxml.nix | |||
@@ -0,0 +1,3 @@ | |||
1 | # Make sure the expected XML output is produced; in particular, make sure it | ||
2 | # doesn't contain source location information. | ||
3 | builtins.toXML { a = "s"; } | ||
diff --git a/test/testdata/eval-okay-toxml2.exp b/test/testdata/eval-okay-toxml2.exp new file mode 100644 index 0000000..634a841 --- /dev/null +++ b/test/testdata/eval-okay-toxml2.exp | |||
@@ -0,0 +1 @@ | |||
"<?xml version='1.0' encoding='utf-8'?>\n<expr>\n <list>\n <string value=\"ab\" />\n <int value=\"10\" />\n <attrs>\n <attr name=\"x\">\n <string value=\"x\" />\n </attr>\n <attr name=\"y\">\n <string value=\"x\" />\n </attr>\n </attrs>\n </list>\n</expr>\n" | |||
diff --git a/test/testdata/eval-okay-toxml2.nix b/test/testdata/eval-okay-toxml2.nix new file mode 100644 index 0000000..ff1791b --- /dev/null +++ b/test/testdata/eval-okay-toxml2.nix | |||
@@ -0,0 +1 @@ | |||
builtins.toXML [("a" + "b") 10 (rec {x = "x"; y = x;})] | |||
diff --git a/test/testdata/eval-okay-tryeval.exp b/test/testdata/eval-okay-tryeval.exp new file mode 100644 index 0000000..2b2e6fa --- /dev/null +++ b/test/testdata/eval-okay-tryeval.exp | |||
@@ -0,0 +1 @@ | |||
{ x = { success = true; value = "x"; }; y = { success = false; value = false; }; z = { success = false; value = false; }; } | |||
diff --git a/test/testdata/eval-okay-tryeval.nix b/test/testdata/eval-okay-tryeval.nix new file mode 100644 index 0000000..629bc44 --- /dev/null +++ b/test/testdata/eval-okay-tryeval.nix | |||
@@ -0,0 +1,5 @@ | |||
1 | { | ||
2 | x = builtins.tryEval "x"; | ||
3 | y = builtins.tryEval (assert false; "y"); | ||
4 | z = builtins.tryEval (throw "bla"); | ||
5 | } | ||
diff --git a/test/testdata/eval-okay-types.exp b/test/testdata/eval-okay-types.exp new file mode 100644 index 0000000..92a1532 --- /dev/null +++ b/test/testdata/eval-okay-types.exp | |||
@@ -0,0 +1 @@ | |||
[ true false true false true false true false true true true true true true true true true true true false true true true false "int" "bool" "string" "null" "set" "list" "lambda" "lambda" "lambda" "lambda" ] | |||
diff --git a/test/testdata/eval-okay-types.nix b/test/testdata/eval-okay-types.nix new file mode 100644 index 0000000..9b58be5 --- /dev/null +++ b/test/testdata/eval-okay-types.nix | |||
@@ -0,0 +1,37 @@ | |||
1 | with builtins; | ||
2 | |||
3 | [ (isNull null) | ||
4 | (isNull (x: x)) | ||
5 | (isFunction (x: x)) | ||
6 | (isFunction "fnord") | ||
7 | (isString ("foo" + "bar")) | ||
8 | (isString [ "x" ]) | ||
9 | (isInt (1 + 2)) | ||
10 | (isInt { x = 123; }) | ||
11 | (isInt (1 / 2)) | ||
12 | (isInt (1 + 1)) | ||
13 | (isInt (1 / 2)) | ||
14 | (isInt (1 * 2)) | ||
15 | (isInt (1 - 2)) | ||
16 | (isFloat (1.2)) | ||
17 | (isFloat (1 + 1.0)) | ||
18 | (isFloat (1 / 2.0)) | ||
19 | (isFloat (1 * 2.0)) | ||
20 | (isFloat (1 - 2.0)) | ||
21 | (isBool (true && false)) | ||
22 | (isBool null) | ||
23 | (isPath /nix/store) | ||
24 | (isPath ./.) | ||
25 | (isAttrs { x = 123; }) | ||
26 | (isAttrs null) | ||
27 | (typeOf (3 * 4)) | ||
28 | (typeOf true) | ||
29 | (typeOf "xyzzy") | ||
30 | (typeOf null) | ||
31 | (typeOf { x = 456; }) | ||
32 | (typeOf [ 1 2 3 ]) | ||
33 | (typeOf (x: x)) | ||
34 | (typeOf ((x: y: x) 1)) | ||
35 | (typeOf map) | ||
36 | (typeOf (map (x: x))) | ||
37 | ] | ||
diff --git a/test/testdata/eval-okay-versions.exp b/test/testdata/eval-okay-versions.exp new file mode 100644 index 0000000..27ba77d --- /dev/null +++ b/test/testdata/eval-okay-versions.exp | |||
@@ -0,0 +1 @@ | |||
true | |||
diff --git a/test/testdata/eval-okay-versions.nix b/test/testdata/eval-okay-versions.nix new file mode 100644 index 0000000..e9111f5 --- /dev/null +++ b/test/testdata/eval-okay-versions.nix | |||
@@ -0,0 +1,43 @@ | |||
1 | let | ||
2 | |||
3 | name1 = "hello-1.0.2"; | ||
4 | name2 = "hello"; | ||
5 | name3 = "915resolution-0.5.2"; | ||
6 | name4 = "xf86-video-i810-1.7.4"; | ||
7 | name5 = "name-that-ends-with-dash--1.0"; | ||
8 | |||
9 | eq = 0; | ||
10 | lt = builtins.sub 0 1; | ||
11 | gt = 1; | ||
12 | |||
13 | versionTest = v1: v2: expected: | ||
14 | let d1 = builtins.compareVersions v1 v2; | ||
15 | d2 = builtins.compareVersions v2 v1; | ||
16 | in d1 == builtins.sub 0 d2 && d1 == expected; | ||
17 | |||
18 | tests = [ | ||
19 | ((builtins.parseDrvName name1).name == "hello") | ||
20 | ((builtins.parseDrvName name1).version == "1.0.2") | ||
21 | ((builtins.parseDrvName name2).name == "hello") | ||
22 | ((builtins.parseDrvName name2).version == "") | ||
23 | ((builtins.parseDrvName name3).name == "915resolution") | ||
24 | ((builtins.parseDrvName name3).version == "0.5.2") | ||
25 | ((builtins.parseDrvName name4).name == "xf86-video-i810") | ||
26 | ((builtins.parseDrvName name4).version == "1.7.4") | ||
27 | ((builtins.parseDrvName name5).name == "name-that-ends-with-dash") | ||
28 | ((builtins.parseDrvName name5).version == "-1.0") | ||
29 | (versionTest "1.0" "2.3" lt) | ||
30 | (versionTest "2.1" "2.3" lt) | ||
31 | (versionTest "2.3" "2.3" eq) | ||
32 | (versionTest "2.5" "2.3" gt) | ||
33 | (versionTest "3.1" "2.3" gt) | ||
34 | (versionTest "2.3.1" "2.3" gt) | ||
35 | (versionTest "2.3.1" "2.3a" gt) | ||
36 | (versionTest "2.3pre1" "2.3" lt) | ||
37 | (versionTest "2.3pre3" "2.3pre12" lt) | ||
38 | (versionTest "2.3a" "2.3c" lt) | ||
39 | (versionTest "2.3pre1" "2.3c" lt) | ||
40 | (versionTest "2.3pre1" "2.3q" lt) | ||
41 | ]; | ||
42 | |||
43 | in (import ./lib.nix).and tests | ||
diff --git a/test/testdata/eval-okay-with.exp b/test/testdata/eval-okay-with.exp new file mode 100644 index 0000000..378c8dc --- /dev/null +++ b/test/testdata/eval-okay-with.exp | |||
@@ -0,0 +1 @@ | |||
"xyzzybarxyzzybar" | |||
diff --git a/test/testdata/eval-okay-with.nix b/test/testdata/eval-okay-with.nix new file mode 100644 index 0000000..033e8d3 --- /dev/null +++ b/test/testdata/eval-okay-with.nix | |||
@@ -0,0 +1,19 @@ | |||
1 | let { | ||
2 | |||
3 | a = "xyzzy"; | ||
4 | |||
5 | as = { | ||
6 | a = "foo"; | ||
7 | b = "bar"; | ||
8 | }; | ||
9 | |||
10 | bs = { | ||
11 | a = "bar"; | ||
12 | }; | ||
13 | |||
14 | x = with as; a + b; | ||
15 | |||
16 | y = with as; with bs; a + b; | ||
17 | |||
18 | body = x + y; | ||
19 | } | ||
diff --git a/test/testdata/eval-okay-xml.exp.xml b/test/testdata/eval-okay-xml.exp.xml new file mode 100644 index 0000000..2009932 --- /dev/null +++ b/test/testdata/eval-okay-xml.exp.xml | |||
@@ -0,0 +1,52 @@ | |||
1 | <?xml version='1.0' encoding='utf-8'?> | ||
2 | <expr> | ||
3 | <attrs> | ||
4 | <attr name="a"> | ||
5 | <string value="foo" /> | ||
6 | </attr> | ||
7 | <attr name="at"> | ||
8 | <function> | ||
9 | <attrspat name="args"> | ||
10 | <attr name="x" /> | ||
11 | <attr name="y" /> | ||
12 | <attr name="z" /> | ||
13 | </attrspat> | ||
14 | </function> | ||
15 | </attr> | ||
16 | <attr name="b"> | ||
17 | <string value="bar" /> | ||
18 | </attr> | ||
19 | <attr name="c"> | ||
20 | <string value="foobar" /> | ||
21 | </attr> | ||
22 | <attr name="ellipsis"> | ||
23 | <function> | ||
24 | <attrspat ellipsis="1"> | ||
25 | <attr name="x" /> | ||
26 | <attr name="y" /> | ||
27 | <attr name="z" /> | ||
28 | </attrspat> | ||
29 | </function> | ||
30 | </attr> | ||
31 | <attr name="f"> | ||
32 | <function> | ||
33 | <attrspat> | ||
34 | <attr name="x" /> | ||
35 | <attr name="y" /> | ||
36 | <attr name="z" /> | ||
37 | </attrspat> | ||
38 | </function> | ||
39 | </attr> | ||
40 | <attr name="id"> | ||
41 | <function> | ||
42 | <varpat name="x" /> | ||
43 | </function> | ||
44 | </attr> | ||
45 | <attr name="x"> | ||
46 | <int value="123" /> | ||
47 | </attr> | ||
48 | <attr name="y"> | ||
49 | <float value="567.89" /> | ||
50 | </attr> | ||
51 | </attrs> | ||
52 | </expr> | ||
diff --git a/test/testdata/eval-okay-xml.nix b/test/testdata/eval-okay-xml.nix new file mode 100644 index 0000000..9ee9f8a --- /dev/null +++ b/test/testdata/eval-okay-xml.nix | |||
@@ -0,0 +1,21 @@ | |||
1 | rec { | ||
2 | |||
3 | x = 123; | ||
4 | |||
5 | y = 567.890; | ||
6 | |||
7 | a = "foo"; | ||
8 | |||
9 | b = "bar"; | ||
10 | |||
11 | c = "foo" + "bar"; | ||
12 | |||
13 | f = {z, x, y}: if y then x else z; | ||
14 | |||
15 | id = x: x; | ||
16 | |||
17 | at = args@{x, y, z}: x; | ||
18 | |||
19 | ellipsis = {x, y, z, ...}: x; | ||
20 | |||
21 | } | ||
diff --git a/test/testdata/eval-okay-zipAttrsWith.exp b/test/testdata/eval-okay-zipAttrsWith.exp new file mode 100644 index 0000000..9c0b15d --- /dev/null +++ b/test/testdata/eval-okay-zipAttrsWith.exp | |||
@@ -0,0 +1 @@ | |||
{ "0" = { n = "0"; v = [ 5 23 29 ]; }; "1" = { n = "1"; v = [ 7 30 ]; }; "2" = { n = "2"; v = [ 18 ]; }; "4" = { n = "4"; v = [ 10 ]; }; "5" = { n = "5"; v = [ 15 25 26 31 ]; }; "6" = { n = "6"; v = [ 3 14 ]; }; "7" = { n = "7"; v = [ 12 ]; }; "8" = { n = "8"; v = [ 2 6 8 9 ]; }; "9" = { n = "9"; v = [ 0 16 ]; }; a = { n = "a"; v = [ 17 21 22 27 ]; }; c = { n = "c"; v = [ 11 24 ]; }; d = { n = "d"; v = [ 4 13 28 ]; }; e = { n = "e"; v = [ 20 ]; }; f = { n = "f"; v = [ 1 19 ]; }; } | |||
diff --git a/test/testdata/eval-okay-zipAttrsWith.nix b/test/testdata/eval-okay-zipAttrsWith.nix new file mode 100644 index 0000000..877d4e5 --- /dev/null +++ b/test/testdata/eval-okay-zipAttrsWith.nix | |||
@@ -0,0 +1,9 @@ | |||
1 | with import ./lib.nix; | ||
2 | |||
3 | let | ||
4 | str = builtins.hashString "sha256" "test"; | ||
5 | in | ||
6 | builtins.zipAttrsWith | ||
7 | (n: v: { inherit n v; }) | ||
8 | (map (n: { ${builtins.substring n 1 str} = n; }) | ||
9 | (range 0 31)) | ||
diff --git a/test/testdata/importdef.sexp b/test/testdata/importdef.sexp new file mode 100644 index 0000000..bf8debb --- /dev/null +++ b/test/testdata/importdef.sexp | |||
@@ -0,0 +1 @@ | |||
(deps ./lib.nix) | |||
diff --git a/test/testdata/imported.nix b/test/testdata/imported.nix new file mode 100644 index 0000000..fb39ee4 --- /dev/null +++ b/test/testdata/imported.nix | |||
@@ -0,0 +1,3 @@ | |||
1 | # The function ‘range’ comes from lib.nix and was added to the lexical | ||
2 | # scope by scopedImport. | ||
3 | range 1 5 ++ import ./imported2.nix | ||
diff --git a/test/testdata/imported2.nix b/test/testdata/imported2.nix new file mode 100644 index 0000000..6d0a299 --- /dev/null +++ b/test/testdata/imported2.nix | |||
@@ -0,0 +1 @@ | |||
range 6 10 | |||
diff --git a/test/testdata/lib.nix b/test/testdata/lib.nix new file mode 100644 index 0000000..028a538 --- /dev/null +++ b/test/testdata/lib.nix | |||
@@ -0,0 +1,61 @@ | |||
1 | with builtins; | ||
2 | |||
3 | rec { | ||
4 | |||
5 | fold = op: nul: list: | ||
6 | if list == [] | ||
7 | then nul | ||
8 | else op (head list) (fold op nul (tail list)); | ||
9 | |||
10 | concat = | ||
11 | fold (x: y: x + y) ""; | ||
12 | |||
13 | and = fold (x: y: x && y) true; | ||
14 | |||
15 | flatten = x: | ||
16 | if isList x | ||
17 | then fold (x: y: (flatten x) ++ y) [] x | ||
18 | else [x]; | ||
19 | |||
20 | sum = foldl' (x: y: add x y) 0; | ||
21 | |||
22 | hasSuffix = ext: fileName: | ||
23 | let lenFileName = stringLength fileName; | ||
24 | lenExt = stringLength ext; | ||
25 | in !(lessThan lenFileName lenExt) && | ||
26 | substring (sub lenFileName lenExt) lenFileName fileName == ext; | ||
27 | |||
28 | # Split a list at the given position. | ||
29 | splitAt = pos: list: | ||
30 | if pos == 0 then {first = []; second = list;} else | ||
31 | if list == [] then {first = []; second = [];} else | ||
32 | let res = splitAt (sub pos 1) (tail list); | ||
33 | in {first = [(head list)] ++ res.first; second = res.second;}; | ||
34 | |||
35 | # Stable merge sort. | ||
36 | sortBy = comp: list: | ||
37 | if lessThan 1 (length list) | ||
38 | then | ||
39 | let | ||
40 | split = splitAt (div (length list) 2) list; | ||
41 | first = sortBy comp split.first; | ||
42 | second = sortBy comp split.second; | ||
43 | in mergeLists comp first second | ||
44 | else list; | ||
45 | |||
46 | mergeLists = comp: list1: list2: | ||
47 | if list1 == [] then list2 else | ||
48 | if list2 == [] then list1 else | ||
49 | if comp (head list2) (head list1) then [(head list2)] ++ mergeLists comp list1 (tail list2) else | ||
50 | [(head list1)] ++ mergeLists comp (tail list1) list2; | ||
51 | |||
52 | id = x: x; | ||
53 | |||
54 | const = x: y: x; | ||
55 | |||
56 | range = first: last: | ||
57 | if first > last | ||
58 | then [] | ||
59 | else genList (n: first + n) (last - first + 1); | ||
60 | |||
61 | } | ||
diff --git a/test/testdata/non-eval-fail-bad-drvPath.nix b/test/testdata/non-eval-fail-bad-drvPath.nix new file mode 100644 index 0000000..23639bc --- /dev/null +++ b/test/testdata/non-eval-fail-bad-drvPath.nix | |||
@@ -0,0 +1,14 @@ | |||
1 | let | ||
2 | package = { | ||
3 | type = "derivation"; | ||
4 | name = "cachix-1.7.3"; | ||
5 | system = builtins.currentSystem; | ||
6 | outputs = [ "out" ]; | ||
7 | # Illegal, because does not end in `.drv` | ||
8 | drvPath = "${builtins.storeDir}/8qlfcic10lw5304gqm8q45nr7g7jl62b-cachix-1.7.3-bin"; | ||
9 | outputName = "out"; | ||
10 | outPath = "${builtins.storeDir}/8qlfcic10lw5304gqm8q45nr7g7jl62b-cachix-1.7.3-bin"; | ||
11 | out = package; | ||
12 | }; | ||
13 | in | ||
14 | package | ||
diff --git a/test/testdata/parse-fail-dup-attrs-1.err.exp b/test/testdata/parse-fail-dup-attrs-1.err.exp new file mode 100644 index 0000000..ffb5198 --- /dev/null +++ b/test/testdata/parse-fail-dup-attrs-1.err.exp | |||
@@ -0,0 +1,6 @@ | |||
1 | error: attribute 'x' already defined at «stdin»:1:3 | ||
2 | at «stdin»:3:3: | ||
3 | 2| y = 456; | ||
4 | 3| x = 789; | ||
5 | | ^ | ||
6 | 4| } | ||
diff --git a/test/testdata/parse-fail-dup-attrs-1.nix b/test/testdata/parse-fail-dup-attrs-1.nix new file mode 100644 index 0000000..2c02317 --- /dev/null +++ b/test/testdata/parse-fail-dup-attrs-1.nix | |||
@@ -0,0 +1,4 @@ | |||
1 | { x = 123; | ||
2 | y = 456; | ||
3 | x = 789; | ||
4 | } | ||
diff --git a/test/testdata/parse-fail-dup-attrs-2.err.exp b/test/testdata/parse-fail-dup-attrs-2.err.exp new file mode 100644 index 0000000..3105e60 --- /dev/null +++ b/test/testdata/parse-fail-dup-attrs-2.err.exp | |||
@@ -0,0 +1,6 @@ | |||
1 | error: attribute 'x' already defined at «stdin»:9:5 | ||
2 | at «stdin»:10:18: | ||
3 | 9| x = 789; | ||
4 | 10| inherit (as) x; | ||
5 | | ^ | ||
6 | 11| }; | ||
diff --git a/test/testdata/parse-fail-dup-attrs-2.nix b/test/testdata/parse-fail-dup-attrs-2.nix new file mode 100644 index 0000000..864d986 --- /dev/null +++ b/test/testdata/parse-fail-dup-attrs-2.nix | |||
@@ -0,0 +1,13 @@ | |||
1 | let { | ||
2 | |||
3 | as = { | ||
4 | x = 123; | ||
5 | y = 456; | ||
6 | }; | ||
7 | |||
8 | bs = { | ||
9 | x = 789; | ||
10 | inherit (as) x; | ||
11 | }; | ||
12 | |||
13 | } | ||
diff --git a/test/testdata/parse-fail-dup-attrs-3.err.exp b/test/testdata/parse-fail-dup-attrs-3.err.exp new file mode 100644 index 0000000..3105e60 --- /dev/null +++ b/test/testdata/parse-fail-dup-attrs-3.err.exp | |||
@@ -0,0 +1,6 @@ | |||
1 | error: attribute 'x' already defined at «stdin»:9:5 | ||
2 | at «stdin»:10:18: | ||
3 | 9| x = 789; | ||
4 | 10| inherit (as) x; | ||
5 | | ^ | ||
6 | 11| }; | ||
diff --git a/test/testdata/parse-fail-dup-attrs-3.nix b/test/testdata/parse-fail-dup-attrs-3.nix new file mode 100644 index 0000000..114d197 --- /dev/null +++ b/test/testdata/parse-fail-dup-attrs-3.nix | |||
@@ -0,0 +1,13 @@ | |||
1 | let { | ||
2 | |||
3 | as = { | ||
4 | x = 123; | ||
5 | y = 456; | ||
6 | }; | ||
7 | |||
8 | bs = rec { | ||
9 | x = 789; | ||
10 | inherit (as) x; | ||
11 | }; | ||
12 | |||
13 | } | ||
diff --git a/test/testdata/parse-fail-dup-attrs-4.err.exp b/test/testdata/parse-fail-dup-attrs-4.err.exp new file mode 100644 index 0000000..c98a8f8 --- /dev/null +++ b/test/testdata/parse-fail-dup-attrs-4.err.exp | |||
@@ -0,0 +1,6 @@ | |||
1 | error: attribute 'services.ssh.port' already defined at «stdin»:2:3 | ||
2 | at «stdin»:3:3: | ||
3 | 2| services.ssh.port = 22; | ||
4 | 3| services.ssh.port = 23; | ||
5 | | ^ | ||
6 | 4| } | ||
diff --git a/test/testdata/parse-fail-dup-attrs-4.nix b/test/testdata/parse-fail-dup-attrs-4.nix new file mode 100644 index 0000000..7741743 --- /dev/null +++ b/test/testdata/parse-fail-dup-attrs-4.nix | |||
@@ -0,0 +1,4 @@ | |||
1 | { | ||
2 | services.ssh.port = 22; | ||
3 | services.ssh.port = 23; | ||
4 | } | ||
diff --git a/test/testdata/parse-fail-dup-attrs-7.err.exp b/test/testdata/parse-fail-dup-attrs-7.err.exp new file mode 100644 index 0000000..4e0a48e --- /dev/null +++ b/test/testdata/parse-fail-dup-attrs-7.err.exp | |||
@@ -0,0 +1,6 @@ | |||
1 | error: attribute 'x' already defined at «stdin»:6:13 | ||
2 | at «stdin»:7:13: | ||
3 | 6| inherit x; | ||
4 | 7| inherit x; | ||
5 | | ^ | ||
6 | 8| }; | ||
diff --git a/test/testdata/parse-fail-dup-attrs-7.nix b/test/testdata/parse-fail-dup-attrs-7.nix new file mode 100644 index 0000000..bbc3eb0 --- /dev/null +++ b/test/testdata/parse-fail-dup-attrs-7.nix | |||
@@ -0,0 +1,9 @@ | |||
1 | rec { | ||
2 | |||
3 | x = 1; | ||
4 | |||
5 | as = { | ||
6 | inherit x; | ||
7 | inherit x; | ||
8 | }; | ||
9 | } \ No newline at end of file | ||
diff --git a/test/testdata/parse-fail-dup-formals.err.exp b/test/testdata/parse-fail-dup-formals.err.exp new file mode 100644 index 0000000..d7c7e02 --- /dev/null +++ b/test/testdata/parse-fail-dup-formals.err.exp | |||
@@ -0,0 +1,4 @@ | |||
1 | error: duplicate formal function argument 'x' | ||
2 | at «stdin»:1:8: | ||
3 | 1| {x, y, x}: x | ||
4 | | ^ | ||
diff --git a/test/testdata/parse-fail-dup-formals.nix b/test/testdata/parse-fail-dup-formals.nix new file mode 100644 index 0000000..a0edd91 --- /dev/null +++ b/test/testdata/parse-fail-dup-formals.nix | |||
@@ -0,0 +1 @@ | |||
{x, y, x}: x \ No newline at end of file | |||
diff --git a/test/testdata/parse-fail-eof-in-string.err.exp b/test/testdata/parse-fail-eof-in-string.err.exp new file mode 100644 index 0000000..17f34b6 --- /dev/null +++ b/test/testdata/parse-fail-eof-in-string.err.exp | |||
@@ -0,0 +1,5 @@ | |||
1 | error: syntax error, unexpected end of file, expecting '"' | ||
2 | at «stdin»:3:6: | ||
3 | 2| # Note that this file must not end with a newline. | ||
4 | 3| a 1"$ | ||
5 | | ^ | ||
diff --git a/test/testdata/parse-fail-eof-in-string.nix b/test/testdata/parse-fail-eof-in-string.nix new file mode 100644 index 0000000..19775d2 --- /dev/null +++ b/test/testdata/parse-fail-eof-in-string.nix | |||
@@ -0,0 +1,3 @@ | |||
1 | # https://github.com/NixOS/nix/issues/6562 | ||
2 | # Note that this file must not end with a newline. | ||
3 | a 1"$ \ No newline at end of file | ||
diff --git a/test/testdata/parse-fail-eof-pos.err.exp b/test/testdata/parse-fail-eof-pos.err.exp new file mode 100644 index 0000000..ef9ca38 --- /dev/null +++ b/test/testdata/parse-fail-eof-pos.err.exp | |||
@@ -0,0 +1,5 @@ | |||
1 | error: syntax error, unexpected end of file | ||
2 | at «stdin»:3:1: | ||
3 | 2| # no content | ||
4 | 3| | ||
5 | | ^ | ||
diff --git a/test/testdata/parse-fail-eof-pos.nix b/test/testdata/parse-fail-eof-pos.nix new file mode 100644 index 0000000..bd66a2c --- /dev/null +++ b/test/testdata/parse-fail-eof-pos.nix | |||
@@ -0,0 +1,2 @@ | |||
1 | ( | ||
2 | # no content | ||
diff --git a/test/testdata/parse-fail-mixed-nested-attrs1.err.exp b/test/testdata/parse-fail-mixed-nested-attrs1.err.exp new file mode 100644 index 0000000..a447215 --- /dev/null +++ b/test/testdata/parse-fail-mixed-nested-attrs1.err.exp | |||
@@ -0,0 +1,6 @@ | |||
1 | error: attribute 'z' already defined at «stdin»:3:16 | ||
2 | at «stdin»:2:3: | ||
3 | 1| { | ||
4 | 2| x.z = 3; | ||
5 | | ^ | ||
6 | 3| x = { y = 3; z = 3; }; | ||
diff --git a/test/testdata/parse-fail-mixed-nested-attrs1.nix b/test/testdata/parse-fail-mixed-nested-attrs1.nix new file mode 100644 index 0000000..11e40e6 --- /dev/null +++ b/test/testdata/parse-fail-mixed-nested-attrs1.nix | |||
@@ -0,0 +1,4 @@ | |||
1 | { | ||
2 | x.z = 3; | ||
3 | x = { y = 3; z = 3; }; | ||
4 | } | ||
diff --git a/test/testdata/parse-fail-mixed-nested-attrs2.err.exp b/test/testdata/parse-fail-mixed-nested-attrs2.err.exp new file mode 100644 index 0000000..ead1f0d --- /dev/null +++ b/test/testdata/parse-fail-mixed-nested-attrs2.err.exp | |||
@@ -0,0 +1,6 @@ | |||
1 | error: attribute 'y' already defined at «stdin»:3:9 | ||
2 | at «stdin»:2:3: | ||
3 | 1| { | ||
4 | 2| x.y.y = 3; | ||
5 | | ^ | ||
6 | 3| x = { y.y= 3; z = 3; }; | ||
diff --git a/test/testdata/parse-fail-mixed-nested-attrs2.nix b/test/testdata/parse-fail-mixed-nested-attrs2.nix new file mode 100644 index 0000000..17da82e --- /dev/null +++ b/test/testdata/parse-fail-mixed-nested-attrs2.nix | |||
@@ -0,0 +1,4 @@ | |||
1 | { | ||
2 | x.y.y = 3; | ||
3 | x = { y.y= 3; z = 3; }; | ||
4 | } | ||
diff --git a/test/testdata/parse-fail-patterns-1.err.exp b/test/testdata/parse-fail-patterns-1.err.exp new file mode 100644 index 0000000..6ba39d8 --- /dev/null +++ b/test/testdata/parse-fail-patterns-1.err.exp | |||
@@ -0,0 +1,5 @@ | |||
1 | error: duplicate formal function argument 'args' | ||
2 | at «stdin»:1:1: | ||
3 | 1| args@{args, x, y, z}: x | ||
4 | | ^ | ||
5 | 2| | ||
diff --git a/test/testdata/parse-fail-patterns-1.nix b/test/testdata/parse-fail-patterns-1.nix new file mode 100644 index 0000000..7b40616 --- /dev/null +++ b/test/testdata/parse-fail-patterns-1.nix | |||
@@ -0,0 +1 @@ | |||
args@{args, x, y, z}: x | |||
diff --git a/test/testdata/parse-fail-regression-20060610.err.exp b/test/testdata/parse-fail-regression-20060610.err.exp new file mode 100644 index 0000000..6ae7c01 --- /dev/null +++ b/test/testdata/parse-fail-regression-20060610.err.exp | |||
@@ -0,0 +1,6 @@ | |||
1 | error: undefined variable 'gcc' | ||
2 | at «stdin»:9:13: | ||
3 | 8| body = ({ | ||
4 | 9| inherit gcc; | ||
5 | | ^ | ||
6 | 10| }).gcc; | ||
diff --git a/test/testdata/parse-fail-regression-20060610.nix b/test/testdata/parse-fail-regression-20060610.nix new file mode 100644 index 0000000..b1934f7 --- /dev/null +++ b/test/testdata/parse-fail-regression-20060610.nix | |||
@@ -0,0 +1,11 @@ | |||
1 | let { | ||
2 | x = | ||
3 | {gcc}: | ||
4 | { | ||
5 | inherit gcc; | ||
6 | }; | ||
7 | |||
8 | body = ({ | ||
9 | inherit gcc; | ||
10 | }).gcc; | ||
11 | } | ||
diff --git a/test/testdata/parse-fail-undef-var-2.err.exp b/test/testdata/parse-fail-undef-var-2.err.exp new file mode 100644 index 0000000..96e87b2 --- /dev/null +++ b/test/testdata/parse-fail-undef-var-2.err.exp | |||
@@ -0,0 +1,6 @@ | |||
1 | error: syntax error, unexpected ':', expecting '}' or ',' | ||
2 | at «stdin»:3:13: | ||
3 | 2| | ||
4 | 3| f = {x, y : ["baz" "bar" z "bat"]}: x + y; | ||
5 | | ^ | ||
6 | 4| | ||
diff --git a/test/testdata/parse-fail-undef-var-2.nix b/test/testdata/parse-fail-undef-var-2.nix new file mode 100644 index 0000000..c10a52b --- /dev/null +++ b/test/testdata/parse-fail-undef-var-2.nix | |||
@@ -0,0 +1,7 @@ | |||
1 | let { | ||
2 | |||
3 | f = {x, y : ["baz" "bar" z "bat"]}: x + y; | ||
4 | |||
5 | body = f {x = "foo"; y = "bar";}; | ||
6 | |||
7 | } | ||
diff --git a/test/testdata/parse-fail-undef-var.err.exp b/test/testdata/parse-fail-undef-var.err.exp new file mode 100644 index 0000000..3d143d9 --- /dev/null +++ b/test/testdata/parse-fail-undef-var.err.exp | |||
@@ -0,0 +1,5 @@ | |||
1 | error: undefined variable 'y' | ||
2 | at «stdin»:1:4: | ||
3 | 1| x: y | ||
4 | | ^ | ||
5 | 2| | ||
diff --git a/test/testdata/parse-fail-undef-var.nix b/test/testdata/parse-fail-undef-var.nix new file mode 100644 index 0000000..7b63008 --- /dev/null +++ b/test/testdata/parse-fail-undef-var.nix | |||
@@ -0,0 +1 @@ | |||
x: y | |||
diff --git a/test/testdata/parse-fail-utf8.err.exp b/test/testdata/parse-fail-utf8.err.exp new file mode 100644 index 0000000..1c83f6e --- /dev/null +++ b/test/testdata/parse-fail-utf8.err.exp | |||
@@ -0,0 +1,5 @@ | |||
1 | error: syntax error, unexpected invalid token, expecting end of file | ||
2 | at «stdin»:1:5: | ||
3 | 1| 123 é 4 | ||
4 | | ^ | ||
5 | 2| | ||
diff --git a/test/testdata/parse-fail-utf8.nix b/test/testdata/parse-fail-utf8.nix new file mode 100644 index 0000000..34948d4 --- /dev/null +++ b/test/testdata/parse-fail-utf8.nix | |||
@@ -0,0 +1 @@ | |||
123 é 4 | |||
diff --git a/test/testdata/parse-okay-1.exp b/test/testdata/parse-okay-1.exp new file mode 100644 index 0000000..d5ab5f1 --- /dev/null +++ b/test/testdata/parse-okay-1.exp | |||
@@ -0,0 +1 @@ | |||
({ x, y, z }: ((x + y) + z)) | |||
diff --git a/test/testdata/parse-okay-1.nix b/test/testdata/parse-okay-1.nix new file mode 100644 index 0000000..23a58ed --- /dev/null +++ b/test/testdata/parse-okay-1.nix | |||
@@ -0,0 +1 @@ | |||
{x, y, z}: x + y + z | |||
diff --git a/test/testdata/parse-okay-crlf.exp b/test/testdata/parse-okay-crlf.exp new file mode 100644 index 0000000..4213609 --- /dev/null +++ b/test/testdata/parse-okay-crlf.exp | |||
@@ -0,0 +1 @@ | |||
rec { foo = "multi\nline\n string\n test\r"; x = y; y = 123; z = 456; } | |||
diff --git a/test/testdata/parse-okay-crlf.nix b/test/testdata/parse-okay-crlf.nix new file mode 100644 index 0000000..21518d4 --- /dev/null +++ b/test/testdata/parse-okay-crlf.nix | |||
@@ -0,0 +1,17 @@ | |||
1 | rec { | ||
2 | |||
3 | /* Dit is | ||
4 | een test. */ | ||
5 | |||
6 | x = | ||
7 | # Dit is een test. y; | ||
8 | |||
9 | y = 123; | ||
10 | |||
11 | # CR or CR/LF (but not explicit \r's) in strings should be | ||
12 | # translated to LF. | ||
13 | foo = "multi line | ||
14 | string | ||
15 | test\r"; | ||
16 | |||
17 | z = 456; } | ||
diff --git a/test/testdata/parse-okay-dup-attrs-5.exp b/test/testdata/parse-okay-dup-attrs-5.exp new file mode 100644 index 0000000..88b0b03 --- /dev/null +++ b/test/testdata/parse-okay-dup-attrs-5.exp | |||
@@ -0,0 +1 @@ | |||
{ services = { ssh = { enable = true; port = 23; }; }; } | |||
diff --git a/test/testdata/parse-okay-dup-attrs-5.nix b/test/testdata/parse-okay-dup-attrs-5.nix new file mode 100644 index 0000000..f4b9efd --- /dev/null +++ b/test/testdata/parse-okay-dup-attrs-5.nix | |||
@@ -0,0 +1,4 @@ | |||
1 | { | ||
2 | services.ssh = { enable = true; }; | ||
3 | services.ssh.port = 23; | ||
4 | } | ||
diff --git a/test/testdata/parse-okay-dup-attrs-6.exp b/test/testdata/parse-okay-dup-attrs-6.exp new file mode 100644 index 0000000..88b0b03 --- /dev/null +++ b/test/testdata/parse-okay-dup-attrs-6.exp | |||
@@ -0,0 +1 @@ | |||
{ services = { ssh = { enable = true; port = 23; }; }; } | |||
diff --git a/test/testdata/parse-okay-dup-attrs-6.nix b/test/testdata/parse-okay-dup-attrs-6.nix new file mode 100644 index 0000000..ae6d7a7 --- /dev/null +++ b/test/testdata/parse-okay-dup-attrs-6.nix | |||
@@ -0,0 +1,4 @@ | |||
1 | { | ||
2 | services.ssh.port = 23; | ||
3 | services.ssh = { enable = true; }; | ||
4 | } | ||
diff --git a/test/testdata/parse-okay-ind-string.exp b/test/testdata/parse-okay-ind-string.exp new file mode 100644 index 0000000..82e9940 --- /dev/null +++ b/test/testdata/parse-okay-ind-string.exp | |||
@@ -0,0 +1 @@ | |||
(let string = "str"; in [ (/some/path) ((/some/path)) ((/some/path)) ((/some/path + "\n end")) (string) ((string)) ((string)) ((string + "\n end")) ("") ("") ("end") ]) | |||
diff --git a/test/testdata/parse-okay-ind-string.nix b/test/testdata/parse-okay-ind-string.nix new file mode 100644 index 0000000..97c9de3 --- /dev/null +++ b/test/testdata/parse-okay-ind-string.nix | |||
@@ -0,0 +1,31 @@ | |||
1 | let | ||
2 | string = "str"; | ||
3 | in [ | ||
4 | /some/path | ||
5 | |||
6 | ''${/some/path}'' | ||
7 | |||
8 | '' | ||
9 | ${/some/path}'' | ||
10 | |||
11 | ''${/some/path} | ||
12 | end'' | ||
13 | |||
14 | string | ||
15 | |||
16 | ''${string}'' | ||
17 | |||
18 | '' | ||
19 | ${string}'' | ||
20 | |||
21 | ''${string} | ||
22 | end'' | ||
23 | |||
24 | '''' | ||
25 | |||
26 | '' | ||
27 | '' | ||
28 | |||
29 | '' | ||
30 | end'' | ||
31 | ] | ||
diff --git a/test/testdata/parse-okay-inherits.exp b/test/testdata/parse-okay-inherits.exp new file mode 100644 index 0000000..1355527 --- /dev/null +++ b/test/testdata/parse-okay-inherits.exp | |||
@@ -0,0 +1 @@ | |||
(let b = 2; c = { }; in { inherit b; inherit (c) d e; a = 1; f = 3; }) | |||
diff --git a/test/testdata/parse-okay-inherits.nix b/test/testdata/parse-okay-inherits.nix new file mode 100644 index 0000000..10596c8 --- /dev/null +++ b/test/testdata/parse-okay-inherits.nix | |||
@@ -0,0 +1,9 @@ | |||
1 | let | ||
2 | c = {}; | ||
3 | b = 2; | ||
4 | in { | ||
5 | a = 1; | ||
6 | inherit b; | ||
7 | inherit (c) d e; | ||
8 | f = 3; | ||
9 | } | ||
diff --git a/test/testdata/parse-okay-mixed-nested-attrs-1.exp b/test/testdata/parse-okay-mixed-nested-attrs-1.exp new file mode 100644 index 0000000..89c66f7 --- /dev/null +++ b/test/testdata/parse-okay-mixed-nested-attrs-1.exp | |||
@@ -0,0 +1 @@ | |||
{ x = { q = 3; y = 3; z = 3; }; } | |||
diff --git a/test/testdata/parse-okay-mixed-nested-attrs-1.nix b/test/testdata/parse-okay-mixed-nested-attrs-1.nix new file mode 100644 index 0000000..fd1001c --- /dev/null +++ b/test/testdata/parse-okay-mixed-nested-attrs-1.nix | |||
@@ -0,0 +1,4 @@ | |||
1 | { | ||
2 | x = { y = 3; z = 3; }; | ||
3 | x.q = 3; | ||
4 | } | ||
diff --git a/test/testdata/parse-okay-mixed-nested-attrs-2.exp b/test/testdata/parse-okay-mixed-nested-attrs-2.exp new file mode 100644 index 0000000..89c66f7 --- /dev/null +++ b/test/testdata/parse-okay-mixed-nested-attrs-2.exp | |||
@@ -0,0 +1 @@ | |||
{ x = { q = 3; y = 3; z = 3; }; } | |||
diff --git a/test/testdata/parse-okay-mixed-nested-attrs-2.nix b/test/testdata/parse-okay-mixed-nested-attrs-2.nix new file mode 100644 index 0000000..ad066b6 --- /dev/null +++ b/test/testdata/parse-okay-mixed-nested-attrs-2.nix | |||
@@ -0,0 +1,4 @@ | |||
1 | { | ||
2 | x.q = 3; | ||
3 | x = { y = 3; z = 3; }; | ||
4 | } | ||
diff --git a/test/testdata/parse-okay-mixed-nested-attrs-3.exp b/test/testdata/parse-okay-mixed-nested-attrs-3.exp new file mode 100644 index 0000000..b89a597 --- /dev/null +++ b/test/testdata/parse-okay-mixed-nested-attrs-3.exp | |||
@@ -0,0 +1 @@ | |||
{ services = { httpd = { enable = true; }; ssh = { enable = true; port = 123; }; }; } | |||
diff --git a/test/testdata/parse-okay-mixed-nested-attrs-3.nix b/test/testdata/parse-okay-mixed-nested-attrs-3.nix new file mode 100644 index 0000000..45a33e4 --- /dev/null +++ b/test/testdata/parse-okay-mixed-nested-attrs-3.nix | |||
@@ -0,0 +1,7 @@ | |||
1 | { | ||
2 | services.ssh.enable = true; | ||
3 | services.ssh = { port = 123; }; | ||
4 | services = { | ||
5 | httpd.enable = true; | ||
6 | }; | ||
7 | } | ||
diff --git a/test/testdata/parse-okay-regression-20041027.exp b/test/testdata/parse-okay-regression-20041027.exp new file mode 100644 index 0000000..9df7219 --- /dev/null +++ b/test/testdata/parse-okay-regression-20041027.exp | |||
@@ -0,0 +1 @@ | |||
({ fetchurl, stdenv }: ((stdenv).mkDerivation { name = "libXi-6.0.1"; src = (fetchurl { md5 = "7e935a42428d63a387b3c048be0f2756"; url = "http://freedesktop.org/~xlibs/release/libXi-6.0.1.tar.bz2"; }); })) | |||
diff --git a/test/testdata/parse-okay-regression-20041027.nix b/test/testdata/parse-okay-regression-20041027.nix new file mode 100644 index 0000000..ae2e256 --- /dev/null +++ b/test/testdata/parse-okay-regression-20041027.nix | |||
@@ -0,0 +1,11 @@ | |||
1 | {stdenv, fetchurl /* pkgconfig, libX11 */ }: | ||
2 | |||
3 | stdenv.mkDerivation { | ||
4 | name = "libXi-6.0.1"; | ||
5 | src = fetchurl { | ||
6 | url = http://freedesktop.org/~xlibs/release/libXi-6.0.1.tar.bz2; | ||
7 | md5 = "7e935a42428d63a387b3c048be0f2756"; | ||
8 | }; | ||
9 | /* buildInputs = [pkgconfig]; | ||
10 | propagatedBuildInputs = [libX11]; */ | ||
11 | } | ||
diff --git a/test/testdata/parse-okay-regression-751.exp b/test/testdata/parse-okay-regression-751.exp new file mode 100644 index 0000000..e2ed886 --- /dev/null +++ b/test/testdata/parse-okay-regression-751.exp | |||
@@ -0,0 +1 @@ | |||
(let const = (a: "const"); in ((const { x = "q"; }))) | |||
diff --git a/test/testdata/parse-okay-regression-751.nix b/test/testdata/parse-okay-regression-751.nix new file mode 100644 index 0000000..05c78b3 --- /dev/null +++ b/test/testdata/parse-okay-regression-751.nix | |||
@@ -0,0 +1,2 @@ | |||
1 | let const = a: "const"; in | ||
2 | ''${ const { x = "q"; }}'' | ||
diff --git a/test/testdata/parse-okay-subversion.exp b/test/testdata/parse-okay-subversion.exp new file mode 100644 index 0000000..32fbba3 --- /dev/null +++ b/test/testdata/parse-okay-subversion.exp | |||
@@ -0,0 +1 @@ | |||
({ db4 ? null, expat, fetchurl, httpServer ? false, httpd ? null, j2sdk ? null, javaSwigBindings ? false, javahlBindings ? false, localServer ? false, openssl ? null, pythonBindings ? false, sslSupport ? false, stdenv, swig ? null }: assert (expat != null); assert (localServer -> (db4 != null)); assert (httpServer -> ((httpd != null) && ((httpd).expat == expat))); assert (sslSupport -> ((openssl != null) && (httpServer -> ((httpd).openssl == openssl)))); assert (pythonBindings -> ((swig != null) && (swig).pythonSupport)); assert (javaSwigBindings -> ((swig != null) && (swig).javaSupport)); assert (javahlBindings -> (j2sdk != null)); ((stdenv).mkDerivation { inherit expat httpServer javaSwigBindings javahlBindings localServer pythonBindings sslSupport; builder = /foo/bar; db4 = (if localServer then db4 else null); httpd = (if httpServer then httpd else null); j2sdk = (if javaSwigBindings then (swig).j2sdk else (if javahlBindings then j2sdk else null)); name = "subversion-1.1.1"; openssl = (if sslSupport then openssl else null); patches = (if javahlBindings then [ (/javahl.patch) ] else [ ]); python = (if pythonBindings then (swig).python else null); src = (fetchurl { md5 = "a180c3fe91680389c210c99def54d9e0"; url = "http://subversion.tigris.org/tarballs/subversion-1.1.1.tar.bz2"; }); swig = (if (pythonBindings || javaSwigBindings) then swig else null); })) | |||
diff --git a/test/testdata/parse-okay-subversion.nix b/test/testdata/parse-okay-subversion.nix new file mode 100644 index 0000000..3562728 --- /dev/null +++ b/test/testdata/parse-okay-subversion.nix | |||
@@ -0,0 +1,43 @@ | |||
1 | { localServer ? false | ||
2 | , httpServer ? false | ||
3 | , sslSupport ? false | ||
4 | , pythonBindings ? false | ||
5 | , javaSwigBindings ? false | ||
6 | , javahlBindings ? false | ||
7 | , stdenv, fetchurl | ||
8 | , openssl ? null, httpd ? null, db4 ? null, expat, swig ? null, j2sdk ? null | ||
9 | }: | ||
10 | |||
11 | assert expat != null; | ||
12 | assert localServer -> db4 != null; | ||
13 | assert httpServer -> httpd != null && httpd.expat == expat; | ||
14 | assert sslSupport -> openssl != null && (httpServer -> httpd.openssl == openssl); | ||
15 | assert pythonBindings -> swig != null && swig.pythonSupport; | ||
16 | assert javaSwigBindings -> swig != null && swig.javaSupport; | ||
17 | assert javahlBindings -> j2sdk != null; | ||
18 | |||
19 | stdenv.mkDerivation { | ||
20 | name = "subversion-1.1.1"; | ||
21 | |||
22 | builder = /foo/bar; | ||
23 | src = fetchurl { | ||
24 | url = http://subversion.tigris.org/tarballs/subversion-1.1.1.tar.bz2; | ||
25 | md5 = "a180c3fe91680389c210c99def54d9e0"; | ||
26 | }; | ||
27 | |||
28 | # This is a hopefully temporary fix for the problem that | ||
29 | # libsvnjavahl.so isn't linked against libstdc++, which causes | ||
30 | # loading the library into the JVM to fail. | ||
31 | patches = if javahlBindings then [/javahl.patch] else []; | ||
32 | |||
33 | openssl = if sslSupport then openssl else null; | ||
34 | httpd = if httpServer then httpd else null; | ||
35 | db4 = if localServer then db4 else null; | ||
36 | swig = if pythonBindings || javaSwigBindings then swig else null; | ||
37 | python = if pythonBindings then swig.python else null; | ||
38 | j2sdk = if javaSwigBindings then swig.j2sdk else | ||
39 | if javahlBindings then j2sdk else null; | ||
40 | |||
41 | inherit expat localServer httpServer sslSupport | ||
42 | pythonBindings javaSwigBindings javahlBindings; | ||
43 | } | ||
diff --git a/test/testdata/parse-okay-url.exp b/test/testdata/parse-okay-url.exp new file mode 100644 index 0000000..e5f0829 --- /dev/null +++ b/test/testdata/parse-okay-url.exp | |||
@@ -0,0 +1 @@ | |||
[ ("x:x") ("https://svn.cs.uu.nl:12443/repos/trace/trunk") ("http://www2.mplayerhq.hu/MPlayer/releases/fonts/font-arial-iso-8859-1.tar.bz2") ("http://losser.st-lab.cs.uu.nl/~armijn/.nix/gcc-3.3.4-static-nix.tar.gz") ("http://fpdownload.macromedia.com/get/shockwave/flash/english/linux/7.0r25/install_flash_player_7_linux.tar.gz") ("https://ftp5.gwdg.de/pub/linux/archlinux/extra/os/x86_64/unzip-6.0-14-x86_64.pkg.tar.zst") ("ftp://ftp.gtk.org/pub/gtk/v1.2/gtk+-1.2.10.tar.gz") ] | |||
diff --git a/test/testdata/parse-okay-url.nix b/test/testdata/parse-okay-url.nix new file mode 100644 index 0000000..08de27d --- /dev/null +++ b/test/testdata/parse-okay-url.nix | |||
@@ -0,0 +1,8 @@ | |||
1 | [ x:x | ||
2 | https://svn.cs.uu.nl:12443/repos/trace/trunk | ||
3 | http://www2.mplayerhq.hu/MPlayer/releases/fonts/font-arial-iso-8859-1.tar.bz2 | ||
4 | http://losser.st-lab.cs.uu.nl/~armijn/.nix/gcc-3.3.4-static-nix.tar.gz | ||
5 | http://fpdownload.macromedia.com/get/shockwave/flash/english/linux/7.0r25/install_flash_player_7_linux.tar.gz | ||
6 | https://ftp5.gwdg.de/pub/linux/archlinux/extra/os/x86_64/unzip-6.0-14-x86_64.pkg.tar.zst | ||
7 | ftp://ftp.gtk.org/pub/gtk/v1.2/gtk+-1.2.10.tar.gz | ||
8 | ] | ||
diff --git a/test/testdata/readDir/bar b/test/testdata/readDir/bar new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/testdata/readDir/bar | |||
diff --git a/test/testdata/readDir/foo/git-hates-directories b/test/testdata/readDir/foo/git-hates-directories new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/testdata/readDir/foo/git-hates-directories | |||
diff --git a/test/testdata/readDir/ldir b/test/testdata/readDir/ldir new file mode 120000 index 0000000..1910281 --- /dev/null +++ b/test/testdata/readDir/ldir | |||
@@ -0,0 +1 @@ | |||
foo \ No newline at end of file | |||
diff --git a/test/testdata/readDir/linked b/test/testdata/readDir/linked new file mode 120000 index 0000000..c503f86 --- /dev/null +++ b/test/testdata/readDir/linked | |||
@@ -0,0 +1 @@ | |||
foo/git-hates-directories \ No newline at end of file | |||
diff --git a/test/testdata/symlink-resolution/broken b/test/testdata/symlink-resolution/broken new file mode 120000 index 0000000..e07da69 --- /dev/null +++ b/test/testdata/symlink-resolution/broken | |||
@@ -0,0 +1 @@ | |||
nonexistent \ No newline at end of file | |||
diff --git a/test/testdata/symlink-resolution/foo/lib/default.nix b/test/testdata/symlink-resolution/foo/lib/default.nix new file mode 100644 index 0000000..8b8441b --- /dev/null +++ b/test/testdata/symlink-resolution/foo/lib/default.nix | |||
@@ -0,0 +1 @@ | |||
"test" | |||
diff --git a/test/testdata/symlink-resolution/foo/overlays b/test/testdata/symlink-resolution/foo/overlays new file mode 120000 index 0000000..0d44a21 --- /dev/null +++ b/test/testdata/symlink-resolution/foo/overlays | |||
@@ -0,0 +1 @@ | |||
../overlays \ No newline at end of file | |||
diff --git a/test/testdata/symlink-resolution/overlays/overlay.nix b/test/testdata/symlink-resolution/overlays/overlay.nix new file mode 100644 index 0000000..b036830 --- /dev/null +++ b/test/testdata/symlink-resolution/overlays/overlay.nix | |||
@@ -0,0 +1 @@ | |||
import ../lib | |||