summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-10-04 21:43:34 +0200
committerGitHub <noreply@github.com>2022-10-04 21:43:34 +0200
commita5e59c9e93b9d435caa3fe786c745f0357bb3c0f (patch)
tree9ac67ae6b7d0d56f6bfdfe40299cddd4fe5c1eaf /tests
parentd64d5d685d86b38dda8a314b7d1404633e26b346 (diff)
parent76d396d3781b9c6a32897b5d93769db2c9f84d36 (diff)
Merge pull request #108 from jow-/optimizations
Various improvements
Diffstat (limited to 'tests')
-rw-r--r--tests/cram/test_basic.t7
-rw-r--r--tests/custom/00_syntax/21_regex_literals26
-rw-r--r--tests/custom/99_bugs/41_compiler_invalid_return_opcode20
3 files changed, 50 insertions, 3 deletions
diff --git a/tests/cram/test_basic.t b/tests/cram/test_basic.t
index c33dee9..d7f78a3 100644
--- a/tests/cram/test_basic.t
+++ b/tests/cram/test_basic.t
@@ -22,6 +22,9 @@ check that ucode provides exepected help:
-e "expression"
Execute the given expression as ucode program.
+ -p "expression"
+ Like `-e` but print the result of expression.
+
-t
Enable VM execution tracing.
@@ -85,7 +88,7 @@ check that ucode prints greetings:
check that ucode provides proper error messages:
$ touch lib.uc; ucode -l lib
- Require either -e expression or source file
+ Require either -e/-p expression or source file
[1]
$ ucode -l foo -e ' '
@@ -101,7 +104,7 @@ check that ucode provides proper error messages:
check that ucode can load fs module:
$ ucode -l fs
- Require either -e expression or source file
+ Require either -e/-p expression or source file
[1]
$ ucode -l fs -e ' '
diff --git a/tests/custom/00_syntax/21_regex_literals b/tests/custom/00_syntax/21_regex_literals
index d7ba7c4..7466a2e 100644
--- a/tests/custom/00_syntax/21_regex_literals
+++ b/tests/custom/00_syntax/21_regex_literals
@@ -4,7 +4,7 @@ within regular expression literals is subject of the underlying
regular expression engine.
-- Expect stdout --
-[ "/Hello world/", "/test/gis", "/test/g", "/test1 \\\/ test2/", "/\\x31\n\\.\u0007\b\\c\\u2600\\\\/" ]
+[ "/Hello world/", "/test/gis", "/test/g", "/test1 / test2/", "/1\n\\.\u0007\bc☀\\\\/" ]
-- End --
-- Testcase --
@@ -93,3 +93,27 @@ In line 7, byte 30:
}
%}
-- End --
+
+
+Testing that slashes within character classes are not treated as regex
+literal delimitters.
+
+-- Expect stdout --
+[
+ "/[/]/",
+ "/[[./.]/]/",
+ "/[[:alpha:]/]/",
+ "/[[=/=]/]/"
+]
+-- End --
+
+-- Testcase --
+{%
+ printf("%.J\n", [
+ /[/]/,
+ /[[./.]/]/,
+ /[[:alpha:]/]/,
+ /[[=/=]/]/
+ ]);
+%}
+-- End --
diff --git a/tests/custom/99_bugs/41_compiler_invalid_return_opcode b/tests/custom/99_bugs/41_compiler_invalid_return_opcode
new file mode 100644
index 0000000..a97dae9
--- /dev/null
+++ b/tests/custom/99_bugs/41_compiler_invalid_return_opcode
@@ -0,0 +1,20 @@
+When compiling an arrow function body with a trailing loop or conditional
+statement having an empty body, the emitted return code incorrectly
+overwrote the target address of the jump instruction.
+
+-- Testcase --
+(() => {
+ if(0)
+ ;
+})();
+
+print("OK\n");
+-- End --
+
+-- Args --
+-R
+-- End --
+
+-- Expect stdout --
+OK
+-- End --