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 export TEST_VAR=foo # for eval-okay-getenv.nix
set +x
fail=0 fail=0
for i in lang/parse-fail-*.nix; do for i in lang/parse-fail-*.nix; do

View file

@ -2,11 +2,6 @@ with import ./lib.nix;
let { let {
range = first: last:
if builtins.lessThan last first
then []
else [first] ++ range (builtins.add first 1) last;
/* Supposedly tail recursive version: /* Supposedly tail recursive version:
range_ = accum: first: last: 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; }) (isInt { x = 123; })
(isBool (true && false)) (isBool (true && false))
(isBool null) (isBool null)
(isAttrs { x = 123; })
(isAttrs null)
(typeOf (3 * 4)) (typeOf (3 * 4))
(typeOf true) (typeOf true)
(typeOf "xyzzy") (typeOf "xyzzy")

View file

@ -53,4 +53,9 @@ rec {
const = x: y: x; const = x: y: x;
range = first: last:
if builtins.lessThan last first
then []
else [first] ++ range (builtins.add first 1) last;
} }