@zappdev/cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/dist/zapp-cli.js +9471 -0
- package/native/src/app/app.zc +490 -0
- package/native/src/event/event.zc +24 -0
- package/native/src/event/events.zc +70 -0
- package/native/src/platform/darwin/backend.zc +923 -0
- package/native/src/platform/darwin/backend_bootstrap.zc +9 -0
- package/native/src/platform/darwin/bootstrap.zc +9 -0
- package/native/src/platform/darwin/engine_jsc.zc +86 -0
- package/native/src/platform/darwin/engine_qjs.zc +92 -0
- package/native/src/platform/darwin/platform.zc +156 -0
- package/native/src/platform/darwin/webview.zc +550 -0
- package/native/src/platform/darwin/webview_bootstrap.zc +9 -0
- package/native/src/platform/darwin/window.zc +1223 -0
- package/native/src/platform/darwin/worker/common.zc +223 -0
- package/native/src/platform/darwin/worker/core/base64_core.zc +29 -0
- package/native/src/platform/darwin/worker/core/crypto_core.zc +19 -0
- package/native/src/platform/darwin/worker/core/encoding_core.zc +32 -0
- package/native/src/platform/darwin/worker/core/fetch_core.zc +145 -0
- package/native/src/platform/darwin/worker/core/url_core.zc +69 -0
- package/native/src/platform/darwin/worker/core/websocket_core.zc +179 -0
- package/native/src/platform/darwin/worker/dispatch.zc +55 -0
- package/native/src/platform/darwin/worker/jsc/base64_jsc.zc +39 -0
- package/native/src/platform/darwin/worker/jsc/crypto_jsc.zc +49 -0
- package/native/src/platform/darwin/worker/jsc/encoding_jsc.zc +86 -0
- package/native/src/platform/darwin/worker/jsc/fetch_jsc.zc +149 -0
- package/native/src/platform/darwin/worker/jsc/url_jsc.zc +54 -0
- package/native/src/platform/darwin/worker/jsc/websocket_jsc.zc +127 -0
- package/native/src/platform/darwin/worker/jsc.zc +670 -0
- package/native/src/platform/darwin/worker/mod.zc +30 -0
- package/native/src/platform/darwin/worker/qjs/fetch_qjs.zc +233 -0
- package/native/src/platform/darwin/worker/qjs/qjs_macros.zc +23 -0
- package/native/src/platform/darwin/worker/qjs/websocket_qjs.zc +223 -0
- package/native/src/platform/darwin/worker/qjs.zc +1053 -0
- package/native/src/platform/darwin/worker/timers.zc +149 -0
- package/native/src/platform/darwin/worker/timers_qjs.zc +209 -0
- package/native/src/platform/platform.zc +64 -0
- package/native/src/platform/shared/log.zc +156 -0
- package/native/src/platform/shared/worker/qjs/base64_qjs.zc +38 -0
- package/native/src/platform/shared/worker/qjs/crypto_qjs.zc +44 -0
- package/native/src/platform/shared/worker/qjs/encoding_qjs.zc +95 -0
- package/native/src/platform/shared/worker/qjs/url_qjs.zc +65 -0
- package/native/src/platform/shared/worker_registry.zc +206 -0
- package/native/src/platform/window.zc +446 -0
- package/native/src/platform/windows/backend.zc +452 -0
- package/native/src/platform/windows/backend_bootstrap.zc +9 -0
- package/native/src/platform/windows/bootstrap.zc +9 -0
- package/native/src/platform/windows/engine_qjs.zc +60 -0
- package/native/src/platform/windows/platform.zc +387 -0
- package/native/src/platform/windows/webview.zc +1175 -0
- package/native/src/platform/windows/webview_bootstrap.zc +9 -0
- package/native/src/platform/windows/window.zc +1271 -0
- package/native/src/platform/windows/worker/common.zc +409 -0
- package/native/src/platform/windows/worker/core/base64_core.zc +52 -0
- package/native/src/platform/windows/worker/core/crypto_core.zc +34 -0
- package/native/src/platform/windows/worker/core/encoding_core.zc +60 -0
- package/native/src/platform/windows/worker/core/fetch_core.zc +274 -0
- package/native/src/platform/windows/worker/core/url_core.zc +216 -0
- package/native/src/platform/windows/worker/core/websocket_core.zc +343 -0
- package/native/src/platform/windows/worker/dispatch.zc +34 -0
- package/native/src/platform/windows/worker/mod.zc +46 -0
- package/native/src/platform/windows/worker/qjs/fetch_qjs.zc +255 -0
- package/native/src/platform/windows/worker/qjs/websocket_qjs.zc +263 -0
- package/native/src/platform/windows/worker/qjs.zc +1049 -0
- package/native/src/platform/windows/worker/timers_qjs.zc +288 -0
- package/native/src/platform/worker.zc +8 -0
- package/native/src/service/service.zc +228 -0
- package/native/vendor/quickjs-ng/.gitattributes +4 -0
- package/native/vendor/quickjs-ng/.github/dependabot.yml +7 -0
- package/native/vendor/quickjs-ng/.github/workflows/ci.yml +812 -0
- package/native/vendor/quickjs-ng/.github/workflows/docs.yml +49 -0
- package/native/vendor/quickjs-ng/.github/workflows/release.yml +162 -0
- package/native/vendor/quickjs-ng/.github/workflows/test-docs.yml +23 -0
- package/native/vendor/quickjs-ng/.github/workflows/tsan.yml +32 -0
- package/native/vendor/quickjs-ng/.github/workflows/valgrind.yml +33 -0
- package/native/vendor/quickjs-ng/.gitmodules +5 -0
- package/native/vendor/quickjs-ng/CMakeLists.txt +553 -0
- package/native/vendor/quickjs-ng/LICENSE +24 -0
- package/native/vendor/quickjs-ng/Makefile +149 -0
- package/native/vendor/quickjs-ng/amalgam.js +53 -0
- package/native/vendor/quickjs-ng/api-test.c +927 -0
- package/native/vendor/quickjs-ng/builtin-array-fromasync.h +119 -0
- package/native/vendor/quickjs-ng/builtin-array-fromasync.js +36 -0
- package/native/vendor/quickjs-ng/builtin-iterator-zip-keyed.h +332 -0
- package/native/vendor/quickjs-ng/builtin-iterator-zip-keyed.js +194 -0
- package/native/vendor/quickjs-ng/builtin-iterator-zip.h +337 -0
- package/native/vendor/quickjs-ng/builtin-iterator-zip.js +210 -0
- package/native/vendor/quickjs-ng/ctest.c +17 -0
- package/native/vendor/quickjs-ng/cutils.h +2013 -0
- package/native/vendor/quickjs-ng/cxxtest.cc +2 -0
- package/native/vendor/quickjs-ng/dtoa.c +1619 -0
- package/native/vendor/quickjs-ng/dtoa.h +87 -0
- package/native/vendor/quickjs-ng/examples/fib.c +67 -0
- package/native/vendor/quickjs-ng/examples/fib_module.js +10 -0
- package/native/vendor/quickjs-ng/examples/hello.js +1 -0
- package/native/vendor/quickjs-ng/examples/hello_module.js +6 -0
- package/native/vendor/quickjs-ng/examples/meson.build +17 -0
- package/native/vendor/quickjs-ng/examples/pi_bigint.js +118 -0
- package/native/vendor/quickjs-ng/examples/point.c +154 -0
- package/native/vendor/quickjs-ng/examples/test_fib.js +8 -0
- package/native/vendor/quickjs-ng/examples/test_point.js +43 -0
- package/native/vendor/quickjs-ng/fuzz.c +51 -0
- package/native/vendor/quickjs-ng/gen/function_source.c +81 -0
- package/native/vendor/quickjs-ng/gen/hello.c +53 -0
- package/native/vendor/quickjs-ng/gen/hello_module.c +106 -0
- package/native/vendor/quickjs-ng/gen/repl.c +3053 -0
- package/native/vendor/quickjs-ng/gen/standalone.c +324 -0
- package/native/vendor/quickjs-ng/gen/test_fib.c +81 -0
- package/native/vendor/quickjs-ng/libregexp-opcode.h +58 -0
- package/native/vendor/quickjs-ng/libregexp.c +2687 -0
- package/native/vendor/quickjs-ng/libregexp.h +98 -0
- package/native/vendor/quickjs-ng/libunicode-table.h +4707 -0
- package/native/vendor/quickjs-ng/libunicode.c +1746 -0
- package/native/vendor/quickjs-ng/libunicode.h +126 -0
- package/native/vendor/quickjs-ng/list.h +107 -0
- package/native/vendor/quickjs-ng/lre-test.c +73 -0
- package/native/vendor/quickjs-ng/meson.build +684 -0
- package/native/vendor/quickjs-ng/meson_options.txt +6 -0
- package/native/vendor/quickjs-ng/qjs-wasi-reactor.c +208 -0
- package/native/vendor/quickjs-ng/qjs.c +748 -0
- package/native/vendor/quickjs-ng/qjsc.c +673 -0
- package/native/vendor/quickjs-ng/quickjs-atom.h +267 -0
- package/native/vendor/quickjs-ng/quickjs-c-atomics.h +54 -0
- package/native/vendor/quickjs-ng/quickjs-libc.c +4986 -0
- package/native/vendor/quickjs-ng/quickjs-libc.h +79 -0
- package/native/vendor/quickjs-ng/quickjs-opcode.h +369 -0
- package/native/vendor/quickjs-ng/quickjs.c +60259 -0
- package/native/vendor/quickjs-ng/quickjs.h +1419 -0
- package/native/vendor/quickjs-ng/repl.js +1927 -0
- package/native/vendor/quickjs-ng/run-test262.c +2417 -0
- package/native/vendor/quickjs-ng/standalone.js +129 -0
- package/native/vendor/quickjs-ng/tests/assert.js +49 -0
- package/native/vendor/quickjs-ng/tests/bug1221.js +16 -0
- package/native/vendor/quickjs-ng/tests/bug1296.js +12 -0
- package/native/vendor/quickjs-ng/tests/bug1297.js +22 -0
- package/native/vendor/quickjs-ng/tests/bug1301.js +21 -0
- package/native/vendor/quickjs-ng/tests/bug1302.js +24 -0
- package/native/vendor/quickjs-ng/tests/bug1305.js +26 -0
- package/native/vendor/quickjs-ng/tests/bug1318.js +54 -0
- package/native/vendor/quickjs-ng/tests/bug1352.js +8 -0
- package/native/vendor/quickjs-ng/tests/bug1354.js +6 -0
- package/native/vendor/quickjs-ng/tests/bug1355.js +58 -0
- package/native/vendor/quickjs-ng/tests/bug1368.js +9 -0
- package/native/vendor/quickjs-ng/tests/bug39/1.js +6 -0
- package/native/vendor/quickjs-ng/tests/bug39/2.js +6 -0
- package/native/vendor/quickjs-ng/tests/bug39/3.js +7 -0
- package/native/vendor/quickjs-ng/tests/bug488-upstream.js +7 -0
- package/native/vendor/quickjs-ng/tests/bug633/0.js +7 -0
- package/native/vendor/quickjs-ng/tests/bug633/1.js +4 -0
- package/native/vendor/quickjs-ng/tests/bug633/2.js +4 -0
- package/native/vendor/quickjs-ng/tests/bug633/3.js +4 -0
- package/native/vendor/quickjs-ng/tests/bug645/0.js +4 -0
- package/native/vendor/quickjs-ng/tests/bug645/1.js +9 -0
- package/native/vendor/quickjs-ng/tests/bug645/2.js +7 -0
- package/native/vendor/quickjs-ng/tests/bug648.js +13 -0
- package/native/vendor/quickjs-ng/tests/bug652.js +4 -0
- package/native/vendor/quickjs-ng/tests/bug741.js +19 -0
- package/native/vendor/quickjs-ng/tests/bug775.js +7 -0
- package/native/vendor/quickjs-ng/tests/bug776.js +7 -0
- package/native/vendor/quickjs-ng/tests/bug832.js +2 -0
- package/native/vendor/quickjs-ng/tests/bug858.js +26 -0
- package/native/vendor/quickjs-ng/tests/bug904.js +6 -0
- package/native/vendor/quickjs-ng/tests/bug988.js +7 -0
- package/native/vendor/quickjs-ng/tests/bug999.js +3 -0
- package/native/vendor/quickjs-ng/tests/destructured-export.js +8 -0
- package/native/vendor/quickjs-ng/tests/detect_module/0.js +1 -0
- package/native/vendor/quickjs-ng/tests/detect_module/1.js +2 -0
- package/native/vendor/quickjs-ng/tests/detect_module/2.js +1 -0
- package/native/vendor/quickjs-ng/tests/detect_module/3.js +8 -0
- package/native/vendor/quickjs-ng/tests/detect_module/4.js +3 -0
- package/native/vendor/quickjs-ng/tests/empty.js +0 -0
- package/native/vendor/quickjs-ng/tests/fixture_cyclic_import.js +2 -0
- package/native/vendor/quickjs-ng/tests/fixture_string_exports.js +12 -0
- package/native/vendor/quickjs-ng/tests/function_source.js +14 -0
- package/native/vendor/quickjs-ng/tests/microbench.js +1267 -0
- package/native/vendor/quickjs-ng/tests/null_or_undefined.js +38 -0
- package/native/vendor/quickjs-ng/tests/str-pad-leak.js +5 -0
- package/native/vendor/quickjs-ng/tests/test_bigint.js +107 -0
- package/native/vendor/quickjs-ng/tests/test_bjson.js +366 -0
- package/native/vendor/quickjs-ng/tests/test_builtin.js +1314 -0
- package/native/vendor/quickjs-ng/tests/test_closure.js +220 -0
- package/native/vendor/quickjs-ng/tests/test_cyclic_import.js +12 -0
- package/native/vendor/quickjs-ng/tests/test_domexception.js +35 -0
- package/native/vendor/quickjs-ng/tests/test_language.js +755 -0
- package/native/vendor/quickjs-ng/tests/test_loop.js +367 -0
- package/native/vendor/quickjs-ng/tests/test_queue_microtask.js +39 -0
- package/native/vendor/quickjs-ng/tests/test_std.js +340 -0
- package/native/vendor/quickjs-ng/tests/test_string_exports.js +25 -0
- package/native/vendor/quickjs-ng/tests/test_worker.js +43 -0
- package/native/vendor/quickjs-ng/tests/test_worker_module.js +30 -0
- package/native/vendor/quickjs-ng/tests.conf +14 -0
- package/native/vendor/quickjs-ng/unicode_download.sh +19 -0
- package/native/vendor/quickjs-ng/unicode_gen.c +3108 -0
- package/native/vendor/quickjs-ng/unicode_gen_def.h +310 -0
- package/native/vendor/quickjs-ng/update-version.sh +32 -0
- package/native/vendor/webview2/include/WebView2.h +60636 -0
- package/native/vendor/webview2/include/WebView2EnvironmentOptions.h +406 -0
- package/package.json +33 -0
- package/src/backend.ts +139 -0
- package/src/build-config.ts +87 -0
- package/src/build.ts +276 -0
- package/src/common.ts +195 -0
- package/src/config.ts +89 -0
- package/src/dev.ts +164 -0
- package/src/generate.ts +200 -0
- package/src/icons.ts +116 -0
- package/src/init.ts +190 -0
- package/src/package.ts +150 -0
- package/src/zapp-cli.ts +263 -0
|
@@ -0,0 +1,755 @@
|
|
|
1
|
+
// This test cannot use imports because it needs to run in non-strict mode.
|
|
2
|
+
|
|
3
|
+
function assert(actual, expected, message) {
|
|
4
|
+
if (arguments.length == 1)
|
|
5
|
+
expected = true;
|
|
6
|
+
|
|
7
|
+
if (actual === expected)
|
|
8
|
+
return;
|
|
9
|
+
|
|
10
|
+
if (typeof actual == 'number' && isNaN(actual)
|
|
11
|
+
&& typeof expected == 'number' && isNaN(expected))
|
|
12
|
+
return;
|
|
13
|
+
|
|
14
|
+
if (actual !== null && expected !== null
|
|
15
|
+
&& typeof actual == 'object' && typeof expected == 'object'
|
|
16
|
+
&& actual.toString() === expected.toString())
|
|
17
|
+
return;
|
|
18
|
+
|
|
19
|
+
var msg = message ? " (" + message + ")" : "";
|
|
20
|
+
throw Error("assertion failed: got |" + actual + "|" +
|
|
21
|
+
", expected |" + expected + "|" + msg);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function assert_throws(expected_error, func, message)
|
|
25
|
+
{
|
|
26
|
+
var err = false;
|
|
27
|
+
var msg = message ? " (" + message + ")" : "";
|
|
28
|
+
try {
|
|
29
|
+
switch (typeof func) {
|
|
30
|
+
case 'string':
|
|
31
|
+
eval(func);
|
|
32
|
+
break;
|
|
33
|
+
case 'function':
|
|
34
|
+
func();
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
} catch(e) {
|
|
38
|
+
err = true;
|
|
39
|
+
if (!(e instanceof expected_error)) {
|
|
40
|
+
throw Error(`expected ${expected_error.name}, got ${e.name}${msg}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (!err) {
|
|
44
|
+
throw Error(`expected ${expected_error.name}${msg}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/*----------------*/
|
|
49
|
+
|
|
50
|
+
function test_op1()
|
|
51
|
+
{
|
|
52
|
+
var r, a;
|
|
53
|
+
r = 1 + 2;
|
|
54
|
+
assert(r, 3, "1 + 2 === 3");
|
|
55
|
+
|
|
56
|
+
r = 1 - 2;
|
|
57
|
+
assert(r, -1, "1 - 2 === -1");
|
|
58
|
+
|
|
59
|
+
r = -1;
|
|
60
|
+
assert(r, -1, "-1 === -1");
|
|
61
|
+
|
|
62
|
+
r = +2;
|
|
63
|
+
assert(r, 2, "+2 === 2");
|
|
64
|
+
|
|
65
|
+
r = 2 * 3;
|
|
66
|
+
assert(r, 6, "2 * 3 === 6");
|
|
67
|
+
|
|
68
|
+
r = 4 / 2;
|
|
69
|
+
assert(r, 2, "4 / 2 === 2");
|
|
70
|
+
|
|
71
|
+
r = 4 % 3;
|
|
72
|
+
assert(r, 1, "4 % 3 === 3");
|
|
73
|
+
|
|
74
|
+
r = 4 << 2;
|
|
75
|
+
assert(r, 16, "4 << 2 === 16");
|
|
76
|
+
|
|
77
|
+
r = 1 << 0;
|
|
78
|
+
assert(r, 1, "1 << 0 === 1");
|
|
79
|
+
|
|
80
|
+
r = 1 << 31;
|
|
81
|
+
assert(r, -2147483648, "1 << 31 === -2147483648");
|
|
82
|
+
|
|
83
|
+
r = 1 << 32;
|
|
84
|
+
assert(r, 1, "1 << 32 === 1");
|
|
85
|
+
|
|
86
|
+
r = (1 << 31) < 0;
|
|
87
|
+
assert(r, true, "(1 << 31) < 0 === true");
|
|
88
|
+
|
|
89
|
+
r = -4 >> 1;
|
|
90
|
+
assert(r, -2, "-4 >> 1 === -2");
|
|
91
|
+
|
|
92
|
+
r = -4 >>> 1;
|
|
93
|
+
assert(r, 0x7ffffffe, "-4 >>> 1 === 0x7ffffffe");
|
|
94
|
+
|
|
95
|
+
r = 1 & 1;
|
|
96
|
+
assert(r, 1, "1 & 1 === 1");
|
|
97
|
+
|
|
98
|
+
r = 0 | 1;
|
|
99
|
+
assert(r, 1, "0 | 1 === 1");
|
|
100
|
+
|
|
101
|
+
r = 1 ^ 1;
|
|
102
|
+
assert(r, 0, "1 ^ 1 === 0");
|
|
103
|
+
|
|
104
|
+
r = ~1;
|
|
105
|
+
assert(r, -2, "~1 === -2");
|
|
106
|
+
|
|
107
|
+
r = !1;
|
|
108
|
+
assert(r, false, "!1 === false");
|
|
109
|
+
|
|
110
|
+
assert((1 < 2), true, "(1 < 2) === true");
|
|
111
|
+
|
|
112
|
+
assert((2 > 1), true, "(2 > 1) === true");
|
|
113
|
+
|
|
114
|
+
assert(('b' > 'a'), true, "('b' > 'a') === true");
|
|
115
|
+
|
|
116
|
+
assert(2 ** 8, 256, "2 ** 8 === 256");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function test_cvt()
|
|
120
|
+
{
|
|
121
|
+
assert((NaN | 0), 0);
|
|
122
|
+
assert((Infinity | 0), 0);
|
|
123
|
+
assert(((-Infinity) | 0), 0);
|
|
124
|
+
assert(("12345" | 0), 12345);
|
|
125
|
+
assert(("0x12345" | 0), 0x12345);
|
|
126
|
+
assert(((4294967296 * 3 - 4) | 0), -4);
|
|
127
|
+
|
|
128
|
+
assert(("12345" >>> 0), 12345);
|
|
129
|
+
assert(("0x12345" >>> 0), 0x12345);
|
|
130
|
+
assert((NaN >>> 0), 0);
|
|
131
|
+
assert((Infinity >>> 0), 0);
|
|
132
|
+
assert(((-Infinity) >>> 0), 0);
|
|
133
|
+
assert(((4294967296 * 3 - 4) >>> 0), (4294967296 - 4));
|
|
134
|
+
assert((19686109595169230000).toString(), "19686109595169230000");
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function test_eq()
|
|
138
|
+
{
|
|
139
|
+
assert(null == undefined);
|
|
140
|
+
assert(undefined == null);
|
|
141
|
+
assert(true == 1);
|
|
142
|
+
assert(0 == false);
|
|
143
|
+
assert("" == 0);
|
|
144
|
+
assert("123" == 123);
|
|
145
|
+
assert("122" != 123);
|
|
146
|
+
assert((new Number(1)) == 1);
|
|
147
|
+
assert(2 == (new Number(2)));
|
|
148
|
+
assert((new String("abc")) == "abc");
|
|
149
|
+
assert({} != "abc");
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function test_inc_dec()
|
|
153
|
+
{
|
|
154
|
+
var a, r;
|
|
155
|
+
|
|
156
|
+
a = 1;
|
|
157
|
+
r = a++;
|
|
158
|
+
assert(r === 1 && a === 2, true, "++");
|
|
159
|
+
|
|
160
|
+
a = 1;
|
|
161
|
+
r = ++a;
|
|
162
|
+
assert(r === 2 && a === 2, true, "++");
|
|
163
|
+
|
|
164
|
+
a = 1;
|
|
165
|
+
r = a--;
|
|
166
|
+
assert(r === 1 && a === 0, true, "--");
|
|
167
|
+
|
|
168
|
+
a = 1;
|
|
169
|
+
r = --a;
|
|
170
|
+
assert(r === 0 && a === 0, true, "--");
|
|
171
|
+
|
|
172
|
+
a = {x:true};
|
|
173
|
+
a.x++;
|
|
174
|
+
assert(a.x, 2, "++");
|
|
175
|
+
|
|
176
|
+
a = {x:true};
|
|
177
|
+
a.x--;
|
|
178
|
+
assert(a.x, 0, "--");
|
|
179
|
+
|
|
180
|
+
a = [true];
|
|
181
|
+
a[0]++;
|
|
182
|
+
assert(a[0], 2, "++");
|
|
183
|
+
|
|
184
|
+
a = {x:true};
|
|
185
|
+
r = a.x++;
|
|
186
|
+
assert(r === 1 && a.x === 2, true, "++");
|
|
187
|
+
|
|
188
|
+
a = {x:true};
|
|
189
|
+
r = a.x--;
|
|
190
|
+
assert(r === 1 && a.x === 0, true, "--");
|
|
191
|
+
|
|
192
|
+
a = [true];
|
|
193
|
+
r = a[0]++;
|
|
194
|
+
assert(r === 1 && a[0] === 2, true, "++");
|
|
195
|
+
|
|
196
|
+
a = [true];
|
|
197
|
+
r = a[0]--;
|
|
198
|
+
assert(r === 1 && a[0] === 0, true, "--");
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function F(x)
|
|
202
|
+
{
|
|
203
|
+
this.x = x;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function test_op2()
|
|
207
|
+
{
|
|
208
|
+
var a, b;
|
|
209
|
+
a = new Object;
|
|
210
|
+
a.x = 1;
|
|
211
|
+
assert(a.x, 1, "new");
|
|
212
|
+
b = new F(2);
|
|
213
|
+
assert(b.x, 2, "new");
|
|
214
|
+
|
|
215
|
+
a = {x : 2};
|
|
216
|
+
assert(("x" in a), true, "in");
|
|
217
|
+
assert(("y" in a), false, "in");
|
|
218
|
+
|
|
219
|
+
a = {};
|
|
220
|
+
assert((a instanceof Object), true, "instanceof");
|
|
221
|
+
assert((a instanceof String), false, "instanceof");
|
|
222
|
+
|
|
223
|
+
assert((typeof 1), "number", "typeof");
|
|
224
|
+
assert((typeof Object), "function", "typeof");
|
|
225
|
+
assert((typeof null), "object", "typeof");
|
|
226
|
+
assert((typeof unknown_var), "undefined", "typeof");
|
|
227
|
+
|
|
228
|
+
a = {x: 1, if: 2, async: 3};
|
|
229
|
+
assert(a.if === 2);
|
|
230
|
+
assert(a.async === 3);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function test_delete()
|
|
234
|
+
{
|
|
235
|
+
var a, err;
|
|
236
|
+
|
|
237
|
+
a = {x: 1, y: 1};
|
|
238
|
+
assert((delete a.x), true, "delete");
|
|
239
|
+
assert(("x" in a), false, "delete");
|
|
240
|
+
|
|
241
|
+
/* the following are not tested by test262 */
|
|
242
|
+
assert(delete "abc"[100], true);
|
|
243
|
+
|
|
244
|
+
err = false;
|
|
245
|
+
try {
|
|
246
|
+
delete null.a;
|
|
247
|
+
} catch(e) {
|
|
248
|
+
err = (e instanceof TypeError);
|
|
249
|
+
}
|
|
250
|
+
assert(err, true, "delete");
|
|
251
|
+
|
|
252
|
+
err = false;
|
|
253
|
+
try {
|
|
254
|
+
a = { f() { delete super.a; } };
|
|
255
|
+
a.f();
|
|
256
|
+
} catch(e) {
|
|
257
|
+
err = (e instanceof ReferenceError);
|
|
258
|
+
}
|
|
259
|
+
assert(err, true, "delete");
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function test_constructor()
|
|
263
|
+
{
|
|
264
|
+
function *G() {}
|
|
265
|
+
let ex
|
|
266
|
+
try { new G() } catch (ex_) { ex = ex_ }
|
|
267
|
+
assert(ex instanceof TypeError)
|
|
268
|
+
assert(ex.message, "G is not a constructor")
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function test_prototype()
|
|
272
|
+
{
|
|
273
|
+
var f = function f() { };
|
|
274
|
+
assert(f.prototype.constructor, f, "prototype");
|
|
275
|
+
|
|
276
|
+
var g = function g() { };
|
|
277
|
+
/* QuickJS bug */
|
|
278
|
+
Object.defineProperty(g, "prototype", { writable: false });
|
|
279
|
+
assert(g.prototype.constructor, g, "prototype");
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function test_arguments()
|
|
283
|
+
{
|
|
284
|
+
function f2() {
|
|
285
|
+
assert(arguments.length, 2, "arguments");
|
|
286
|
+
assert(arguments[0], 1, "arguments");
|
|
287
|
+
assert(arguments[1], 3, "arguments");
|
|
288
|
+
}
|
|
289
|
+
f2(1, 3);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function test_class()
|
|
293
|
+
{
|
|
294
|
+
var o;
|
|
295
|
+
class C {
|
|
296
|
+
constructor() {
|
|
297
|
+
this.x = 10;
|
|
298
|
+
}
|
|
299
|
+
f() {
|
|
300
|
+
return 1;
|
|
301
|
+
}
|
|
302
|
+
static F() {
|
|
303
|
+
return -1;
|
|
304
|
+
}
|
|
305
|
+
get y() {
|
|
306
|
+
return 12;
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
class D extends C {
|
|
310
|
+
constructor() {
|
|
311
|
+
super();
|
|
312
|
+
this.z = 20;
|
|
313
|
+
}
|
|
314
|
+
g() {
|
|
315
|
+
return 2;
|
|
316
|
+
}
|
|
317
|
+
static G() {
|
|
318
|
+
return -2;
|
|
319
|
+
}
|
|
320
|
+
h() {
|
|
321
|
+
return super.f();
|
|
322
|
+
}
|
|
323
|
+
static H() {
|
|
324
|
+
return super["F"]();
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
assert(C.F(), -1);
|
|
329
|
+
assert(Object.getOwnPropertyDescriptor(C.prototype, "y").get.name === "get y");
|
|
330
|
+
|
|
331
|
+
o = new C();
|
|
332
|
+
assert(o.f(), 1);
|
|
333
|
+
assert(o.x, 10);
|
|
334
|
+
|
|
335
|
+
assert(D.F(), -1);
|
|
336
|
+
assert(D.G(), -2);
|
|
337
|
+
assert(D.H(), -1);
|
|
338
|
+
|
|
339
|
+
o = new D();
|
|
340
|
+
assert(o.f(), 1);
|
|
341
|
+
assert(o.g(), 2);
|
|
342
|
+
assert(o.x, 10);
|
|
343
|
+
assert(o.z, 20);
|
|
344
|
+
assert(o.h(), 1);
|
|
345
|
+
|
|
346
|
+
/* test class name scope */
|
|
347
|
+
var E1 = class E { static F() { return E; } };
|
|
348
|
+
assert(E1, E1.F());
|
|
349
|
+
|
|
350
|
+
class S {
|
|
351
|
+
static x = 42;
|
|
352
|
+
static y = S.x;
|
|
353
|
+
static z = this.x;
|
|
354
|
+
}
|
|
355
|
+
assert(S.x, 42);
|
|
356
|
+
assert(S.y, 42);
|
|
357
|
+
assert(S.z, 42);
|
|
358
|
+
|
|
359
|
+
class P {
|
|
360
|
+
get;
|
|
361
|
+
set;
|
|
362
|
+
async;
|
|
363
|
+
get = () => "123";
|
|
364
|
+
set = () => "456";
|
|
365
|
+
async = () => "789";
|
|
366
|
+
static() { return 42; }
|
|
367
|
+
}
|
|
368
|
+
assert(new P().get(), "123");
|
|
369
|
+
assert(new P().set(), "456");
|
|
370
|
+
assert(new P().async(), "789");
|
|
371
|
+
assert(new P().static(), 42);
|
|
372
|
+
|
|
373
|
+
/* test that division after private field in parens is not parsed as regex */
|
|
374
|
+
class Q {
|
|
375
|
+
#x = 10;
|
|
376
|
+
f() { return (this.#x / 2); }
|
|
377
|
+
}
|
|
378
|
+
assert(new Q().f(), 5);
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
function test_template()
|
|
382
|
+
{
|
|
383
|
+
var a, b;
|
|
384
|
+
b = 123;
|
|
385
|
+
a = `abc${b}d`;
|
|
386
|
+
assert(a, "abc123d");
|
|
387
|
+
|
|
388
|
+
a = String.raw `abc${b}d`;
|
|
389
|
+
assert(a, "abc123d");
|
|
390
|
+
|
|
391
|
+
a = "aaa";
|
|
392
|
+
b = "bbb";
|
|
393
|
+
assert(`aaa${a, b}ccc`, "aaabbbccc");
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function test_template_skip()
|
|
397
|
+
{
|
|
398
|
+
var a = "Bar";
|
|
399
|
+
var { b = `${a + `a${a}` }baz` } = {};
|
|
400
|
+
assert(b, "BaraBarbaz");
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function test_object_literal()
|
|
404
|
+
{
|
|
405
|
+
var x = 0, get = 1, set = 2; async = 3;
|
|
406
|
+
a = { get: 2, set: 3, async: 4, get a(){ return this.get} };
|
|
407
|
+
assert(JSON.stringify(a), '{"get":2,"set":3,"async":4,"a":2}');
|
|
408
|
+
assert(a.a, 2);
|
|
409
|
+
|
|
410
|
+
a = { x, get, set, async };
|
|
411
|
+
assert(JSON.stringify(a), '{"x":0,"get":1,"set":2,"async":3}');
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function test_regexp_skip()
|
|
415
|
+
{
|
|
416
|
+
var a, b;
|
|
417
|
+
[a, b = /abc\(/] = [1];
|
|
418
|
+
assert(a, 1);
|
|
419
|
+
|
|
420
|
+
[a, b =/abc\(/] = [2];
|
|
421
|
+
assert(a, 2);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function test_labels()
|
|
425
|
+
{
|
|
426
|
+
do x: { break x; } while(0);
|
|
427
|
+
if (1)
|
|
428
|
+
x: { break x; }
|
|
429
|
+
else
|
|
430
|
+
x: { break x; }
|
|
431
|
+
with ({}) x: { break x; };
|
|
432
|
+
while (0) x: { break x; };
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
function test_destructuring()
|
|
436
|
+
{
|
|
437
|
+
function * g () { return 0; };
|
|
438
|
+
var [x] = g();
|
|
439
|
+
assert(x, void 0);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function test_spread()
|
|
443
|
+
{
|
|
444
|
+
var x;
|
|
445
|
+
x = [1, 2, ...[3, 4]];
|
|
446
|
+
assert(x.toString(), "1,2,3,4");
|
|
447
|
+
|
|
448
|
+
x = [ ...[ , ] ];
|
|
449
|
+
assert(Object.getOwnPropertyNames(x).toString(), "0,length");
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function test_function_length()
|
|
453
|
+
{
|
|
454
|
+
assert( ((a, b = 1, c) => {}).length, 1);
|
|
455
|
+
assert( (([a,b]) => {}).length, 1);
|
|
456
|
+
assert( (({a,b}) => {}).length, 1);
|
|
457
|
+
assert( ((c, [a,b] = 1, d) => {}).length, 1);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function test_argument_scope()
|
|
461
|
+
{
|
|
462
|
+
var f;
|
|
463
|
+
var c = "global";
|
|
464
|
+
|
|
465
|
+
f = function(a = eval("var arguments")) {};
|
|
466
|
+
// for some reason v8 does not throw an exception here
|
|
467
|
+
if (typeof require === 'undefined')
|
|
468
|
+
assert_throws(SyntaxError, f);
|
|
469
|
+
|
|
470
|
+
f = function(a = eval("1"), b = arguments[0]) { return b; };
|
|
471
|
+
assert(f(12), 12);
|
|
472
|
+
|
|
473
|
+
f = function(a, b = arguments[0]) { return b; };
|
|
474
|
+
assert(f(12), 12);
|
|
475
|
+
|
|
476
|
+
f = function(a, b = () => arguments) { return b; };
|
|
477
|
+
assert(f(12)()[0], 12);
|
|
478
|
+
|
|
479
|
+
f = function(a = eval("1"), b = () => arguments) { return b; };
|
|
480
|
+
assert(f(12)()[0], 12);
|
|
481
|
+
|
|
482
|
+
(function() {
|
|
483
|
+
"use strict";
|
|
484
|
+
f = function(a = this) { return a; };
|
|
485
|
+
assert(f.call(123), 123);
|
|
486
|
+
|
|
487
|
+
f = function f(a = f) { return a; };
|
|
488
|
+
assert(f(), f);
|
|
489
|
+
|
|
490
|
+
f = function f(a = eval("f")) { return a; };
|
|
491
|
+
assert(f(), f);
|
|
492
|
+
})();
|
|
493
|
+
|
|
494
|
+
f = (a = eval("var c = 1"), probe = () => c) => {
|
|
495
|
+
var c = 2;
|
|
496
|
+
assert(c, 2);
|
|
497
|
+
assert(probe(), 1);
|
|
498
|
+
}
|
|
499
|
+
f();
|
|
500
|
+
|
|
501
|
+
f = (a = eval("var arguments = 1"), probe = () => arguments) => {
|
|
502
|
+
var arguments = 2;
|
|
503
|
+
assert(arguments, 2);
|
|
504
|
+
assert(probe(), 1);
|
|
505
|
+
}
|
|
506
|
+
f();
|
|
507
|
+
|
|
508
|
+
f = function f(a = eval("var c = 1"), b = c, probe = () => c) {
|
|
509
|
+
assert(b, 1);
|
|
510
|
+
assert(c, 1);
|
|
511
|
+
assert(probe(), 1)
|
|
512
|
+
}
|
|
513
|
+
f();
|
|
514
|
+
|
|
515
|
+
assert(c, "global");
|
|
516
|
+
f = function f(a, b = c, probe = () => c) {
|
|
517
|
+
eval("var c = 1");
|
|
518
|
+
assert(c, 1);
|
|
519
|
+
assert(b, "global");
|
|
520
|
+
assert(probe(), "global")
|
|
521
|
+
}
|
|
522
|
+
f();
|
|
523
|
+
assert(c, "global");
|
|
524
|
+
|
|
525
|
+
f = function f(a = eval("var c = 1"), probe = (d = eval("c")) => d) {
|
|
526
|
+
assert(probe(), 1)
|
|
527
|
+
}
|
|
528
|
+
f();
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
function test_function_expr_name()
|
|
532
|
+
{
|
|
533
|
+
var f;
|
|
534
|
+
|
|
535
|
+
/* non strict mode test : assignment to the function name silently
|
|
536
|
+
fails */
|
|
537
|
+
|
|
538
|
+
f = function myfunc() {
|
|
539
|
+
myfunc = 1;
|
|
540
|
+
return myfunc;
|
|
541
|
+
};
|
|
542
|
+
assert(f(), f);
|
|
543
|
+
|
|
544
|
+
f = function myfunc() {
|
|
545
|
+
myfunc = 1;
|
|
546
|
+
(() => {
|
|
547
|
+
myfunc = 1;
|
|
548
|
+
})();
|
|
549
|
+
return myfunc;
|
|
550
|
+
};
|
|
551
|
+
assert(f(), f);
|
|
552
|
+
|
|
553
|
+
f = function myfunc() {
|
|
554
|
+
eval("myfunc = 1");
|
|
555
|
+
return myfunc;
|
|
556
|
+
};
|
|
557
|
+
assert(f(), f);
|
|
558
|
+
|
|
559
|
+
/* strict mode test : assignment to the function name raises a
|
|
560
|
+
TypeError exception */
|
|
561
|
+
|
|
562
|
+
f = function myfunc() {
|
|
563
|
+
"use strict";
|
|
564
|
+
myfunc = 1;
|
|
565
|
+
};
|
|
566
|
+
assert_throws(TypeError, f);
|
|
567
|
+
|
|
568
|
+
f = function myfunc() {
|
|
569
|
+
"use strict";
|
|
570
|
+
(() => {
|
|
571
|
+
myfunc = 1;
|
|
572
|
+
})();
|
|
573
|
+
};
|
|
574
|
+
assert_throws(TypeError, f);
|
|
575
|
+
|
|
576
|
+
f = function myfunc() {
|
|
577
|
+
"use strict";
|
|
578
|
+
eval("myfunc = 1");
|
|
579
|
+
};
|
|
580
|
+
assert_throws(TypeError, f);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
function test_expr(expr, err) {
|
|
584
|
+
if (err)
|
|
585
|
+
assert_throws(err, expr, `for ${expr}`);
|
|
586
|
+
else
|
|
587
|
+
assert(1, eval(expr), `for ${expr}`);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
function test_name(name, err)
|
|
591
|
+
{
|
|
592
|
+
test_expr(`(function() { return typeof ${name} ? 1 : 1; })()`);
|
|
593
|
+
test_expr(`(function() { var ${name}; ${name} = 1; return ${name}; })()`);
|
|
594
|
+
test_expr(`(function() { let ${name}; ${name} = 1; return ${name}; })()`, name == 'let' ? SyntaxError : undefined);
|
|
595
|
+
test_expr(`(function() { const ${name} = 1; return ${name}; })()`, name == 'let' ? SyntaxError : undefined);
|
|
596
|
+
test_expr(`(function(${name}) { ${name} = 1; return ${name}; })()`);
|
|
597
|
+
test_expr(`(function({${name}}) { ${name} = 1; return ${name}; })({})`);
|
|
598
|
+
test_expr(`(function ${name}() { return ${name} ? 1 : 0; })()`);
|
|
599
|
+
test_expr(`"use strict"; (function() { return typeof ${name} ? 1 : 1; })()`, err);
|
|
600
|
+
test_expr(`"use strict"; (function() { if (0) ${name} = 1; return 1; })()`, err);
|
|
601
|
+
test_expr(`"use strict"; (function() { var x; if (0) x = ${name}; return 1; })()`, err);
|
|
602
|
+
test_expr(`"use strict"; (function() { var ${name}; return 1; })()`, err);
|
|
603
|
+
test_expr(`"use strict"; (function() { let ${name}; return 1; })()`, err);
|
|
604
|
+
test_expr(`"use strict"; (function() { const ${name} = 1; return 1; })()`, err);
|
|
605
|
+
test_expr(`"use strict"; (function() { var ${name}; ${name} = 1; return 1; })()`, err);
|
|
606
|
+
test_expr(`"use strict"; (function() { var ${name}; ${name} = 1; return ${name}; })()`, err);
|
|
607
|
+
test_expr(`"use strict"; (function(${name}) { return 1; })()`, err);
|
|
608
|
+
test_expr(`"use strict"; (function({${name}}) { return 1; })({})`, err);
|
|
609
|
+
test_expr(`"use strict"; (function ${name}() { return 1; })()`, err);
|
|
610
|
+
test_expr(`(function() { "use strict"; return typeof ${name} ? 1 : 1; })()`, err);
|
|
611
|
+
test_expr(`(function() { "use strict"; if (0) ${name} = 1; return 1; })()`, err);
|
|
612
|
+
test_expr(`(function() { "use strict"; var x; if (0) x = ${name}; return 1; })()`, err);
|
|
613
|
+
test_expr(`(function() { "use strict"; var ${name}; return 1; })()`, err);
|
|
614
|
+
test_expr(`(function() { "use strict"; let ${name}; return 1; })()`, err);
|
|
615
|
+
test_expr(`(function() { "use strict"; const ${name} = 1; return 1; })()`, err);
|
|
616
|
+
test_expr(`(function() { "use strict"; var ${name}; ${name} = 1; return 1; })()`, err);
|
|
617
|
+
test_expr(`(function() { "use strict"; var ${name}; ${name} = 1; return ${name}; })()`, err);
|
|
618
|
+
test_expr(`(function(${name}) { "use strict"; return 1; })()`, err);
|
|
619
|
+
test_expr(`(function({${name}}) { "use strict"; return 1; })({})`, SyntaxError);
|
|
620
|
+
test_expr(`(function ${name}() { "use strict"; return 1; })()`, err);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
function test_reserved_names()
|
|
624
|
+
{
|
|
625
|
+
test_name('await');
|
|
626
|
+
test_name('yield', SyntaxError);
|
|
627
|
+
test_name('implements', SyntaxError);
|
|
628
|
+
test_name('interface', SyntaxError);
|
|
629
|
+
test_name('let', SyntaxError);
|
|
630
|
+
test_name('package', SyntaxError);
|
|
631
|
+
test_name('private', SyntaxError);
|
|
632
|
+
test_name('protected', SyntaxError);
|
|
633
|
+
test_name('public', SyntaxError);
|
|
634
|
+
test_name('static', SyntaxError);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
function test_number_literals()
|
|
638
|
+
{
|
|
639
|
+
assert(0.1.a, undefined);
|
|
640
|
+
assert(0x1.a, undefined);
|
|
641
|
+
assert(0b1.a, undefined);
|
|
642
|
+
assert(01.a, undefined);
|
|
643
|
+
assert(0o1.a, undefined);
|
|
644
|
+
test_expr('0.a', SyntaxError);
|
|
645
|
+
assert(parseInt("0_1"), 0);
|
|
646
|
+
assert(parseInt("1_0"), 1);
|
|
647
|
+
assert(parseInt("0_1", 8), 0);
|
|
648
|
+
assert(parseInt("1_0", 8), 1);
|
|
649
|
+
assert(parseFloat("0_1"), 0);
|
|
650
|
+
assert(parseFloat("1_0"), 1);
|
|
651
|
+
assert(1_0, 10);
|
|
652
|
+
assert(parseInt("Infinity"), NaN);
|
|
653
|
+
assert(parseFloat("Infinity"), Infinity);
|
|
654
|
+
assert(parseFloat("Infinity1"), Infinity);
|
|
655
|
+
assert(parseFloat("Infinity_"), Infinity);
|
|
656
|
+
assert(parseFloat("Infinity."), Infinity);
|
|
657
|
+
test_expr('0_0', SyntaxError);
|
|
658
|
+
test_expr('00_0', SyntaxError);
|
|
659
|
+
test_expr('01_0', SyntaxError);
|
|
660
|
+
test_expr('08_0', SyntaxError);
|
|
661
|
+
test_expr('09_0', SyntaxError);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
function test_syntax()
|
|
665
|
+
{
|
|
666
|
+
assert_throws(SyntaxError, "do");
|
|
667
|
+
assert_throws(SyntaxError, "do;");
|
|
668
|
+
assert_throws(SyntaxError, "do{}");
|
|
669
|
+
assert_throws(SyntaxError, "if");
|
|
670
|
+
assert_throws(SyntaxError, "if\n");
|
|
671
|
+
assert_throws(SyntaxError, "if 1");
|
|
672
|
+
assert_throws(SyntaxError, "if \0");
|
|
673
|
+
assert_throws(SyntaxError, "if ;");
|
|
674
|
+
assert_throws(SyntaxError, "if 'abc'");
|
|
675
|
+
assert_throws(SyntaxError, "if `abc`");
|
|
676
|
+
assert_throws(SyntaxError, "if /abc/");
|
|
677
|
+
assert_throws(SyntaxError, "if abc");
|
|
678
|
+
assert_throws(SyntaxError, "if abc\u0064");
|
|
679
|
+
assert_throws(SyntaxError, "if abc\\u0064");
|
|
680
|
+
assert_throws(SyntaxError, "if \u0123");
|
|
681
|
+
assert_throws(SyntaxError, "if \\u0123");
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/* optional chaining tests not present in test262 */
|
|
685
|
+
function test_optional_chaining()
|
|
686
|
+
{
|
|
687
|
+
var a, z;
|
|
688
|
+
z = null;
|
|
689
|
+
a = { b: { c: 2 } };
|
|
690
|
+
assert(delete z?.b.c, true);
|
|
691
|
+
assert(delete a?.b.c, true);
|
|
692
|
+
assert(JSON.stringify(a), '{"b":{}}', "optional chaining delete");
|
|
693
|
+
|
|
694
|
+
a = { b: { c: 2 } };
|
|
695
|
+
assert(delete z?.b["c"], true);
|
|
696
|
+
assert(delete a?.b["c"], true);
|
|
697
|
+
assert(JSON.stringify(a), '{"b":{}}');
|
|
698
|
+
|
|
699
|
+
a = {
|
|
700
|
+
b() { return this._b; },
|
|
701
|
+
_b: { c: 42 }
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
assert((a?.b)().c, 42);
|
|
705
|
+
|
|
706
|
+
assert((a?.["b"])().c, 42);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
function test_parse_semicolon()
|
|
710
|
+
{
|
|
711
|
+
/* 'yield' or 'await' may not be considered as a token if the
|
|
712
|
+
previous ';' is missing */
|
|
713
|
+
function *f()
|
|
714
|
+
{
|
|
715
|
+
function func() {
|
|
716
|
+
}
|
|
717
|
+
yield 1;
|
|
718
|
+
var h = x => x + 1
|
|
719
|
+
yield 2;
|
|
720
|
+
}
|
|
721
|
+
async function g()
|
|
722
|
+
{
|
|
723
|
+
function func() {
|
|
724
|
+
}
|
|
725
|
+
await 1;
|
|
726
|
+
var h = x => x + 1
|
|
727
|
+
await 2;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
test_op1();
|
|
732
|
+
test_cvt();
|
|
733
|
+
test_eq();
|
|
734
|
+
test_inc_dec();
|
|
735
|
+
test_op2();
|
|
736
|
+
test_delete();
|
|
737
|
+
test_constructor();
|
|
738
|
+
test_prototype();
|
|
739
|
+
test_arguments();
|
|
740
|
+
test_class();
|
|
741
|
+
test_template();
|
|
742
|
+
test_template_skip();
|
|
743
|
+
test_object_literal();
|
|
744
|
+
test_regexp_skip();
|
|
745
|
+
test_labels();
|
|
746
|
+
test_destructuring();
|
|
747
|
+
test_spread();
|
|
748
|
+
test_function_length();
|
|
749
|
+
test_argument_scope();
|
|
750
|
+
test_function_expr_name();
|
|
751
|
+
test_reserved_names();
|
|
752
|
+
test_number_literals();
|
|
753
|
+
test_syntax();
|
|
754
|
+
test_optional_chaining();
|
|
755
|
+
test_parse_semicolon();
|