aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/functional/lang/eval-fail-fetchTree-negative.err.exp8
-rw-r--r--tests/functional/lang/eval-fail-fetchTree-negative.nix5
-rw-r--r--tests/functional/lang/eval-fail-flake-ref-to-string-negative-integer.err.exp14
-rw-r--r--tests/functional/lang/eval-fail-flake-ref-to-string-negative-integer.nix7
-rw-r--r--tests/functional/lang/eval-fail-fromJSON-overflowing.err.exp8
-rw-r--r--tests/functional/lang/eval-fail-fromJSON-overflowing.nix1
-rw-r--r--tests/functional/lang/eval-fail-overflowing-add.err.exp6
-rw-r--r--tests/functional/lang/eval-fail-overflowing-add.nix4
-rw-r--r--tests/functional/lang/eval-fail-overflowing-div.err.exp23
-rw-r--r--tests/functional/lang/eval-fail-overflowing-div.nix7
-rw-r--r--tests/functional/lang/eval-fail-overflowing-mul.err.exp16
-rw-r--r--tests/functional/lang/eval-fail-overflowing-mul.nix3
-rw-r--r--tests/functional/lang/eval-fail-overflowing-sub.err.exp9
-rw-r--r--tests/functional/lang/eval-fail-overflowing-sub.nix4
-rw-r--r--tests/unit/libexpr-support/tests/libexpr.hh2
15 files changed, 116 insertions, 1 deletions
diff --git a/tests/functional/lang/eval-fail-fetchTree-negative.err.exp b/tests/functional/lang/eval-fail-fetchTree-negative.err.exp
new file mode 100644
index 000000000..d9ba1f0b2
--- /dev/null
+++ b/tests/functional/lang/eval-fail-fetchTree-negative.err.exp
@@ -0,0 +1,8 @@
+error:
+ … while calling the 'fetchTree' builtin
+ at /pwd/lang/eval-fail-fetchTree-negative.nix:1:1:
+ 1| builtins.fetchTree {
+ | ^
+ 2| type = "file";
+
+ error: negative value given for fetchTree attr owner: -1
diff --git a/tests/functional/lang/eval-fail-fetchTree-negative.nix b/tests/functional/lang/eval-fail-fetchTree-negative.nix
new file mode 100644
index 000000000..90bcab5d8
--- /dev/null
+++ b/tests/functional/lang/eval-fail-fetchTree-negative.nix
@@ -0,0 +1,5 @@
+builtins.fetchTree {
+ type = "file";
+ url = "file://eval-fail-fetchTree-negative.nix";
+ owner = -1;
+}
diff --git a/tests/functional/lang/eval-fail-flake-ref-to-string-negative-integer.err.exp b/tests/functional/lang/eval-fail-flake-ref-to-string-negative-integer.err.exp
new file mode 100644
index 000000000..25c8d7eaa
--- /dev/null
+++ b/tests/functional/lang/eval-fail-flake-ref-to-string-negative-integer.err.exp
@@ -0,0 +1,14 @@
+error:
+ … while calling the 'seq' builtin
+ at /pwd/lang/eval-fail-flake-ref-to-string-negative-integer.nix:1:16:
+ 1| let n = -1; in builtins.seq n (builtins.flakeRefToString {
+ | ^
+ 2| type = "github";
+
+ … while calling the 'flakeRefToString' builtin
+ at /pwd/lang/eval-fail-flake-ref-to-string-negative-integer.nix:1:32:
+ 1| let n = -1; in builtins.seq n (builtins.flakeRefToString {
+ | ^
+ 2| type = "github";
+
+ error: negative value given for flake ref attr repo: -1
diff --git a/tests/functional/lang/eval-fail-flake-ref-to-string-negative-integer.nix b/tests/functional/lang/eval-fail-flake-ref-to-string-negative-integer.nix
new file mode 100644
index 000000000..e0208eb25
--- /dev/null
+++ b/tests/functional/lang/eval-fail-flake-ref-to-string-negative-integer.nix
@@ -0,0 +1,7 @@
+let n = -1; in builtins.seq n (builtins.flakeRefToString {
+ type = "github";
+ owner = "NixOS";
+ repo = n;
+ ref = "23.05";
+ dir = "lib";
+})
diff --git a/tests/functional/lang/eval-fail-fromJSON-overflowing.err.exp b/tests/functional/lang/eval-fail-fromJSON-overflowing.err.exp
new file mode 100644
index 000000000..a39082b45
--- /dev/null
+++ b/tests/functional/lang/eval-fail-fromJSON-overflowing.err.exp
@@ -0,0 +1,8 @@
+error:
+ … while calling the 'fromJSON' builtin
+ at /pwd/lang/eval-fail-fromJSON-overflowing.nix:1:1:
+ 1| builtins.fromJSON ''{"attr": 18446744073709551615}''
+ | ^
+ 2|
+
+ error: unsigned json number 18446744073709551615 outside of Nix integer range
diff --git a/tests/functional/lang/eval-fail-fromJSON-overflowing.nix b/tests/functional/lang/eval-fail-fromJSON-overflowing.nix
new file mode 100644
index 000000000..6dfbce3f6
--- /dev/null
+++ b/tests/functional/lang/eval-fail-fromJSON-overflowing.nix
@@ -0,0 +1 @@
+builtins.fromJSON ''{"attr": 18446744073709551615}''
diff --git a/tests/functional/lang/eval-fail-overflowing-add.err.exp b/tests/functional/lang/eval-fail-overflowing-add.err.exp
new file mode 100644
index 000000000..6458cf1c9
--- /dev/null
+++ b/tests/functional/lang/eval-fail-overflowing-add.err.exp
@@ -0,0 +1,6 @@
+error: integer overflow in adding 9223372036854775807 + 1
+ at /pwd/lang/eval-fail-overflowing-add.nix:4:8:
+ 3| b = 1;
+ 4| in a + b
+ | ^
+ 5|
diff --git a/tests/functional/lang/eval-fail-overflowing-add.nix b/tests/functional/lang/eval-fail-overflowing-add.nix
new file mode 100644
index 000000000..24258fc20
--- /dev/null
+++ b/tests/functional/lang/eval-fail-overflowing-add.nix
@@ -0,0 +1,4 @@
+let
+ a = 9223372036854775807;
+ b = 1;
+in a + b
diff --git a/tests/functional/lang/eval-fail-overflowing-div.err.exp b/tests/functional/lang/eval-fail-overflowing-div.err.exp
new file mode 100644
index 000000000..8ce07d4d6
--- /dev/null
+++ b/tests/functional/lang/eval-fail-overflowing-div.err.exp
@@ -0,0 +1,23 @@
+error:
+ … while calling the 'seq' builtin
+ at /pwd/lang/eval-fail-overflowing-div.nix:7:4:
+ 6| b = -1;
+ 7| in builtins.seq intMin (builtins.seq b (intMin / b))
+ | ^
+ 8|
+
+ … while calling the 'seq' builtin
+ at /pwd/lang/eval-fail-overflowing-div.nix:7:25:
+ 6| b = -1;
+ 7| in builtins.seq intMin (builtins.seq b (intMin / b))
+ | ^
+ 8|
+
+ … while calling the 'div' builtin
+ at /pwd/lang/eval-fail-overflowing-div.nix:7:48:
+ 6| b = -1;
+ 7| in builtins.seq intMin (builtins.seq b (intMin / b))
+ | ^
+ 8|
+
+ error: integer overflow in dividing -9223372036854775808 / -1
diff --git a/tests/functional/lang/eval-fail-overflowing-div.nix b/tests/functional/lang/eval-fail-overflowing-div.nix
new file mode 100644
index 000000000..44fbe9d7e
--- /dev/null
+++ b/tests/functional/lang/eval-fail-overflowing-div.nix
@@ -0,0 +1,7 @@
+let
+ # lol, this has to be written as an expression like this because negative
+ # numbers use unary negation rather than parsing directly, and 2**63 is out
+ # of range
+ intMin = -9223372036854775807 - 1;
+ b = -1;
+in builtins.seq intMin (builtins.seq b (intMin / b))
diff --git a/tests/functional/lang/eval-fail-overflowing-mul.err.exp b/tests/functional/lang/eval-fail-overflowing-mul.err.exp
new file mode 100644
index 000000000..f42b39d4d
--- /dev/null
+++ b/tests/functional/lang/eval-fail-overflowing-mul.err.exp
@@ -0,0 +1,16 @@
+error:
+ … while calling the 'mul' builtin
+ at /pwd/lang/eval-fail-overflowing-mul.nix:3:10:
+ 2| a = 4294967297;
+ 3| in a * a * a
+ | ^
+ 4|
+
+ … while calling the 'mul' builtin
+ at /pwd/lang/eval-fail-overflowing-mul.nix:3:6:
+ 2| a = 4294967297;
+ 3| in a * a * a
+ | ^
+ 4|
+
+ error: integer overflow in multiplying 4294967297 * 4294967297
diff --git a/tests/functional/lang/eval-fail-overflowing-mul.nix b/tests/functional/lang/eval-fail-overflowing-mul.nix
new file mode 100644
index 000000000..6081d9c7b
--- /dev/null
+++ b/tests/functional/lang/eval-fail-overflowing-mul.nix
@@ -0,0 +1,3 @@
+let
+ a = 4294967297;
+in a * a * a
diff --git a/tests/functional/lang/eval-fail-overflowing-sub.err.exp b/tests/functional/lang/eval-fail-overflowing-sub.err.exp
new file mode 100644
index 000000000..66a3a03f8
--- /dev/null
+++ b/tests/functional/lang/eval-fail-overflowing-sub.err.exp
@@ -0,0 +1,9 @@
+error:
+ … while calling the 'sub' builtin
+ at /pwd/lang/eval-fail-overflowing-sub.nix:4:6:
+ 3| b = 2;
+ 4| in a - b
+ | ^
+ 5|
+
+ error: integer overflow in subtracting -9223372036854775807 - 2
diff --git a/tests/functional/lang/eval-fail-overflowing-sub.nix b/tests/functional/lang/eval-fail-overflowing-sub.nix
new file mode 100644
index 000000000..229b8c6d2
--- /dev/null
+++ b/tests/functional/lang/eval-fail-overflowing-sub.nix
@@ -0,0 +1,4 @@
+let
+ a = -9223372036854775807;
+ b = 2;
+in a - b
diff --git a/tests/unit/libexpr-support/tests/libexpr.hh b/tests/unit/libexpr-support/tests/libexpr.hh
index b820e3fab..01dcbb34c 100644
--- a/tests/unit/libexpr-support/tests/libexpr.hh
+++ b/tests/unit/libexpr-support/tests/libexpr.hh
@@ -77,7 +77,7 @@ namespace nix {
if (arg.type() != nInt) {
return false;
}
- return arg.integer == v;
+ return arg.integer.value == v;
}
MATCHER_P(IsFloatEq, v, fmt("The float is equal to \"%1%\"", v)) {