| Index: test/mjsunit/strict-mode.js
|
| diff --git a/test/mjsunit/strict-mode.js b/test/mjsunit/strict-mode.js
|
| index fbba64ed66606c125dbbec74a5849402c3b41144..5b12e1e54d236d6f1ad97b296cfe997cc48f583d 100644
|
| --- a/test/mjsunit/strict-mode.js
|
| +++ b/test/mjsunit/strict-mode.js
|
| @@ -438,7 +438,7 @@ repeat(10, function() { testAssignToUndefined(false); });
|
| })();
|
|
|
| // Not transforming this in Function.call and Function.apply.
|
| -(function testThisTransform() {
|
| +(function testThisTransformCallApply() {
|
| function non_strict() {
|
| return this;
|
| }
|
| @@ -478,3 +478,58 @@ repeat(10, function() { testAssignToUndefined(false); });
|
| assertEquals(typeof strict.apply("Hello"), "string");
|
| assertTrue(strict.apply(object) === object);
|
| })();
|
| +
|
| +(function testThisTransform() {
|
| + try {
|
| + function strict() {
|
| + "use strict";
|
| + return typeof(this);
|
| + }
|
| + function nonstrict() {
|
| + return typeof(this);
|
| + }
|
| +
|
| + // Set up fakes
|
| + String.prototype.strict = strict;
|
| + String.prototype.nonstrict = nonstrict;
|
| + Number.prototype.strict = strict;
|
| + Number.prototype.nonstrict = nonstrict;
|
| + Boolean.prototype.strict = strict;
|
| + Boolean.prototype.nonstrict = nonstrict;
|
| +
|
| + function callStrict(o) {
|
| + return o.strict();
|
| + }
|
| + function callNonStrict(o) {
|
| + return o.nonstrict();
|
| + }
|
| +
|
| + for (var i = 0; i < 10; i ++) {
|
| + assertEquals(("hello").strict(), "string");
|
| + assertEquals(("hello").nonstrict(), "object");
|
| + assertEquals((10 + i).strict(), "number");
|
| + assertEquals((10 + i).nonstrict(), "object");
|
| + assertEquals((true).strict(), "boolean");
|
| + assertEquals((true).nonstrict(), "object");
|
| + assertEquals((false).strict(), "boolean");
|
| + assertEquals((false).nonstrict(), "object");
|
| +
|
| + assertEquals(callStrict("howdy"), "string");
|
| + assertEquals(callNonStrict("howdy"), "object");
|
| + assertEquals(callStrict(17 + i), "number");
|
| + assertEquals(callNonStrict(19 + i), "object");
|
| + assertEquals(callStrict(true), "boolean");
|
| + assertEquals(callNonStrict(true), "object");
|
| + assertEquals(callStrict(false), "boolean");
|
| + assertEquals(callNonStrict(false), "object");
|
| + }
|
| + } finally {
|
| + // Cleanup
|
| + delete String.prototype.strict;
|
| + delete String.prototype.nonstrict;
|
| + delete Number.prototype.strict;
|
| + delete Number.prototype.nonstrict;
|
| + delete Boolean.prototype.strict;
|
| + delete Boolean.prototype.nonstrict;
|
| + }
|
| +})();
|
|
|