lazy-class-definition.js (1135B)
1 load(libdir + 'bytecode-cache.js'); 2 3 // Bury the class definition deep in a lazy function to hit edge cases of lazy 4 // script handling. 5 6 test = ` 7 function f1() { 8 function f2() { 9 function f3() { 10 class C { 11 constructor() { 12 this.x = 42; 13 } 14 } 15 return new C; 16 } 17 return f3(); 18 } 19 return f2(); 20 } 21 if (generation >= 2) { 22 assertEq(f1().x, 42); 23 } 24 `; 25 evalWithCache(test, {}); 26 27 // NOTE: Fields currently force full parsing, but this test may be more 28 // interesting in future. 29 test = ` 30 function f1() { 31 function f2() { 32 function f3() { 33 class C { 34 y = 12; 35 36 constructor() { 37 this.x = 42; 38 } 39 } 40 return new C; 41 } 42 return f3(); 43 } 44 return f2(); 45 } 46 if (generation >= 2) { 47 assertEq(f1().x, 42); 48 assertEq(f1().y, 12); 49 } 50 `; 51 evalWithCache(test, {});