Chromium Code Reviews| Index: test/mjsunit/strict-mode.js |
| diff --git a/test/mjsunit/strict-mode.js b/test/mjsunit/strict-mode.js |
| index a0320c065212378e2e9472853daa1b2daaa44769..f871430232901b010c3e82e836e53e952d06f75f 100644 |
| --- a/test/mjsunit/strict-mode.js |
| +++ b/test/mjsunit/strict-mode.js |
| @@ -978,20 +978,7 @@ repeat(10, function() { testAssignToUndefined(false); }); |
| })(); |
| -(function TestStrictFunctionPills() { |
| - function strict() { |
| - "use strict"; |
| - } |
| - assertThrows(function() { strict.caller; }, TypeError); |
| - assertThrows(function() { strict.arguments; }, TypeError); |
| - |
| - var another = new Function("'use strict'"); |
| - assertThrows(function() { another.caller; }, TypeError); |
| - assertThrows(function() { another.arguments; }, TypeError); |
| - |
| - var third = (function() { "use strict"; return function() {}; })(); |
| - assertThrows(function() { third.caller; }, TypeError); |
| - assertThrows(function() { third.arguments; }, TypeError); |
| +function CheckPillDescriptor(func, name) { |
| function CheckPill(pill) { |
| assertEquals("function", typeof pill); |
| @@ -1005,13 +992,28 @@ repeat(10, function() { testAssignToUndefined(false); }); |
| assertFalse(d.enumerable); |
| } |
| - function CheckPillDescriptor(func, name) { |
| - var descriptor = Object.getOwnPropertyDescriptor(func, name); |
| - CheckPill(descriptor.get) |
| - CheckPill(descriptor.set); |
| - assertFalse(descriptor.enumerable); |
| - assertFalse(descriptor.configurable); |
| + var descriptor = Object.getOwnPropertyDescriptor(func, name); |
| + CheckPill(descriptor.get) |
| + CheckPill(descriptor.set); |
| + assertFalse(descriptor.enumerable); |
| + assertFalse(descriptor.configurable); |
| +} |
| + |
| + |
| +(function TestStrictFunctionPills() { |
| + function strict() { |
| + "use strict"; |
| } |
| + assertThrows(function() { strict.caller; }, TypeError); |
| + assertThrows(function() { strict.arguments; }, TypeError); |
| + |
| + var another = new Function("'use strict'"); |
| + assertThrows(function() { another.caller; }, TypeError); |
| + assertThrows(function() { another.arguments; }, TypeError); |
| + |
| + var third = (function() { "use strict"; return function() {}; })(); |
| + assertThrows(function() { third.caller; }, TypeError); |
| + assertThrows(function() { third.arguments; }, TypeError); |
| CheckPillDescriptor(strict, "caller"); |
| CheckPillDescriptor(strict, "arguments"); |
| @@ -1020,3 +1022,41 @@ repeat(10, function() { testAssignToUndefined(false); }); |
| CheckPillDescriptor(third, "caller"); |
| CheckPillDescriptor(third, "arguments"); |
| })(); |
| + |
| + |
| +(function TestStrictArgumentPills() { |
| + function strict() { |
| + "use strict"; |
| + return arguments; |
| + } |
| + |
| + var args = strict(); |
| + CheckPillDescriptor(args, "caller"); |
| + CheckPillDescriptor(args, "callee"); |
| + |
| + args = strict(17, "value", strict); |
| + assertEquals(17, args[0]) |
| + assertEquals("value", args[1]) |
| + assertEquals(strict, args[2]); |
| + CheckPillDescriptor(args, "caller"); |
| + CheckPillDescriptor(args, "callee"); |
| + |
| + function outer() { |
| + "use strict"; |
| + function inner() { |
| + return arguments; |
| + } |
| + return inner; |
| + } |
| + |
| + var args = outer()(); |
| + CheckPillDescriptor(args, "caller"); |
| + CheckPillDescriptor(args, "callee"); |
| + |
| + args = outer()(17, "value", strict); |
| + assertEquals(17, args[0]) |
| + assertEquals("value", args[1]) |
| + assertEquals(strict, args[2]); |
| + CheckPillDescriptor(args, "caller"); |
| + CheckPillDescriptor(args, "callee"); |
|
Lasse Reichstein
2011/03/15 09:58:40
How about a strict function calling a non-strict f
Martin Maly
2011/03/16 01:21:24
Correct. That part is not yet implemented.
|
| +})(); |