about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-02-26T18·08+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-02-26T18·08+0100
commit5ad263c26b5b9cc0ba067050e4a09b2491c9d40c (patch)
treea9251f24871514ace96343edd0059580c379fbf4
parent3d0a9ec8258fc2a6ec6a73e249aa38fbd03207d8 (diff)
Test some more primops
-rw-r--r--tests/lang.sh4
-rw-r--r--tests/lang/eval-okay-arithmetic.nix5
-rw-r--r--tests/lang/eval-okay-elem.exp1
-rw-r--r--tests/lang/eval-okay-elem.nix6
-rw-r--r--tests/lang/eval-okay-filter.exp1
-rw-r--r--tests/lang/eval-okay-filter.nix5
-rw-r--r--tests/lang/eval-okay-types.exp2
-rw-r--r--tests/lang/eval-okay-types.nix2
-rw-r--r--tests/lang/lib.nix5
9 files changed, 24 insertions, 7 deletions
diff --git a/tests/lang.sh b/tests/lang.sh
index 7324806522..dfe807a6d1 100644
--- a/tests/lang.sh
+++ b/tests/lang.sh
@@ -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
diff --git a/tests/lang/eval-okay-arithmetic.nix b/tests/lang/eval-okay-arithmetic.nix
index 8f307b20ea..bbbbc4691d 100644
--- a/tests/lang/eval-okay-arithmetic.nix
+++ b/tests/lang/eval-okay-arithmetic.nix
@@ -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:
diff --git a/tests/lang/eval-okay-elem.exp b/tests/lang/eval-okay-elem.exp
new file mode 100644
index 0000000000..3cf6c0e962
--- /dev/null
+++ b/tests/lang/eval-okay-elem.exp
@@ -0,0 +1 @@
+[ true false 30 ]
diff --git a/tests/lang/eval-okay-elem.nix b/tests/lang/eval-okay-elem.nix
new file mode 100644
index 0000000000..71ea7a4ed0
--- /dev/null
+++ b/tests/lang/eval-okay-elem.nix
@@ -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) ]
+
diff --git a/tests/lang/eval-okay-filter.exp b/tests/lang/eval-okay-filter.exp
new file mode 100644
index 0000000000..355d51c27d
--- /dev/null
+++ b/tests/lang/eval-okay-filter.exp
@@ -0,0 +1 @@
+[ 0 2 4 6 8 10 100 102 104 106 108 110 ]
diff --git a/tests/lang/eval-okay-filter.nix b/tests/lang/eval-okay-filter.nix
new file mode 100644
index 0000000000..85109b0d0e
--- /dev/null
+++ b/tests/lang/eval-okay-filter.nix
@@ -0,0 +1,5 @@
+with import ./lib.nix;
+
+builtins.filter
+  (x: x / 2 * 2 == x)
+  (builtins.concatLists [ (range 0 10) (range 100 110) ])
diff --git a/tests/lang/eval-okay-types.exp b/tests/lang/eval-okay-types.exp
index 7a1f2cc170..82487f7100 100644
--- a/tests/lang/eval-okay-types.exp
+++ b/tests/lang/eval-okay-types.exp
@@ -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" ]
diff --git a/tests/lang/eval-okay-types.nix b/tests/lang/eval-okay-types.nix
index c3fe370ef7..8cb225e247 100644
--- a/tests/lang/eval-okay-types.nix
+++ b/tests/lang/eval-okay-types.nix
@@ -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")
diff --git a/tests/lang/lib.nix b/tests/lang/lib.nix
index cdba2b9477..882005dc1b 100644
--- a/tests/lang/lib.nix
+++ b/tests/lang/lib.nix
@@ -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;
+
 }