aboutsummaryrefslogtreecommitdiff
path: root/src/z/parser/js/test_fixture.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/z/parser/js/test_fixture.js')
-rw-r--r--src/z/parser/js/test_fixture.js86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/z/parser/js/test_fixture.js b/src/z/parser/js/test_fixture.js
new file mode 100644
index 0000000..378ceb3
--- /dev/null
+++ b/src/z/parser/js/test_fixture.js
@@ -0,0 +1,86 @@
+#!/usr/bin/env node
+// comment line
+/* block
+ comment */
+var x = 42;
+let y = "hello";
+const z = `template ${x} literal`;
+let a = 0b1010;
+let b = 0xFF;
+let c = 0o77;
+let d = 123n;
+let e = /pattern/gi;
+let f = true;
+let g = null;
+function hello(a, b) {
+ if (a > b) {
+ return a;
+ } else {
+ return b;
+ }
+}
+const arrow = (x) => x * 2;
+const obj = {
+ a: 1,
+ b: "two",
+ c,
+ [d]: 4,
+ method() { return 5; },
+ get prop() { return 6; },
+ set prop(v) { },
+};
+const arr = [1, 2, ...rest, 4];
+for (var i = 0; i < 10; i++) {
+ continue;
+}
+for (const key in obj) {
+ break;
+}
+for (const val of arr) {
+ ;
+}
+while (x < 10) {
+ x++;
+}
+do {
+ x--;
+} while (x > 0);
+try {
+ throw "err";
+} catch (e) {
+ console.log(e);
+} finally {
+ cleanup();
+}
+switch (x) {
+ case 1:
+ break;
+ case 2:
+ return;
+ default:
+ break;
+}
+class Foo extends Bar {
+ constructor() { super(); }
+ static method() { }
+ get prop() { return 1; }
+ set prop(v) { }
+}
+const { a: p, b: q } = obj;
+const [head, ...tail] = arr;
+import { something } from "module";
+export default x;
+export const named = 1;
+export function exported() { }
+import "side-effect";
+import * as ns from "module";
+export { x as y } from "module";
+export * from "module";
+delete obj.a;
+typeof x;
+void x;
+x ?? y;
+x?.y?.z;
+x ??= y;
+x &&= y;
+x ||= y;