about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-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 7324806522b7..dfe807a6d1c0 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 8f307b20ea95..bbbbc4691d75 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 000000000000..3cf6c0e962f0
--- /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 000000000000..71ea7a4ed03d
--- /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 000000000000..355d51c27d8f
--- /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 000000000000..85109b0d0eb8
--- /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 7a1f2cc17027..82487f7100e2 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 c3fe370ef770..8cb225e247fb 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 cdba2b947793..882005dc1b5c 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;
+
 }