Debian Codegraph @

js/src/jit-test/tests/cacheir/setgname-let.js

raw
1 let x = 2;
2
3 function simple() {
4 for (var i = 0; i < 10; i++) {
5 x = i;
6 assertEq(x, i);
7 }
8 }
9
10 function setname() {
11 function set(obj, v) {
12 with (obj) {
13 x = v;
14 }
15 }
16
17 set({}, 100)
18 assertEq(x, 100);
19 set({x: 1}, 0);
20 assertEq(x, 100);
21 set({__proto__: {x: 1}}, 13);
22 assertEq(x, 100);
23 }
24
25
26 function noshadow() {
27 for (var i = 0; i < 20; i++) {
28 x = i;
29 assertEq(x, i);
30
31 if (i == 10) {
32 globalThis.x = "haha";
33 assertEq(x, 10);
34 }
35 }
36 }
37
38 function uninitialized() {
39 for (var i = 0; i < 20; i++) {
40 var threw = false;
41 try {
42 undef = 2;
43 } catch {
44 threw = true;
45 }
46 assertEq(threw, true);
47 }
48 }
49
50 function simpleStrict() {
51 "use strict";
52 for (var i = 0; i < 10; i++) {
53 x = i;
54 assertEq(x, i);
55 }
56 }
57
58 // No with in strict!
59
60 function noshadowStrict() {
61 "use strict";
62 for (var i = 0; i < 20; i++) {
63 x = i;
64 assertEq(x, i);
65
66 if (i == 10) {
67 globalThis.x = "haha";
68 assertEq(x, 10);
69 }
70 }
71 }
72
73 function uninitializedStrict() {
74 for (var i = 0; i < 20; i++) {
75 var threw = false;
76 try {
77 undef = 2;
78 } catch {
79 threw = true;
80 }
81 assertEq(threw, true);
82 }
83 }
84
85 simple();
86 setname();
87 noshadow();
88 uninitialized();
89 simpleStrict();
90 noshadowStrict();
91 uninitializedStrict();
92
93 let undef = 42;