tests/functional2/lang: Migrate trivial eval-okay tests
Change-Id: I07a2e70eacd3d7bca3fc4d7074b9892b9ea35346
This commit is contained in:
@@ -1 +0,0 @@
|
||||
[ false false true true true true false true ]
|
||||
@@ -1,11 +0,0 @@
|
||||
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 +0,0 @@
|
||||
[ "newx" "foo" "newx" "y" ]
|
||||
@@ -1,11 +0,0 @@
|
||||
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;
|
||||
values
|
||||
@@ -1 +0,0 @@
|
||||
true
|
||||
@@ -1 +0,0 @@
|
||||
({ __functor = self: x: self.foo && x; foo = false; } // { foo = true; }) true
|
||||
@@ -1 +0,0 @@
|
||||
[ 1 2 ]
|
||||
@@ -1 +0,0 @@
|
||||
builtins.catAttrs "a" [ { a = 1; } { b = 0; } { a = 2; } ]
|
||||
@@ -1 +0,0 @@
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
@@ -1,59 +0,0 @@
|
||||
# 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 +0,0 @@
|
||||
[ 3 7 4 9 ]
|
||||
@@ -1,5 +0,0 @@
|
||||
# Bla
|
||||
let
|
||||
x = __curPos;
|
||||
y = __curPos;
|
||||
in [ x.line x.column y.line y.column ]
|
||||
@@ -1 +0,0 @@
|
||||
[ true false 30 ]
|
||||
@@ -1,6 +0,0 @@
|
||||
with import ./lib.nix;
|
||||
|
||||
let xs = range 10 40; in
|
||||
|
||||
[ (builtins.elem 23 xs) (builtins.elem 42 xs) (builtins.elemAt xs 20) ]
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
[ 0 2 4 6 8 10 100 102 104 106 108 110 ]
|
||||
@@ -1,5 +0,0 @@
|
||||
with import ./lib.nix;
|
||||
|
||||
builtins.filter
|
||||
(x: x / 2 * 2 == x)
|
||||
(builtins.concatLists [ (range 0 10) (range 100 110) ])
|
||||
@@ -1 +0,0 @@
|
||||
"github:NixOS/nixpkgs/23.05?dir=lib"
|
||||
@@ -1,7 +0,0 @@
|
||||
builtins.flakeRefToString {
|
||||
type = "github";
|
||||
owner = "NixOS";
|
||||
repo = "nixpkgs";
|
||||
ref = "23.05";
|
||||
dir = "lib";
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
[ 3.4 3.5 2.5 1.5 ]
|
||||
@@ -1,6 +0,0 @@
|
||||
[
|
||||
(1.1 + 2.3)
|
||||
(builtins.add (0.5 + 0.5) (2.0 + 0.5))
|
||||
((0.5 + 0.5) * (2.0 + 0.5))
|
||||
((1.5 + 1.5) / (0.5 * 4.0))
|
||||
]
|
||||
@@ -1 +0,0 @@
|
||||
"23;24;23;23"
|
||||
@@ -1,9 +0,0 @@
|
||||
with import ./lib.nix;
|
||||
|
||||
let
|
||||
n1 = builtins.floor 23.5;
|
||||
n2 = builtins.ceil 23.5;
|
||||
n3 = builtins.floor 23;
|
||||
n4 = builtins.ceil 23;
|
||||
in
|
||||
builtins.concatStringsSep ";" (map toString [ n1 n2 n3 n4 ])
|
||||
@@ -1 +0,0 @@
|
||||
{ "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 ]; }
|
||||
@@ -1,5 +0,0 @@
|
||||
with import ./lib.nix;
|
||||
|
||||
builtins.groupBy (n:
|
||||
builtins.substring 0 1 (builtins.hashString "sha256" (toString n))
|
||||
) (range 0 31)
|
||||
@@ -1 +0,0 @@
|
||||
[ "d41d8cd98f00b204e9800998ecf8427e" "6c69ee7f211c640419d5366cc076ae46" "bb3438fbabd460ea6dbd27d153e2233b" "da39a3ee5e6b4b0d3255bfef95601890afd80709" "cd54e8568c1b37cf1e5badb0779bcbf382212189" "6d12e10b1d331dad210e47fd25d4f260802b7e77" "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" "900a4469df00ccbfd0c145c6d1e4b7953dd0afafadd7534e3a4019e8d38fc663" "ad0387b3bd8652f730ca46d25f9c170af0fd589f42e7f23f5a9e6412d97d7e56" "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" "9d0886f8c6b389398a16257bc79780fab9831c7fc11c8ab07fa732cb7b348feade382f92617c9c5305fefba0af02ab5fd39a587d330997ff5bd0db19f7666653" "21644b72aa259e5a588cd3afbafb1d4310f4889680f6c83b9d531596a5a284f34dbebff409d23bcc86aee6bad10c891606f075c6f4755cb536da27db5693f3a7" ]
|
||||
@@ -1,4 +0,0 @@
|
||||
let
|
||||
strings = [ "" "text 1" "text 2" ];
|
||||
in
|
||||
builtins.concatLists (map (hash: map (builtins.hashString hash) strings) ["md5" "sha1" "sha256" "sha512"])
|
||||
@@ -1 +0,0 @@
|
||||
3
|
||||
@@ -1 +0,0 @@
|
||||
if "foo" != "f" + "oo" then 1 else if false then 2 else 3
|
||||
@@ -1 +0,0 @@
|
||||
[ { } { 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 ]
|
||||
@@ -1,50 +0,0 @@
|
||||
let
|
||||
alphabet =
|
||||
{ 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";
|
||||
};
|
||||
foo = {
|
||||
inherit (alphabet) f o b a r z q u x;
|
||||
aa = throw "aa";
|
||||
};
|
||||
alphabetFail = builtins.mapAttrs throw alphabet;
|
||||
in
|
||||
[ (builtins.intersectAttrs { a = abort "l1"; } { b = abort "r1"; })
|
||||
(builtins.intersectAttrs { a = abort "l2"; } { a = 1; })
|
||||
(builtins.intersectAttrs alphabetFail { a = 1; })
|
||||
(builtins.intersectAttrs { a = abort "laa"; } alphabet)
|
||||
(builtins.intersectAttrs alphabetFail { m = 1; })
|
||||
(builtins.intersectAttrs { m = abort "lam"; } alphabet)
|
||||
(builtins.intersectAttrs alphabetFail { n = 1; })
|
||||
(builtins.intersectAttrs { n = abort "lan"; } alphabet)
|
||||
(builtins.intersectAttrs alphabetFail { n = 1; p = 2; })
|
||||
(builtins.intersectAttrs { n = abort "lan2"; p = abort "lap"; } alphabet)
|
||||
(builtins.intersectAttrs alphabetFail { n = 1; p = 2; })
|
||||
(builtins.intersectAttrs { n = abort "lan2"; p = abort "lap"; } alphabet)
|
||||
(builtins.intersectAttrs alphabetFail alphabet)
|
||||
(builtins.intersectAttrs alphabet foo == builtins.intersectAttrs foo alphabet)
|
||||
]
|
||||
@@ -1 +0,0 @@
|
||||
"AAbar"
|
||||
@@ -1,10 +0,0 @@
|
||||
# this test shows how to use listToAttrs and that evaluation is still lazy (throw isn't called)
|
||||
let
|
||||
asi = name: value : { inherit name value; };
|
||||
list = [ ( asi "a" "A" ) ( asi "b" "B" ) ];
|
||||
a = builtins.listToAttrs list;
|
||||
b = builtins.listToAttrs ( list ++ list );
|
||||
r = builtins.listToAttrs [ (asi "result" [ a b ]) ( asi "throw" (throw "this should not be thrown")) ];
|
||||
x = builtins.listToAttrs [ (asi "foo" "bar") (asi "foo" "bla") ];
|
||||
in
|
||||
builtins.concatStringsSep "" (map (x: x.a) r.result) + x.foo
|
||||
@@ -1 +0,0 @@
|
||||
1
|
||||
@@ -1 +0,0 @@
|
||||
assert !false && (true || false) -> true; 1
|
||||
@@ -1 +0,0 @@
|
||||
"foobarblabarxyzzybar"
|
||||
@@ -1 +0,0 @@
|
||||
builtins.concatStringsSep "" (map (x: x + "bar") [ "foo" "bla" "xyzzy" ])
|
||||
@@ -1 +0,0 @@
|
||||
{ x = "x-foo"; y = "y-bar"; }
|
||||
@@ -1,3 +0,0 @@
|
||||
with import ./lib.nix;
|
||||
|
||||
builtins.mapAttrs (name: value: name + "-" + value) { x = "foo"; y = "bar"; }
|
||||
@@ -1 +0,0 @@
|
||||
{ set1 = { a = 1; b = 2; }; set2 = { a = 1; b = 2; }; set3 = { a = 1; b = 2; }; set4 = { a = 1; b = 2; }; }
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
set1 = { a = 1; };
|
||||
set1 = { "${"b" + ""}" = 2; };
|
||||
|
||||
set2 = { "${"b" + ""}" = 2; };
|
||||
set2 = { a = 1; };
|
||||
|
||||
set3.a = 1;
|
||||
set3."${"b" + ""}" = 2;
|
||||
|
||||
set4."${"b" + ""}" = 2;
|
||||
set4.a = 1;
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
2
|
||||
@@ -1,3 +0,0 @@
|
||||
with { x = 1; };
|
||||
with { x = 2; };
|
||||
x
|
||||
@@ -1 +0,0 @@
|
||||
true
|
||||
@@ -1 +0,0 @@
|
||||
{ ${null} = true; } == {}
|
||||
@@ -1 +0,0 @@
|
||||
{ dir = "lib"; owner = "NixOS"; ref = "23.05"; repo = "nixpkgs"; type = "github"; }
|
||||
@@ -1 +0,0 @@
|
||||
builtins.parseFlakeRef "github:NixOS/nixpkgs/23.05?dir=lib"
|
||||
@@ -1 +0,0 @@
|
||||
{ right = [ 0 2 4 6 8 10 100 102 104 106 108 110 ]; wrong = [ 1 3 5 7 9 101 103 105 107 109 ]; }
|
||||
@@ -1,5 +0,0 @@
|
||||
with import ./lib.nix;
|
||||
|
||||
builtins.partition
|
||||
(x: x / 2 * 2 == x)
|
||||
(builtins.concatLists [ (range 0 10) (range 100 110) ])
|
||||
@@ -1 +0,0 @@
|
||||
false
|
||||
@@ -1,3 +0,0 @@
|
||||
let
|
||||
throw = abort "Error!";
|
||||
in (builtins.tryEval <foobaz>).success
|
||||
@@ -1 +0,0 @@
|
||||
3
|
||||
@@ -1 +0,0 @@
|
||||
((_: _) 1) + ((__: __) 2)
|
||||
@@ -1 +0,0 @@
|
||||
3
|
||||
@@ -1,2 +0,0 @@
|
||||
((__curPosFoo: __curPosFoo) 1) + ((__curPosBar: __curPosBar) 2)
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
[ "faabar" "fbar" "fubar" "faboor" "fubar" "XaXbXcX" "X" "a_b" "fubar" ]
|
||||
@@ -1,12 +0,0 @@
|
||||
with builtins;
|
||||
|
||||
[ (replaceStrings ["o"] ["a"] "foobar")
|
||||
(replaceStrings ["o"] [""] "foobar")
|
||||
(replaceStrings ["oo"] ["u"] "foobar")
|
||||
(replaceStrings ["oo" "a"] ["a" "oo"] "foobar")
|
||||
(replaceStrings ["oo" "oo"] ["u" "i"] "foobar")
|
||||
(replaceStrings [""] ["X"] "abc")
|
||||
(replaceStrings [""] ["X"] "")
|
||||
(replaceStrings ["-"] ["_"] "a-b")
|
||||
(replaceStrings ["oo" "XX"] ["u" (throw "unreachable")] "foobar")
|
||||
]
|
||||
@@ -1 +0,0 @@
|
||||
[ [ 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 ] ] ]
|
||||
@@ -1,20 +0,0 @@
|
||||
with builtins;
|
||||
|
||||
[ (sort lessThan [ 483 249 526 147 42 77 ])
|
||||
(sort (x: y: y < x) [ 483 249 526 147 42 77 ])
|
||||
(sort lessThan [ "foo" "bar" "xyzzy" "fnord" ])
|
||||
(sort (x: y: x.key < y.key)
|
||||
[ { key = 1; value = "foo"; } { key = 2; value = "bar"; } { key = 1; value = "fnord"; } ])
|
||||
(sort lessThan [
|
||||
[ 1 6 ]
|
||||
[ ]
|
||||
[ 2 3 ]
|
||||
[ 3 ]
|
||||
[ 1 5 ]
|
||||
[ 2 ]
|
||||
[ 1 ]
|
||||
[ ]
|
||||
[ 1 4 ]
|
||||
[ 3 ]
|
||||
])
|
||||
]
|
||||
@@ -1 +0,0 @@
|
||||
[ "1" "2" "3" ]
|
||||
@@ -1 +0,0 @@
|
||||
builtins.splitVersion "1.2.3"
|
||||
@@ -1 +0,0 @@
|
||||
{ x = { success = true; value = "x"; }; y = { success = false; value = false; }; z = { success = false; value = false; }; }
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
x = builtins.tryEval "x";
|
||||
y = builtins.tryEval (assert false; "y");
|
||||
z = builtins.tryEval (throw "bla");
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
[ 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" ]
|
||||
@@ -1,37 +0,0 @@
|
||||
with builtins;
|
||||
|
||||
[ (isNull null)
|
||||
(isNull (x: x))
|
||||
(isFunction (x: x))
|
||||
(isFunction "fnord")
|
||||
(isString ("foo" + "bar"))
|
||||
(isString [ "x" ])
|
||||
(isInt (1 + 2))
|
||||
(isInt { x = 123; })
|
||||
(isInt (1 / 2))
|
||||
(isInt (1 + 1))
|
||||
(isInt (1 / 2))
|
||||
(isInt (1 * 2))
|
||||
(isInt (1 - 2))
|
||||
(isFloat (1.2))
|
||||
(isFloat (1 + 1.0))
|
||||
(isFloat (1 / 2.0))
|
||||
(isFloat (1 * 2.0))
|
||||
(isFloat (1 - 2.0))
|
||||
(isBool (true && false))
|
||||
(isBool null)
|
||||
(isPath /nix/store)
|
||||
(isPath ./.)
|
||||
(isAttrs { x = 123; })
|
||||
(isAttrs null)
|
||||
(typeOf (3 * 4))
|
||||
(typeOf true)
|
||||
(typeOf "xyzzy")
|
||||
(typeOf null)
|
||||
(typeOf { x = 456; })
|
||||
(typeOf [ 1 2 3 ])
|
||||
(typeOf (x: x))
|
||||
(typeOf ((x: y: x) 1))
|
||||
(typeOf map)
|
||||
(typeOf (map (x: x)))
|
||||
]
|
||||
@@ -1 +0,0 @@
|
||||
{ "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 ]; }; }
|
||||
@@ -1,9 +0,0 @@
|
||||
with import ./lib.nix;
|
||||
|
||||
let
|
||||
str = builtins.hashString "sha256" "test";
|
||||
in
|
||||
builtins.zipAttrsWith
|
||||
(n: v: { inherit n v; })
|
||||
(map (n: { ${builtins.substring n 1 str} = n; })
|
||||
(range 0 31))
|
||||
Reference in New Issue
Block a user