summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/custom/00_syntax/10_numeric_literals4
-rw-r--r--tests/custom/03_stdlib/08_int23
-rw-r--r--tests/custom/04_bugs/29_empty_string_as_number8
3 files changed, 23 insertions, 12 deletions
diff --git a/tests/custom/00_syntax/10_numeric_literals b/tests/custom/00_syntax/10_numeric_literals
index 7aa49b6..a19bbd5 100644
--- a/tests/custom/00_syntax/10_numeric_literals
+++ b/tests/custom/00_syntax/10_numeric_literals
@@ -8,6 +8,8 @@ doubles internally.
-- Expect stdout --
Integers literals: 123, 127, 2748, 57082
Float literals: 10, 10.3, 1.23456e-65, 16.0625
+Octal literals: 63, 118
+Binary literals: 7, 11
Special values: Infinity, Infinity, NaN, NaN
Minimum values: -9223372036854775808, -1.79769e+308
Maximum values: 9223372036854775807, 1.79769e+308
@@ -18,6 +20,8 @@ Maximum truncation: 18446744073709551615, Infinity
-- Testcase --
Integers literals: {{ 123 }}, {{ 0177 }}, {{ 0xabc }}, {{ 0xDEFA }}
Float literals: {{ 10. }}, {{ 10.3 }}, {{ 123.456e-67 }}, {{ 0x10.1 }}
+Octal literals: {{ 0o77 }}, {{ 0O166 }}
+Binary literals: {{ 0b111 }}, {{ 0B1011 }}
Special values: {{ Infinity }}, {{ 1 / 0 }}, {{ NaN }}, {{ "x" / 1 }}
Minimum values: {{ -9223372036854775808 }}, {{ -1.7976931348623158e+308 }}
Maximum values: {{ 9223372036854775807 }}, {{ 1.7976931348623158e+308 }}
diff --git a/tests/custom/03_stdlib/08_int b/tests/custom/03_stdlib/08_int
index a6b5923..eae4904 100644
--- a/tests/custom/03_stdlib/08_int
+++ b/tests/custom/03_stdlib/08_int
@@ -1,8 +1,9 @@
The `int()` function converts the given value into a signed integer
-value and returns the resulting number.
+value and returns the resulting number. In case the value is of type
+string, a second optional base argument may be specified which is
+passed to the underlying strtoll(3) implementation.
Returns `NaN` if the given argument is not convertible into a number.
-
Returns `NaN` if the conversion result is out of range.
-- Testcase --
@@ -19,7 +20,11 @@ Returns `NaN` if the conversion result is out of range.
int("0xffffffffffffffff"),
int("0177"),
int("+145"),
- int("-96")
+ int("-96"),
+ int("0177", 8),
+ int("0x1000", 16),
+ int("1111", 2),
+ int("0xffffffffffffffff", 16)
]);
%}
-- End --
@@ -30,13 +35,17 @@ Returns `NaN` if the conversion result is out of range.
0,
123,
456,
- 0,
"NaN",
"NaN",
- 4096,
"NaN",
+ 0,
+ 0,
+ 177,
+ 145,
+ -96,
127,
- "NaN",
- -96
+ 4096,
+ 15,
+ "NaN"
]
-- End --
diff --git a/tests/custom/04_bugs/29_empty_string_as_number b/tests/custom/04_bugs/29_empty_string_as_number
index 675f8a1..51a93b2 100644
--- a/tests/custom/04_bugs/29_empty_string_as_number
+++ b/tests/custom/04_bugs/29_empty_string_as_number
@@ -1,10 +1,9 @@
-When an empty string was casted to a number, e.g. explicitly through `+`
-or `int()` or implicitly through numerical calculations, it was incorrectly
-treated as `NaN` and not `0`.
+When an empty string was explicitly casted to a number through `+` or
+implicitly through numerical calculations, it was incorrectly treated
+as `NaN` and not `0`.
-- Testcase --
{{ +"" }}
-{{ int("") }}
{{ "" + 0 }}
{{ "" - 0.0 }}
-- End --
@@ -13,5 +12,4 @@ treated as `NaN` and not `0`.
0
0
0
-0
-- End --