summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/custom/03_stdlib/40_proto1
-rw-r--r--tests/custom/99_bugs/46_getenv_destroys_environ13
-rw-r--r--tests/custom/99_bugs/47_compiler_no_prop_kw_after_spread17
-rw-r--r--tests/custom/99_bugs/48_use_after_free_on_iteration_insert40
-rw-r--r--tests/custom/99_bugs/49_trailing_garbage_string_as_number23
-rw-r--r--tests/custom/99_bugs/50_missing_upvalue_resolving27
-rw-r--r--tests/custom/99_bugs/51_preserve_lexer_flags20
7 files changed, 141 insertions, 0 deletions
diff --git a/tests/custom/03_stdlib/40_proto b/tests/custom/03_stdlib/40_proto
index d96d124..0f65910 100644
--- a/tests/custom/03_stdlib/40_proto
+++ b/tests/custom/03_stdlib/40_proto
@@ -38,6 +38,7 @@ When invoked with two arguments, returns the given value.
Hello, World!
[
{
+ "ioctl": "function ioctl(...) { [native code] }",
"lock": "function lock(...) { [native code] }",
"truncate": "function truncate(...) { [native code] }",
"isatty": "function isatty(...) { [native code] }",
diff --git a/tests/custom/99_bugs/46_getenv_destroys_environ b/tests/custom/99_bugs/46_getenv_destroys_environ
new file mode 100644
index 0000000..1879dee
--- /dev/null
+++ b/tests/custom/99_bugs/46_getenv_destroys_environ
@@ -0,0 +1,13 @@
+A call to getenv() without parameters destroys environ, and subsequent calls
+to getenv() (with or without parameter) return nothing.
+
+-- Testcase --
+{%
+ getenv();
+ print(length(getenv()) > 0, '\n');
+%}
+-- End --
+
+-- Expect stdout --
+true
+-- End --
diff --git a/tests/custom/99_bugs/47_compiler_no_prop_kw_after_spread b/tests/custom/99_bugs/47_compiler_no_prop_kw_after_spread
new file mode 100644
index 0000000..26f1bff
--- /dev/null
+++ b/tests/custom/99_bugs/47_compiler_no_prop_kw_after_spread
@@ -0,0 +1,17 @@
+Ensure that unquoted property names following spread expressions in object
+declaration literals are not treated as keywords.
+
+-- Testcase --
+{%
+printf("%.J\n", {
+ ...{},
+ for: true
+});
+%}
+-- End --
+
+-- Expect stdout --
+{
+ "for": true
+}
+-- End --
diff --git a/tests/custom/99_bugs/48_use_after_free_on_iteration_insert b/tests/custom/99_bugs/48_use_after_free_on_iteration_insert
new file mode 100644
index 0000000..558f83a
--- /dev/null
+++ b/tests/custom/99_bugs/48_use_after_free_on_iteration_insert
@@ -0,0 +1,40 @@
+Ensure that adding keys to an object currently being iterated will not
+clobber active iterators pointing into that object due to a reallocation
+of the underlying hash table array.
+
+-- Testcase --
+{%
+ let obj = { '0': 0, '1': 1 };
+ let i = 2;
+
+ for (let k, v in obj) {
+ while (i < 16) {
+ obj[i] = i;
+ i++;
+ }
+ }
+
+ printf("%.J\n", obj);
+%}
+-- End --
+
+-- Expect stdout --
+{
+ "0": 0,
+ "1": 1,
+ "2": 2,
+ "3": 3,
+ "4": 4,
+ "5": 5,
+ "6": 6,
+ "7": 7,
+ "8": 8,
+ "9": 9,
+ "10": 10,
+ "11": 11,
+ "12": 12,
+ "13": 13,
+ "14": 14,
+ "15": 15
+}
+-- End --
diff --git a/tests/custom/99_bugs/49_trailing_garbage_string_as_number b/tests/custom/99_bugs/49_trailing_garbage_string_as_number
new file mode 100644
index 0000000..1b48146
--- /dev/null
+++ b/tests/custom/99_bugs/49_trailing_garbage_string_as_number
@@ -0,0 +1,23 @@
+Ensure that numeric strings followed by non-whitespace are treated as NaN.
+
+-- Testcase --
+{%
+printf("%.J\n", [
+ "1" == 1,
+ " 1" == 1,
+ "1 " == 1,
+ "1a" == 1,
+ "1 a" == 1
+]);
+%}
+-- End --
+
+-- Expect stdout --
+[
+ true,
+ true,
+ true,
+ false,
+ false
+]
+-- End --
diff --git a/tests/custom/99_bugs/50_missing_upvalue_resolving b/tests/custom/99_bugs/50_missing_upvalue_resolving
new file mode 100644
index 0000000..5e96634
--- /dev/null
+++ b/tests/custom/99_bugs/50_missing_upvalue_resolving
@@ -0,0 +1,27 @@
+Commit e5fe6b1 ("treewide: refactor vector usage code") accidentially dropped
+the upvalue resolving logic from uc_vm_stack_push(), leading to unresolved
+upvalues leaking into the script execution context.
+
+-- File test.uc --
+export let obj = { foo: true, bar: false };
+-- End --
+
+-- Testcase --
+import * as test from "./files/test.uc";
+
+printf("%.J\n", [
+ type(test.obj),
+ test.obj.foo
+]);
+-- End --
+
+-- Args --
+-R
+-- End --
+
+-- Expect stdout --
+[
+ "object",
+ true
+]
+-- End --
diff --git a/tests/custom/99_bugs/51_preserve_lexer_flags b/tests/custom/99_bugs/51_preserve_lexer_flags
new file mode 100644
index 0000000..aba646c
--- /dev/null
+++ b/tests/custom/99_bugs/51_preserve_lexer_flags
@@ -0,0 +1,20 @@
+Ensure keyword and regexp flags are preserved across comments when lexing
+object literals and division operators.
+
+-- Testcase --
+{%
+ printf("%.J\n", [
+ { /* comment */ default: true },
+ 4 /* comment */ /2/1
+ ]);
+%}
+-- End --
+
+-- Expect stdout --
+[
+ {
+ "default": true
+ },
+ 2
+]
+-- End --