Test some more primops

This commit is contained in:
Eelco Dolstra 2014-02-26 19:08:44 +01:00
parent 3d0a9ec825
commit 5ad263c26b
9 changed files with 24 additions and 7 deletions

View File

@ -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

View File

@ -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:

View File

@ -0,0 +1 @@
[ true false 30 ]

View 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) ]

View File

@ -0,0 +1 @@
[ 0 2 4 6 8 10 100 102 104 106 108 110 ]

View File

@ -0,0 +1,5 @@
with import ./lib.nix;
builtins.filter
(x: x / 2 * 2 == x)
(builtins.concatLists [ (range 0 10) (range 100 110) ])

View File

@ -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" ]

View File

@ -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")

View File

@ -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;
}