1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/basic/spread-call-this.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,123 @@ 1.4 +let global = this; 1.5 +let p = {}; 1.6 +let q = {}; 1.7 + 1.8 +let g1 = function() { 1.9 + assertEq(this, global); 1.10 + assertEq(arguments.callee, g1); 1.11 +}; 1.12 +g1(...[]); 1.13 + 1.14 +let g2 = x => { 1.15 + assertEq(this, global); 1.16 + // arguments.callee is unbound function object, and following assertion fails. 1.17 + // see Bug 889158 1.18 + //assertEq(arguments.callee, g2); 1.19 +}; 1.20 +g2(...[]); 1.21 + 1.22 +let g3 = function() { 1.23 + assertEq(this, p); 1.24 + assertEq(arguments.callee, g3); 1.25 +}; 1.26 +g3.apply(p, ...[]); 1.27 +g3.call(p, ...[]); 1.28 + 1.29 +g2.apply(p, ...[]); 1.30 +g2.call(p, ...[]); 1.31 + 1.32 +let o = { 1.33 + f1: function() { 1.34 + assertEq(this, o); 1.35 + assertEq(arguments.callee, o.f1); 1.36 + 1.37 + let g1 = function() { 1.38 + assertEq(this, global); 1.39 + assertEq(arguments.callee, g1); 1.40 + }; 1.41 + g1(...[]); 1.42 + 1.43 + let g2 = x => { 1.44 + assertEq(this, o); 1.45 + //assertEq(arguments.callee, g2); 1.46 + }; 1.47 + g2(...[]); 1.48 + 1.49 + let g3 = function() { 1.50 + assertEq(this, q); 1.51 + assertEq(arguments.callee, g3); 1.52 + }; 1.53 + g3.apply(q, ...[]); 1.54 + g3.call(q, ...[]); 1.55 + 1.56 + let g4 = x => { 1.57 + assertEq(this, o); 1.58 + //assertEq(arguments.callee, g4); 1.59 + }; 1.60 + g4.apply(q, ...[]); 1.61 + g4.call(q, ...[]); 1.62 + }, 1.63 + f2: x => { 1.64 + assertEq(this, global); 1.65 + //assertEq(arguments.callee, o.f2); 1.66 + let g1 = function() { 1.67 + assertEq(this, global); 1.68 + assertEq(arguments.callee, g1); 1.69 + }; 1.70 + g1(...[]); 1.71 + 1.72 + let g2 = x => { 1.73 + assertEq(this, global); 1.74 + //assertEq(arguments.callee, g2); 1.75 + }; 1.76 + g2(...[]); 1.77 + 1.78 + let g3 = function() { 1.79 + assertEq(this, q); 1.80 + assertEq(arguments.callee, g3); 1.81 + }; 1.82 + g3.apply(q, ...[]); 1.83 + g3.call(q, ...[]); 1.84 + 1.85 + let g4 = x => { 1.86 + assertEq(this, global); 1.87 + //assertEq(arguments.callee, g4); 1.88 + }; 1.89 + g4.apply(q, ...[]); 1.90 + g4.call(q, ...[]); 1.91 + }, 1.92 + f3: function() { 1.93 + assertEq(this, p); 1.94 + assertEq(arguments.callee, o.f3); 1.95 + 1.96 + let g1 = function() { 1.97 + assertEq(this, global); 1.98 + assertEq(arguments.callee, g1); 1.99 + }; 1.100 + g1(...[]); 1.101 + 1.102 + let g2 = x => { 1.103 + assertEq(this, p); 1.104 + //assertEq(arguments.callee, g2); 1.105 + }; 1.106 + g2(...[]); 1.107 + 1.108 + let g3 = function() { 1.109 + assertEq(this, q); 1.110 + assertEq(arguments.callee, g3); 1.111 + }; 1.112 + g3.apply(q, ...[]); 1.113 + g3.call(q, ...[]); 1.114 + 1.115 + let g4 = x => { 1.116 + assertEq(this, p); 1.117 + //assertEq(arguments.callee, g4); 1.118 + }; 1.119 + g4.apply(q, ...[]); 1.120 + g4.call(q, ...[]); 1.121 + } 1.122 +}; 1.123 +o.f1(...[]); 1.124 +o.f2(...[]); 1.125 +o.f3.apply(p, ...[]); 1.126 +o.f2.apply(p, ...[]);