spread-call-this-strict.js (1607B)
1 "use strict"; 2 3 let global = this; 4 let p = {}; 5 let q = {}; 6 7 let g1 = function() { 8 assertEq(this, undefined); 9 }; 10 g1(...[]); 11 12 let g2 = x => { 13 assertEq(this, global); 14 }; 15 g2(...[]); 16 17 let g3 = function() { 18 assertEq(this, p); 19 }; 20 g3.apply(p, ...[]); 21 g3.call(p, ...[]); 22 23 g2.apply(p, ...[]); 24 g2.call(p, ...[]); 25 26 let o = { 27 f1: function() { 28 assertEq(this, o); 29 30 let g1 = function() { 31 assertEq(this, undefined); 32 }; 33 g1(...[]); 34 35 let g2 = x => { 36 assertEq(this, o); 37 }; 38 g2(...[]); 39 40 let g3 = function() { 41 assertEq(this, q); 42 }; 43 g3.apply(q, ...[]); 44 g3.call(q, ...[]); 45 46 let g4 = x => { 47 assertEq(this, o); 48 }; 49 g4.apply(q, ...[]); 50 g4.call(q, ...[]); 51 }, 52 f2: x => { 53 assertEq(this, global); 54 let g1 = function() { 55 assertEq(this, undefined); 56 }; 57 g1(...[]); 58 59 let g2 = x => { 60 assertEq(this, global); 61 }; 62 g2(...[]); 63 64 let g3 = function() { 65 assertEq(this, q); 66 }; 67 g3.apply(q, ...[]); 68 g3.call(q, ...[]); 69 70 let g4 = x => { 71 assertEq(this, global); 72 }; 73 g4.apply(q, ...[]); 74 g4.call(q, ...[]); 75 }, 76 f3: function() { 77 assertEq(this, p); 78 79 let g1 = function() { 80 assertEq(this, undefined); 81 }; 82 g1(...[]); 83 84 let g2 = x => { 85 assertEq(this, p); 86 }; 87 g2(...[]); 88 89 let g3 = function() { 90 assertEq(this, q); 91 }; 92 g3.apply(q, ...[]); 93 g3.call(q, ...[]); 94 95 let g4 = x => { 96 assertEq(this, p); 97 }; 98 g4.apply(q, ...[]); 99 g4.call(q, ...[]); 100 } 101 }; 102 o.f1(...[]); 103 o.f2(...[]); 104 o.f3.apply(p, ...[]); 105 o.f2.apply(p, ...[]);