blob: 093b756fbb7d7af8c362ae1a071e104c8f12f63e [file] [log] [blame]
sbarati@apple.com36c13402015-09-18 23:37:42 +00001function assert(cond) {
2 if (!cond)
3 throw new Error("broke assertion");
4}
5noInline(assert);
6
7function shouldThrowInvalidConstAssignment(f) {
8 var threw = false;
9 try {
10 f();
11 } catch(e) {
12 //print(e);
13 if (e.name.indexOf("TypeError") !== -1 && e.message.indexOf("readonly") !== -1)
14 threw = true;
15 }
16 assert(threw);
17}
18noInline(shouldThrowInvalidConstAssignment);
19
20function baz(){}
21noInline(baz);
22
23function foo() {
24 for (const item of [1,2,3]) {
25 item = 20;
26 }
27}
28for (var i = 0; i < 1000; i++)
29 shouldThrowInvalidConstAssignment(foo);