feat(tvix/tests): check in Nix' language test suite
This adds scaffolding code for running the Nix language test suite. The majority of eval-okay-* tests should eventually be runnable as-is by Tvix, however the eval-fail-* tests might not as we intend to have more useful error messages than upstream Nix. Change-Id: I4f3227f0889c55e4274b804a3072850fb78dd1bd Reviewed-on: https://cl.tvl.fyi/c/depot/+/6126 Tested-by: BuildkiteCI Autosubmit: tazjin <tazjin@tvl.su> Reviewed-by: grfn <grfn@gws.fyi>
This commit is contained in:
parent
b28da8ad56
commit
92c53fe982
248 changed files with 2217 additions and 9 deletions
|
@ -23,8 +23,7 @@ let
|
|||
command = "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt"
|
||||
includes = [ "*.nix" ]
|
||||
excludes = [
|
||||
"third_party/nix/tests/*",
|
||||
"third_party/nix/src/tests/*"
|
||||
"tvix/eval/src/tests/*",
|
||||
]
|
||||
|
||||
[formatter.rust]
|
||||
|
|
2
tvix/eval/.skip-subtree
Normal file
2
tvix/eval/.skip-subtree
Normal file
|
@ -0,0 +1,2 @@
|
|||
Do not traverse further, readTree will encounter Nix language tests
|
||||
and such and fail.
|
|
@ -1,9 +1,9 @@
|
|||
use rnix::{self, types::TypedNode};
|
||||
|
||||
use crate::errors::EvalResult;
|
||||
use crate::{errors::EvalResult, value::Value};
|
||||
|
||||
pub fn interpret(code: String) -> EvalResult<String> {
|
||||
let ast = rnix::parse(&code);
|
||||
pub fn interpret(code: &str) -> EvalResult<Value> {
|
||||
let ast = rnix::parse(code);
|
||||
|
||||
let errors = ast.errors();
|
||||
if !errors.is_empty() {
|
||||
|
@ -15,6 +15,5 @@ pub fn interpret(code: String) -> EvalResult<String> {
|
|||
let code = crate::compiler::compile(ast)?;
|
||||
println!("code: {:?}", code);
|
||||
|
||||
let value = crate::vm::run_chunk(code)?;
|
||||
Ok(format!("value: {} :: {}", value, value.type_of()))
|
||||
crate::vm::run_chunk(code)
|
||||
}
|
||||
|
|
|
@ -12,6 +12,9 @@ mod opcode;
|
|||
mod value;
|
||||
mod vm;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
fn main() {
|
||||
let mut args = env::args();
|
||||
if args.len() > 2 {
|
||||
|
@ -47,8 +50,8 @@ fn run_prompt() {
|
|||
}
|
||||
|
||||
fn run(code: String) {
|
||||
match eval::interpret(code) {
|
||||
Ok(result) => println!("=> {}", result),
|
||||
match eval::interpret(&code) {
|
||||
Ok(result) => println!("=> {} :: {}", result, result.type_of()),
|
||||
Err(err) => eprintln!("{}", err),
|
||||
}
|
||||
}
|
||||
|
|
28
tvix/eval/src/tests/mod.rs
Normal file
28
tvix/eval/src/tests/mod.rs
Normal file
|
@ -0,0 +1,28 @@
|
|||
use crate::eval::interpret;
|
||||
|
||||
use test_generator::test_resources;
|
||||
|
||||
// eval-okay-* tests contain a snippet of Nix code, and an expectation
|
||||
// of the produced string output of the evaluator.
|
||||
//
|
||||
// These evaluations are always supposed to succeed, i.e. all snippets
|
||||
// are guaranteed to be valid Nix code.
|
||||
#[test_resources("src/tests/nix_tests/eval-okay-*.nix")]
|
||||
fn eval_okay(code_path: &str) {
|
||||
let base = code_path
|
||||
.strip_suffix("nix")
|
||||
.expect("test files always end in .nix");
|
||||
let exp_path = format!("{}exp", base);
|
||||
|
||||
let code = std::fs::read_to_string(code_path).expect("should be able to read test code");
|
||||
let exp = std::fs::read_to_string(exp_path).expect("should be able to read test expectation");
|
||||
|
||||
let result = interpret(&code).expect("evaluation of eval-okay test should succeed");
|
||||
let result_str = format!("{}", result);
|
||||
|
||||
assert_eq!(
|
||||
exp.trim(),
|
||||
result_str,
|
||||
"result value (and its representation) must match expectation"
|
||||
);
|
||||
}
|
8
tvix/eval/src/tests/nix_tests/README.md
Normal file
8
tvix/eval/src/tests/nix_tests/README.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
These test definitions are taken from the Nix 2.3 code base, they can
|
||||
be found upstream at:
|
||||
|
||||
https://github.com/NixOS/nix/tree/2.3.16/tests/lang
|
||||
|
||||
These tests follow the licensing directions of Nix 2.3 itself:
|
||||
|
||||
https://github.com/NixOS/nix/blob/2.3.16/COPYING
|
BIN
tvix/eval/src/tests/nix_tests/binary-data
Normal file
BIN
tvix/eval/src/tests/nix_tests/binary-data
Normal file
Binary file not shown.
1
tvix/eval/src/tests/nix_tests/data
Normal file
1
tvix/eval/src/tests/nix_tests/data
Normal file
|
@ -0,0 +1 @@
|
|||
foo
|
1
tvix/eval/src/tests/nix_tests/dir1/a.nix
Normal file
1
tvix/eval/src/tests/nix_tests/dir1/a.nix
Normal file
|
@ -0,0 +1 @@
|
|||
"a"
|
1
tvix/eval/src/tests/nix_tests/dir2/a.nix
Normal file
1
tvix/eval/src/tests/nix_tests/dir2/a.nix
Normal file
|
@ -0,0 +1 @@
|
|||
"X"
|
1
tvix/eval/src/tests/nix_tests/dir2/b.nix
Normal file
1
tvix/eval/src/tests/nix_tests/dir2/b.nix
Normal file
|
@ -0,0 +1 @@
|
|||
"b"
|
1
tvix/eval/src/tests/nix_tests/dir3/a.nix
Normal file
1
tvix/eval/src/tests/nix_tests/dir3/a.nix
Normal file
|
@ -0,0 +1 @@
|
|||
"X"
|
1
tvix/eval/src/tests/nix_tests/dir3/b.nix
Normal file
1
tvix/eval/src/tests/nix_tests/dir3/b.nix
Normal file
|
@ -0,0 +1 @@
|
|||
"X"
|
1
tvix/eval/src/tests/nix_tests/dir3/c.nix
Normal file
1
tvix/eval/src/tests/nix_tests/dir3/c.nix
Normal file
|
@ -0,0 +1 @@
|
|||
"c"
|
1
tvix/eval/src/tests/nix_tests/dir4/a.nix
Normal file
1
tvix/eval/src/tests/nix_tests/dir4/a.nix
Normal file
|
@ -0,0 +1 @@
|
|||
"X"
|
1
tvix/eval/src/tests/nix_tests/dir4/c.nix
Normal file
1
tvix/eval/src/tests/nix_tests/dir4/c.nix
Normal file
|
@ -0,0 +1 @@
|
|||
"X"
|
1
tvix/eval/src/tests/nix_tests/eval-fail-abort.nix
Normal file
1
tvix/eval/src/tests/nix_tests/eval-fail-abort.nix
Normal file
|
@ -0,0 +1 @@
|
|||
if true then abort "this should fail" else 1
|
|
@ -0,0 +1,4 @@
|
|||
# This must fail to evaluate, since ./fnord doesn't exist. If it did
|
||||
# exist, it would produce "/nix/store/<hash>-fnord/xyzzy" (with an
|
||||
# appropriate context).
|
||||
"${./fnord}/xyzzy"
|
5
tvix/eval/src/tests/nix_tests/eval-fail-assert.nix
Normal file
5
tvix/eval/src/tests/nix_tests/eval-fail-assert.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
let {
|
||||
x = arg: assert arg == "y"; 123;
|
||||
|
||||
body = x "x";
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
"${x: x}"
|
|
@ -0,0 +1 @@
|
|||
"${./fnord}"
|
|
@ -0,0 +1 @@
|
|||
''${x: x}''
|
5
tvix/eval/src/tests/nix_tests/eval-fail-blackhole.nix
Normal file
5
tvix/eval/src/tests/nix_tests/eval-fail-blackhole.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
let {
|
||||
body = x;
|
||||
x = y;
|
||||
y = x;
|
||||
}
|
1
tvix/eval/src/tests/nix_tests/eval-fail-deepseq.nix
Normal file
1
tvix/eval/src/tests/nix_tests/eval-fail-deepseq.nix
Normal file
|
@ -0,0 +1 @@
|
|||
builtins.deepSeq { x = abort "foo"; } 456
|
|
@ -0,0 +1,5 @@
|
|||
let
|
||||
paths = [ ./this-file-is-definitely-not-there-7392097 "/and/neither/is/this/37293620" ];
|
||||
in
|
||||
toString (builtins.concatLists (map (hash: map (builtins.hashFile hash) paths) ["md5" "sha1" "sha256" "sha512"]))
|
||||
|
1
tvix/eval/src/tests/nix_tests/eval-fail-missing-arg.nix
Normal file
1
tvix/eval/src/tests/nix_tests/eval-fail-missing-arg.nix
Normal file
|
@ -0,0 +1 @@
|
|||
({x, y, z}: x + y + z) {x = "foo"; z = "bar";}
|
6
tvix/eval/src/tests/nix_tests/eval-fail-path-slash.nix
Normal file
6
tvix/eval/src/tests/nix_tests/eval-fail-path-slash.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
# Trailing slashes in paths are not allowed.
|
||||
# This restriction could be lifted sometime,
|
||||
# for example if we make '/' a path concatenation operator.
|
||||
# See https://github.com/NixOS/nix/issues/1138
|
||||
# and https://nixos.org/nix-dev/2016-June/020829.html
|
||||
/nix/store/
|
5
tvix/eval/src/tests/nix_tests/eval-fail-remove.nix
Normal file
5
tvix/eval/src/tests/nix_tests/eval-fail-remove.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
let {
|
||||
attrs = {x = 123; y = 456;};
|
||||
|
||||
body = (removeAttrs attrs ["x"]).x;
|
||||
}
|
10
tvix/eval/src/tests/nix_tests/eval-fail-scope-5.nix
Normal file
10
tvix/eval/src/tests/nix_tests/eval-fail-scope-5.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
let {
|
||||
|
||||
x = "a";
|
||||
y = "b";
|
||||
|
||||
f = {x ? y, y ? x}: x + y;
|
||||
|
||||
body = f {};
|
||||
|
||||
}
|
1
tvix/eval/src/tests/nix_tests/eval-fail-seq.nix
Normal file
1
tvix/eval/src/tests/nix_tests/eval-fail-seq.nix
Normal file
|
@ -0,0 +1 @@
|
|||
builtins.seq (abort "foo") 2
|
1
tvix/eval/src/tests/nix_tests/eval-fail-substring.nix
Normal file
1
tvix/eval/src/tests/nix_tests/eval-fail-substring.nix
Normal file
|
@ -0,0 +1 @@
|
|||
builtins.substring (builtins.sub 0 1) 1 "x"
|
1
tvix/eval/src/tests/nix_tests/eval-fail-to-path.nix
Normal file
1
tvix/eval/src/tests/nix_tests/eval-fail-to-path.nix
Normal file
|
@ -0,0 +1 @@
|
|||
builtins.toPath "foo/bar"
|
|
@ -0,0 +1 @@
|
|||
({x, z}: x + z) {x = "foo"; y = "bla"; z = "bar";}
|
1
tvix/eval/src/tests/nix_tests/eval-okay-any-all.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-any-all.exp
Normal file
|
@ -0,0 +1 @@
|
|||
[ false false true true true true false true ]
|
11
tvix/eval/src/tests/nix_tests/eval-okay-any-all.nix
Normal file
11
tvix/eval/src/tests/nix_tests/eval-okay-any-all.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
with builtins;
|
||||
|
||||
[ (any (x: x == 1) [])
|
||||
(any (x: x == 1) [2 3 4])
|
||||
(any (x: x == 1) [1 2 3 4])
|
||||
(any (x: x == 1) [4 3 2 1])
|
||||
(all (x: x == 1) [])
|
||||
(all (x: x == 1) [1])
|
||||
(all (x: x == 1) [1 2 3])
|
||||
(all (x: x == 1) [1 1 1])
|
||||
]
|
1
tvix/eval/src/tests/nix_tests/eval-okay-arithmetic.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-arithmetic.exp
Normal file
|
@ -0,0 +1 @@
|
|||
2216
|
59
tvix/eval/src/tests/nix_tests/eval-okay-arithmetic.nix
Normal file
59
tvix/eval/src/tests/nix_tests/eval-okay-arithmetic.nix
Normal file
|
@ -0,0 +1,59 @@
|
|||
with import ./lib.nix;
|
||||
|
||||
let {
|
||||
|
||||
/* Supposedly tail recursive version:
|
||||
|
||||
range_ = accum: first: last:
|
||||
if first == last then ([first] ++ accum)
|
||||
else range_ ([first] ++ accum) (builtins.add first 1) last;
|
||||
|
||||
range = range_ [];
|
||||
*/
|
||||
|
||||
x = 12;
|
||||
|
||||
err = abort "urgh";
|
||||
|
||||
body = sum
|
||||
[ (sum (range 1 50))
|
||||
(123 + 456)
|
||||
(0 + -10 + -(-11) + -x)
|
||||
(10 - 7 - -2)
|
||||
(10 - (6 - -1))
|
||||
(10 - 1 + 2)
|
||||
(3 * 4 * 5)
|
||||
(56088 / 123 / 2)
|
||||
(3 + 4 * const 5 0 - 6 / id 2)
|
||||
|
||||
(builtins.bitAnd 12 10) # 0b1100 & 0b1010 = 8
|
||||
(builtins.bitOr 12 10) # 0b1100 | 0b1010 = 14
|
||||
(builtins.bitXor 12 10) # 0b1100 ^ 0b1010 = 6
|
||||
|
||||
(if 3 < 7 then 1 else err)
|
||||
(if 7 < 3 then err else 1)
|
||||
(if 3 < 3 then err else 1)
|
||||
|
||||
(if 3 <= 7 then 1 else err)
|
||||
(if 7 <= 3 then err else 1)
|
||||
(if 3 <= 3 then 1 else err)
|
||||
|
||||
(if 3 > 7 then err else 1)
|
||||
(if 7 > 3 then 1 else err)
|
||||
(if 3 > 3 then err else 1)
|
||||
|
||||
(if 3 >= 7 then err else 1)
|
||||
(if 7 >= 3 then 1 else err)
|
||||
(if 3 >= 3 then 1 else err)
|
||||
|
||||
(if 2 > 1 == 1 < 2 then 1 else err)
|
||||
(if 1 + 2 * 3 >= 7 then 1 else err)
|
||||
(if 1 + 2 * 3 < 7 then err else 1)
|
||||
|
||||
# Not integer, but so what.
|
||||
(if "aa" < "ab" then 1 else err)
|
||||
(if "aa" < "aa" then err else 1)
|
||||
(if "foo" < "foobar" then 1 else err)
|
||||
];
|
||||
|
||||
}
|
1
tvix/eval/src/tests/nix_tests/eval-okay-attrnames.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-attrnames.exp
Normal file
|
@ -0,0 +1 @@
|
|||
"newxfoonewxy"
|
11
tvix/eval/src/tests/nix_tests/eval-okay-attrnames.nix
Normal file
11
tvix/eval/src/tests/nix_tests/eval-okay-attrnames.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
with import ./lib.nix;
|
||||
|
||||
let
|
||||
|
||||
attrs = {y = "y"; x = "x"; foo = "foo";} // rec {x = "newx"; bar = x;};
|
||||
|
||||
names = builtins.attrNames attrs;
|
||||
|
||||
values = map (name: builtins.getAttr name attrs) names;
|
||||
|
||||
in assert values == builtins.attrValues attrs; concat values
|
1
tvix/eval/src/tests/nix_tests/eval-okay-attrs.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-attrs.exp
Normal file
|
@ -0,0 +1 @@
|
|||
987
|
5
tvix/eval/src/tests/nix_tests/eval-okay-attrs.nix
Normal file
5
tvix/eval/src/tests/nix_tests/eval-okay-attrs.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
let {
|
||||
as = { x = 123; y = 456; } // { z = 789; } // { z = 987; };
|
||||
|
||||
body = if as ? a then as.a else assert as ? z; as.z;
|
||||
}
|
1
tvix/eval/src/tests/nix_tests/eval-okay-attrs2.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-attrs2.exp
Normal file
|
@ -0,0 +1 @@
|
|||
987
|
10
tvix/eval/src/tests/nix_tests/eval-okay-attrs2.nix
Normal file
10
tvix/eval/src/tests/nix_tests/eval-okay-attrs2.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
let {
|
||||
as = { x = 123; y = 456; } // { z = 789; } // { z = 987; };
|
||||
|
||||
A = "a";
|
||||
Z = "z";
|
||||
|
||||
body = if builtins.hasAttr A as
|
||||
then builtins.getAttr A as
|
||||
else assert builtins.hasAttr Z as; builtins.getAttr Z as;
|
||||
}
|
1
tvix/eval/src/tests/nix_tests/eval-okay-attrs3.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-attrs3.exp
Normal file
|
@ -0,0 +1 @@
|
|||
"foo 22 80 itchyxac"
|
22
tvix/eval/src/tests/nix_tests/eval-okay-attrs3.nix
Normal file
22
tvix/eval/src/tests/nix_tests/eval-okay-attrs3.nix
Normal file
|
@ -0,0 +1,22 @@
|
|||
let
|
||||
|
||||
config =
|
||||
{
|
||||
services.sshd.enable = true;
|
||||
services.sshd.port = 22;
|
||||
services.httpd.port = 80;
|
||||
hostName = "itchy";
|
||||
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";
|
||||
foo = {
|
||||
a = "a";
|
||||
b.c = "c";
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
if config.services.sshd.enable
|
||||
then "foo ${toString config.services.sshd.port} ${toString config.services.httpd.port} ${config.hostName}"
|
||||
+ "${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}"
|
||||
+ "${config.foo.a}"
|
||||
+ "${config.foo.b.c}"
|
||||
else "bar"
|
1
tvix/eval/src/tests/nix_tests/eval-okay-attrs4.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-attrs4.exp
Normal file
|
@ -0,0 +1 @@
|
|||
[ true false true false false true false false ]
|
7
tvix/eval/src/tests/nix_tests/eval-okay-attrs4.nix
Normal file
7
tvix/eval/src/tests/nix_tests/eval-okay-attrs4.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
let
|
||||
|
||||
as = { x.y.z = 123; a.b.c = 456; };
|
||||
|
||||
bs = null;
|
||||
|
||||
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) ]
|
1
tvix/eval/src/tests/nix_tests/eval-okay-attrs5.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-attrs5.exp
Normal file
|
@ -0,0 +1 @@
|
|||
[ 123 "foo" 456 456 "foo" "xyzzy" "xyzzy" true ]
|
21
tvix/eval/src/tests/nix_tests/eval-okay-attrs5.nix
Normal file
21
tvix/eval/src/tests/nix_tests/eval-okay-attrs5.nix
Normal file
|
@ -0,0 +1,21 @@
|
|||
with import ./lib.nix;
|
||||
|
||||
let
|
||||
|
||||
as = { x.y.z = 123; a.b.c = 456; };
|
||||
|
||||
bs = { f-o-o.bar = "foo"; };
|
||||
|
||||
or = x: y: x || y;
|
||||
|
||||
in
|
||||
[ as.x.y.z
|
||||
as.foo or "foo"
|
||||
as.x.y.bla or as.a.b.c
|
||||
as.a.b.c or as.x.y.z
|
||||
as.x.y.bla or bs.f-o-o.bar or "xyzzy"
|
||||
as.x.y.bla or bs.bar.foo or "xyzzy"
|
||||
(123).bla or null.foo or "xyzzy"
|
||||
# Backwards compatibility test.
|
||||
(fold or [] [true false false])
|
||||
]
|
1
tvix/eval/src/tests/nix_tests/eval-okay-attrs6.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-attrs6.exp
Normal file
|
@ -0,0 +1 @@
|
|||
{ __overrides = { bar = "qux"; }; bar = "qux"; foo = "bar"; }
|
4
tvix/eval/src/tests/nix_tests/eval-okay-attrs6.nix
Normal file
4
tvix/eval/src/tests/nix_tests/eval-okay-attrs6.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
rec {
|
||||
"${"foo"}" = "bar";
|
||||
__overrides = { bar = "qux"; };
|
||||
}
|
1
tvix/eval/src/tests/nix_tests/eval-okay-autoargs.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-autoargs.exp
Normal file
|
@ -0,0 +1 @@
|
|||
"xyzzy!xyzzy!foobar"
|
1
tvix/eval/src/tests/nix_tests/eval-okay-autoargs.flags
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-autoargs.flags
Normal file
|
@ -0,0 +1 @@
|
|||
--arg lib import(lang/lib.nix) --argstr xyzzy xyzzy! -A result
|
15
tvix/eval/src/tests/nix_tests/eval-okay-autoargs.nix
Normal file
15
tvix/eval/src/tests/nix_tests/eval-okay-autoargs.nix
Normal file
|
@ -0,0 +1,15 @@
|
|||
let
|
||||
|
||||
foobar = "foobar";
|
||||
|
||||
in
|
||||
|
||||
{ xyzzy2 ? xyzzy # mutually recursive args
|
||||
, xyzzy ? "blaat" # will be overridden by --argstr
|
||||
, fb ? foobar
|
||||
, lib # will be set by --arg
|
||||
}:
|
||||
|
||||
{
|
||||
result = lib.concat [xyzzy xyzzy2 fb];
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
"a\nb"
|
|
@ -0,0 +1,2 @@
|
|||
"a\
|
||||
b"
|
|
@ -0,0 +1 @@
|
|||
"a\nb"
|
|
@ -0,0 +1,2 @@
|
|||
''a''\
|
||||
b''
|
1
tvix/eval/src/tests/nix_tests/eval-okay-builtins-add.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-builtins-add.exp
Normal file
|
@ -0,0 +1 @@
|
|||
[ 5 4 "int" "tt" "float" 4 ]
|
8
tvix/eval/src/tests/nix_tests/eval-okay-builtins-add.nix
Normal file
8
tvix/eval/src/tests/nix_tests/eval-okay-builtins-add.nix
Normal file
|
@ -0,0 +1,8 @@
|
|||
[
|
||||
(builtins.add 2 3)
|
||||
(builtins.add 2 2)
|
||||
(builtins.typeOf (builtins.add 2 2))
|
||||
("t" + "t")
|
||||
(builtins.typeOf (builtins.add 2.0 2))
|
||||
(builtins.add 2.0 2)
|
||||
]
|
1
tvix/eval/src/tests/nix_tests/eval-okay-builtins.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-builtins.exp
Normal file
|
@ -0,0 +1 @@
|
|||
/foo
|
12
tvix/eval/src/tests/nix_tests/eval-okay-builtins.nix
Normal file
12
tvix/eval/src/tests/nix_tests/eval-okay-builtins.nix
Normal file
|
@ -0,0 +1,12 @@
|
|||
assert builtins ? currentSystem;
|
||||
assert !builtins ? __currentSystem;
|
||||
|
||||
let {
|
||||
|
||||
x = if builtins ? dirOf then builtins.dirOf /foo/bar else "";
|
||||
|
||||
y = if builtins ? fnord then builtins.fnord "foo" else "";
|
||||
|
||||
body = x + y;
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
true
|
|
@ -0,0 +1 @@
|
|||
({ __functor = self: x: self.foo && x; foo = false; } // { foo = true; }) true
|
1
tvix/eval/src/tests/nix_tests/eval-okay-catattrs.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-catattrs.exp
Normal file
|
@ -0,0 +1 @@
|
|||
[ 1 2 ]
|
1
tvix/eval/src/tests/nix_tests/eval-okay-catattrs.nix
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-catattrs.nix
Normal file
|
@ -0,0 +1 @@
|
|||
builtins.catAttrs "a" [ { a = 1; } { b = 0; } { a = 2; } ]
|
343
tvix/eval/src/tests/nix_tests/eval-okay-closure.exp.xml
Normal file
343
tvix/eval/src/tests/nix_tests/eval-okay-closure.exp.xml
Normal file
|
@ -0,0 +1,343 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<expr>
|
||||
<list>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="-13" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="-12" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="-11" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="-9" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="-8" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="-7" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="-5" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="-4" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="-3" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="key">
|
||||
<int value="-1" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="0" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="1" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="2" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="4" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="5" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="6" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="key">
|
||||
<int value="8" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="9" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="10" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="13" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="14" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="15" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="key">
|
||||
<int value="17" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="18" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="19" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="22" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="23" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="key">
|
||||
<int value="26" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="27" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="28" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="31" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="32" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="key">
|
||||
<int value="35" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="36" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="40" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="41" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="key">
|
||||
<int value="44" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="45" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="49" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="key">
|
||||
<int value="53" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="54" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="58" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="key">
|
||||
<int value="62" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="67" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="key">
|
||||
<int value="71" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="key">
|
||||
<int value="80" />
|
||||
</attr>
|
||||
</attrs>
|
||||
</list>
|
||||
</expr>
|
13
tvix/eval/src/tests/nix_tests/eval-okay-closure.nix
Normal file
13
tvix/eval/src/tests/nix_tests/eval-okay-closure.nix
Normal file
|
@ -0,0 +1,13 @@
|
|||
let
|
||||
|
||||
closure = builtins.genericClosure {
|
||||
startSet = [{key = 80;}];
|
||||
operator = {key, foo ? false}:
|
||||
if builtins.lessThan key 0
|
||||
then []
|
||||
else [{key = builtins.sub key 9;} {key = builtins.sub key 13; foo = true;}];
|
||||
};
|
||||
|
||||
sort = (import ./lib.nix).sortBy (a: b: builtins.lessThan a.key b.key);
|
||||
|
||||
in sort closure
|
1
tvix/eval/src/tests/nix_tests/eval-okay-comments.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-comments.exp
Normal file
|
@ -0,0 +1 @@
|
|||
"abcdefghijklmnopqrstuvwxyz"
|
59
tvix/eval/src/tests/nix_tests/eval-okay-comments.nix
Normal file
59
tvix/eval/src/tests/nix_tests/eval-okay-comments.nix
Normal file
|
@ -0,0 +1,59 @@
|
|||
# A simple comment
|
||||
"a"+ # And another
|
||||
## A double comment
|
||||
"b"+ ## And another
|
||||
# Nested # comments #
|
||||
"c"+ # and # some # other #
|
||||
# An empty line, following here:
|
||||
|
||||
"d"+ # and a comment not starting the line !
|
||||
|
||||
"e"+
|
||||
/* multiline comments */
|
||||
"f" +
|
||||
/* multiline
|
||||
comments,
|
||||
on
|
||||
multiple
|
||||
lines
|
||||
*/
|
||||
"g" +
|
||||
# Small, tricky comments
|
||||
/**/ "h"+ /*/*/ "i"+ /***/ "j"+ /* /*/ "k"+ /*/* /*/ "l"+
|
||||
# Comments with an even number of ending '*' used to fail:
|
||||
"m"+
|
||||
/* */ /* **/ /* ***/ /* ****/ "n"+
|
||||
/* */ /** */ /*** */ /**** */ "o"+
|
||||
/** **/ /*** ***/ /**** ****/ "p"+
|
||||
/* * ** *** **** ***** */ "q"+
|
||||
# Random comments
|
||||
/* ***** ////// * / * / /* */ "r"+
|
||||
# Mixed comments
|
||||
/* # */
|
||||
"s"+
|
||||
# /* #
|
||||
"t"+
|
||||
# /* # */
|
||||
"u"+
|
||||
# /*********/
|
||||
"v"+
|
||||
## */*
|
||||
"w"+
|
||||
/*
|
||||
* Multiline, decorated comments
|
||||
* # This ain't a nest'd comm'nt
|
||||
*/
|
||||
"x"+
|
||||
''${/** with **/"y"
|
||||
# real
|
||||
/* comments
|
||||
inside ! # */
|
||||
|
||||
# (and empty lines)
|
||||
|
||||
}''+ /* And a multiline comment,
|
||||
on the same line,
|
||||
after some spaces
|
||||
*/ # followed by a one-line comment
|
||||
"z"
|
||||
/* EOF */
|
1
tvix/eval/src/tests/nix_tests/eval-okay-concat.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-concat.exp
Normal file
|
@ -0,0 +1 @@
|
|||
[ 1 2 3 4 5 6 7 8 9 ]
|
1
tvix/eval/src/tests/nix_tests/eval-okay-concat.nix
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-concat.nix
Normal file
|
@ -0,0 +1 @@
|
|||
[1 2 3] ++ [4 5 6] ++ [7 8 9]
|
1
tvix/eval/src/tests/nix_tests/eval-okay-concatmap.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-concatmap.exp
Normal file
|
@ -0,0 +1 @@
|
|||
[ [ 1 3 5 7 9 ] [ "a" "z" "b" "z" ] ]
|
5
tvix/eval/src/tests/nix_tests/eval-okay-concatmap.nix
Normal file
5
tvix/eval/src/tests/nix_tests/eval-okay-concatmap.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
with import ./lib.nix;
|
||||
|
||||
[ (builtins.concatMap (x: if x / 2 * 2 == x then [] else [ x ]) (range 0 10))
|
||||
(builtins.concatMap (x: [x] ++ ["z"]) ["a" "b"])
|
||||
]
|
|
@ -0,0 +1 @@
|
|||
[ "" "foobarxyzzy" "foo, bar, xyzzy" "foo" "" ]
|
|
@ -0,0 +1,8 @@
|
|||
with builtins;
|
||||
|
||||
[ (concatStringsSep "" [])
|
||||
(concatStringsSep "" ["foo" "bar" "xyzzy"])
|
||||
(concatStringsSep ", " ["foo" "bar" "xyzzy"])
|
||||
(concatStringsSep ", " ["foo"])
|
||||
(concatStringsSep ", " [])
|
||||
]
|
|
@ -0,0 +1 @@
|
|||
true
|
|
@ -0,0 +1,24 @@
|
|||
let
|
||||
drv = derivation {
|
||||
name = "fail";
|
||||
builder = "/bin/false";
|
||||
system = "x86_64-linux";
|
||||
outputs = [ "out" "foo" ];
|
||||
};
|
||||
|
||||
path = "${./eval-okay-context-introspection.nix}";
|
||||
|
||||
desired-context = {
|
||||
"${builtins.unsafeDiscardStringContext path}" = {
|
||||
path = true;
|
||||
};
|
||||
"${builtins.unsafeDiscardStringContext drv.drvPath}" = {
|
||||
outputs = [ "foo" "out" ];
|
||||
allOutputs = true;
|
||||
};
|
||||
};
|
||||
|
||||
legit-context = builtins.getContext "${path}${drv.outPath}${drv.foo.outPath}${drv.drvPath}";
|
||||
|
||||
constructed-context = builtins.getContext (builtins.appendContext "" desired-context);
|
||||
in legit-context == constructed-context
|
1
tvix/eval/src/tests/nix_tests/eval-okay-context.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-context.exp
Normal file
|
@ -0,0 +1 @@
|
|||
"foo eval-okay-context.nix bar"
|
6
tvix/eval/src/tests/nix_tests/eval-okay-context.nix
Normal file
6
tvix/eval/src/tests/nix_tests/eval-okay-context.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
let s = "foo ${builtins.substring 33 100 (baseNameOf "${./eval-okay-context.nix}")} bar";
|
||||
in
|
||||
if s != "foo eval-okay-context.nix bar"
|
||||
then abort "context not discarded"
|
||||
else builtins.unsafeDiscardStringContext s
|
||||
|
1
tvix/eval/src/tests/nix_tests/eval-okay-curpos.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-curpos.exp
Normal file
|
@ -0,0 +1 @@
|
|||
[ 3 7 4 9 ]
|
5
tvix/eval/src/tests/nix_tests/eval-okay-curpos.nix
Normal file
5
tvix/eval/src/tests/nix_tests/eval-okay-curpos.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Bla
|
||||
let
|
||||
x = __curPos;
|
||||
y = __curPos;
|
||||
in [ x.line x.column y.line y.column ]
|
1
tvix/eval/src/tests/nix_tests/eval-okay-deepseq.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-deepseq.exp
Normal file
|
@ -0,0 +1 @@
|
|||
456
|
1
tvix/eval/src/tests/nix_tests/eval-okay-deepseq.nix
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-deepseq.nix
Normal file
|
@ -0,0 +1 @@
|
|||
builtins.deepSeq (let as = { x = 123; y = as; }; in as) 456
|
|
@ -0,0 +1 @@
|
|||
"b-overridden"
|
|
@ -0,0 +1,24 @@
|
|||
let
|
||||
pkgs_ = with pkgs; {
|
||||
a = derivation {
|
||||
name = "a";
|
||||
system = builtins.currentSystem;
|
||||
builder = "/bin/sh";
|
||||
args = [ "-c" "touch $out" ];
|
||||
inherit b;
|
||||
};
|
||||
|
||||
inherit b;
|
||||
};
|
||||
|
||||
packageOverrides = p: {
|
||||
b = derivation {
|
||||
name = "b-overridden";
|
||||
system = builtins.currentSystem;
|
||||
builder = "/bin/sh";
|
||||
args = [ "-c" "touch $out" ];
|
||||
};
|
||||
};
|
||||
|
||||
pkgs = pkgs_ // (packageOverrides pkgs_);
|
||||
in pkgs.a.b.name
|
1
tvix/eval/src/tests/nix_tests/eval-okay-delayed-with.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-delayed-with.exp
Normal file
|
@ -0,0 +1 @@
|
|||
"b-overridden b-overridden a"
|
29
tvix/eval/src/tests/nix_tests/eval-okay-delayed-with.nix
Normal file
29
tvix/eval/src/tests/nix_tests/eval-okay-delayed-with.nix
Normal file
|
@ -0,0 +1,29 @@
|
|||
let
|
||||
|
||||
pkgs_ = with pkgs; {
|
||||
a = derivation {
|
||||
name = "a";
|
||||
system = builtins.currentSystem;
|
||||
builder = "/bin/sh";
|
||||
args = [ "-c" "touch $out" ];
|
||||
inherit b;
|
||||
};
|
||||
|
||||
b = derivation {
|
||||
name = "b";
|
||||
system = builtins.currentSystem;
|
||||
builder = "/bin/sh";
|
||||
args = [ "-c" "touch $out" ];
|
||||
inherit a;
|
||||
};
|
||||
|
||||
c = b;
|
||||
};
|
||||
|
||||
packageOverrides = pkgs: with pkgs; {
|
||||
b = derivation (b.drvAttrs // { name = "${b.name}-overridden"; });
|
||||
};
|
||||
|
||||
pkgs = pkgs_ // (packageOverrides pkgs_);
|
||||
|
||||
in "${pkgs.a.b.name} ${pkgs.c.name} ${pkgs.b.a.name}"
|
|
@ -0,0 +1 @@
|
|||
true
|
|
@ -0,0 +1 @@
|
|||
{ a."${"b"}" = true; a."${"c"}" = false; }.a.b
|
|
@ -0,0 +1 @@
|
|||
{ binds = true; hasAttrs = true; multiAttrs = true; recBinds = true; selectAttrs = true; selectOrAttrs = true; }
|
|
@ -0,0 +1,17 @@
|
|||
let
|
||||
aString = "a";
|
||||
|
||||
bString = "b";
|
||||
in {
|
||||
hasAttrs = { a.b = null; } ? ${aString}.b;
|
||||
|
||||
selectAttrs = { a.b = true; }.a.${bString};
|
||||
|
||||
selectOrAttrs = { }.${aString} or true;
|
||||
|
||||
binds = { ${aString}."${bString}c" = true; }.a.bc;
|
||||
|
||||
recBinds = rec { ${bString} = a; a = true; }.b;
|
||||
|
||||
multiAttrs = { ${aString} = true; ${bString} = false; }.a;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
{ binds = true; hasAttrs = true; multiAttrs = true; recBinds = true; selectAttrs = true; selectOrAttrs = true; }
|
17
tvix/eval/src/tests/nix_tests/eval-okay-dynamic-attrs.nix
Normal file
17
tvix/eval/src/tests/nix_tests/eval-okay-dynamic-attrs.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
let
|
||||
aString = "a";
|
||||
|
||||
bString = "b";
|
||||
in {
|
||||
hasAttrs = { a.b = null; } ? "${aString}".b;
|
||||
|
||||
selectAttrs = { a.b = true; }.a."${bString}";
|
||||
|
||||
selectOrAttrs = { }."${aString}" or true;
|
||||
|
||||
binds = { "${aString}"."${bString}c" = true; }.a.bc;
|
||||
|
||||
recBinds = rec { "${bString}" = a; a = true; }.b;
|
||||
|
||||
multiAttrs = { "${aString}" = true; "${bString}" = false; }.a;
|
||||
}
|
1
tvix/eval/src/tests/nix_tests/eval-okay-elem.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-elem.exp
Normal file
|
@ -0,0 +1 @@
|
|||
[ true false 30 ]
|
6
tvix/eval/src/tests/nix_tests/eval-okay-elem.nix
Normal file
6
tvix/eval/src/tests/nix_tests/eval-okay-elem.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
with import ./lib.nix;
|
||||
|
||||
let xs = range 10 40; in
|
||||
|
||||
[ (builtins.elem 23 xs) (builtins.elem 42 xs) (builtins.elemAt xs 20) ]
|
||||
|
1
tvix/eval/src/tests/nix_tests/eval-okay-empty-args.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-empty-args.exp
Normal file
|
@ -0,0 +1 @@
|
|||
"ab"
|
1
tvix/eval/src/tests/nix_tests/eval-okay-empty-args.nix
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-empty-args.nix
Normal file
|
@ -0,0 +1 @@
|
|||
({}: {x,y,}: "${x}${y}") {} {x = "a"; y = "b";}
|
|
@ -0,0 +1 @@
|
|||
[ true true true false ]
|
10
tvix/eval/src/tests/nix_tests/eval-okay-eq-derivations.nix
Normal file
10
tvix/eval/src/tests/nix_tests/eval-okay-eq-derivations.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
let
|
||||
|
||||
drvA1 = derivation { name = "a"; builder = "/foo"; system = "i686-linux"; };
|
||||
drvA2 = derivation { name = "a"; builder = "/foo"; system = "i686-linux"; };
|
||||
drvA3 = derivation { name = "a"; builder = "/foo"; system = "i686-linux"; } // { dummy = 1; };
|
||||
|
||||
drvC1 = derivation { name = "c"; builder = "/foo"; system = "i686-linux"; };
|
||||
drvC2 = derivation { name = "c"; builder = "/bar"; system = "i686-linux"; };
|
||||
|
||||
in [ (drvA1 == drvA1) (drvA1 == drvA2) (drvA1 == drvA3) (drvC1 == drvC2) ]
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue