aboutsummaryrefslogtreecommitdiff
path: root/tests/functional/lang
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-04 06:36:36 +0100
committereldritch horrors <pennae@lix.systems>2024-03-04 07:11:25 +0100
commit2ba978800355189e263aa7fe13277fd62ce743bc (patch)
treec68b6e852052fe6be14a9c17e3884e3bd1779cf1 /tests/functional/lang
parentd42cd24afe1ff417a33c769d666cb2af231ca40b (diff)
Merge pull request #9555 from 9999years/positions-in-errors
Pass positions when evaluating (cherry picked from commit c8458bd731eb1c74159bebe459ea00165e056b65) Change-Id: I1b4a5d58973be6264ffdb23b4492da200fdb71be
Diffstat (limited to 'tests/functional/lang')
-rw-r--r--tests/functional/lang/eval-fail-attr-name-type.err.exp20
-rw-r--r--tests/functional/lang/eval-fail-attr-name-type.nix7
-rw-r--r--tests/functional/lang/eval-fail-call-primop.err.exp12
-rw-r--r--tests/functional/lang/eval-fail-call-primop.nix1
-rw-r--r--tests/functional/lang/eval-fail-not-throws.err.exp18
-rw-r--r--tests/functional/lang/eval-fail-not-throws.nix1
-rw-r--r--tests/functional/lang/eval-fail-using-set-as-attr-name.err.exp11
-rw-r--r--tests/functional/lang/eval-fail-using-set-as-attr-name.nix5
8 files changed, 75 insertions, 0 deletions
diff --git a/tests/functional/lang/eval-fail-attr-name-type.err.exp b/tests/functional/lang/eval-fail-attr-name-type.err.exp
new file mode 100644
index 000000000..5f9a073dd
--- /dev/null
+++ b/tests/functional/lang/eval-fail-attr-name-type.err.exp
@@ -0,0 +1,20 @@
+error:
+ … while evaluating the attribute 'puppy."${key}"'
+
+ at /pwd/lang/eval-fail-attr-name-type.nix:3:5:
+
+ 2| attrs = {
+ 3| puppy.doggy = {};
+ | ^
+ 4| };
+
+ … while evaluating an attribute name
+
+ at /pwd/lang/eval-fail-attr-name-type.nix:7:17:
+
+ 6| in
+ 7| attrs.puppy.${key}
+ | ^
+ 8|
+
+ error: value is an integer while a string was expected
diff --git a/tests/functional/lang/eval-fail-attr-name-type.nix b/tests/functional/lang/eval-fail-attr-name-type.nix
new file mode 100644
index 000000000..a0e76004a
--- /dev/null
+++ b/tests/functional/lang/eval-fail-attr-name-type.nix
@@ -0,0 +1,7 @@
+let
+ attrs = {
+ puppy.doggy = {};
+ };
+ key = 1;
+in
+ attrs.puppy.${key}
diff --git a/tests/functional/lang/eval-fail-call-primop.err.exp b/tests/functional/lang/eval-fail-call-primop.err.exp
new file mode 100644
index 000000000..19b407c47
--- /dev/null
+++ b/tests/functional/lang/eval-fail-call-primop.err.exp
@@ -0,0 +1,12 @@
+error:
+ … while calling the 'length' builtin
+
+ at /pwd/lang/eval-fail-call-primop.nix:1:1:
+
+ 1| builtins.length 1
+ | ^
+ 2|
+
+ … while evaluating the first argument passed to builtins.length
+
+ error: value is an integer while a list was expected
diff --git a/tests/functional/lang/eval-fail-call-primop.nix b/tests/functional/lang/eval-fail-call-primop.nix
new file mode 100644
index 000000000..972eb72c7
--- /dev/null
+++ b/tests/functional/lang/eval-fail-call-primop.nix
@@ -0,0 +1 @@
+builtins.length 1
diff --git a/tests/functional/lang/eval-fail-not-throws.err.exp b/tests/functional/lang/eval-fail-not-throws.err.exp
new file mode 100644
index 000000000..b290afb0a
--- /dev/null
+++ b/tests/functional/lang/eval-fail-not-throws.err.exp
@@ -0,0 +1,18 @@
+error:
+ … in the argument of the not operator
+
+ at /pwd/lang/eval-fail-not-throws.nix:1:4:
+
+ 1| ! (throw "uh oh!")
+ | ^
+ 2|
+
+ … while calling the 'throw' builtin
+
+ at /pwd/lang/eval-fail-not-throws.nix:1:4:
+
+ 1| ! (throw "uh oh!")
+ | ^
+ 2|
+
+ error: uh oh!
diff --git a/tests/functional/lang/eval-fail-not-throws.nix b/tests/functional/lang/eval-fail-not-throws.nix
new file mode 100644
index 000000000..a74ce4ebe
--- /dev/null
+++ b/tests/functional/lang/eval-fail-not-throws.nix
@@ -0,0 +1 @@
+! (throw "uh oh!")
diff --git a/tests/functional/lang/eval-fail-using-set-as-attr-name.err.exp b/tests/functional/lang/eval-fail-using-set-as-attr-name.err.exp
new file mode 100644
index 000000000..811d01b03
--- /dev/null
+++ b/tests/functional/lang/eval-fail-using-set-as-attr-name.err.exp
@@ -0,0 +1,11 @@
+error:
+ … while evaluating an attribute name
+
+ at /pwd/lang/eval-fail-using-set-as-attr-name.nix:5:10:
+
+ 4| in
+ 5| attr.${key}
+ | ^
+ 6|
+
+ error: value is a set while a string was expected
diff --git a/tests/functional/lang/eval-fail-using-set-as-attr-name.nix b/tests/functional/lang/eval-fail-using-set-as-attr-name.nix
new file mode 100644
index 000000000..48e071a41
--- /dev/null
+++ b/tests/functional/lang/eval-fail-using-set-as-attr-name.nix
@@ -0,0 +1,5 @@
+let
+ attr = {foo = "bar";};
+ key = {};
+in
+ attr.${key}