forked from lix-project/lix
Test some more primops
This commit is contained in:
parent
3d0a9ec825
commit
5ad263c26b
|
@ -2,6 +2,8 @@ source common.sh
|
|||
|
||||
export TEST_VAR=foo # for eval-okay-getenv.nix
|
||||
|
||||
set +x
|
||||
|
||||
fail=0
|
||||
|
||||
for i in lang/parse-fail-*.nix; do
|
||||
|
@ -48,7 +50,7 @@ for i in lang/eval-okay-*.nix; do
|
|||
fail=1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if test -e lang/$i.exp.xml; then
|
||||
if ! nix-instantiate --eval --xml --no-location --strict \
|
||||
lang/$i.nix > lang/$i.out.xml; then
|
||||
|
|
|
@ -2,11 +2,6 @@ with import ./lib.nix;
|
|||
|
||||
let {
|
||||
|
||||
range = first: last:
|
||||
if builtins.lessThan last first
|
||||
then []
|
||||
else [first] ++ range (builtins.add first 1) last;
|
||||
|
||||
/* Supposedly tail recursive version:
|
||||
|
||||
range_ = accum: first: last:
|
||||
|
|
1
tests/lang/eval-okay-elem.exp
Normal file
1
tests/lang/eval-okay-elem.exp
Normal file
|
@ -0,0 +1 @@
|
|||
[ true false 30 ]
|
6
tests/lang/eval-okay-elem.nix
Normal file
6
tests/lang/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
tests/lang/eval-okay-filter.exp
Normal file
1
tests/lang/eval-okay-filter.exp
Normal file
|
@ -0,0 +1 @@
|
|||
[ 0 2 4 6 8 10 100 102 104 106 108 110 ]
|
5
tests/lang/eval-okay-filter.nix
Normal file
5
tests/lang/eval-okay-filter.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
with import ./lib.nix;
|
||||
|
||||
builtins.filter
|
||||
(x: x / 2 * 2 == x)
|
||||
(builtins.concatLists [ (range 0 10) (range 100 110) ])
|
|
@ -1 +1 @@
|
|||
[ true false true false true false true false true false "int" "bool" "string" "null" "set" "list" "lambda" "lambda" "lambda" "lambda" ]
|
||||
[ true false true false true false true false true false true false "int" "bool" "string" "null" "set" "list" "lambda" "lambda" "lambda" "lambda" ]
|
||||
|
|
|
@ -10,6 +10,8 @@ with builtins;
|
|||
(isInt { x = 123; })
|
||||
(isBool (true && false))
|
||||
(isBool null)
|
||||
(isAttrs { x = 123; })
|
||||
(isAttrs null)
|
||||
(typeOf (3 * 4))
|
||||
(typeOf true)
|
||||
(typeOf "xyzzy")
|
||||
|
|
|
@ -53,4 +53,9 @@ rec {
|
|||
|
||||
const = x: y: x;
|
||||
|
||||
range = first: last:
|
||||
if builtins.lessThan last first
|
||||
then []
|
||||
else [first] ++ range (builtins.add first 1) last;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue