summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorStephan Unverwerth <s.unverwerth@gmx.de>2020-04-17 15:52:38 +0200
committerGitHub <noreply@github.com>2020-04-17 15:52:38 +0200
commit63e1ea78198e85f47e69314e77ee68572c4795b8 (patch)
treeda5b1a1eeaa48ad2e5bde9c6890ac93716f60f34 /Libraries
parent19cdda80000f31e96db2cbc85f051250621d9241 (diff)
downloadserenity-63e1ea78198e85f47e69314e77ee68572c4795b8.zip
LibJS: Add test for semicolon insertion (#1828)
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibJS/Tests/automatic-semicolon-insertion.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/Libraries/LibJS/Tests/automatic-semicolon-insertion.js b/Libraries/LibJS/Tests/automatic-semicolon-insertion.js
new file mode 100644
index 0000000000..bec9c02252
--- /dev/null
+++ b/Libraries/LibJS/Tests/automatic-semicolon-insertion.js
@@ -0,0 +1,32 @@
+load("test-common.js");
+
+/**
+ * This file tests automatic semicolon insertion rules.
+ * If this file produces syntax errors, something is wrong.
+ */
+
+function foo() {
+ for (var i = 0; i < 4; i++) {
+ break // semicolon inserted here
+ continue // semicolon inserted here
+ }
+
+ var j // semicolon inserted here
+
+ do {
+ } while (1 === 2) // semicolon inserted here
+
+ return // semicolon inserted here
+ 1;
+var curly/* semicolon inserted here */}
+
+try {
+ assert(foo() === undefined);
+
+ console.log("PASS");
+} catch (e) {
+ console.log("FAIL: " + e);
+}
+
+// This vardecl must appear exactly at the end of the file (no newline or whitespace after it)
+var eof