Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

View File

@ -0,0 +1,142 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Test behaviour of JSON reviver function.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Ensure the holder for our array is indeed an array
PASS Array.isArray(currentHolder) is true
PASS currentHolder.length is 5
Ensure that the holder already has all the properties present at the start of filtering
PASS currentHolder[0] is "a value"
PASS currentHolder[1] is "another value"
PASS currentHolder[2] is "and another value"
PASS currentHolder[3] is "to delete"
PASS currentHolder[4] is "extra value"
Ensure the holder for our array is indeed an array
PASS Array.isArray(currentHolder) is true
PASS currentHolder.length is 5
Ensure that we always get the same holder
PASS currentHolder is lastHolder
Ensure that returning undefined has removed the property 0 from the holder during filtering.
PASS currentHolder.hasOwnProperty(0) is false
Ensure the holder for our array is indeed an array
PASS Array.isArray(currentHolder) is true
PASS currentHolder.length is 5
Ensure that we always get the same holder
PASS currentHolder is lastHolder
Ensure that changing the value of a property is reflected while filtering.
PASS currentHolder[2] is "a replaced value"
Ensure that the changed value is reflected in the arguments passed to the reviver
PASS value is currentHolder[2]
Ensure the holder for our array is indeed an array
PASS Array.isArray(currentHolder) is true
PASS currentHolder.length is 5
Ensure that we always get the same holder
PASS currentHolder is lastHolder
Ensure that we visited a value that we have deleted, and that deletion is reflected while filtering.
PASS currentHolder.hasOwnProperty(3) is false
Ensure that when visiting a deleted property value is undefined
PASS value is undefined.
Ensure the holder for our array is indeed an array
PASS Array.isArray(currentHolder) is true
PASS currentHolder.length is 4
Ensure that we always get the same holder
PASS currentHolder is lastHolder
PASS Ensured that property was visited despite Array length being reduced.
PASS value is undefined.
Ensure that we created the root holder as specified in ES5
PASS '' in lastHolder is true
PASS result is lastHolder['']
Ensure that a deleted value is revived if the reviver function returns a value
PASS result.hasOwnProperty(3) is true
Test behaviour of revivor used in conjunction with an object
PASS currentHolder != globalObject is true
Ensure that the holder already has all the properties present at the start of filtering
PASS currentHolder['a property'] is "a value"
PASS currentHolder['another property'] is "another value"
PASS currentHolder['and another property'] is "and another value"
PASS currentHolder['to delete'] is "will be deleted"
PASS currentHolder != globalObject is true
Ensure that we get the same holder object for each property
PASS currentHolder is lastHolder
Ensure that returning undefined has correctly removed the property 'a property' from the holder object
PASS currentHolder.hasOwnProperty('a property') is false
PASS currentHolder != globalObject is true
Ensure that we get the same holder object for each property
PASS currentHolder is lastHolder
Ensure that changing the value of a property is reflected while filtering.
PASS currentHolder['and another property'] is "a replaced value"
Ensure that the changed value is reflected in the arguments passed to the reviver
PASS value is "a replaced value"
PASS currentHolder != globalObject is true
Ensure that we get the same holder object for each property
PASS currentHolder is lastHolder
Ensure that we visited a value that we have deleted, and that deletion is reflected while filtering.
PASS currentHolder.hasOwnProperty('to delete') is false
Ensure that when visiting a deleted property value is undefined
PASS value is undefined.
Ensure that we created the root holder as specified in ES5
PASS lastHolder.hasOwnProperty('') is true
PASS result.hasOwnProperty('a property') is false
PASS result.hasOwnProperty('to delete') is true
PASS result is lastHolder['']
Test behaviour of revivor that introduces a cycle
PASS JSON.parse("[0,1]", reviveAddsCycle) threw exception RangeError: Maximum call stack size exceeded.
Test behaviour of revivor that introduces a new array classed object (the result of a regex)
PASS JSON.stringify(JSON.parse("[0,1]", reviveIntroducesNewArrayLikeObject)) is '[0,["a","a"]]'
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,204 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description("Test behaviour of JSON reviver function.")
if (!Array.isArray)
Array.isArray = function(o) { return o.constructor === Array; }
function arrayReviver(i,v) {
if (i != "") {
currentHolder = this;
debug("");
debug("Ensure the holder for our array is indeed an array");
shouldBeTrue("Array.isArray(currentHolder)");
shouldBe("currentHolder.length", "" + expectedLength);
if (i > 0) {
debug("");
debug("Ensure that we always get the same holder");
shouldBe("currentHolder", "lastHolder");
}
switch (Number(i)) {
case 0:
v = undefined;
debug("");
debug("Ensure that the holder already has all the properties present at the start of filtering");
shouldBe("currentHolder[0]", '"a value"');
shouldBe("currentHolder[1]", '"another value"');
shouldBe("currentHolder[2]", '"and another value"');
shouldBe("currentHolder[3]", '"to delete"');
shouldBe("currentHolder[4]", '"extra value"');
break;
case 1:
debug("");
debug("Ensure that returning undefined has removed the property 0 from the holder during filtering.");
shouldBeFalse("currentHolder.hasOwnProperty(0)");
currentHolder[2] = "a replaced value";
break;
case 2:
debug("");
debug("Ensure that changing the value of a property is reflected while filtering.")
shouldBe("currentHolder[2]", '"a replaced value"');
value = v;
debug("");
debug("Ensure that the changed value is reflected in the arguments passed to the reviver");
shouldBe("value", "currentHolder[2]");
delete this[3];
break;
case 3:
debug("");
debug("Ensure that we visited a value that we have deleted, and that deletion is reflected while filtering.");
shouldBeFalse("currentHolder.hasOwnProperty(3)");
value = v;
debug("");
debug("Ensure that when visiting a deleted property value is undefined");
shouldBeUndefined("value");
this.length = 3;
v = "undelete the property";
expectedLength = 4;
break;
case 4:
if (this.length != 4) {
testFailed("Did not call reviver for deleted property");
expectedLength = this.length = 3;
break;
}
case 5:
testPassed("Ensured that property was visited despite Array length being reduced.");
value = v;
shouldBeUndefined("value");
this[10] = "fail";
break;
default:
testFailed("Visited unexpected property " + i + " with value " + v);
}
}
lastHolder = this;
return v;
}
expectedLength = 5;
var result = JSON.parse('["a value", "another value", "and another value", "to delete", "extra value"]', arrayReviver);
debug("");
debug("Ensure that we created the root holder as specified in ES5");
shouldBeTrue("'' in lastHolder");
shouldBe("result", "lastHolder['']");
debug("");
debug("Ensure that a deleted value is revived if the reviver function returns a value");
shouldBeTrue("result.hasOwnProperty(3)");
function objectReviver(i,v) {
if (i != "") {
currentHolder = this;
shouldBeTrue("currentHolder != globalObject");
if (seen) {
debug("");
debug("Ensure that we get the same holder object for each property");
shouldBe("currentHolder", "lastHolder");
}
seen = true;
switch (i) {
case "a property":
v = undefined;
debug("");
debug("Ensure that the holder already has all the properties present at the start of filtering");
shouldBe("currentHolder['a property']", '"a value"');
shouldBe("currentHolder['another property']", '"another value"');
shouldBe("currentHolder['and another property']", '"and another value"');
shouldBe("currentHolder['to delete']", '"will be deleted"');
break;
case "another property":
debug("");
debug("Ensure that returning undefined has correctly removed the property 'a property' from the holder object");
shouldBeFalse("currentHolder.hasOwnProperty('a property')");
currentHolder['and another property'] = "a replaced value";
break;
case "and another property":
debug("Ensure that changing the value of a property is reflected while filtering.");
shouldBe("currentHolder['and another property']", '"a replaced value"');
value = v;
debug("");
debug("Ensure that the changed value is reflected in the arguments passed to the reviver");
shouldBe("value", '"a replaced value"');
delete this["to delete"];
break;
case "to delete":
debug("");
debug("Ensure that we visited a value that we have deleted, and that deletion is reflected while filtering.");
shouldBeFalse("currentHolder.hasOwnProperty('to delete')");
value = v;
debug("");
debug("Ensure that when visiting a deleted property value is undefined");
shouldBeUndefined("value");
v = "undelete the property";
this["new property"] = "fail";
break;
default:
testFailed("Visited unexpected property " + i + " with value " + v);
}
}
lastHolder = this;
return v;
}
debug("");
debug("Test behaviour of revivor used in conjunction with an object");
var seen = false;
var globalObject = this;
var result = JSON.parse('{"a property" : "a value", "another property" : "another value", "and another property" : "and another value", "to delete" : "will be deleted"}', objectReviver);
debug("");
debug("Ensure that we created the root holder as specified in ES5");
shouldBeTrue("lastHolder.hasOwnProperty('')");
shouldBeFalse("result.hasOwnProperty('a property')");
shouldBeTrue("result.hasOwnProperty('to delete')");
shouldBe("result", "lastHolder['']");
debug("");
debug("Test behaviour of revivor that introduces a cycle");
function reviveAddsCycle(i, v) {
if (i == 0)
this[1] = this;
return v;
}
shouldThrow('JSON.parse("[0,1]", reviveAddsCycle)');
debug("");
debug("Test behaviour of revivor that introduces a new array classed object (the result of a regex)");
var createdBadness = false;
function reviveIntroducesNewArrayLikeObject(i, v) {
if (i == 0 && !createdBadness) {
this[1] = /(a)+/.exec("a");
createdBadness = true;
}
return v;
}
shouldBe('JSON.stringify(JSON.parse("[0,1]", reviveIntroducesNewArrayLikeObject))', '\'[0,["a","a"]]\'');

View File

@ -0,0 +1,176 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Test to ensure correct behaviour of Object.defineProperty
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {value:1}), 'foo')) is JSON.stringify({value: 1, writable: false, enumerable: false, configurable: false})
PASS JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {}), 'foo')) is JSON.stringify({writable: false, enumerable: false, configurable: false})
PASS JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {get:undefined}), 'foo')) is JSON.stringify({enumerable: false, configurable: false})
PASS JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {value:1, writable: false}), 'foo')) is JSON.stringify({value: 1, writable: false, enumerable: false, configurable: false})
PASS JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {value:1, writable: true}), 'foo')) is JSON.stringify({value: 1, writable: true, enumerable: false, configurable: false})
PASS JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {value:1, enumerable: false}), 'foo')) is JSON.stringify({value: 1, writable: false, enumerable: false, configurable: false})
PASS JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {value:1, enumerable: true}), 'foo')) is JSON.stringify({value: 1, writable: false, enumerable: true, configurable: false})
PASS JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {value:1, configurable: false}), 'foo')) is JSON.stringify({value: 1, writable: false, enumerable: false, configurable: false})
PASS JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {value:1, configurable: true}), 'foo')) is JSON.stringify({value: 1, writable: false, enumerable: false, configurable: true})
PASS JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty([1,2,3], 'foo', {value:1, configurable: true}), 'foo')) is JSON.stringify({value: 1, writable: false, enumerable: false, configurable: true})
PASS Object.getOwnPropertyDescriptor(Object.defineProperty([1,2,3], '1', {value:'foo', configurable: true}), '1').value is 'foo'
PASS a=[1,2,3], Object.defineProperty(a, '1', {value:'foo', configurable: true}), a[1] is 'foo'
PASS Object.getOwnPropertyDescriptor(Object.defineProperty([1,2,3], '1', {get:getter, configurable: true}), '1').get is getter
PASS Object.defineProperty([1,2,3], '1', {get:getter, configurable: true})[1] threw exception called getter.
PASS Object.defineProperty() threw exception TypeError: Object.defineProperty called on non-object.
PASS Object.defineProperty(null) threw exception TypeError: Object.defineProperty called on non-object.
PASS Object.defineProperty('foo') threw exception TypeError: Object.defineProperty called on non-object.
PASS Object.defineProperty({}) threw exception TypeError: Property description must be an object: undefined.
PASS Object.defineProperty({}, 'foo') threw exception TypeError: Property description must be an object: undefined.
PASS Object.defineProperty({}, 'foo', {get:undefined, value:true}).foo threw exception TypeError: Invalid property descriptor. Cannot both specify accessors and a value or writable attribute, #<Object>.
PASS Object.defineProperty({get foo() { return true; } }, 'foo', {configurable:false}).foo is true
PASS Object.defineProperty(createUnconfigurableProperty({}, 'foo'), 'foo', {configurable: true}) threw exception TypeError: Cannot redefine property: foo.
PASS Object.defineProperty(createUnconfigurableProperty({}, 'foo'), 'foo', {writable: true}) threw exception TypeError: Cannot redefine property: foo.
PASS Object.defineProperty(createUnconfigurableProperty({}, 'foo'), 'foo', {enumerable: true}) threw exception TypeError: Cannot redefine property: foo.
PASS Object.defineProperty(createUnconfigurableProperty({}, 'foo', false, true), 'foo', {enumerable: false}), 'foo' threw exception TypeError: Cannot redefine property: foo.
PASS JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty(createUnconfigurableProperty({}, 'foo', true), 'foo', {writable: false}), 'foo')) is JSON.stringify({value: 1, writable: false, enumerable: false, configurable: false})
PASS Object.defineProperty({}, 'foo', {value:1, get: function(){}}) threw exception TypeError: Invalid property descriptor. Cannot both specify accessors and a value or writable attribute, #<Object>.
PASS Object.defineProperty({}, 'foo', {value:1, set: function(){}}) threw exception TypeError: Invalid property descriptor. Cannot both specify accessors and a value or writable attribute, #<Object>.
PASS Object.defineProperty({}, 'foo', {writable:true, get: function(){}}) threw exception TypeError: Invalid property descriptor. Cannot both specify accessors and a value or writable attribute, #<Object>.
PASS Object.defineProperty({}, 'foo', {writable:true, set: function(){}}) threw exception TypeError: Invalid property descriptor. Cannot both specify accessors and a value or writable attribute, #<Object>.
PASS Object.defineProperty({}, 'foo', {get: null}) threw exception TypeError: Getter must be a function: null.
PASS Object.defineProperty({}, 'foo', {set: null}) threw exception TypeError: Setter must be a function: null.
PASS Object.defineProperty({}, 'foo', {set: setter}).foo='test' threw exception called setter.
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter}), 'foo', {set: setter1}) threw exception TypeError: Cannot redefine property: foo.
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter}), 'foo', {get: getter1}) threw exception TypeError: Cannot redefine property: foo.
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter}), 'foo', {value: 1}) threw exception TypeError: Cannot redefine property: foo.
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter, configurable: true}), 'foo', {set: setter1}).foo='test' threw exception called setter1.
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter, configurable: true}), 'foo', {get: getter1}).foo threw exception called getter1.
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter, configurable: true}), 'foo', {value: true}).foo is true
PASS 'foo' in Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter, configurable: true}), 'foo', {writable: true}) is true
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter, configurable: true}), 'foo', {writable: true}).foo is undefined.
PASS Object.defineProperty({}, 'foo', {get: getter}).foo threw exception called getter.
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {get: getter}), 'foo', {get: getter1}) threw exception TypeError: Cannot redefine property: foo.
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {get: getter}), 'foo', {set: setter1}) threw exception TypeError: Cannot redefine property: foo.
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {get: getter, configurable: true}), 'foo', {get: getter1}).foo threw exception called getter1.
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {get: getter, configurable: true}), 'foo', {set: setter1}).foo='test' threw exception called setter1.
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {get: getter, configurable: true}), 'foo', {value: true}).foo is true
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {get: getter, configurable: true}), 'foo', {writable: true}).foo is undefined.
PASS 'foo' in Object.defineProperty(Object.defineProperty({}, 'foo', {get: getter, configurable: true}), 'foo', {writable: true}) is true
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1}), 'foo', {set: setter1}) threw exception TypeError: Cannot redefine property: foo.
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1, configurable: true}), 'foo', {set: setter1}).foo='test' threw exception called setter1.
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1}), 'foo', {get: getter1}) threw exception TypeError: Cannot redefine property: foo.
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1}), 'foo', {set: setter1}) threw exception TypeError: Cannot redefine property: foo.
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1, configurable: true}), 'foo', {get: getter1}).foo threw exception called getter1.
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1, configurable: true}), 'foo', {set: setter1}).foo='test' threw exception called setter1.
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1, configurable: true, writable: false}), 'foo', {value: 2, configurable: true, writable: true}).foo is 2
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1, configurable: true, writable: false}), 'foo', {value: 2, configurable: true, writable: false}).foo is 2
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1, configurable: false, writable: false}), 'foo', {value: 1, configurable: false, writable: false}).foo is 1
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: true, enumerable: true}), 'foo', {get: function() { return 2; }, configurable: true, enumerable: false}).foo is 2
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: true, enumerable: false}), 'foo', {get: function() { return 2; }, configurable: true, enumerable: false}).foo is 2
PASS var result = false; var o = Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: true, enumerable: true}), 'foo', {get: function() { return 2; }, configurable: true, enumerable: false}); for (x in o) result = true; result is false
PASS var result = false; var o = Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: true, enumerable: false}), 'foo', {get: function() { return 2; }, configurable: true, enumerable: true}); for (x in o) result = true; result is true
PASS var o = Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: true}); delete o.foo; o.foo is undefined.
PASS var o = Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: false}); delete o.foo; o.foo is 1
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: true}), 'foo', {value:2}).foo is 2
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: false}), 'foo', {value:2}).foo threw exception TypeError: Cannot redefine property: foo.
PASS var o = Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: true}), 'foo', {value:2}); o.foo = 3; o.foo is 2
PASS Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1}), 'foo', {value:2, configurable: true}) threw exception TypeError: Cannot redefine property: foo.
PASS Object.defineProperty(Object.defineProperty([], 'foo', {value: 1}), 'foo', {value:2, configurable: true}) threw exception TypeError: Cannot redefine property: foo.
PASS var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}); o.foo is 42
PASS var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}); o.foo = 42; o.result; is 42
PASS var o = Object.defineProperty({}, 'foo', {get:undefined, set:function(x){this.result = x;}}); o.foo is undefined
PASS var o = Object.defineProperty({}, 'foo', {get:undefined, set:function(x){this.result = x;}}); o.foo = 42; o.result; is 42
PASS var o = Object.defineProperty({}, 'foo', {set:function(x){this.result = x;}}); o.foo is undefined
PASS var o = Object.defineProperty({}, 'foo', {set:function(x){this.result = x;}}); o.foo = 42; o.result; is 42
PASS var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:undefined}); o.foo is 42
PASS var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:undefined}); o.foo = 42; o.result; is undefined
PASS var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}}); o.foo is 42
PASS var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}}); o.foo = 42; o.result; is undefined
PASS var o = Object.defineProperty({}, 'foo', {get:undefined, set:undefined}); o.foo is undefined
PASS var o = Object.defineProperty({}, 'foo', {get:undefined, set:undefined}); o.foo = 42; o.result; is undefined
PASS var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:function(){return 13;}}); o.foo is 13
PASS var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:function(){return 13;}}); o.foo = 42; o.result; is 42
PASS var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:undefined}); o.foo is undefined
PASS var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:undefined}); o.foo = 42; o.result; is 42
PASS var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:function(){this.result = 13;}}); o.foo is 42
PASS var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:function(){this.result = 13;}}); o.foo = 42; o.result; is 13
PASS var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:undefined}); o.foo is 42
PASS var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:undefined}); o.foo = 42; o.result; is undefined
PASS 'use strict'; var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}); o.foo is 42
PASS 'use strict'; var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}); o.foo = 42; o.result; is 42
PASS 'use strict'; var o = Object.defineProperty({}, 'foo', {get:undefined, set:function(x){this.result = x;}}); o.foo is undefined
PASS 'use strict'; var o = Object.defineProperty({}, 'foo', {get:undefined, set:function(x){this.result = x;}}); o.foo = 42; o.result; is 42
PASS 'use strict'; var o = Object.defineProperty({}, 'foo', {set:function(x){this.result = x;}}); o.foo is undefined
PASS 'use strict'; var o = Object.defineProperty({}, 'foo', {set:function(x){this.result = x;}}); o.foo = 42; o.result; is 42
PASS 'use strict'; var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:undefined}); o.foo is 42
PASS 'use strict'; var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:undefined}); o.foo = 42; o.result; threw exception TypeError: Cannot set property foo of #<Object> which has only a getter.
PASS 'use strict'; var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}}); o.foo is 42
PASS 'use strict'; var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}}); o.foo = 42; o.result; threw exception TypeError: Cannot set property foo of #<Object> which has only a getter.
PASS 'use strict'; var o = Object.defineProperty({}, 'foo', {get:undefined, set:undefined}); o.foo is undefined
PASS 'use strict'; var o = Object.defineProperty({}, 'foo', {get:undefined, set:undefined}); o.foo = 42; o.result; threw exception TypeError: Cannot set property foo of #<Object> which has only a getter.
PASS 'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:function(){return 13;}}); o.foo is 13
PASS 'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:function(){return 13;}}); o.foo = 42; o.result; is 42
PASS 'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:undefined}); o.foo is undefined
PASS 'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:undefined}); o.foo = 42; o.result; is 42
PASS 'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:function(){this.result = 13;}}); o.foo is 42
PASS 'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:function(){this.result = 13;}}); o.foo = 42; o.result; is 13
PASS 'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:undefined}); o.foo is 42
PASS 'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:undefined}); o.foo = 42; o.result; threw exception TypeError: Cannot set property foo of #<Object> which has only a getter.
PASS 0 in Object.prototype is true
PASS '0' in Object.prototype is true
PASS var o = {}; o.readOnly = false; o.readOnly is true
PASS 'use strict'; var o = {}; o.readOnly = false; o.readOnly threw exception TypeError: Cannot assign to read only property 'readOnly' of object '#<Object>'.
PASS Object.getOwnPropertyDescriptor(Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return false; }, configurable: true}), 'foo', {value:false}), 'foo').writable is false
PASS Object.getOwnPropertyDescriptor(Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return false; }, configurable: true}), 'foo', {value:false, writable: false}), 'foo').writable is false
PASS Object.getOwnPropertyDescriptor(Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return false; }, configurable: true}), 'foo', {value:false, writable: true}), 'foo').writable is true
PASS var a = Object.defineProperty([], 'length', {writable: false}); a[0] = 42; 0 in a; is false
PASS 'use strict'; var a = Object.defineProperty([], 'length', {writable: false}); a[0] = 42; 0 in a; threw exception TypeError: Cannot assign to read only property 'length' of object '[object Array]'.
PASS var a = Object.defineProperty([42], '0', {writable: false}); a[0] = false; a[0]; is 42
PASS 'use strict'; var a = Object.defineProperty([42], '0', {writable: false}); a[0] = false; a[0]; threw exception TypeError: Cannot assign to read only property '0' of object '[object Array]'.
PASS var a = Object.defineProperty([], '0', {set: undefined}); a[0] = 42; a[0]; is undefined.
PASS 'use strict'; var a = Object.defineProperty([], '0', {set: undefined}); a[0] = 42; a[0]; threw exception TypeError: Cannot set property 0 of [object Array] which has only a getter.
PASS anObj.slot1 is "foo"
PASS anObj.slot2 is "bar"
PASS anObj.propertyIsEnumerable('slot1') is true
PASS anObj.propertyIsEnumerable('slot2') is false
PASS anObj.slot4 is "goo"
PASS anObj.slot5 is 123
PASS anObj._Slot5 is 123
PASS Object.getOwnPropertyDescriptor(anObj, 'slot5') is undefined.
PASS anObj.slot5 is 456
PASS anObj._Slot5 is 123
PASS Object.getOwnPropertyDescriptor(anObj, 'slot5').value is 456
PASS anObj.slot1 is "foo"
PASS anObj.slot2 is "bar"
PASS anObj.propertyIsEnumerable('slot1') is true
PASS anObj.propertyIsEnumerable('slot2') is false
PASS anObj.slot4 is "goo"
PASS anObj.slot5 is 123
PASS anObj._Slot5 is 123
PASS Object.getOwnPropertyDescriptor(anObj, 'slot5') is undefined.
PASS anObj.slot5 is 456
PASS anObj._Slot5 is 123
PASS Object.getOwnPropertyDescriptor(anObj, 'slot5').value is 456
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,239 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description("Test to ensure correct behaviour of Object.defineProperty");
shouldBe("JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {value:1}), 'foo'))",
"JSON.stringify({value: 1, writable: false, enumerable: false, configurable: false})");
shouldBe("JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {}), 'foo'))",
"JSON.stringify({writable: false, enumerable: false, configurable: false})");
shouldBe("JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {get:undefined}), 'foo'))",
"JSON.stringify({enumerable: false, configurable: false})");
shouldBe("JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {value:1, writable: false}), 'foo'))",
"JSON.stringify({value: 1, writable: false, enumerable: false, configurable: false})");
shouldBe("JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {value:1, writable: true}), 'foo'))",
"JSON.stringify({value: 1, writable: true, enumerable: false, configurable: false})");
shouldBe("JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {value:1, enumerable: false}), 'foo'))",
"JSON.stringify({value: 1, writable: false, enumerable: false, configurable: false})");
shouldBe("JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {value:1, enumerable: true}), 'foo'))",
"JSON.stringify({value: 1, writable: false, enumerable: true, configurable: false})");
shouldBe("JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {value:1, configurable: false}), 'foo'))",
"JSON.stringify({value: 1, writable: false, enumerable: false, configurable: false})");
shouldBe("JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {value:1, configurable: true}), 'foo'))",
"JSON.stringify({value: 1, writable: false, enumerable: false, configurable: true})");
shouldBe("JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty([1,2,3], 'foo', {value:1, configurable: true}), 'foo'))",
"JSON.stringify({value: 1, writable: false, enumerable: false, configurable: true})");
shouldBe("Object.getOwnPropertyDescriptor(Object.defineProperty([1,2,3], '1', {value:'foo', configurable: true}), '1').value", "'foo'");
shouldBe("a=[1,2,3], Object.defineProperty(a, '1', {value:'foo', configurable: true}), a[1]", "'foo'");
shouldBe("Object.getOwnPropertyDescriptor(Object.defineProperty([1,2,3], '1', {get:getter, configurable: true}), '1').get", "getter");
shouldThrow("Object.defineProperty([1,2,3], '1', {get:getter, configurable: true})[1]", "'called getter'");
shouldThrow("Object.defineProperty()");
shouldThrow("Object.defineProperty(null)");
shouldThrow("Object.defineProperty('foo')");
shouldThrow("Object.defineProperty({})");
shouldThrow("Object.defineProperty({}, 'foo')");
shouldThrow("Object.defineProperty({}, 'foo', {get:undefined, value:true}).foo");
shouldBeTrue("Object.defineProperty({get foo() { return true; } }, 'foo', {configurable:false}).foo");
function createUnconfigurableProperty(o, prop, writable, enumerable) {
writable = writable || false;
enumerable = enumerable || false;
return Object.defineProperty(o, prop, {value:1, configurable:false, writable: writable, enumerable: enumerable});
}
shouldThrow("Object.defineProperty(createUnconfigurableProperty({}, 'foo'), 'foo', {configurable: true})");
shouldThrow("Object.defineProperty(createUnconfigurableProperty({}, 'foo'), 'foo', {writable: true})");
shouldThrow("Object.defineProperty(createUnconfigurableProperty({}, 'foo'), 'foo', {enumerable: true})");
shouldThrow("Object.defineProperty(createUnconfigurableProperty({}, 'foo', false, true), 'foo', {enumerable: false}), 'foo'");
shouldBe("JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty(createUnconfigurableProperty({}, 'foo', true), 'foo', {writable: false}), 'foo'))",
"JSON.stringify({value: 1, writable: false, enumerable: false, configurable: false})");
shouldThrow("Object.defineProperty({}, 'foo', {value:1, get: function(){}})");
shouldThrow("Object.defineProperty({}, 'foo', {value:1, set: function(){}})");
shouldThrow("Object.defineProperty({}, 'foo', {writable:true, get: function(){}})");
shouldThrow("Object.defineProperty({}, 'foo', {writable:true, set: function(){}})");
shouldThrow("Object.defineProperty({}, 'foo', {get: null})");
shouldThrow("Object.defineProperty({}, 'foo', {set: null})");
function getter(){ throw "called getter"; }
function getter1(){ throw "called getter1"; }
function setter(){ throw "called setter"; }
function setter1(){ throw "called setter1"; }
shouldThrow("Object.defineProperty({}, 'foo', {set: setter}).foo='test'", "'called setter'");
shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter}), 'foo', {set: setter1})");
shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter}), 'foo', {get: getter1})");
shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter}), 'foo', {value: 1})");
shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter, configurable: true}), 'foo', {set: setter1}).foo='test'", "'called setter1'");
shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter, configurable: true}), 'foo', {get: getter1}).foo", "'called getter1'");
shouldBeTrue("Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter, configurable: true}), 'foo', {value: true}).foo");
shouldBeTrue("'foo' in Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter, configurable: true}), 'foo', {writable: true})");
shouldBeUndefined("Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter, configurable: true}), 'foo', {writable: true}).foo");
shouldThrow("Object.defineProperty({}, 'foo', {get: getter}).foo", "'called getter'");
shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {get: getter}), 'foo', {get: getter1})");
shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {get: getter}), 'foo', {set: setter1})");
shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {get: getter, configurable: true}), 'foo', {get: getter1}).foo", "'called getter1'");
shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {get: getter, configurable: true}), 'foo', {set: setter1}).foo='test'", "'called setter1'");
shouldBeTrue("Object.defineProperty(Object.defineProperty({}, 'foo', {get: getter, configurable: true}), 'foo', {value: true}).foo");
shouldBeUndefined("Object.defineProperty(Object.defineProperty({}, 'foo', {get: getter, configurable: true}), 'foo', {writable: true}).foo");
shouldBeTrue("'foo' in Object.defineProperty(Object.defineProperty({}, 'foo', {get: getter, configurable: true}), 'foo', {writable: true})");
shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1}), 'foo', {set: setter1})");
shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1, configurable: true}), 'foo', {set: setter1}).foo='test'", "'called setter1'");
shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1}), 'foo', {get: getter1})");
shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1}), 'foo', {set: setter1})");
shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1, configurable: true}), 'foo', {get: getter1}).foo", "'called getter1'");
shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1, configurable: true}), 'foo', {set: setter1}).foo='test'", "'called setter1'");
// Should be able to redefine an non-writable property, if it is configurable.
shouldBe("Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1, configurable: true, writable: false}), 'foo', {value: 2, configurable: true, writable: true}).foo", "2");
shouldBe("Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1, configurable: true, writable: false}), 'foo', {value: 2, configurable: true, writable: false}).foo", "2");
// Should be able to redefine an non-writable, non-configurable property, with the same value and attributes.
shouldBe("Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1, configurable: false, writable: false}), 'foo', {value: 1, configurable: false, writable: false}).foo", "1");
// Should be able to redefine a configurable accessor, with the same or with different attributes.
// Check the accessor function changed.
shouldBe("Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: true, enumerable: true}), 'foo', {get: function() { return 2; }, configurable: true, enumerable: false}).foo", "2");
shouldBe("Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: true, enumerable: false}), 'foo', {get: function() { return 2; }, configurable: true, enumerable: false}).foo", "2");
// Check the attributes changed.
shouldBeFalse("var result = false; var o = Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: true, enumerable: true}), 'foo', {get: function() { return 2; }, configurable: true, enumerable: false}); for (x in o) result = true; result");
shouldBeTrue("var result = false; var o = Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: true, enumerable: false}), 'foo', {get: function() { return 2; }, configurable: true, enumerable: true}); for (x in o) result = true; result");
// Should be able to define an non-configurable accessor.
shouldBeUndefined("var o = Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: true}); delete o.foo; o.foo");
shouldBe("var o = Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: false}); delete o.foo; o.foo", '1');
shouldBe("Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: true}), 'foo', {value:2}).foo", "2");
shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: false}), 'foo', {value:2}).foo");
// Defining a data descriptor over an accessor should result in a read only property.
shouldBe("var o = Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: true}), 'foo', {value:2}); o.foo = 3; o.foo", "2");
// Trying to redefine a non-configurable property as configurable should throw.
shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1}), 'foo', {value:2, configurable: true})");
shouldThrow("Object.defineProperty(Object.defineProperty([], 'foo', {value: 1}), 'foo', {value:2, configurable: true})");
// Test an object with a getter setter.
// Either accessor may be omitted or replaced with undefined, or both may be replaced with undefined.
shouldBe("var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}); o.foo", '42')
shouldBe("var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}); o.foo = 42; o.result;", '42');
shouldBe("var o = Object.defineProperty({}, 'foo', {get:undefined, set:function(x){this.result = x;}}); o.foo", 'undefined')
shouldBe("var o = Object.defineProperty({}, 'foo', {get:undefined, set:function(x){this.result = x;}}); o.foo = 42; o.result;", '42');
shouldBe("var o = Object.defineProperty({}, 'foo', {set:function(x){this.result = x;}}); o.foo", 'undefined')
shouldBe("var o = Object.defineProperty({}, 'foo', {set:function(x){this.result = x;}}); o.foo = 42; o.result;", '42');
shouldBe("var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:undefined}); o.foo", '42')
shouldBe("var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:undefined}); o.foo = 42; o.result;", 'undefined');
shouldBe("var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}}); o.foo", '42')
shouldBe("var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}}); o.foo = 42; o.result;", 'undefined');
shouldBe("var o = Object.defineProperty({}, 'foo', {get:undefined, set:undefined}); o.foo", 'undefined')
shouldBe("var o = Object.defineProperty({}, 'foo', {get:undefined, set:undefined}); o.foo = 42; o.result;", 'undefined');
// Test replacing or removing either the getter or setter individually.
shouldBe("var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:function(){return 13;}}); o.foo", '13')
shouldBe("var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:function(){return 13;}}); o.foo = 42; o.result;", '42')
shouldBe("var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:undefined}); o.foo", 'undefined')
shouldBe("var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:undefined}); o.foo = 42; o.result;", '42')
shouldBe("var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:function(){this.result = 13;}}); o.foo", '42')
shouldBe("var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:function(){this.result = 13;}}); o.foo = 42; o.result;", '13')
shouldBe("var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:undefined}); o.foo", '42')
shouldBe("var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:undefined}); o.foo = 42; o.result;", 'undefined')
// Repeat of the above, in strict mode.
// Either accessor may be omitted or replaced with undefined, or both may be replaced with undefined.
shouldBe("'use strict'; var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}); o.foo", '42')
shouldBe("'use strict'; var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}); o.foo = 42; o.result;", '42');
shouldBe("'use strict'; var o = Object.defineProperty({}, 'foo', {get:undefined, set:function(x){this.result = x;}}); o.foo", 'undefined')
shouldBe("'use strict'; var o = Object.defineProperty({}, 'foo', {get:undefined, set:function(x){this.result = x;}}); o.foo = 42; o.result;", '42');
shouldBe("'use strict'; var o = Object.defineProperty({}, 'foo', {set:function(x){this.result = x;}}); o.foo", 'undefined')
shouldBe("'use strict'; var o = Object.defineProperty({}, 'foo', {set:function(x){this.result = x;}}); o.foo = 42; o.result;", '42');
shouldBe("'use strict'; var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:undefined}); o.foo", '42')
shouldThrow("'use strict'; var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:undefined}); o.foo = 42; o.result;");
shouldBe("'use strict'; var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}}); o.foo", '42')
shouldThrow("'use strict'; var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}}); o.foo = 42; o.result;");
shouldBe("'use strict'; var o = Object.defineProperty({}, 'foo', {get:undefined, set:undefined}); o.foo", 'undefined')
shouldThrow("'use strict'; var o = Object.defineProperty({}, 'foo', {get:undefined, set:undefined}); o.foo = 42; o.result;");
// Test replacing or removing either the getter or setter individually.
shouldBe("'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:function(){return 13;}}); o.foo", '13')
shouldBe("'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:function(){return 13;}}); o.foo = 42; o.result;", '42')
shouldBe("'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:undefined}); o.foo", 'undefined')
shouldBe("'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:undefined}); o.foo = 42; o.result;", '42')
shouldBe("'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:function(){this.result = 13;}}); o.foo", '42')
shouldBe("'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:function(){this.result = 13;}}); o.foo = 42; o.result;", '13')
shouldBe("'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:undefined}); o.foo", '42')
shouldThrow("'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:undefined}); o.foo = 42; o.result;")
Object.defineProperty(Object.prototype, 0, {get:function(){ return false; }, configurable:true})
shouldBeTrue("0 in Object.prototype");
shouldBeTrue("'0' in Object.prototype");
delete Object.prototype[0];
Object.defineProperty(Object.prototype, 'readOnly', {value:true, configurable:true, writable:false})
shouldBeTrue("var o = {}; o.readOnly = false; o.readOnly");
shouldThrow("'use strict'; var o = {}; o.readOnly = false; o.readOnly");
delete Object.prototype.readOnly;
// Check the writable attribute is set correctly when redefining an accessor as a data descriptor.
shouldBeFalse("Object.getOwnPropertyDescriptor(Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return false; }, configurable: true}), 'foo', {value:false}), 'foo').writable");
shouldBeFalse("Object.getOwnPropertyDescriptor(Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return false; }, configurable: true}), 'foo', {value:false, writable: false}), 'foo').writable");
shouldBeTrue("Object.getOwnPropertyDescriptor(Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return false; }, configurable: true}), 'foo', {value:false, writable: true}), 'foo').writable");
// If array length is read-only, [[Put]] should fail.
shouldBeFalse("var a = Object.defineProperty([], 'length', {writable: false}); a[0] = 42; 0 in a;");
shouldThrow("'use strict'; var a = Object.defineProperty([], 'length', {writable: false}); a[0] = 42; 0 in a;");
// If array property is read-only, [[Put]] should fail.
shouldBe("var a = Object.defineProperty([42], '0', {writable: false}); a[0] = false; a[0];", '42');
shouldThrow("'use strict'; var a = Object.defineProperty([42], '0', {writable: false}); a[0] = false; a[0];");
// If array property is an undefined setter, [[Put]] should fail.
shouldBeUndefined("var a = Object.defineProperty([], '0', {set: undefined}); a[0] = 42; a[0];");
shouldThrow("'use strict'; var a = Object.defineProperty([], '0', {set: undefined}); a[0] = 42; a[0];");
function testObject()
{
// Test case from https://bugs.webkit.org/show_bug.cgi?id=38636
Object.defineProperty(anObj, 'slot1', {value: 'foo', enumerable: true});
Object.defineProperty(anObj, 'slot2', {value: 'bar', writable: true});
Object.defineProperty(anObj, 'slot3', {value: 'baz', enumerable: false});
Object.defineProperty(anObj, 'slot4', {value: 'goo', configurable: false});
shouldBe("anObj.slot1", '"foo"');
shouldBe("anObj.slot2", '"bar"');
anObj.slot2 = 'bad value';
shouldBeTrue("anObj.propertyIsEnumerable('slot1')");
shouldBeFalse("anObj.propertyIsEnumerable('slot2')");
delete anObj.slot4;
shouldBe("anObj.slot4", '"goo"');
// Test case from https://bugs.webkit.org/show_bug.cgi?id=48911
Object.defineProperty(Object.getPrototypeOf(anObj), 'slot5', {get: function() { return this._Slot5; }, set: function(v) { this._Slot5 = v; }, configurable: false});
anObj.slot5 = 123;
shouldBe("anObj.slot5", '123');
shouldBe("anObj._Slot5", '123');
shouldBeUndefined("Object.getOwnPropertyDescriptor(anObj, 'slot5')");
Object.defineProperty(anObj, 'slot5', { value: 456 });
shouldBe("anObj.slot5", '456');
shouldBe("anObj._Slot5", '123');
shouldBe("Object.getOwnPropertyDescriptor(anObj, 'slot5').value", '456');
}
var anObj = {};
testObject();
var anObj = this;
testObject();

View File

@ -0,0 +1,9 @@
Resolve or reject do not take effect on a rejected Promise.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS result is "foo"
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,41 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('Resolve or reject do not take effect on a rejected Promise.');
var result;
new Promise(function(resolve, reject) {
reject('foo');
resolve('resolve');
reject('reject');
}).then(function() {
testFailed('fulfilled');
finishJSTest();
}, function(localResult) {
result = localResult;
shouldBeEqualToString('result', 'foo');
finishJSTest();
});

View File

@ -0,0 +1,9 @@
Resolve or reject do not take effect on a resolved Promise.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS result is "foo"
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,43 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('Resolve or reject do not take effect on a resolved Promise.');
var result;
new Promise(function(resolve, reject) {
var anotherResolve;
resolve(new Promise(function(r) { anotherResolve = r; }));
resolve('resolve');
reject('reject');
anotherResolve('foo');
}).then(function(localResult) {
result = localResult;
shouldBeEqualToString('result', 'foo');
finishJSTest();
}, function() {
testFailed('rejected');
finishJSTest();
});

View File

@ -0,0 +1,15 @@
Test Promise.prototype.catch.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS thisInInit is undefined
PASS firstPromise instanceof Promise is true
PASS secondPromise instanceof Promise is true
PASS thisInOnFulfilled is undefined
PASS result is "hello"
PASS result is "bye"
PASS fulfilled
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,71 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony --ignore-unhandled-promises
'use strict';
description('Test Promise.prototype.catch.');
var reject;
var result;
var thisInInit;
var thisInOnFulfilled;
var firstPromise = new Promise(function(_, newReject) {
thisInInit = this;
reject = newReject;
});
var secondPromise = firstPromise.catch(function(localResult) {
thisInOnFulfilled = this;
shouldBe('thisInOnFulfilled', 'undefined');
result = localResult;
shouldBeEqualToString('result', 'hello');
return 'bye';
});
secondPromise.then(function(localResult) {
result = localResult;
shouldBeEqualToString('result', 'bye');
testPassed('fulfilled');
finishJSTest();
}, function() {
testFailed('rejected');
finishJSTest();
});
shouldBe('thisInInit', 'undefined');
shouldBeTrue('firstPromise instanceof Promise');
shouldBeTrue('secondPromise instanceof Promise');
try {
firstPromise.catch(null);
} catch (e) {
testFailed('catch(null) should not throw an exception');
}
try {
firstPromise.catch(37);
} catch (e) {
testFailed('catch(37) should not throw an exception');
}
reject('hello');

View File

@ -0,0 +1,19 @@
Test chained Promise.prototype.then.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
This should be the first debug output.
PASS fulfilled
PASS result is "hello"
PASS fulfilled
PASS result is "hello2"
PASS rejected
PASS result is "error"
PASS rejected
PASS result is "error2"
PASS fulfilled
PASS result is "recovered"
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,72 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('Test chained Promise.prototype.then.');
var resolve;
var promise = new Promise(function (r) {resolve = r;});
var result;
promise.then(function(localResult) { // fulfilled - continue
testPassed('fulfilled');
result = localResult;
shouldBeEqualToString('result', 'hello');
return 'hello2';
}, function() {
testFailed('rrejected');
}).then() // pass through
.then(function(localResult) { // fulfilled - throw an exception
testPassed('fulfilled');
result = localResult;
shouldBeEqualToString('result', 'hello2');
throw 'error';
}, function() {
testFailed('rejected');
}).then(function() { // rejected - throw an exception
testFailed('fulfilled');
}, function(localResult) {
testPassed('rejected');
result = localResult;
shouldBeEqualToString('result', 'error');
throw 'error2';
}).then() // pass through
.then(function() { // rejected - recover
testFailed('fulfilled');
}, function(localResult) {
testPassed('rejected');
result = localResult;
shouldBeEqualToString('result', 'error2');
return 'recovered';
}).then(function(localResult) { // fulfilled - the last
testPassed('fulfilled');
result = localResult;
shouldBeEqualToString('result', 'recovered');
finishJSTest();
}, function() {
testFailed('rejected');
finishJSTest();
});
resolve('hello');
debug('This should be the first debug output.');

View File

@ -0,0 +1,10 @@
An exception thrown from an onFulfilled callback should reject the Promise.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS thisInThenCallback is undefined
PASS result is "foobar"
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,43 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('An exception thrown from an onFulfilled callback should reject the Promise.');
var thisInThenCallback;
var result;
new Promise(function(resolve) {
resolve('hello');
}).then(function(result) {
throw 'foobar';
}).then(function(localResult) {
testFailed('Unexpected invocation of onFulfilled');
}, function(localResult) {
thisInThenCallback = this;
shouldBe('thisInThenCallback', 'undefined');
result = localResult;
shouldBeEqualToString('result', 'foobar');
finishJSTest();
});

View File

@ -0,0 +1,9 @@
|this| in Promise constructor should be undefined.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS receiverInStrict is undefined
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,32 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('|this| in Promise constructor should be undefined.');
var receiverInStrict;
new Promise(function () {
receiverInStrict = this;
shouldBe('receiverInStrict', 'undefined');
});

View File

@ -0,0 +1,19 @@
Test Promise construction.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS promise instanceof Promise is true
PASS promise.constructor is Promise
PASS thisInInit is undefined
PASS resolve instanceof Function is true
PASS reject instanceof Function is true
PASS new Promise() threw exception TypeError: Promise resolver undefined is not a function.
PASS new Promise(37) threw exception TypeError: Promise resolver 37 is not a function.
PASS promise = new Promise(function() { throw Error("foo"); }) did not throw exception.
PASS result.message is "foo"
PASS fulfilled
PASS result is "hello"
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,70 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('Test Promise construction.');
var thisInInit;
var resolve, reject;
var result;
var promise = new Promise(function(newResolve, newReject) {
thisInInit = this;
resolve = newResolve;
reject = newReject;
});
shouldBeTrue('promise instanceof Promise');
shouldBe('promise.constructor', 'Promise');
shouldBe('thisInInit', 'undefined');
shouldBeTrue('resolve instanceof Function');
shouldBeTrue('reject instanceof Function');
shouldThrow('new Promise()', '"TypeError: Promise resolver undefined is not a function"');
shouldThrow('new Promise(37)', '"TypeError: Promise resolver 37 is not a function"');
try {
promise = new Promise(function() { throw Error('foo'); });
testPassed('promise = new Promise(function() { throw Error("foo"); }) did not throw exception.');
} catch (e) {
testFailed('new Promise(function() { throw Error(\'foo\'); }) should not throw an exception.');
}
promise.then(undefined, function(localResult) {
result = localResult;
shouldBeEqualToString('result.message', 'foo');
});
new Promise(function(resolve) {
resolve("hello");
throw Error("foo");
}).then(function(localResult) {
result = localResult;
testPassed('fulfilled');
shouldBeEqualToString('result', 'hello');
finishJSTest();
}, function(localResult) {
result = localResult;
testFailed('rejected');
finishJSTest();
});

View File

@ -0,0 +1,10 @@
Test whether deeply chained then-s work.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS result is undefined
PASS result is 5042
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,42 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('Test whether deeply chained then-s work.');
var result;
var resolve;
var promise = new Promise(function (r) { resolve = r; });
for (var i = 0; i < 5000; ++i) {
promise = promise.then(function (value) { return value + 1; }, function () { testFailed('rejected'); });
}
promise.then(function (value) {
result = value;
shouldBe('result', '5042');
}).then(finishJSTest, finishJSTest);
shouldBe('result', 'undefined');
resolve(42);

View File

@ -0,0 +1,10 @@
Test whether deeply chained then-s work.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS result is undefined
PASS result is 5042
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,42 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('Test whether deeply chained then-s work.');
var result;
var reject;
var promise = new Promise(function (_, r) { reject = r; });
for (var i = 0; i < 5000; ++i) {
promise = promise.then(function (value) { testFailed('fulfilled'); throw value + 1; }, function (value) { throw value + 1; });
}
promise.catch(function (value) {
result = value;
shouldBe('result', '5042');
}).then(finishJSTest, finishJSTest);
shouldBe('result', 'undefined');
reject(42);

View File

@ -0,0 +1,12 @@
Test Promise rejection.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS promiseState is "pending"
PASS promiseState is "pending"
PASS promiseState is "rejected"
PASS promiseResult is "hello"
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,53 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('Test Promise rejection.');
var reject;
var promise = new Promise(function(_, r) { reject = r; });
var promiseState = 'pending';
var promiseResult = undefined;
promise.then(function(result) {
promiseState = 'fulfilled';
promiseResult = result;
}, function(result) {
promiseState = 'rejected';
promiseResult = result;
});
shouldBeEqualToString('promiseState', 'pending');
reject('hello');
shouldBeEqualToString('promiseState', 'pending');
promise.then(function() {
testFailed('fulfilled.');
finishJSTest();
}, function() {
shouldBeEqualToString('promiseState', 'rejected');
shouldBeEqualToString('promiseResult', 'hello');
finishJSTest();
});

View File

@ -0,0 +1,10 @@
Test chained Promise resolutions.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS result is "hello"
PASS result is "bye"
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,60 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('Test chained Promise resolutions.');
var resolve1, resolve2, resolve3;
var reject4, resolve5, resolve6;
var result;
var promise1 = new Promise(function(r) { resolve1 = r; });
var promise2 = new Promise(function(r) { resolve2 = r; });
var promise3 = new Promise(function(r) { resolve3 = r; });
var promise4 = new Promise(function(_, r) { reject4 = r; });
var promise5 = new Promise(function(r) { resolve5 = r; });
var promise6 = new Promise(function(r) { resolve6 = r; });
resolve3(promise2);
resolve2(promise1);
resolve6(promise5);
resolve5(promise4);
promise3.then(function(localResult) {
result = localResult;
shouldBeEqualToString('result', 'hello');
}, function() {
testFailed('rejected');
});
promise6.then(function() {
testFailed('fulfilled');
finishJSTest();
}, function(localResult) {
result = localResult;
shouldBeEqualToString('result', 'bye');
finishJSTest();
});
resolve1('hello');
reject4('bye');

View File

@ -0,0 +1,10 @@
Test Promise resolution.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS thisInOnFulfilled is undefined
PASS result is "hello"
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,12 @@
Test whether Promise processes microtasks in the correct order.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS promiseState is "pending"
PASS promiseState is "pending"
PASS promiseState is "fulfilled"
PASS promiseResult is "hello"
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,53 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('Test whether Promise processes microtasks in the correct order.');
var resolve;
var promise = new Promise(function(r) { resolve = r; });
var promiseState = 'pending';
var promiseResult = undefined;
promise.then(function(result) {
promiseState = 'fulfilled';
promiseResult = result;
}, function(result) {
promiseState = 'rejected';
promiseResult = result;
});
shouldBeEqualToString('promiseState', 'pending');
resolve('hello');
shouldBeEqualToString('promiseState', 'pending');
promise.then(function() {
shouldBeEqualToString('promiseState', 'fulfilled');
shouldBeEqualToString('promiseResult', 'hello');
finishJSTest();
}, function() {
testFailed('promise is rejected.');
finishJSTest();
});

View File

@ -0,0 +1,10 @@
Test whether Promise will be rejected if it is resolved with itself.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS rejected
PASS result is "TypeError: Chaining cycle detected for promise #<Promise>"
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,40 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('Test whether Promise will be rejected if it is resolved with itself.');
var resolve;
var result;
var promise = new Promise(function(r) { resolve = r; });
promise.then(function () {
testFailed('fulfilled');
}, function (error) {
testPassed('rejected');
result = error.toString();
shouldBeEqualToString('result', 'TypeError: Chaining cycle detected for promise #<Promise>');
}).then(finishJSTest, finishJSTest);
resolve(promise);

View File

@ -0,0 +1,11 @@
Test whether Promise treats thenable correctly.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
The promise is already rejected now.
PASS rejected
PASS result is "hello"
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,43 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('Test whether Promise treats thenable correctly.');
var callback;
var result;
new Promise(function(resolve) {
resolve({then: function() { throw 'hello'; }});
}).then(function() {
testFailed('fulfilled');
finishJSTest();
}, function(localResult) {
testPassed('rejected');
result = localResult
shouldBeEqualToString('result', 'hello');
finishJSTest();
});
debug('The promise is already rejected now.');

View File

@ -0,0 +1,13 @@
Test whether Promise treats thenable correctly.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
The promise is not fulfilled now.
PASS value.then is called.
PASS thisValue is value
PASS fulfilled
PASS result is "hello"
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,51 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('Test whether Promise treats thenable correctly.');
var thisValue;
var result;
var value = {
then: function(onFulfilled) {
testPassed('value.then is called.');
thisValue = this;
shouldBe('thisValue', 'value');
onFulfilled('hello');
}
};
new Promise(function(resolve) {
resolve(value);
}).then(function(localResult) {
testPassed('fulfilled');
result = localResult;
shouldBeEqualToString('result', 'hello');
finishJSTest();
}, function() {
testFailed('rejected');
finishJSTest();
});
debug('The promise is not fulfilled now.');

View File

@ -0,0 +1,13 @@
Test whether Promise treats thenable correctly.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
The promise is not rejected now.
PASS value.then is called.
PASS thisValue is value
PASS rejected
PASS result is "hello"
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,51 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('Test whether Promise treats thenable correctly.');
var thisValue;
var result;
var value = {
then: function(onFulfilled, onRejected) {
testPassed('value.then is called.');
thisValue = this;
shouldBe('thisValue', 'value');
onRejected('hello');
}
};
new Promise(function(resolve) {
resolve(value);
}).then(function() {
testFailed('fulfilled');
finishJSTest();
}, function(localResult) {
testPassed('rejected');
result = localResult;
shouldBeEqualToString('result', 'hello');
finishJSTest();
});
debug('The promise is not rejected now.');

View File

@ -0,0 +1,42 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('Test Promise resolution.');
var thisInOnFulfilled;
var result;
new Promise(function(resolve) {
resolve('hello');
}).then(function(localResult) {
thisInOnFulfilled = this;
shouldBe('thisInOnFulfilled', 'undefined');
result = localResult;
shouldBeEqualToString('result', 'hello');
finishJSTest();
}, function() {
fail('rejected');
finishJSTest();
});

View File

@ -0,0 +1,11 @@
Test Promise.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS thisInInit is undefined
PASS thisInOnFulfilled is undefined
PASS result is "hello"
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,46 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('Test Promise.');
var resolve;
var thisInInit;
var thisInOnFulfilled;
var result;
new Promise(function(newResolve) {
thisInInit = this;
resolve = newResolve;
}).then(function(localResult) {
thisInOnFulfilled = this;
shouldBe('thisInOnFulfilled', 'undefined');
result = localResult;
shouldBeEqualToString('result', 'hello');
finishJSTest();
});
shouldBe('thisInInit', 'undefined');
resolve('hello');

View File

@ -0,0 +1,32 @@
Test Promise.all
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS result is undefined
PASS Promise.all() is rejected.
PASS Promise.all([]) is fulfilled.
PASS result.length is 0
PASS Promise.all([p1, p2, p3]) is fulfilled.
PASS result.length is 3
PASS result[0] is "p1"
PASS result[1] is "p2"
PASS result[2] is "p3"
PASS Promise.all([p1, p6, p5]) is rejected.
PASS result is "p6"
PASS Promise.all([p9]) is fulfilled.
PASS result.length is 1
PASS result[0] is "p2"
PASS Promise.all([p9,,,]) is fulfilled.
PASS result.length is 3
PASS result[0] is "p2"
PASS result[1] is undefined
PASS result[2] is undefined
PASS Promise.all([p9,42]) is fulfilled.
PASS result.length is 2
PASS result[0] is "p2"
PASS result[1] is 42
PASS Promise.all({}) is rejected.
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,117 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony --ignore-unhandled-promises
'use strict';
description('Test Promise.all');
var result = undefined;
var p1 = new Promise(function(resolve) { resolve('p1'); });
var p2 = new Promise(function(resolve) { resolve('p2'); });
var p3 = new Promise(function(resolve) { resolve('p3'); });
var p4 = new Promise(function() {});
var p5 = new Promise(function() {});
var p6 = new Promise(function(_, reject) { reject('p6'); });
var p7 = new Promise(function(_, reject) { reject('p7'); });
var p8 = new Promise(function(_, reject) { reject('p8'); });
var p9 = new Promise(function(resolve) { resolve(p2); });
Promise.all([p1, p2, p5]).then(function(result) {
testFailed('Promise.all([p1, p2, p5]) is fulfilled.');
}, function() {
testFailed('Promise.all([p1, p2, p5]) is rejected.');
});
Promise.all().then(function() {
testFailed('Promise.all() is fulfilled.');
}, function() {
testPassed('Promise.all() is rejected.');
return Promise.all([]).then(function(localResult) {
testPassed('Promise.all([]) is fulfilled.');
result = localResult;
shouldBe('result.length', '0');
}, function() {
testFailed('Promise.all([]) is rejected.');
});
}).then(function() {
return Promise.all([p1, p2, p3]).then(function(localResult) {
testPassed('Promise.all([p1, p2, p3]) is fulfilled.');
result = localResult;
shouldBe('result.length', '3');
shouldBeEqualToString('result[0]', 'p1');
shouldBeEqualToString('result[1]', 'p2');
shouldBeEqualToString('result[2]', 'p3');
}, function() {
testFailed('Promise.all([p1, p2, p3]) is rejected.');
});
}).then(function() {
return Promise.all([p1, p6, p5]).then(function(localResult) {
testFailed('Promise.all([p1, p6, p5]) is fulfilled.');
}, function(localResult) {
testPassed('Promise.all([p1, p6, p5]) is rejected.');
result = localResult;
shouldBeEqualToString('result', 'p6');
});
}).then(function() {
return Promise.all([p9]).then(function(localResult) {
testPassed('Promise.all([p9]) is fulfilled.');
result = localResult;
shouldBe('result.length', '1');
shouldBeEqualToString('result[0]', 'p2');
}, function(result) {
testFailed('Promise.all([p9]) is rejected.');
});
}).then(function() {
// Array hole should not be skipped.
return Promise.all([p9,,,]).then(function(localResult) {
testPassed('Promise.all([p9,,,]) is fulfilled.');
result = localResult;
shouldBe('result.length', '3');
shouldBeEqualToString('result[0]', 'p2');
shouldBe('result[1]', 'undefined');
shouldBe('result[2]', 'undefined');
}, function(localResult) {
testFailed('Promise.all([p9,,,]) is rejected.');
});
}).then(function() {
// Immediate value should be converted to a promise object by the
// ToPromise operation.
return Promise.all([p9,42]).then(function(localResult) {
testPassed('Promise.all([p9,42]) is fulfilled.');
result = localResult;
shouldBe('result.length', '2');
shouldBeEqualToString('result[0]', 'p2');
shouldBe('result[1]', '42');
}, function(localResult) {
testFailed('Promise.all([p9,42]) is rejected.');
});
}).then(function() {
return Promise.all({}).then(function(localResult) {
testFailed('Promise.all({}) is fulfilled.');
}, function(localResult) {
testPassed('Promise.all({}) is rejected.');
});
}).then(finishJSTest, finishJSTest);
shouldBe('result', 'undefined');

View File

@ -0,0 +1,14 @@
Test Promise.resolve as cast
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS promise is value
PASS result is undefined
PASS result2 is undefined
PASS result is "hello"
PASS result2 is 42
PASS fulfilled
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,56 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('Test Promise.resolve as cast');
var result = undefined;
var result2 = undefined;
var resolve;
var value = new Promise(function (r) { resolve = r;} );
var promise = Promise.resolve(value);
// If [[IsPromise]] is true, Promise.resolve simply returns argument.
shouldBe('promise', 'value');
promise.then(function(res) {
result = res;
shouldBeEqualToString('result', 'hello');
return Promise.resolve(42).then(function (res) {
result2 = res;
shouldBe('result2', '42');
});
}).then(function () {
testPassed('fulfilled');
finishJSTest();
}, function() {
testFailed('rejected');
finishJSTest();
});
resolve('hello');
shouldBe('result', 'undefined');
shouldBe('result2', 'undefined');

View File

@ -0,0 +1,21 @@
Test Promise.race
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS result is undefined
PASS Promise.race() is rejected.
PASS Promise.race({}) is rejected.
PASS Promise.race([p4, p1, p6]) is fulfilled.
PASS result is "p1"
PASS Promise.race([p4, p6, p1]) is rejected.
PASS result is "p6"
PASS Promise.race([p9]) is fulfilled.
PASS result is "p2"
PASS Promise.race([p4,,]) is fulfilled.
PASS result is undefined
PASS Promise.race([p4,42]) is fulfilled.
PASS result is 42
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,108 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony --ignore-unhandled-promises
'use strict';
description('Test Promise.race');
var result;
var p1 = new Promise(function(resolve) { resolve('p1'); });
var p2 = new Promise(function(resolve) { resolve('p2'); });
var p3 = new Promise(function(resolve) { resolve('p3'); });
var p4 = new Promise(function() {});
var p5 = new Promise(function() {});
var p6 = new Promise(function(_, reject) { reject('p6'); });
var p7 = new Promise(function(_, reject) { reject('p7'); });
var p8 = new Promise(function(_, reject) { reject('p8'); });
var p9 = new Promise(function(resolve) { resolve(p2); });
Promise.race([p4, p5]).then(function(localResult) {
testFailed('Promise.race([p4, p5]) is fulfilled.');
}, function() {
testFailed('Promise.race([p4, p5]) is rejected.');
});
// If the argument is an empty array, the result promise won't be fulfilled.
Promise.race([]).then(function(localResult) {
testFailed('Promise.race([]) is fulfilled.');
}, function() {
testFailed('Promise.race([]) is rejected.');
});
Promise.race().then(function(localResult) {
testFailed('Promise.race() is fulfilled.');
}, function() {
testPassed('Promise.race() is rejected.');
}).then(function() {
return Promise.race({}).then(function(localResult) {
testFailed('Promise.race({}) is fulfilled.');
}, function() {
testPassed('Promise.race({}) is rejected.');
});
}).then(function() {
return Promise.race([p4, p1, p6]).then(function(localResult) {
testPassed('Promise.race([p4, p1, p6]) is fulfilled.');
result = localResult;
shouldBeEqualToString('result', 'p1');
}, function() {
testFailed('Promise.race([p4, p1, p6]) is rejected.');
});
}).then(function() {
return Promise.race([p4, p6, p1]).then(function(localResult) {
testFailed('Promise.race([p4, p6, p1]) is fulfilled.');
}, function(localResult) {
testPassed('Promise.race([p4, p6, p1]) is rejected.');
result = localResult;
shouldBeEqualToString('result', 'p6');
});
}).then(function() {
return Promise.race([p9]).then(function(localResult) {
testPassed('Promise.race([p9]) is fulfilled.');
result = localResult;
shouldBeEqualToString('result', 'p2');
}, function() {
testFailed('Promise.race([p9]) is rejected.');
});
}).then(function() {
// Array hole should not be skipped.
return Promise.race([p4,,]).then(function(localResult) {
testPassed('Promise.race([p4,,]) is fulfilled.');
result = localResult;
shouldBe('result', 'undefined');
}, function() {
testFailed('Promise.race([p4,,]) is rejected.');
});
}).then(function() {
// Immediate value should be converted to a promise object by the
// ToPromise operation.
return Promise.race([p4,42]).then(function(localResult) {
testPassed('Promise.race([p4,42]) is fulfilled.');
result = localResult;
shouldBe('result', '42');
}, function() {
testFailed('Promise.race([p4,42]) is rejected.');
});
}).then(finishJSTest, finishJSTest);
shouldBe('result', 'undefined');

View File

@ -0,0 +1,10 @@
Test Promise.reject
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS result is undefined
PASS result is "hello"
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,38 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('Test Promise.reject');
var result = undefined;
Promise.reject('hello').then(function(result) {
testFailed('fulfilled');
finishJSTest();
}, function(localResult) {
result = localResult;
shouldBeEqualToString('result', 'hello');
finishJSTest();
});
shouldBe('result', 'undefined');

View File

@ -0,0 +1,10 @@
Test Promise.resolve
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS result is undefined
PASS result is "hello"
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,43 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('Test Promise.resolve');
var result = undefined;
var resolve;
var promise = Promise.resolve(new Promise(function (r) { resolve = r;} ));
promise.then(function(localResult) {
result = localResult;
shouldBeEqualToString('result', 'hello');
finishJSTest();
}, function() {
testFailed('rejected');
finishJSTest();
});
resolve('hello');
shouldBe('result', 'undefined');

View File

@ -0,0 +1,12 @@
Test whether then callback receivers are correctly set.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS fulfilled
PASS thisInOnFulfilled is undefined
PASS rejected
PASS thisInOnRejected is undefined
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,47 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('Test whether then callback receivers are correctly set.');
var thisInOnFulfilled;
var thisInOnRejected;
Promise.resolve().then(function () {
return Promise.resolve(42).then(function () {
testPassed('fulfilled');
thisInOnFulfilled = this;
shouldBe('thisInOnFulfilled', 'undefined');
}, function () {
testFailed('rejected');
});
}).then(function () {
return Promise.reject(42).then(function () {
testFailed('fulfilled');
}, function () {
testPassed('rejected');
thisInOnRejected = this;
shouldBe('thisInOnRejected', 'undefined');
});
}).then(finishJSTest, finishJSTest);

View File

@ -0,0 +1,17 @@
Test Promise.prototype.then
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS thisInInit is undefined
PASS firstPromise instanceof Promise is true
PASS secondPromise instanceof Promise is true
PASS thisInOnFulfilled is undefined
PASS result is "hello"
PASS result is "world"
PASS rejected
PASS result is "exception"
PASS resolved
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,9 @@
Promise.prototype.then should work without callbacks.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS result is "hello"
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,35 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('Promise.prototype.then should work without callbacks.');
var result;
new Promise(function(resolve) { resolve('hello'); }).then(
// then without callbacks
).then(function(localResult) {
result = localResult;
shouldBeEqualToString('result', 'hello');
finishJSTest();
});

View File

@ -0,0 +1,68 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony
'use strict';
description('Test Promise.prototype.then');
var resolve;
var result;
var thisInOnFulfilled;
var thisInInit;
var firstPromise = new Promise(function(newResolve) {
thisInInit = this;
resolve = newResolve;
});
var secondPromise = firstPromise.then(function(localResult) {
thisInOnFulfilled = this;
shouldBe('thisInOnFulfilled', 'undefined');
result = localResult;
shouldBeEqualToString('result', 'hello');
return 'world';
});
shouldBe('thisInInit', 'undefined');
shouldBeTrue('firstPromise instanceof Promise');
shouldBeTrue('secondPromise instanceof Promise');
secondPromise.then(undefined, 37).then(function(localResult) {
result = localResult;
shouldBeEqualToString('result', 'world');
throw 'exception'
}).then(1, 2).then(function() {
testFailed('resolved');
}, function(localResult) {
testPassed('rejected');
result = localResult;
shouldBeEqualToString('result', 'exception');
}).then(function() {
testPassed('resolved');
finishJSTest();
}, function() {
testFailed('rejected');
finishJSTest();
});
resolve('hello');

View File

@ -0,0 +1,206 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This test thoroughly checks the behaviour of the 'arguments' object.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS access_1(1, 2, 3) is 1
PASS access_2(1, 2, 3) is 2
PASS access_3(1, 2, 3) is 3
PASS access_4(1, 2, 3) is undefined
PASS access_5(1, 2, 3) is undefined
PASS access_1(1) is 1
PASS access_2(1) is undefined
PASS access_3(1) is undefined
PASS access_4(1) is undefined
PASS access_5(1) is undefined
PASS access_1(1, 2, 3, 4, 5) is 1
PASS access_2(1, 2, 3, 4, 5) is 2
PASS access_3(1, 2, 3, 4, 5) is 3
PASS access_4(1, 2, 3, 4, 5) is 4
PASS access_5(1, 2, 3, 4, 5) is 5
PASS argumentLengthIs5() is 5
PASS argumentLengthIs5(1,2,3,4,5) is 5
PASS argumentLengthIs5(1,2,3,4,5,6,7,8,9,10) is 5
PASS duplicateArgumentAndReturnLast_call(1) is 1
PASS duplicateArgumentAndReturnFirst_call(1) is 1
PASS duplicateArgumentAndReturnLast_apply(1) is 1
PASS duplicateArgumentAndReturnFirst_apply(1) is 1
PASS tear_off_equal_access_1(1, 2, 3) is 1
PASS tear_off_equal_access_2(1, 2, 3) is 2
PASS tear_off_equal_access_3(1, 2, 3) is 3
PASS tear_off_equal_access_4(1, 2, 3) is undefined
PASS tear_off_equal_access_5(1, 2, 3) is undefined
PASS tear_off_too_few_access_1(1) is 1
PASS tear_off_too_few_access_2(1) is undefined
PASS tear_off_too_few_access_3(1) is undefined
PASS tear_off_too_few_access_4(1) is undefined
PASS tear_off_too_few_access_5(1) is undefined
PASS tear_off_too_many_access_1(1, 2, 3, 4, 5) is 1
PASS tear_off_too_many_access_2(1, 2, 3, 4, 5) is 2
PASS tear_off_too_many_access_3(1, 2, 3, 4, 5) is 3
PASS tear_off_too_many_access_4(1, 2, 3, 4, 5) is 4
PASS tear_off_too_many_access_5(1, 2, 3, 4, 5) is 5
PASS live_1(0, 2, 3) is 1
PASS live_2(1, 0, 3) is 2
PASS live_3(1, 2, 0) is 3
PASS live_1(0) is 1
PASS live_2(1) is undefined
PASS live_3(1) is undefined
PASS live_1(0, 2, 3, 4, 5) is 1
PASS live_2(1, 0, 3, 4, 5) is 2
PASS live_3(1, 2, 0, 4, 5) is 3
PASS extra_args_modify_4(1, 2, 3, 0, 5) is 4
PASS extra_args_modify_5(1, 2, 3, 4, 0) is 5
PASS tear_off_live_1(0, 2, 3)() is 1
PASS tear_off_live_2(1, 0, 3)() is 2
PASS tear_off_live_3(1, 2, 0)() is 3
PASS tear_off_live_1(0)() is 1
PASS tear_off_live_2(1)() is undefined
PASS tear_off_live_3(1)() is undefined
PASS tear_off_live_1(0, 2, 3, 4, 5)() is 1
PASS tear_off_live_2(1, 0, 3, 4, 5)() is 2
PASS tear_off_live_3(1, 2, 0, 4, 5)() is 3
PASS tear_off_extra_args_modify_4(1, 2, 3, 0, 5)() is 4
PASS tear_off_extra_args_modify_5(1, 2, 3, 4, 0)() is 5
PASS delete_1(1, 2, 3) is undefined
PASS delete_2(1, 2, 3) is undefined
PASS delete_3(1, 2, 3) is undefined
PASS delete_4(1, 2, 3) is undefined
PASS delete_5(1, 2, 3) is undefined
PASS delete_1(1) is undefined
PASS delete_2(1) is undefined
PASS delete_3(1) is undefined
PASS delete_4(1) is undefined
PASS delete_5(1) is undefined
PASS delete_1(1, 2, 3, 4, 5) is undefined
PASS delete_2(1, 2, 3, 4, 5) is undefined
PASS delete_3(1, 2, 3, 4, 5) is undefined
PASS delete_4(1, 2, 3, 4, 5) is undefined
PASS delete_5(1, 2, 3, 4, 5) is undefined
PASS tear_off_delete_1(1, 2, 3)() is undefined
PASS tear_off_delete_2(1, 2, 3)() is undefined
PASS tear_off_delete_3(1, 2, 3)() is undefined
PASS tear_off_delete_4(1, 2, 3)() is undefined
PASS tear_off_delete_5(1, 2, 3)() is undefined
PASS tear_off_delete_1(1)() is undefined
PASS tear_off_delete_2(1)() is undefined
PASS tear_off_delete_3(1)() is undefined
PASS tear_off_delete_4(1)() is undefined
PASS tear_off_delete_5(1)() is undefined
PASS tear_off_delete_1(1, 2, 3, 4, 5)() is undefined
PASS tear_off_delete_2(1, 2, 3, 4, 5)() is undefined
PASS tear_off_delete_3(1, 2, 3, 4, 5)() is undefined
PASS tear_off_delete_4(1, 2, 3, 4, 5)() is undefined
PASS tear_off_delete_5(1, 2, 3, 4, 5)() is undefined
PASS delete_not_live_1(1, 2, 3) is 1
PASS delete_not_live_2(1, 2, 3) is 2
PASS delete_not_live_3(1, 2, 3) is 3
PASS delete_not_live_1(1) is 1
PASS delete_not_live_2(1) is undefined
PASS delete_not_live_3(1) is undefined
PASS delete_not_live_1(1, 2, 3, 4, 5) is 1
PASS delete_not_live_2(1, 2, 3, 4, 5) is 2
PASS delete_not_live_3(1, 2, 3, 4, 5) is 3
PASS tear_off_delete_not_live_1(1, 2, 3)() is 1
PASS tear_off_delete_not_live_2(1, 2, 3)() is 2
PASS tear_off_delete_not_live_3(1, 2, 3)() is 3
PASS tear_off_delete_not_live_1(1)() is 1
PASS tear_off_delete_not_live_2(1)() is undefined
PASS tear_off_delete_not_live_3(1)() is undefined
PASS tear_off_delete_not_live_1(1, 2, 3, 4, 5)() is 1
PASS tear_off_delete_not_live_2(1, 2, 3, 4, 5)() is 2
PASS tear_off_delete_not_live_3(1, 2, 3, 4, 5)() is 3
PASS access_after_delete_named_2(1, 2, 3) is 2
PASS access_after_delete_named_3(1, 2, 3) is 3
PASS access_after_delete_named_4(1, 2, 3) is undefined
PASS access_after_delete_named_2(1) is undefined
PASS access_after_delete_named_3(1) is undefined
PASS access_after_delete_named_4(1) is undefined
PASS access_after_delete_named_2(1, 2, 3, 4) is 2
PASS access_after_delete_named_3(1, 2, 3, 4) is 3
PASS access_after_delete_named_4(1, 2, 3, 4) is 4
PASS access_after_delete_extra_1(1, 2, 3) is 1
PASS access_after_delete_extra_2(1, 2, 3) is 2
PASS access_after_delete_extra_3(1, 2, 3) is 3
PASS access_after_delete_extra_5(1, 2, 3) is undefined
PASS access_after_delete_extra_1(1) is 1
PASS access_after_delete_extra_2(1) is undefined
PASS access_after_delete_extra_3(1) is undefined
PASS access_after_delete_extra_5(1) is undefined
PASS access_after_delete_extra_1(1, 2, 3, 4, 5) is 1
PASS access_after_delete_extra_2(1, 2, 3, 4, 5) is 2
PASS access_after_delete_extra_3(1, 2, 3, 4, 5) is 3
PASS access_after_delete_extra_5(1, 2, 3, 4, 5) is 5
PASS argumentsParam(true) is true
PASS argumentsFunctionConstructorParam(true) is true
PASS argumentsVarUndefined() is '[object Arguments]'
PASS argumentCalleeInException() is argumentCalleeInException
PASS shadowedArgumentsApply([true]) is true
PASS shadowedArgumentsLength([]) is 0
PASS shadowedArgumentsLength() threw exception TypeError: Cannot read properties of undefined (reading 'length').
PASS shadowedArgumentsCallee([]) is undefined.
PASS shadowedArgumentsIndex([true]) is true
PASS descriptor.value is "one"
PASS descriptor.writable is true
PASS descriptor.enumerable is true
PASS descriptor.configurable is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS true is true
PASS false is false
PASS true is true
PASS false is false
PASS false is false
PASS undefined is undefined.
PASS true is true
PASS false is false
PASS successfullyParsed is true
TEST COMPLETE

682
deps/v8/test/webkit/fast/js/arguments.js vendored Normal file
View File

@ -0,0 +1,682 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description(
"This test thoroughly checks the behaviour of the 'arguments' object."
);
function access_1(a, b, c)
{
return arguments[0];
}
function access_2(a, b, c)
{
return arguments[1];
}
function access_3(a, b, c)
{
return arguments[2];
}
function access_4(a, b, c)
{
return arguments[3];
}
function access_5(a, b, c)
{
return arguments[4];
}
function argumentLengthIs5() {
arguments.length = 5;
return arguments.length;
}
function duplicateArgumentAndReturnLast_call(a) {
Array.prototype.push.call(arguments, a);
return arguments[1];
}
function duplicateArgumentAndReturnFirst_call(a) {
Array.prototype.push.call(arguments, a);
return arguments[0];
}
function duplicateArgumentAndReturnLast_apply(a) {
Array.prototype.push.apply(arguments, arguments);
return arguments[1];
}
function duplicateArgumentAndReturnFirst_apply(a) {
Array.prototype.push.apply(arguments, arguments);
return arguments[0];
}
shouldBe("access_1(1, 2, 3)", "1");
shouldBe("access_2(1, 2, 3)", "2");
shouldBe("access_3(1, 2, 3)", "3");
shouldBe("access_4(1, 2, 3)", "undefined");
shouldBe("access_5(1, 2, 3)", "undefined");
shouldBe("access_1(1)", "1");
shouldBe("access_2(1)", "undefined");
shouldBe("access_3(1)", "undefined");
shouldBe("access_4(1)", "undefined");
shouldBe("access_5(1)", "undefined");
shouldBe("access_1(1, 2, 3, 4, 5)", "1");
shouldBe("access_2(1, 2, 3, 4, 5)", "2");
shouldBe("access_3(1, 2, 3, 4, 5)", "3");
shouldBe("access_4(1, 2, 3, 4, 5)", "4");
shouldBe("access_5(1, 2, 3, 4, 5)", "5");
shouldBe("argumentLengthIs5()", "5");
shouldBe("argumentLengthIs5(1,2,3,4,5)", "5");
shouldBe("argumentLengthIs5(1,2,3,4,5,6,7,8,9,10)", "5");
shouldBe("duplicateArgumentAndReturnLast_call(1)", "1");
shouldBe("duplicateArgumentAndReturnFirst_call(1)", "1");
shouldBe("duplicateArgumentAndReturnLast_apply(1)", "1");
shouldBe("duplicateArgumentAndReturnFirst_apply(1)", "1");
function f(a, b, c)
{
return arguments;
}
function tear_off_equal_access_1(a, b, c)
{
return f(a, b, c)[0];
}
function tear_off_equal_access_2(a, b, c)
{
return f(a, b, c)[1];
}
function tear_off_equal_access_3(a, b, c)
{
return f(a, b, c)[2];
}
function tear_off_equal_access_4(a, b, c)
{
return f(a, b, c)[3];
}
function tear_off_equal_access_5(a, b, c)
{
return f(a, b, c)[4];
}
shouldBe("tear_off_equal_access_1(1, 2, 3)", "1");
shouldBe("tear_off_equal_access_2(1, 2, 3)", "2");
shouldBe("tear_off_equal_access_3(1, 2, 3)", "3");
shouldBe("tear_off_equal_access_4(1, 2, 3)", "undefined");
shouldBe("tear_off_equal_access_5(1, 2, 3)", "undefined");
function tear_off_too_few_access_1(a)
{
return f(a)[0];
}
function tear_off_too_few_access_2(a)
{
return f(a)[1];
}
function tear_off_too_few_access_3(a)
{
return f(a)[2];
}
function tear_off_too_few_access_4(a)
{
return f(a)[3];
}
function tear_off_too_few_access_5(a)
{
return f(a)[4];
}
shouldBe("tear_off_too_few_access_1(1)", "1");
shouldBe("tear_off_too_few_access_2(1)", "undefined");
shouldBe("tear_off_too_few_access_3(1)", "undefined");
shouldBe("tear_off_too_few_access_4(1)", "undefined");
shouldBe("tear_off_too_few_access_5(1)", "undefined");
function tear_off_too_many_access_1(a, b, c, d, e)
{
return f(a, b, c, d, e)[0];
}
function tear_off_too_many_access_2(a, b, c, d, e)
{
return f(a, b, c, d, e)[1];
}
function tear_off_too_many_access_3(a, b, c, d, e)
{
return f(a, b, c, d, e)[2];
}
function tear_off_too_many_access_4(a, b, c, d, e)
{
return f(a, b, c, d, e)[3];
}
function tear_off_too_many_access_5(a, b, c, d, e)
{
return f(a, b, c, d, e)[4];
}
shouldBe("tear_off_too_many_access_1(1, 2, 3, 4, 5)", "1");
shouldBe("tear_off_too_many_access_2(1, 2, 3, 4, 5)", "2");
shouldBe("tear_off_too_many_access_3(1, 2, 3, 4, 5)", "3");
shouldBe("tear_off_too_many_access_4(1, 2, 3, 4, 5)", "4");
shouldBe("tear_off_too_many_access_5(1, 2, 3, 4, 5)", "5");
function live_1(a, b, c)
{
arguments[0] = 1;
return a;
}
function live_2(a, b, c)
{
arguments[1] = 2;
return b;
}
function live_3(a, b, c)
{
arguments[2] = 3;
return c;
}
shouldBe("live_1(0, 2, 3)", "1");
shouldBe("live_2(1, 0, 3)", "2");
shouldBe("live_3(1, 2, 0)", "3");
// Arguments that were not provided are not live
shouldBe("live_1(0)", "1");
shouldBe("live_2(1)", "undefined");
shouldBe("live_3(1)", "undefined");
shouldBe("live_1(0, 2, 3, 4, 5)", "1");
shouldBe("live_2(1, 0, 3, 4, 5)", "2");
shouldBe("live_3(1, 2, 0, 4, 5)", "3");
function extra_args_modify_4(a, b, c)
{
arguments[3] = 4;
return arguments[3];
}
function extra_args_modify_5(a, b, c)
{
arguments[4] = 5;
return arguments[4];
}
shouldBe("extra_args_modify_4(1, 2, 3, 0, 5)", "4");
shouldBe("extra_args_modify_5(1, 2, 3, 4, 0)", "5");
function tear_off_live_1(a, b, c)
{
var args = arguments;
return function()
{
args[0] = 1;
return a;
};
}
function tear_off_live_2(a, b, c)
{
var args = arguments;
return function()
{
args[1] = 2;
return b;
};
}
function tear_off_live_3(a, b, c)
{
var args = arguments;
return function()
{
args[2] = 3;
return c;
};
}
shouldBe("tear_off_live_1(0, 2, 3)()", "1");
shouldBe("tear_off_live_2(1, 0, 3)()", "2");
shouldBe("tear_off_live_3(1, 2, 0)()", "3");
// Arguments that were not provided are not live
shouldBe("tear_off_live_1(0)()", "1");
shouldBe("tear_off_live_2(1)()", "undefined");
shouldBe("tear_off_live_3(1)()", "undefined");
shouldBe("tear_off_live_1(0, 2, 3, 4, 5)()", "1");
shouldBe("tear_off_live_2(1, 0, 3, 4, 5)()", "2");
shouldBe("tear_off_live_3(1, 2, 0, 4, 5)()", "3");
function tear_off_extra_args_modify_4(a, b, c)
{
return function()
{
arguments[3] = 4;
return arguments[3];
}
}
function tear_off_extra_args_modify_5(a, b, c)
{
return function()
{
arguments[4] = 5;
return arguments[4];
}
}
shouldBe("tear_off_extra_args_modify_4(1, 2, 3, 0, 5)()", "4");
shouldBe("tear_off_extra_args_modify_5(1, 2, 3, 4, 0)()", "5");
function delete_1(a, b, c)
{
delete arguments[0];
return arguments[0];
}
function delete_2(a, b, c)
{
delete arguments[1];
return arguments[1];
}
function delete_3(a, b, c)
{
delete arguments[2];
return arguments[2];
}
function delete_4(a, b, c)
{
delete arguments[3];
return arguments[3];
}
function delete_5(a, b, c)
{
delete arguments[4];
return arguments[4];
}
shouldBe("delete_1(1, 2, 3)", "undefined");
shouldBe("delete_2(1, 2, 3)", "undefined");
shouldBe("delete_3(1, 2, 3)", "undefined");
shouldBe("delete_4(1, 2, 3)", "undefined");
shouldBe("delete_5(1, 2, 3)", "undefined");
shouldBe("delete_1(1)", "undefined");
shouldBe("delete_2(1)", "undefined");
shouldBe("delete_3(1)", "undefined");
shouldBe("delete_4(1)", "undefined");
shouldBe("delete_5(1)", "undefined");
shouldBe("delete_1(1, 2, 3, 4, 5)", "undefined");
shouldBe("delete_2(1, 2, 3, 4, 5)", "undefined");
shouldBe("delete_3(1, 2, 3, 4, 5)", "undefined");
shouldBe("delete_4(1, 2, 3, 4, 5)", "undefined");
shouldBe("delete_5(1, 2, 3, 4, 5)", "undefined");
function tear_off_delete_1(a, b, c)
{
return function()
{
delete arguments[0];
return arguments[0];
};
}
function tear_off_delete_2(a, b, c)
{
return function()
{
delete arguments[1];
return arguments[1];
};
}
function tear_off_delete_3(a, b, c)
{
return function()
{
delete arguments[2];
return arguments[2];
};
}
function tear_off_delete_4(a, b, c)
{
return function()
{
delete arguments[3];
return arguments[3];
};
}
function tear_off_delete_5(a, b, c)
{
return function()
{
delete arguments[4];
return arguments[4];
};
}
shouldBe("tear_off_delete_1(1, 2, 3)()", "undefined");
shouldBe("tear_off_delete_2(1, 2, 3)()", "undefined");
shouldBe("tear_off_delete_3(1, 2, 3)()", "undefined");
shouldBe("tear_off_delete_4(1, 2, 3)()", "undefined");
shouldBe("tear_off_delete_5(1, 2, 3)()", "undefined");
shouldBe("tear_off_delete_1(1)()", "undefined");
shouldBe("tear_off_delete_2(1)()", "undefined");
shouldBe("tear_off_delete_3(1)()", "undefined");
shouldBe("tear_off_delete_4(1)()", "undefined");
shouldBe("tear_off_delete_5(1)()", "undefined");
shouldBe("tear_off_delete_1(1, 2, 3, 4, 5)()", "undefined");
shouldBe("tear_off_delete_2(1, 2, 3, 4, 5)()", "undefined");
shouldBe("tear_off_delete_3(1, 2, 3, 4, 5)()", "undefined");
shouldBe("tear_off_delete_4(1, 2, 3, 4, 5)()", "undefined");
shouldBe("tear_off_delete_5(1, 2, 3, 4, 5)()", "undefined");
function delete_not_live_1(a, b, c)
{
delete arguments[0];
return a;
}
function delete_not_live_2(a, b, c)
{
delete arguments[1];
return b;
}
function delete_not_live_3(a, b, c)
{
delete arguments[2];
return c;
}
shouldBe("delete_not_live_1(1, 2, 3)", "1");
shouldBe("delete_not_live_2(1, 2, 3)", "2");
shouldBe("delete_not_live_3(1, 2, 3)", "3");
shouldBe("delete_not_live_1(1)", "1");
shouldBe("delete_not_live_2(1)", "undefined");
shouldBe("delete_not_live_3(1)", "undefined");
shouldBe("delete_not_live_1(1, 2, 3, 4, 5)", "1");
shouldBe("delete_not_live_2(1, 2, 3, 4, 5)", "2");
shouldBe("delete_not_live_3(1, 2, 3, 4, 5)", "3");
function tear_off_delete_not_live_1(a, b, c)
{
return function()
{
delete arguments[0];
return a;
};
}
function tear_off_delete_not_live_2(a, b, c)
{
return function ()
{
delete arguments[1];
return b;
};
}
function tear_off_delete_not_live_3(a, b, c)
{
return function()
{
delete arguments[2];
return c;
};
}
shouldBe("tear_off_delete_not_live_1(1, 2, 3)()", "1");
shouldBe("tear_off_delete_not_live_2(1, 2, 3)()", "2");
shouldBe("tear_off_delete_not_live_3(1, 2, 3)()", "3");
shouldBe("tear_off_delete_not_live_1(1)()", "1");
shouldBe("tear_off_delete_not_live_2(1)()", "undefined");
shouldBe("tear_off_delete_not_live_3(1)()", "undefined");
shouldBe("tear_off_delete_not_live_1(1, 2, 3, 4, 5)()", "1");
shouldBe("tear_off_delete_not_live_2(1, 2, 3, 4, 5)()", "2");
shouldBe("tear_off_delete_not_live_3(1, 2, 3, 4, 5)()", "3");
function access_after_delete_named_2(a, b, c)
{
delete arguments[0];
return b;
}
function access_after_delete_named_3(a, b, c)
{
delete arguments[0];
return c;
}
function access_after_delete_named_4(a, b, c)
{
delete arguments[0];
return arguments[3];
}
shouldBe("access_after_delete_named_2(1, 2, 3)", "2");
shouldBe("access_after_delete_named_3(1, 2, 3)", "3");
shouldBe("access_after_delete_named_4(1, 2, 3)", "undefined");
shouldBe("access_after_delete_named_2(1)", "undefined");
shouldBe("access_after_delete_named_3(1)", "undefined");
shouldBe("access_after_delete_named_4(1)", "undefined");
shouldBe("access_after_delete_named_2(1, 2, 3, 4)", "2");
shouldBe("access_after_delete_named_3(1, 2, 3, 4)", "3");
shouldBe("access_after_delete_named_4(1, 2, 3, 4)", "4");
function access_after_delete_extra_1(a, b, c)
{
delete arguments[3];
return a;
}
function access_after_delete_extra_2(a, b, c)
{
delete arguments[3];
return b;
}
function access_after_delete_extra_3(a, b, c)
{
delete arguments[3];
return c;
}
function access_after_delete_extra_5(a, b, c)
{
delete arguments[3];
return arguments[4];
}
shouldBe("access_after_delete_extra_1(1, 2, 3)", "1");
shouldBe("access_after_delete_extra_2(1, 2, 3)", "2");
shouldBe("access_after_delete_extra_3(1, 2, 3)", "3");
shouldBe("access_after_delete_extra_5(1, 2, 3)", "undefined");
shouldBe("access_after_delete_extra_1(1)", "1");
shouldBe("access_after_delete_extra_2(1)", "undefined");
shouldBe("access_after_delete_extra_3(1)", "undefined");
shouldBe("access_after_delete_extra_5(1)", "undefined");
shouldBe("access_after_delete_extra_1(1, 2, 3, 4, 5)", "1");
shouldBe("access_after_delete_extra_2(1, 2, 3, 4, 5)", "2");
shouldBe("access_after_delete_extra_3(1, 2, 3, 4, 5)", "3");
shouldBe("access_after_delete_extra_5(1, 2, 3, 4, 5)", "5");
function argumentsParam(arguments)
{
return arguments;
}
shouldBeTrue("argumentsParam(true)");
var argumentsFunctionConstructorParam = new Function("arguments", "return arguments;");
shouldBeTrue("argumentsFunctionConstructorParam(true)");
function argumentsVarUndefined()
{
var arguments;
return String(arguments);
}
shouldBe("argumentsVarUndefined()", "'[object Arguments]'");
function argumentCalleeInException() {
try {
throw "";
} catch (e) {
return arguments.callee;
}
}
shouldBe("argumentCalleeInException()", "argumentCalleeInException")
function shadowedArgumentsApply(arguments) {
return function(a){ return a; }.apply(null, arguments);
}
function shadowedArgumentsLength(arguments) {
return arguments.length;
}
function shadowedArgumentsCallee(arguments) {
return arguments.callee;
}
function shadowedArgumentsIndex(arguments) {
return arguments[0]
}
shouldBeTrue("shadowedArgumentsApply([true])");
shouldBe("shadowedArgumentsLength([])", '0');
shouldThrow("shadowedArgumentsLength()");
shouldBeUndefined("shadowedArgumentsCallee([])");
shouldBeTrue("shadowedArgumentsIndex([true])");
descriptor = (function(){ return Object.getOwnPropertyDescriptor(arguments, 1); })("zero","one","two");
shouldBe("descriptor.value", '"one"');
shouldBe("descriptor.writable", 'true');
shouldBe("descriptor.enumerable", 'true');
shouldBe("descriptor.configurable", 'true');
// Test cases for [[DefineOwnProperty]] applied to the arguments object.
(function(a0,a1,a2,a3){
Object.defineProperties(arguments, {
1: { get: function(){ return 201; } },
2: { value: 202, writable: false },
3: { writable: false },
});
// Test a0 is a live mapped argument.
shouldBeTrue(String( a0 === 100 ));
shouldBeTrue(String( arguments[0] === 100 ));
a0 = 300;
shouldBeTrue(String( a0 === 300 ));
shouldBeTrue(String( arguments[0] === 300 ));
arguments[0] = 400;
shouldBeTrue(String( a0 === 400 ));
shouldBeTrue(String( arguments[0] === 400 ));
// When a1 is redefined as an accessor, it is no longer live.
shouldBeTrue(String( a1 === 101 ));
shouldBeTrue(String( arguments[1] === 201 ));
a1 = 301;
shouldBeTrue(String( a1 === 301 ));
shouldBeTrue(String( arguments[1] === 201 ));
arguments[1] = 401;
shouldBeTrue(String( a1 === 301 ));
shouldBeTrue(String( arguments[1] === 201 ));
// When a2 is made read-only the value is set, but it is no longer live.
// (per 10.6 [[DefineOwnProperty]] 5.b.ii.1)
shouldBeTrue(String( a2 === 202 ));
shouldBeTrue(String( arguments[2] === 202 ));
a2 = 302;
shouldBeTrue(String( a2 === 302 ));
shouldBeTrue(String( arguments[2] === 202 ));
arguments[2] = 402;
shouldBeTrue(String( a2 === 302 ));
shouldBeTrue(String( arguments[2] === 202 ));
// When a3 is made read-only, it is no longer live.
// (per 10.6 [[DefineOwnProperty]] 5.b.ii.1)
shouldBeTrue(String( a3 === 103 ));
shouldBeTrue(String( arguments[3] === 103 ));
a3 = 303;
shouldBeTrue(String( a3 === 303 ));
shouldBeTrue(String( arguments[3] === 103 ));
arguments[3] = 403;
shouldBeTrue(String( a3 === 303 ));
shouldBeTrue(String( arguments[3] === 103 ));
})(100,101,102,103);
// Test cases for [[DefineOwnProperty]] applied to the arguments object.
(function(arg){
shouldBeTrue(String( Object.getOwnPropertyDescriptor(arguments, 0).writable ));
shouldBeTrue(String( Object.getOwnPropertyDescriptor(arguments, 0).enumerable ));
Object.defineProperty(arguments, 0, { writable: false });
shouldBeFalse(String( Object.getOwnPropertyDescriptor(arguments, 0).writable ));
shouldBeTrue(String( Object.getOwnPropertyDescriptor(arguments, 0).enumerable ));
Object.defineProperty(arguments, 0, { enumerable: false });
shouldBeFalse(String( Object.getOwnPropertyDescriptor(arguments, 0).writable ));
shouldBeFalse(String( Object.getOwnPropertyDescriptor(arguments, 0).enumerable ));
delete arguments[1];
shouldBeUndefined(String( Object.getOwnPropertyDescriptor(arguments, 1) ));
Object.defineProperty(arguments, 1, { writable: true });
shouldBeTrue(String( Object.getOwnPropertyDescriptor(arguments, 1).writable ));
shouldBeFalse(String( Object.getOwnPropertyDescriptor(arguments, 1).enumerable ));
})(0,1);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,55 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description(
"Tests that defining a setter on the Array prototype works even if it is done after arrays are allocated."
);
var ouches = 0;
function foo(haveABadTime) {
var result = [];
result.length = 5;
for (var i = 0; i < result.length; ++i) {
if (i == haveABadTime) {
debug("Henceforth I will have a bad time.");
Array.prototype.__defineSetter__("3", function() { ouches++; });
}
result[i] = i;
}
return result;
}
var expected = "\"0,1,2,3,4\"";
for (var i = 0; i < 1000; ++i) {
var haveABadTime;
if (i == 950) {
haveABadTime = 2;
expected = "\"0,1,2,,4\"";
} else
haveABadTime = -1;
shouldBe("\"" + foo(haveABadTime).join(",") + "\"", expected);
}
shouldBe("ouches", "50");

View File

@ -0,0 +1,33 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This test checks for regression against 6234: Can delete array index property incorrectly.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS a[1] is "before"
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,32 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description(
'This test checks for regression against <a href="https://bugs.webkit.org/show_bug.cgi?id=6234">6234: Can delete array index property incorrectly.</a>'
);
var a = new Array();
a[1] = "before";
a['1.0'] = "after";
delete a['1.0'];
shouldBe("a[1]", '"before"');

View File

@ -0,0 +1,122 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Test some array functions on non-array objects.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS properties(['b', 'a']) is '0:b, 1:a, length:2(DontDelete, DontEnum)'
PASS properties({ length:2, 0:'b', 1:'a' }) is '0:b, 1:a, length:2'
PASS properties(new OneItemConstructor) is '0:a(FromPrototype), length:1(FromPrototype)'
PASS properties(new TwoItemConstructor) is '0:b(FromPrototype), 1:a(FromPrototype), length:2(FromPrototype)'
PASS Array.prototype.toString.call({}) is "[object Object]"
PASS Array.prototype.toString.call(new Date) is "[object Date]"
PASS Array.prototype.toString.call({sort: function() { return 'sort' }}) is "[object Object]"
PASS Array.prototype.toString.call({join: function() { return 'join' }}) is "join"
PASS Array.prototype.toString.call({__proto__: Array.prototype, 0: 'a', 1: 'b', 2: 'c', length: 3}) is "a,b,c"
PASS ({__proto__: Array.prototype, 0: 'a', 1: 'b', 2: 'c', length: 3}).toString() is "a,b,c"
PASS Array.prototype.toString.call({__proto__: Array.prototype, 0: 'a', 1: 'b', 2: 'c', length: 3, join: function() { return 'join' }}) is "join"
PASS ({__proto__: Array.prototype, 0: 'a', 1: 'b', 2: 'c', length: 3, join: function() { return 'join' }}).toString() is "join"
PASS Array.prototype.toString.call(42) is "Number.prototype.join:42"
PASS [0, 1, 2].toString() is "array-join"
FAIL Array.prototype.toLocaleString.call({}) should throw an exception. Was .
PASS Array.prototype.concat.call(x = { length:2, 0:'b', 1:'a' }) is [x]
PASS Array.prototype.join.call({}) is ''
PASS Array.prototype.join.call(['b', 'a']) is 'b,a'
PASS Array.prototype.join.call({ length:2, 0:'b', 1:'a' }) is 'b,a'
PASS Array.prototype.join.call(new TwoItemConstructor) is 'b,a'
PASS Array.prototype.pop.call({}) is undefined
PASS Array.prototype.pop.call({ length:2, 0:'b', 1:'a' }) is 'a'
PASS Array.prototype.pop.call({ length:2, 0:'b', 1:'a' }) is 'a'
PASS Array.prototype.pop.call(new TwoItemConstructor) is 'a'
PASS Array.prototype.pop.call(x = {}); properties(x) is 'length:0'
PASS Array.prototype.pop.call(x = ['b', 'a']); properties(x) is '0:b, length:1(DontDelete, DontEnum)'
PASS Array.prototype.pop.call(x = { length:2, 0:'b', 1:'a' }); properties(x) is '0:b, length:1'
PASS Array.prototype.pop.call(x = new TwoItemConstructor); properties(x) is '0:b(FromPrototype), 1:a(FromPrototype), length:1'
PASS Array.prototype.push.call({}) is 0
PASS Array.prototype.push.call(['b', 'a']) is 2
PASS Array.prototype.push.call({ length:2, 0:'b', 1:'a' }) is 2
PASS Array.prototype.push.call(new TwoItemConstructor) is 2
PASS Array.prototype.push.call(x = {}); properties(x) is 'length:0'
PASS Array.prototype.push.call(x = ['b', 'a']); properties(x) is '0:b, 1:a, length:2(DontDelete, DontEnum)'
PASS Array.prototype.push.call(x = { length:2, 0:'b', 1:'a' }); properties(x) is '0:b, 1:a, length:2'
PASS Array.prototype.push.call(x = new TwoItemConstructor); properties(x) is '0:b(FromPrototype), 1:a(FromPrototype), length:2'
PASS Array.prototype.push.call({}, 'c') is 1
PASS Array.prototype.push.call(['b', 'a'], 'c') is 3
PASS Array.prototype.push.call({ length:2, 0:'b', 1:'a' }, 'c') is 3
PASS Array.prototype.push.call(new TwoItemConstructor, 'c') is 3
PASS Array.prototype.push.call(x = {}, 'c'); properties(x) is '0:c, length:1'
PASS Array.prototype.push.call(x = ['b', 'a'], 'c'); properties(x) is '0:b, 1:a, 2:c, length:3(DontDelete, DontEnum)'
PASS Array.prototype.push.call(x = { length:2, 0:'b', 1:'a' }, 'c'); properties(x) is '0:b, 1:a, 2:c, length:3'
PASS Array.prototype.push.call(x = new TwoItemConstructor, 'c'); properties(x) is '0:b(FromPrototype), 1:a(FromPrototype), 2:c, length:3'
PASS properties(Array.prototype.reverse.call({})) is ''
PASS properties(Array.prototype.reverse.call(['b', 'a'])) is '0:a, 1:b, length:2(DontDelete, DontEnum)'
PASS properties(Array.prototype.reverse.call({ length:2, 0:'b', 1:'a' })) is '0:a, 1:b, length:2'
PASS properties(Array.prototype.reverse.call(new OneItemConstructor)) is '0:a(FromPrototype), length:1(FromPrototype)'
PASS properties(Array.prototype.reverse.call(new TwoItemConstructor)) is '0:a, 1:b, length:2(FromPrototype)'
PASS Array.prototype.shift.call({}) is undefined
PASS Array.prototype.shift.call(['b', 'a']) is 'b'
PASS Array.prototype.shift.call({ length:2, 0:'b', 1:'a' }) is 'b'
PASS Array.prototype.shift.call(new TwoItemConstructor) is 'b'
PASS Array.prototype.shift.call(x = {}); properties(x) is 'length:0'
PASS Array.prototype.shift.call(x = ['b', 'a']); properties(x) is '0:a, length:1(DontDelete, DontEnum)'
PASS Array.prototype.shift.call(x = { length:2, 0:'b', 1:'a' }); properties(x) is '0:a, length:1'
PASS Array.prototype.shift.call(x = new TwoItemConstructor); properties(x) is '0:a, 1:a(FromPrototype), length:1'
PASS Array.prototype.slice.call({}, 0, 1) is []
PASS Array.prototype.slice.call(['b', 'a'], 0, 1) is ['b']
PASS Array.prototype.slice.call({ length:2, 0:'b', 1:'a' }, 0, 1) is ['b']
PASS Array.prototype.slice.call(new TwoItemConstructor, 0, 1) is ['b']
PASS properties(Array.prototype.sort.call({})) is ''
PASS properties(Array.prototype.sort.call(['b', 'a'])) is '0:a, 1:b, length:2(DontDelete, DontEnum)'
PASS properties(Array.prototype.sort.call({ length:2, 0:'b', 1:'a' })) is '0:a, 1:b, length:2'
PASS properties(Array.prototype.sort.call(new OneItemConstructor)) is '0:a(FromPrototype), length:1(FromPrototype)'
PASS properties(Array.prototype.sort.call(new TwoItemConstructor)) is '0:a, 1:b, length:2(FromPrototype)'
PASS Array.prototype.splice.call({}, 0, 1) is []
PASS Array.prototype.splice.call(['b', 'a'], 0, 1) is ['b']
PASS Array.prototype.splice.call({ length:2, 0:'b', 1:'a' }, 0, 1) is ['b']
PASS Array.prototype.splice.call(new TwoItemConstructor, 0, 1) is ['b']
PASS Array.prototype.splice.call(x = {}, 0, 1); properties(x) is 'length:0'
PASS Array.prototype.splice.call(x = ['b', 'a'], 0, 1); properties(x) is '0:a, length:1(DontDelete, DontEnum)'
PASS Array.prototype.splice.call(x = { length:2, 0:'b', 1:'a' }, 0, 1); properties(x) is '0:a, length:1'
PASS Array.prototype.splice.call(x = new TwoItemConstructor, 0, 1); properties(x) is '0:a, 1:a(FromPrototype), length:1'
PASS Array.prototype.unshift.call({}) is 0
PASS Array.prototype.unshift.call(['b', 'a']) is 2
PASS Array.prototype.unshift.call({ length:2, 0:'b', 1:'a' }) is 2
PASS Array.prototype.unshift.call(new TwoItemConstructor) is 2
PASS Array.prototype.unshift.call(x = {}); properties(x) is 'length:0'
PASS Array.prototype.unshift.call(x = ['b', 'a']); properties(x) is '0:b, 1:a, length:2(DontDelete, DontEnum)'
PASS Array.prototype.unshift.call(x = { length:2, 0:'b', 1:'a' }); properties(x) is '0:b, 1:a, length:2'
PASS Array.prototype.unshift.call(x = new TwoItemConstructor); properties(x) is '0:b(FromPrototype), 1:a(FromPrototype), length:2'
PASS Array.prototype.unshift.call({}, 'c') is 1
PASS Array.prototype.unshift.call(['b', 'a'], 'c') is 3
PASS Array.prototype.unshift.call({ length:2, 0:'b', 1:'a' }, 'c') is 3
PASS Array.prototype.unshift.call(new TwoItemConstructor, 'c') is 3
PASS Array.prototype.unshift.call(x = {}, 'c'); properties(x) is '0:c, length:1'
PASS Array.prototype.unshift.call(x = ['b', 'a'], 'c'); properties(x) is '0:c, 1:b, 2:a, length:3(DontDelete, DontEnum)'
PASS Array.prototype.unshift.call(x = { length:2, 0:'b', 1:'a' }, 'c'); properties(x) is '0:c, 1:b, 2:a, length:3'
PASS Array.prototype.unshift.call(x = new TwoItemConstructor, 'c'); properties(x) is '0:c, 1:b, 2:a, length:3'
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,204 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description(
"Test some array functions on non-array objects."
);
function properties(object, extraName1, extraName2, extraName3)
{
var string = "";
// destructive, lists properties
var names = [];
var enumerables = {};
for (propertyName in object) {
names.push(propertyName);
enumerables[propertyName] = 1;
}
names.push("length");
names.push(extraName1);
names.push(extraName2);
names.push(extraName3);
names.sort();
var propertyStrings = [];
for (i = 0; i < names.length; ++i) {
var name = names[i];
if (name == names[i - 1])
continue;
if (!(name in object))
continue;
var propertyString = name + ":" + object[name];
var flags = [];
if (!object.hasOwnProperty(name))
flags.push("FromPrototype");
if (!enumerables[name])
flags.push("DontEnum");
if (name != "length") {
try {
object[name] = "ReadOnlyTestValue";
} catch (e) {
}
if (object[name] != "ReadOnlyTestValue")
flags.push("ReadOnly");
}
delete object[name];
if (object.hasOwnProperty(name))
flags.push("DontDelete");
flags.sort();
if (flags.length)
propertyString += "(" + flags.join(", ") + ")";
propertyStrings.push(propertyString);
}
return propertyStrings.join(", ");
}
var x;
var oneItemPrototype = { length:1, 0:'a' };
function OneItemConstructor()
{
}
OneItemConstructor.prototype = oneItemPrototype;
var twoItemPrototype = { length:2, 0:'b', 1:'a' };
function TwoItemConstructor()
{
}
TwoItemConstructor.prototype = twoItemPrototype;
shouldBe("properties(['b', 'a'])", "'0:b, 1:a, length:2(DontDelete, DontEnum)'");
shouldBe("properties({ length:2, 0:'b', 1:'a' })", "'0:b, 1:a, length:2'");
shouldBe("properties(new OneItemConstructor)", "'0:a(FromPrototype), length:1(FromPrototype)'");
shouldBe("properties(new TwoItemConstructor)", "'0:b(FromPrototype), 1:a(FromPrototype), length:2(FromPrototype)'");
shouldBe("Array.prototype.toString.call({})", '"' + ({}).toString() + '"');
shouldBe("Array.prototype.toString.call(new Date)", '"' + Object.prototype.toString.call(new Date) + '"');
shouldBe("Array.prototype.toString.call({sort: function() { return 'sort' }})", '"' + Object.prototype.toString.call({}) + '"');
shouldBe("Array.prototype.toString.call({join: function() { return 'join' }})", '"join"');
shouldBe("Array.prototype.toString.call({__proto__: Array.prototype, 0: 'a', 1: 'b', 2: 'c', length: 3})", '"a,b,c"');
shouldBe("({__proto__: Array.prototype, 0: 'a', 1: 'b', 2: 'c', length: 3}).toString()", '"a,b,c"');
shouldBe("Array.prototype.toString.call({__proto__: Array.prototype, 0: 'a', 1: 'b', 2: 'c', length: 3, join: function() { return 'join' }})", '"join"');
shouldBe("({__proto__: Array.prototype, 0: 'a', 1: 'b', 2: 'c', length: 3, join: function() { return 'join' }}).toString()", '"join"');
Number.prototype.join = function() { return "Number.prototype.join:" + this; }
shouldBe("Array.prototype.toString.call(42)", '"Number.prototype.join:42"');
var arrayJoin = Array.prototype.join;
Array.prototype.join = function() { return 'array-join' };
shouldBe("[0, 1, 2].toString()", '"array-join"');
Array.prototype.join = arrayJoin;
shouldThrow("Array.prototype.toLocaleString.call({})");
shouldBe("Array.prototype.concat.call(x = { length:2, 0:'b', 1:'a' })", "[x]");
shouldBe("Array.prototype.join.call({})", "''");
shouldBe("Array.prototype.join.call(['b', 'a'])", "'b,a'");
shouldBe("Array.prototype.join.call({ length:2, 0:'b', 1:'a' })", "'b,a'");
shouldBe("Array.prototype.join.call(new TwoItemConstructor)", "'b,a'");
shouldBe("Array.prototype.pop.call({})", "undefined");
shouldBe("Array.prototype.pop.call({ length:2, 0:'b', 1:'a' })", "'a'");
shouldBe("Array.prototype.pop.call({ length:2, 0:'b', 1:'a' })", "'a'");
shouldBe("Array.prototype.pop.call(new TwoItemConstructor)", "'a'");
shouldBe("Array.prototype.pop.call(x = {}); properties(x)", "'length:0'");
shouldBe("Array.prototype.pop.call(x = ['b', 'a']); properties(x)", "'0:b, length:1(DontDelete, DontEnum)'");
shouldBe("Array.prototype.pop.call(x = { length:2, 0:'b', 1:'a' }); properties(x)", "'0:b, length:1'");
shouldBe("Array.prototype.pop.call(x = new TwoItemConstructor); properties(x)", "'0:b(FromPrototype), 1:a(FromPrototype), length:1'");
shouldBe("Array.prototype.push.call({})", "0");
shouldBe("Array.prototype.push.call(['b', 'a'])", "2");
shouldBe("Array.prototype.push.call({ length:2, 0:'b', 1:'a' })", "2");
shouldBe("Array.prototype.push.call(new TwoItemConstructor)", "2");
shouldBe("Array.prototype.push.call(x = {}); properties(x)", "'length:0'");
shouldBe("Array.prototype.push.call(x = ['b', 'a']); properties(x)", "'0:b, 1:a, length:2(DontDelete, DontEnum)'");
shouldBe("Array.prototype.push.call(x = { length:2, 0:'b', 1:'a' }); properties(x)", "'0:b, 1:a, length:2'");
shouldBe("Array.prototype.push.call(x = new TwoItemConstructor); properties(x)", "'0:b(FromPrototype), 1:a(FromPrototype), length:2'");
shouldBe("Array.prototype.push.call({}, 'c')", "1");
shouldBe("Array.prototype.push.call(['b', 'a'], 'c')", "3");
shouldBe("Array.prototype.push.call({ length:2, 0:'b', 1:'a' }, 'c')", "3");
shouldBe("Array.prototype.push.call(new TwoItemConstructor, 'c')", "3");
shouldBe("Array.prototype.push.call(x = {}, 'c'); properties(x)", "'0:c, length:1'");
shouldBe("Array.prototype.push.call(x = ['b', 'a'], 'c'); properties(x)", "'0:b, 1:a, 2:c, length:3(DontDelete, DontEnum)'");
shouldBe("Array.prototype.push.call(x = { length:2, 0:'b', 1:'a' }, 'c'); properties(x)", "'0:b, 1:a, 2:c, length:3'");
shouldBe("Array.prototype.push.call(x = new TwoItemConstructor, 'c'); properties(x)", "'0:b(FromPrototype), 1:a(FromPrototype), 2:c, length:3'");
shouldBe("properties(Array.prototype.reverse.call({}))", "''");
shouldBe("properties(Array.prototype.reverse.call(['b', 'a']))", "'0:a, 1:b, length:2(DontDelete, DontEnum)'");
shouldBe("properties(Array.prototype.reverse.call({ length:2, 0:'b', 1:'a' }))", "'0:a, 1:b, length:2'");
shouldBe("properties(Array.prototype.reverse.call(new OneItemConstructor))", "'0:a(FromPrototype), length:1(FromPrototype)'");
shouldBe("properties(Array.prototype.reverse.call(new TwoItemConstructor))", "'0:a, 1:b, length:2(FromPrototype)'");
shouldBe("Array.prototype.shift.call({})", "undefined");
shouldBe("Array.prototype.shift.call(['b', 'a'])", "'b'");
shouldBe("Array.prototype.shift.call({ length:2, 0:'b', 1:'a' })", "'b'");
shouldBe("Array.prototype.shift.call(new TwoItemConstructor)", "'b'");
shouldBe("Array.prototype.shift.call(x = {}); properties(x)", "'length:0'");
shouldBe("Array.prototype.shift.call(x = ['b', 'a']); properties(x)", "'0:a, length:1(DontDelete, DontEnum)'");
shouldBe("Array.prototype.shift.call(x = { length:2, 0:'b', 1:'a' }); properties(x)", "'0:a, length:1'");
shouldBe("Array.prototype.shift.call(x = new TwoItemConstructor); properties(x)", "'0:a, 1:a(FromPrototype), length:1'");
shouldBe("Array.prototype.slice.call({}, 0, 1)", "[]");
shouldBe("Array.prototype.slice.call(['b', 'a'], 0, 1)", "['b']");
shouldBe("Array.prototype.slice.call({ length:2, 0:'b', 1:'a' }, 0, 1)", "['b']");
shouldBe("Array.prototype.slice.call(new TwoItemConstructor, 0, 1)", "['b']");
shouldBe("properties(Array.prototype.sort.call({}))", "''");
shouldBe("properties(Array.prototype.sort.call(['b', 'a']))", "'0:a, 1:b, length:2(DontDelete, DontEnum)'");
shouldBe("properties(Array.prototype.sort.call({ length:2, 0:'b', 1:'a' }))", "'0:a, 1:b, length:2'");
shouldBe("properties(Array.prototype.sort.call(new OneItemConstructor))", "'0:a(FromPrototype), length:1(FromPrototype)'");
shouldBe("properties(Array.prototype.sort.call(new TwoItemConstructor))", "'0:a, 1:b, length:2(FromPrototype)'");
shouldBe("Array.prototype.splice.call({}, 0, 1)", "[]");
shouldBe("Array.prototype.splice.call(['b', 'a'], 0, 1)", "['b']");
shouldBe("Array.prototype.splice.call({ length:2, 0:'b', 1:'a' }, 0, 1)", "['b']");
shouldBe("Array.prototype.splice.call(new TwoItemConstructor, 0, 1)", "['b']");
shouldBe("Array.prototype.splice.call(x = {}, 0, 1); properties(x)", "'length:0'");
shouldBe("Array.prototype.splice.call(x = ['b', 'a'], 0, 1); properties(x)", "'0:a, length:1(DontDelete, DontEnum)'");
shouldBe("Array.prototype.splice.call(x = { length:2, 0:'b', 1:'a' }, 0, 1); properties(x)", "'0:a, length:1'");
shouldBe("Array.prototype.splice.call(x = new TwoItemConstructor, 0, 1); properties(x)", "'0:a, 1:a(FromPrototype), length:1'");
shouldBe("Array.prototype.unshift.call({})", "0");
shouldBe("Array.prototype.unshift.call(['b', 'a'])", "2");
shouldBe("Array.prototype.unshift.call({ length:2, 0:'b', 1:'a' })", "2");
shouldBe("Array.prototype.unshift.call(new TwoItemConstructor)", "2");
shouldBe("Array.prototype.unshift.call(x = {}); properties(x)", "'length:0'");
shouldBe("Array.prototype.unshift.call(x = ['b', 'a']); properties(x)", "'0:b, 1:a, length:2(DontDelete, DontEnum)'");
shouldBe("Array.prototype.unshift.call(x = { length:2, 0:'b', 1:'a' }); properties(x)", "'0:b, 1:a, length:2'");
shouldBe("Array.prototype.unshift.call(x = new TwoItemConstructor); properties(x)", "'0:b(FromPrototype), 1:a(FromPrototype), length:2'");
shouldBe("Array.prototype.unshift.call({}, 'c')", "1");
shouldBe("Array.prototype.unshift.call(['b', 'a'], 'c')", "3");
shouldBe("Array.prototype.unshift.call({ length:2, 0:'b', 1:'a' }, 'c')", "3");
shouldBe("Array.prototype.unshift.call(new TwoItemConstructor, 'c')", "3");
shouldBe("Array.prototype.unshift.call(x = {}, 'c'); properties(x)", "'0:c, length:1'");
shouldBe("Array.prototype.unshift.call(x = ['b', 'a'], 'c'); properties(x)", "'0:c, 1:b, 2:a, length:3(DontDelete, DontEnum)'");
shouldBe("Array.prototype.unshift.call(x = { length:2, 0:'b', 1:'a' }, 'c'); properties(x)", "'0:c, 1:b, 2:a, length:3'");
shouldBe("Array.prototype.unshift.call(x = new TwoItemConstructor, 'c'); properties(x)", "'0:c, 1:b, 2:a, length:3'");
// FIXME: Add tests for every, forEach, some, indexOf, lastIndexOf, filter, and map

View File

@ -0,0 +1,54 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This is a test case for bug 64679.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS Array.prototype.toString.call(undefined) threw exception TypeError: Cannot convert undefined or null to object.
PASS Array.prototype.toLocaleString.call(undefined) threw exception TypeError: Cannot convert undefined or null to object.
PASS Array.prototype.concat.call(undefined, []) threw exception TypeError: Array.prototype.concat called on null or undefined.
PASS Array.prototype.join.call(undefined, []) threw exception TypeError: Cannot convert undefined or null to object.
PASS Array.prototype.pop.call(undefined) threw exception TypeError: Cannot convert undefined or null to object.
PASS Array.prototype.push.call(undefined, {}) threw exception TypeError: Cannot convert undefined or null to object.
PASS Array.prototype.reverse.call(undefined) threw exception TypeError: Cannot convert undefined or null to object.
PASS Array.prototype.shift.call(undefined) threw exception TypeError: Cannot convert undefined or null to object.
PASS Array.prototype.slice.call(undefined, 0, 1) threw exception TypeError: Cannot convert undefined or null to object.
PASS Array.prototype.sort.call(undefined) threw exception TypeError: Cannot convert undefined or null to object.
PASS Array.prototype.splice.call(undefined, 0, 1) threw exception TypeError: Cannot convert undefined or null to object.
PASS Array.prototype.unshift.call(undefined, {}) threw exception TypeError: Cannot convert undefined or null to object.
PASS Array.prototype.every.call(undefined, toString) threw exception TypeError: Array.prototype.every called on null or undefined.
PASS Array.prototype.forEach.call(undefined, toString) threw exception TypeError: Array.prototype.forEach called on null or undefined.
PASS Array.prototype.some.call(undefined, toString) threw exception TypeError: Array.prototype.some called on null or undefined.
PASS Array.prototype.indexOf.call(undefined, 0) threw exception TypeError: Array.prototype.indexOf called on null or undefined.
PASS Array.prototype.indlastIndexOfexOf.call(undefined, 0) threw exception TypeError: Cannot read properties of undefined (reading 'call').
PASS Array.prototype.filter.call(undefined, toString) threw exception TypeError: Array.prototype.filter called on null or undefined.
PASS Array.prototype.reduce.call(undefined, toString) threw exception TypeError: Array.prototype.reduce called on null or undefined.
PASS Array.prototype.reduceRight.call(undefined, toString) threw exception TypeError: Array.prototype.reduceRight called on null or undefined.
PASS Array.prototype.map.call(undefined, toString) threw exception TypeError: Array.prototype.map called on null or undefined.
PASS [{toLocaleString:function(){throw 1}},{toLocaleString:function(){throw 2}}].toLocaleString() threw exception 1.
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,52 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description(
'This is a test case for <a href="https://bugs.webkit.org/show_bug.cgi?id=64679">bug 64679</a>.'
);
// These calls pass undefined as this value, and as such should throw in toObject.
shouldThrow("Array.prototype.toString.call(undefined)");
shouldThrow("Array.prototype.toLocaleString.call(undefined)");
shouldThrow("Array.prototype.concat.call(undefined, [])");
shouldThrow("Array.prototype.join.call(undefined, [])");
shouldThrow("Array.prototype.pop.call(undefined)");
shouldThrow("Array.prototype.push.call(undefined, {})");
shouldThrow("Array.prototype.reverse.call(undefined)");
shouldThrow("Array.prototype.shift.call(undefined)");
shouldThrow("Array.prototype.slice.call(undefined, 0, 1)");
shouldThrow("Array.prototype.sort.call(undefined)");
shouldThrow("Array.prototype.splice.call(undefined, 0, 1)");
shouldThrow("Array.prototype.unshift.call(undefined, {})");
shouldThrow("Array.prototype.every.call(undefined, toString)");
shouldThrow("Array.prototype.forEach.call(undefined, toString)");
shouldThrow("Array.prototype.some.call(undefined, toString)");
shouldThrow("Array.prototype.indexOf.call(undefined, 0)");
shouldThrow("Array.prototype.indlastIndexOfexOf.call(undefined, 0)");
shouldThrow("Array.prototype.filter.call(undefined, toString)");
shouldThrow("Array.prototype.reduce.call(undefined, toString)");
shouldThrow("Array.prototype.reduceRight.call(undefined, toString)");
shouldThrow("Array.prototype.map.call(undefined, toString)");
// Test exception ordering in Array.prototype.toLocaleString ( https://bugs.webkit.org/show_bug.cgi?id=80663 )
shouldThrow("[{toLocaleString:function(){throw 1}},{toLocaleString:function(){throw 2}}].toLocaleString()", '1');

View File

@ -0,0 +1,132 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Tests that defining a setter on the Array prototype works.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS "0,1,2,,4" is "0,1,2,,4"
PASS ouches is 100
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,42 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description(
"Tests that defining a setter on the Array prototype works."
);
var ouches = 0;
Array.prototype.__defineSetter__("3", function() { ouches++; });
function foo() {
var result = [];
result.length = 5;
for (var i = 0; i < result.length; ++i)
result[i] = i;
return result;
}
for (var i = 0; i < 100; ++i)
shouldBe("\"" + foo().join(",") + "\"", "\"0,1,2,,4\"");
shouldBe("ouches", "100");

View File

@ -0,0 +1,33 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This test checks for regressions against 6261:Do not use a separator argument when doing toString/toLocalString.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS a.toString('!') is '5,3'
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,32 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description(
'This test checks for regressions against <a href="https://bugs.webkit.org/show_bug.cgi?id=6261">6261:Do not use a separator argument when doing toString/toLocalString.</a>'
);
var a = new Array;
a[0] = 5;
a[1] = 3;
//Shouldn't use argument for toString
shouldBe("a.toString('!')", "'5,3'");

View File

@ -0,0 +1,238 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Test behaviour of strict mode
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS testThis.call(null) is null
PASS testThis.call(1) is 1
PASS testThis.call(true) is true
PASS testThis.call(false) is false
PASS testThis.call(undefined) is undefined
PASS testLineContinuation.call(undefined) === undefined is false
PASS testEscapeSequence.call(undefined) === undefined is false
PASS testThis.call('a string') is 'a string'
PASS testThisDotAccess.call('a string') is 'a string'.length
PASS testThisDotAccess.call(null) threw exception TypeError: Cannot read properties of null (reading 'length').
PASS testThisDotAccess.call(undefined) threw exception TypeError: Cannot read properties of undefined (reading 'length').
PASS testThisDotAccess.call(true) is undefined.
PASS testThisDotAccess.call(false) is undefined.
PASS testThisDotAccess.call(1) is undefined.
PASS testThisBracketAccess.call('a string', 'length') is 'a string'.length
PASS testThisBracketAccess.call(null, 'length') threw exception TypeError: Cannot read properties of null (reading 'length').
PASS testThisBracketAccess.call(undefined, 'length') threw exception TypeError: Cannot read properties of undefined (reading 'length').
PASS testThisBracketAccess.call(true, 'length') is undefined.
PASS testThisBracketAccess.call(false, 'length') is undefined.
PASS testThisBracketAccess.call(1, 'length') is undefined.
PASS Function('"use strict"; return this;')() is undefined.
PASS Function('"use strict"; with({});') threw exception SyntaxError: Strict mode code may not include a with statement.
PASS testGlobalAccess() is undefined
PASS testThis.call() is undefined
PASS testThis.apply() is undefined
PASS testThis.call(undefined) is undefined
PASS testThis.apply(undefined) is undefined
PASS (function eval(){'use strict';}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){(function eval(){'use strict';})}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (eval){'use strict';}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){(function (eval){'use strict';})}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function arguments(){'use strict';}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){(function arguments(){'use strict';})}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (arguments){'use strict';}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){(function (arguments){'use strict';})}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){'use strict'; var eval;}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){(function (){'use strict'; var eval;})}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){'use strict'; var arguments;}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){(function (){'use strict'; var arguments;})}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){'use strict'; try{}catch(eval){}}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){(function (){'use strict'; try{}catch(eval){}})}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){'use strict'; try{}catch(arguments){}}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){(function (){'use strict'; try{}catch(arguments){}})}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (a, a){'use strict';}) threw exception SyntaxError: Duplicate parameter name not allowed in this context.
PASS (function (){(function (a, a){'use strict';})}) threw exception SyntaxError: Duplicate parameter name not allowed in this context.
PASS (function (a){'use strict'; delete a;})() threw exception SyntaxError: Delete of an unqualified identifier in strict mode..
PASS (function (){(function (a){'use strict'; delete a;})()}) threw exception SyntaxError: Delete of an unqualified identifier in strict mode..
PASS (function (){'use strict'; var a; delete a;})() threw exception SyntaxError: Delete of an unqualified identifier in strict mode..
PASS (function (){(function (){'use strict'; var a; delete a;})()}) threw exception SyntaxError: Delete of an unqualified identifier in strict mode..
PASS (function (){var a; function f() {'use strict'; delete a;} })() threw exception SyntaxError: Delete of an unqualified identifier in strict mode..
PASS (function (){(function (){var a; function f() {'use strict'; delete a;} })()}) threw exception SyntaxError: Delete of an unqualified identifier in strict mode..
PASS (function (){'use strict'; with(1){};}) threw exception SyntaxError: Strict mode code may not include a with statement.
PASS (function (){(function (){'use strict'; with(1){};})}) threw exception SyntaxError: Strict mode code may not include a with statement.
PASS (function (){'use strict'; arguments.callee; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them.
PASS (function (){'use strict'; arguments.caller; })() is undefined.
PASS (function f(){'use strict'; f.arguments; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them.
PASS (function f(){'use strict'; f.caller; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them.
PASS (function f(){'use strict'; f.arguments=5; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them.
PASS (function f(){'use strict'; f.caller=5; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them.
PASS (function (arg){'use strict'; arguments.callee; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them.
PASS (function (arg){'use strict'; arguments.caller; })() is undefined.
PASS (function f(arg){'use strict'; f.arguments; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them.
PASS (function f(arg){'use strict'; f.caller; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them.
PASS (function f(arg){'use strict'; f.arguments=5; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them.
PASS (function f(arg){'use strict'; f.caller=5; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them.
PASS "caller" in function(){"use strict"} is true
PASS (function(){"use strict";}).hasOwnProperty("caller") is false
PASS (function(){"use strict";}).__proto__.hasOwnProperty("caller") is true
PASS "arguments" in function(){"use strict"} is true
PASS (function(){"use strict";}).hasOwnProperty("arguments") is false
PASS (function(){"use strict";}).__proto__.hasOwnProperty("arguments") is true
PASS 'use strict'; (function (){with(1){};}) threw exception SyntaxError: Strict mode code may not include a with statement.
PASS (function (){'use strict'; (function (){with(1){};})}) threw exception SyntaxError: Strict mode code may not include a with statement.
PASS 'use strict'; (function (){var a; delete a;}) threw exception SyntaxError: Delete of an unqualified identifier in strict mode..
PASS (function (){'use strict'; (function (){var a; delete a;})}) threw exception SyntaxError: Delete of an unqualified identifier in strict mode..
PASS 'use strict'; var a; (function (){ delete a;}) threw exception SyntaxError: Delete of an unqualified identifier in strict mode..
PASS (function (){'use strict'; var a; (function (){ delete a;})}) threw exception SyntaxError: Delete of an unqualified identifier in strict mode..
PASS var a; (function (){ 'use strict'; delete a;}) threw exception SyntaxError: Delete of an unqualified identifier in strict mode..
PASS (function (){var a; (function (){ 'use strict'; delete a;})}) threw exception SyntaxError: Delete of an unqualified identifier in strict mode..
PASS 'misc directive'; 'use strict'; with({}){} threw exception SyntaxError: Strict mode code may not include a with statement.
PASS (function (){'misc directive'; 'use strict'; with({}){}}) threw exception SyntaxError: Strict mode code may not include a with statement.
PASS 'use strict'; return threw exception SyntaxError: Illegal return statement.
PASS 'use strict'; break threw exception SyntaxError: Illegal break statement.
PASS (function (){'use strict'; break}) threw exception SyntaxError: Illegal break statement.
PASS 'use strict'; continue threw exception SyntaxError: Illegal continue statement: no surrounding iteration statement.
PASS (function (){'use strict'; continue}) threw exception SyntaxError: Illegal continue statement: no surrounding iteration statement.
PASS 'use strict'; for(;;)return threw exception SyntaxError: Illegal return statement.
PASS 'use strict'; for(;;)break missingLabel threw exception SyntaxError: Undefined label 'missingLabel'.
PASS (function (){'use strict'; for(;;)break missingLabel}) threw exception SyntaxError: Undefined label 'missingLabel'.
PASS 'use strict'; for(;;)continue missingLabel threw exception SyntaxError: Undefined label 'missingLabel'.
PASS (function (){'use strict'; for(;;)continue missingLabel}) threw exception SyntaxError: Undefined label 'missingLabel'.
PASS 'use strict'; 007; threw exception SyntaxError: Octal literals are not allowed in strict mode..
PASS (function (){'use strict'; 007;}) threw exception SyntaxError: Octal literals are not allowed in strict mode..
PASS 'use strict'; '\007'; threw exception SyntaxError: Octal escape sequences are not allowed in strict mode..
PASS (function (){'use strict'; '\007';}) threw exception SyntaxError: Octal escape sequences are not allowed in strict mode..
PASS '\007'; 'use strict'; threw exception SyntaxError: Octal escape sequences are not allowed in strict mode..
PASS (function (){'\007'; 'use strict';}) threw exception SyntaxError: Octal escape sequences are not allowed in strict mode..
PASS 'use strict'; delete aDeletableProperty; threw exception SyntaxError: Delete of an unqualified identifier in strict mode..
PASS (function (){'use strict'; delete aDeletableProperty;}) threw exception SyntaxError: Delete of an unqualified identifier in strict mode..
PASS 'use strict'; (function (){ delete someDeclaredGlobal;}) threw exception SyntaxError: Delete of an unqualified identifier in strict mode..
PASS (function (){'use strict'; (function (){ delete someDeclaredGlobal;})}) threw exception SyntaxError: Delete of an unqualified identifier in strict mode..
PASS (function (){ 'use strict'; delete someDeclaredGlobal;}) threw exception SyntaxError: Delete of an unqualified identifier in strict mode..
PASS (function (){(function (){ 'use strict'; delete someDeclaredGlobal;})}) threw exception SyntaxError: Delete of an unqualified identifier in strict mode..
PASS 'use strict'; if (0) { someGlobal = 'Shouldn\'t be able to assign this.'; }; true; is true
PASS 'use strict'; someGlobal = 'Shouldn\'t be able to assign this.'; threw exception ReferenceError: someGlobal is not defined.
PASS 'use strict'; (function f(){ f = 'shouldn\'t be able to assign to function expression name'; })() threw exception TypeError: Assignment to constant variable..
PASS 'use strict'; eval('var introducedVariable = "FAIL: variable introduced into containing scope";'); introducedVariable threw exception ReferenceError: introducedVariable is not defined.
PASS 'use strict'; objectWithReadonlyProperty.prop = 'fail' threw exception TypeError: Cannot assign to read only property 'prop' of object '#<Object>'.
PASS 'use strict'; delete objectWithReadonlyProperty.prop threw exception TypeError: Cannot delete property 'prop' of #<Object>.
PASS 'use strict'; delete objectWithReadonlyProperty[readonlyPropName] threw exception TypeError: Cannot delete property 'prop' of #<Object>.
PASS 'use strict'; ++eval threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){'use strict'; ++eval}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS 'use strict'; eval++ threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){'use strict'; eval++}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS 'use strict'; --eval threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){'use strict'; --eval}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS 'use strict'; eval-- threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){'use strict'; eval--}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS 'use strict'; function f() { ++arguments } threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){'use strict'; function f() { ++arguments }}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS 'use strict'; function f() { arguments++ } threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){'use strict'; function f() { arguments++ }}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS 'use strict'; function f() { --arguments } threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){'use strict'; function f() { --arguments }}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS 'use strict'; function f() { arguments-- } threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){'use strict'; function f() { arguments-- }}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS global.eval('"use strict"; if (0) ++arguments; true;') threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS 'use strict'; ++(1, eval) threw exception SyntaxError: Invalid left-hand side expression in prefix operation.
PASS (function (){'use strict'; ++(1, eval)}) threw exception SyntaxError: Invalid left-hand side expression in prefix operation.
PASS 'use strict'; (1, eval)++ threw exception SyntaxError: Invalid left-hand side expression in postfix operation.
PASS (function (){'use strict'; (1, eval)++}) threw exception SyntaxError: Invalid left-hand side expression in postfix operation.
PASS 'use strict'; --(1, eval) threw exception SyntaxError: Invalid left-hand side expression in prefix operation.
PASS (function (){'use strict'; --(1, eval)}) threw exception SyntaxError: Invalid left-hand side expression in prefix operation.
PASS 'use strict'; (1, eval)-- threw exception SyntaxError: Invalid left-hand side expression in postfix operation.
PASS (function (){'use strict'; (1, eval)--}) threw exception SyntaxError: Invalid left-hand side expression in postfix operation.
PASS 'use strict'; function f() { ++(1, arguments) } threw exception SyntaxError: Invalid left-hand side expression in prefix operation.
PASS (function (){'use strict'; function f() { ++(1, arguments) }}) threw exception SyntaxError: Invalid left-hand side expression in prefix operation.
PASS 'use strict'; function f() { (1, arguments)++ } threw exception SyntaxError: Invalid left-hand side expression in postfix operation.
PASS (function (){'use strict'; function f() { (1, arguments)++ }}) threw exception SyntaxError: Invalid left-hand side expression in postfix operation.
PASS 'use strict'; function f() { --(1, arguments) } threw exception SyntaxError: Invalid left-hand side expression in prefix operation.
PASS (function (){'use strict'; function f() { --(1, arguments) }}) threw exception SyntaxError: Invalid left-hand side expression in prefix operation.
PASS 'use strict'; function f() { (1, arguments)-- } threw exception SyntaxError: Invalid left-hand side expression in postfix operation.
PASS (function (){'use strict'; function f() { (1, arguments)-- }}) threw exception SyntaxError: Invalid left-hand side expression in postfix operation.
FAIL 'use strict'; undefined; if (0) delete +a.b should throw an exception. Was undefined.
FAIL (function (){'use strict'; undefined; if (0) delete +a.b}) should throw an exception. Was function (){'use strict'; undefined; if (0) delete +a.b}.
FAIL 'use strict'; undefined; if (0) delete ++a.b should throw an exception. Was undefined.
FAIL (function (){'use strict'; undefined; if (0) delete ++a.b}) should throw an exception. Was function (){'use strict'; undefined; if (0) delete ++a.b}.
FAIL 'use strict'; undefined; if (0) delete void a.b should throw an exception. Was undefined.
FAIL (function (){'use strict'; undefined; if (0) delete void a.b}) should throw an exception. Was function (){'use strict'; undefined; if (0) delete void a.b}.
PASS (function (a){'use strict'; a = false; return a !== arguments[0]; })(true) is true
PASS (function (a){'use strict'; arguments[0] = false; return a !== arguments[0]; })(true) is true
PASS (function (a){'use strict'; a=false; return arguments; })(true)[0] is true
PASS (function (a){'use strict'; arguments[0]=false; return a; })(true) is true
PASS (function (a){'use strict'; arguments[0]=true; return arguments; })(false)[0] is true
PASS (function (){'use strict'; arguments[0]=true; return arguments; })(false)[0] is true
PASS (function (a){'use strict'; arguments[0]=true; a=false; return arguments; })()[0] is true
PASS (function (a){'use strict'; arguments[0]=false; a=true; return a; })() is true
PASS (function (a){'use strict'; arguments[0]=true; return arguments; })()[0] is true
PASS (function (){'use strict'; arguments[0]=true; return arguments; })()[0] is true
PASS (function (a){'use strict'; var local; (function (){local;})(); a = false; return a !== arguments[0]; })(true) is true
PASS (function (a){'use strict'; var local; (function (){local;})(); arguments[0] = false; return a !== arguments[0]; })(true) is true
PASS (function (a){'use strict'; var local; (function (){local;})(); a=false; return arguments; })(true)[0] is true
PASS (function (a){'use strict'; var local; (function (){local;})(); arguments[0]=false; return a; })(true) is true
PASS (function (a){'use strict'; var local; (function (){local;})(); arguments[0]=true; return arguments; })(false)[0] is true
PASS (function (){'use strict'; var local; (function (){local;})(); arguments[0]=true; return arguments; })(false)[0] is true
PASS (function (a){'use strict'; var local; (function (){local;})(); arguments[0]=true; a=false; return arguments; })()[0] is true
PASS (function (a){'use strict'; var local; (function (){local;})(); arguments[0]=true; return arguments; })()[0] is true
PASS (function (a){'use strict'; var local; (function (){local;})(); arguments[0]=false; a=true; return a; })() is true
PASS (function (){'use strict'; var local; (function (){local;})(); arguments[0]=true; return arguments; })()[0] is true
PASS 'use strict'; (function (){var a = true; eval('var a = false'); return a; })() is true
PASS (function (){var a = true; eval('"use strict"; var a = false'); return a; })() is true
PASS (function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f.__proto__, 'arguments').value; })() is undefined.
PASS (function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f.__proto__, 'caller').value; })() is undefined.
PASS (function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(arguments, 'callee').value; })() is undefined.
PASS (function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(arguments, 'caller'); })() is undefined.
PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(arguments, 'callee'); return descriptor.get === descriptor.set; })() is true
PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f.__proto__, 'caller'); return descriptor.get === descriptor.set; })() is true
PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f.__proto__, 'arguments'); return descriptor.get === descriptor.set; })() is true
PASS 'use strict'; (function f() { for(var i in this); })(); true; is true
PASS 'use strict'̻ threw exception SyntaxError: Invalid or unexpected token.
PASS (function (){'use strict'̻}) threw exception SyntaxError: Invalid or unexpected token.
PASS 'use strict'5.f threw exception SyntaxError: Invalid or unexpected token.
PASS (function (){'use strict'5.f}) threw exception SyntaxError: Invalid or unexpected token.
PASS 'use strict';̻ threw exception SyntaxError: Invalid or unexpected token.
PASS (function (){'use strict';̻}) threw exception SyntaxError: Invalid or unexpected token.
PASS 'use strict';5.f threw exception SyntaxError: Invalid or unexpected token.
PASS (function (){'use strict';5.f}) threw exception SyntaxError: Invalid or unexpected token.
PASS 'use strict';1-(eval=1); threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){'use strict';1-(eval=1);}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS 'use strict';arguments=1; threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){'use strict';arguments=1;}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS 'use strict';1-(arguments=1); threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){'use strict';1-(arguments=1);}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS 'use strict';var a=(eval=1); threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){'use strict';var a=(eval=1);}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS 'use strict';var a=(arguments=1); threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){'use strict';var a=(arguments=1);}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS 'use strict'; try { throw 1; } catch (e) { aGlobal = true; } is true
PASS 'use strict'; (function () { try { throw 1; } catch (e) { aGlobal = true; }})(); aGlobal; is true
PASS (function () {'use strict'; try { throw 1; } catch (e) { aGlobal = true; }})(); aGlobal; is true
PASS try { throw 1; } catch (e) { aGlobal = true; } is true
PASS (function () { try { throw 1; } catch (e) { aGlobal = true; }})(); aGlobal; is true
PASS (function () {try { throw 1; } catch (e) { aGlobal = true; }})(); aGlobal; is true
FAIL String(Object.getOwnPropertyDescriptor((function() { "use strict"; }).__proto__, "caller").get) should be function () {
[native code]
}. Was function () { [native code] }.
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,232 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description("Test behaviour of strict mode");
var globalThisTest;
function testThis() {
"use strict";
return this;
}
function testThisDotAccess() {
"use strict";
return this.length;
}
function testThisBracketAccess(prop) {
"use strict";
return this[prop];
}
function testGlobalAccess() {
return testThis();
}
function shouldBeSyntaxError(str) {
shouldThrow(str);
shouldThrow("(function (){" + str + "})");
}
function testLineContinuation() {
"use stric\
t";
return this;
}
function testEscapeSequence() {
"use\u0020strict";
return this;
}
shouldBe("testThis.call(null)", "null");
shouldBe("testThis.call(1)", "1");
shouldBe("testThis.call(true)", "true");
shouldBe("testThis.call(false)", "false");
shouldBe("testThis.call(undefined)", "undefined");
shouldBeFalse("testLineContinuation.call(undefined) === undefined");
shouldBeFalse("testEscapeSequence.call(undefined) === undefined");
shouldBe("testThis.call('a string')", "'a string'");
shouldBe("testThisDotAccess.call('a string')", "'a string'.length");
shouldThrow("testThisDotAccess.call(null)");
shouldThrow("testThisDotAccess.call(undefined)");
shouldBeUndefined("testThisDotAccess.call(true)");
shouldBeUndefined("testThisDotAccess.call(false)");
shouldBeUndefined("testThisDotAccess.call(1)");
shouldBe("testThisBracketAccess.call('a string', 'length')", "'a string'.length");
shouldThrow("testThisBracketAccess.call(null, 'length')");
shouldThrow("testThisBracketAccess.call(undefined, 'length')");
shouldBeUndefined("testThisBracketAccess.call(true, 'length')");
shouldBeUndefined("testThisBracketAccess.call(false, 'length')");
shouldBeUndefined("testThisBracketAccess.call(1, 'length')");
shouldBeUndefined("Function('\"use strict\"; return this;')()");
shouldThrow("Function('\"use strict\"; with({});')");
shouldBe("testGlobalAccess()", "undefined");
shouldBe("testThis.call()", "undefined");
shouldBe("testThis.apply()", "undefined");
shouldBe("testThis.call(undefined)", "undefined");
shouldBe("testThis.apply(undefined)", "undefined");
shouldBeSyntaxError("(function eval(){'use strict';})");
shouldBeSyntaxError("(function (eval){'use strict';})");
shouldBeSyntaxError("(function arguments(){'use strict';})");
shouldBeSyntaxError("(function (arguments){'use strict';})");
shouldBeSyntaxError("(function (){'use strict'; var eval;})");
shouldBeSyntaxError("(function (){'use strict'; var arguments;})");
shouldBeSyntaxError("(function (){'use strict'; try{}catch(eval){}})");
shouldBeSyntaxError("(function (){'use strict'; try{}catch(arguments){}})");
shouldBeSyntaxError("(function (a, a){'use strict';})");
shouldBeSyntaxError("(function (a){'use strict'; delete a;})()");
shouldBeSyntaxError("(function (){'use strict'; var a; delete a;})()");
shouldBeSyntaxError("(function (){var a; function f() {'use strict'; delete a;} })()");
shouldBeSyntaxError("(function (){'use strict'; with(1){};})");
shouldThrow("(function (){'use strict'; arguments.callee; })()");
shouldBeUndefined("(function (){'use strict'; arguments.caller; })()");
shouldThrow("(function f(){'use strict'; f.arguments; })()");
shouldThrow("(function f(){'use strict'; f.caller; })()");
shouldThrow("(function f(){'use strict'; f.arguments=5; })()");
shouldThrow("(function f(){'use strict'; f.caller=5; })()");
shouldThrow("(function (arg){'use strict'; arguments.callee; })()");
shouldBeUndefined("(function (arg){'use strict'; arguments.caller; })()");
shouldThrow("(function f(arg){'use strict'; f.arguments; })()");
shouldThrow("(function f(arg){'use strict'; f.caller; })()");
shouldThrow("(function f(arg){'use strict'; f.arguments=5; })()");
shouldThrow("(function f(arg){'use strict'; f.caller=5; })()");
// arguments/caller poisoning should be visible on the intrinsic %FunctionPrototype%, but not throw with 'in' & 'hasOwnProperty'.
shouldBeTrue('"caller" in function(){"use strict"}');
shouldBeFalse('(function(){"use strict";}).hasOwnProperty("caller")');
shouldBeTrue('(function(){"use strict";}).__proto__.hasOwnProperty("caller")');
shouldBeTrue('"arguments" in function(){"use strict"}');
shouldBeFalse('(function(){"use strict";}).hasOwnProperty("arguments")');
shouldBeTrue('(function(){"use strict";}).__proto__.hasOwnProperty("arguments")');
shouldBeSyntaxError("'use strict'; (function (){with(1){};})");
shouldBeSyntaxError("'use strict'; (function (){var a; delete a;})");
shouldBeSyntaxError("'use strict'; var a; (function (){ delete a;})");
shouldBeSyntaxError("var a; (function (){ 'use strict'; delete a;})");
shouldBeSyntaxError("'misc directive'; 'use strict'; with({}){}");
shouldThrow("'use strict'; return");
shouldBeSyntaxError("'use strict'; break");
shouldBeSyntaxError("'use strict'; continue");
shouldThrow("'use strict'; for(;;)return");
shouldBeSyntaxError("'use strict'; for(;;)break missingLabel");
shouldBeSyntaxError("'use strict'; for(;;)continue missingLabel");
shouldBeSyntaxError("'use strict'; 007;");
shouldBeSyntaxError("'use strict'; '\\007';");
shouldBeSyntaxError("'\\007'; 'use strict';");
var someDeclaredGlobal;
aDeletableProperty = 'test';
shouldBeSyntaxError("'use strict'; delete aDeletableProperty;");
shouldBeSyntaxError("'use strict'; (function (){ delete someDeclaredGlobal;})");
shouldBeSyntaxError("(function (){ 'use strict'; delete someDeclaredGlobal;})");
shouldBeTrue("'use strict'; if (0) { someGlobal = 'Shouldn\\'t be able to assign this.'; }; true;");
shouldThrow("'use strict'; someGlobal = 'Shouldn\\'t be able to assign this.'; ");
shouldThrow("'use strict'; (function f(){ f = 'shouldn\\'t be able to assign to function expression name'; })()");
shouldThrow("'use strict'; eval('var introducedVariable = \"FAIL: variable introduced into containing scope\";'); introducedVariable");
var objectWithReadonlyProperty = {};
Object.defineProperty(objectWithReadonlyProperty, "prop", {value: "value", writable:false});
shouldThrow("'use strict'; objectWithReadonlyProperty.prop = 'fail'");
shouldThrow("'use strict'; delete objectWithReadonlyProperty.prop");
readonlyPropName = "prop";
shouldThrow("'use strict'; delete objectWithReadonlyProperty[readonlyPropName]");
shouldBeSyntaxError("'use strict'; ++eval");
shouldBeSyntaxError("'use strict'; eval++");
shouldBeSyntaxError("'use strict'; --eval");
shouldBeSyntaxError("'use strict'; eval--");
shouldBeSyntaxError("'use strict'; function f() { ++arguments }");
shouldBeSyntaxError("'use strict'; function f() { arguments++ }");
shouldBeSyntaxError("'use strict'; function f() { --arguments }");
shouldBeSyntaxError("'use strict'; function f() { arguments-- }");
var global = this;
shouldThrow("global.eval('\"use strict\"; if (0) ++arguments; true;')");
shouldBeSyntaxError("'use strict'; ++(1, eval)");
shouldBeSyntaxError("'use strict'; (1, eval)++");
shouldBeSyntaxError("'use strict'; --(1, eval)");
shouldBeSyntaxError("'use strict'; (1, eval)--");
shouldBeSyntaxError("'use strict'; function f() { ++(1, arguments) }");
shouldBeSyntaxError("'use strict'; function f() { (1, arguments)++ }");
shouldBeSyntaxError("'use strict'; function f() { --(1, arguments) }");
shouldBeSyntaxError("'use strict'; function f() { (1, arguments)-- }");
shouldBeSyntaxError("'use strict'; undefined; if (0) delete +a.b");
shouldBeSyntaxError("'use strict'; undefined; if (0) delete ++a.b");
shouldBeSyntaxError("'use strict'; undefined; if (0) delete void a.b");
shouldBeTrue("(function (a){'use strict'; a = false; return a !== arguments[0]; })(true)");
shouldBeTrue("(function (a){'use strict'; arguments[0] = false; return a !== arguments[0]; })(true)");
shouldBeTrue("(function (a){'use strict'; a=false; return arguments; })(true)[0]");
shouldBeTrue("(function (a){'use strict'; arguments[0]=false; return a; })(true)");
shouldBeTrue("(function (a){'use strict'; arguments[0]=true; return arguments; })(false)[0]");
shouldBeTrue("(function (){'use strict'; arguments[0]=true; return arguments; })(false)[0]");
shouldBeTrue("(function (a){'use strict'; arguments[0]=true; a=false; return arguments; })()[0]");
shouldBeTrue("(function (a){'use strict'; arguments[0]=false; a=true; return a; })()");
shouldBeTrue("(function (a){'use strict'; arguments[0]=true; return arguments; })()[0]");
shouldBeTrue("(function (){'use strict'; arguments[0]=true; return arguments; })()[0]");
// Same tests again, this time forcing an activation to be created as well
shouldBeTrue("(function (a){'use strict'; var local; (function (){local;})(); a = false; return a !== arguments[0]; })(true)");
shouldBeTrue("(function (a){'use strict'; var local; (function (){local;})(); arguments[0] = false; return a !== arguments[0]; })(true)");
shouldBeTrue("(function (a){'use strict'; var local; (function (){local;})(); a=false; return arguments; })(true)[0]");
shouldBeTrue("(function (a){'use strict'; var local; (function (){local;})(); arguments[0]=false; return a; })(true)");
shouldBeTrue("(function (a){'use strict'; var local; (function (){local;})(); arguments[0]=true; return arguments; })(false)[0]");
shouldBeTrue("(function (){'use strict'; var local; (function (){local;})(); arguments[0]=true; return arguments; })(false)[0]");
shouldBeTrue("(function (a){'use strict'; var local; (function (){local;})(); arguments[0]=true; a=false; return arguments; })()[0]");
shouldBeTrue("(function (a){'use strict'; var local; (function (){local;})(); arguments[0]=true; return arguments; })()[0]");
shouldBeTrue("(function (a){'use strict'; var local; (function (){local;})(); arguments[0]=false; a=true; return a; })()");
shouldBeTrue("(function (){'use strict'; var local; (function (){local;})(); arguments[0]=true; return arguments; })()[0]");
shouldBeTrue("'use strict'; (function (){var a = true; eval('var a = false'); return a; })()");
shouldBeTrue("(function (){var a = true; eval('\"use strict\"; var a = false'); return a; })()");
shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f.__proto__, 'arguments').value; })()");
shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f.__proto__, 'caller').value; })()");
shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(arguments, 'callee').value; })()");
shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(arguments, 'caller'); })()");
shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(arguments, 'callee'); return descriptor.get === descriptor.set; })()");
shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f.__proto__, 'caller'); return descriptor.get === descriptor.set; })()");
shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f.__proto__, 'arguments'); return descriptor.get === descriptor.set; })()");
shouldBeTrue("'use strict'; (function f() { for(var i in this); })(); true;")
shouldBeSyntaxError("'use strict'\u033b");
shouldBeSyntaxError("'use strict'5.f");
shouldBeSyntaxError("'use strict';\u033b");
shouldBeSyntaxError("'use strict';5.f");
shouldBeSyntaxError("'use strict';1-(eval=1);");
shouldBeSyntaxError("'use strict';arguments=1;");
shouldBeSyntaxError("'use strict';1-(arguments=1);");
shouldBeSyntaxError("'use strict';var a=(eval=1);");
shouldBeSyntaxError("'use strict';var a=(arguments=1);");
var aGlobal = false;
shouldBeTrue("'use strict'; try { throw 1; } catch (e) { aGlobal = true; }");
aGlobal = false;
shouldBeTrue("'use strict'; (function () { try { throw 1; } catch (e) { aGlobal = true; }})(); aGlobal;");
aGlobal = false;
shouldBeTrue("(function () {'use strict'; try { throw 1; } catch (e) { aGlobal = true; }})(); aGlobal;");
aGlobal = false;
shouldBeTrue("try { throw 1; } catch (e) { aGlobal = true; }");
aGlobal = false;
shouldBeTrue("(function () { try { throw 1; } catch (e) { aGlobal = true; }})(); aGlobal;");
aGlobal = false;
shouldBeTrue("(function () {try { throw 1; } catch (e) { aGlobal = true; }})(); aGlobal;");
// Make sure this doesn't crash!
shouldBe('String(Object.getOwnPropertyDescriptor((function() { "use strict"; }).__proto__, "caller").get)', "'function () {\\n [native code]\\n}'");

View File

@ -0,0 +1,33 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This test checks for a regression against Date.setMonth fails with big values due to overflow.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS d.valueOf() is new Date(1980, 8, 1).valueOf()
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,30 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description(
'This test checks for a regression against <a href="https://bugs.webkit.org/show_bug.cgi?id=4781">Date.setMonth fails with big values due to overflow</a>.'
);
var d = new Date(1970, 0, 1);
d.setMonth(128);
shouldBe("d.valueOf()", "new Date(1980, 8, 1).valueOf()");

View File

@ -0,0 +1,33 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This test checks for a regression against Date.setMonth fails with negative values.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS d.valueOf() is new Date(2004, 9, 15).valueOf()
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,30 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description(
'This test checks for a regression against <a href="https://bugs.webkit.org/show_bug.cgi?id=5280">Date.setMonth fails with negative values</a>.'
);
var d = new Date(2005, 6, 15);
d.setMonth(-3);
shouldBe("d.valueOf()", "new Date(2004, 9, 15).valueOf()");

View File

@ -0,0 +1,38 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The following test checks if an existing milliseconds value gets preserved if a call to setHours(), setMinutes() or setSeconds() does not specify the milliseconds. See https://bugs.webkit.org/show_bug.cgi?id=3759
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS d.getMilliseconds() is 1
PASS d.getMilliseconds() is 1
PASS d.getMilliseconds() is 1
PASS d.getMilliseconds() is 1
PASS d.getMilliseconds() is 1
PASS d.getMilliseconds() is 1
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,44 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description(
'The following test checks if an existing milliseconds value gets preserved if a call to setHours(), setMinutes() or setSeconds() does not specify the milliseconds. See <a href="https://bugs.webkit.org/show_bug.cgi?id=3759">https://bugs.webkit.org/show_bug.cgi?id=3759</a>'
);
var d = new Date(0);
d.setMilliseconds(1);
var oldValue = d.getMilliseconds();
d.setHours(8);
shouldBe("d.getMilliseconds()", oldValue.toString());
d.setHours(8, 30);
shouldBe("d.getMilliseconds()", oldValue.toString());
d.setHours(8, 30, 40);
shouldBe("d.getMilliseconds()", oldValue.toString());
d.setMinutes(45);
shouldBe("d.getMilliseconds()", oldValue.toString());
d.setMinutes(45, 40);
shouldBe("d.getMilliseconds()", oldValue.toString());
d.setSeconds(50);
shouldBe("d.getMilliseconds()", oldValue.toString());

View File

@ -0,0 +1,43 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Tests for Date.toISOString
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS Date.toISOString.call({}) threw exception TypeError: Cannot read properties of undefined (reading 'call').
PASS Date.toISOString.call(0) threw exception TypeError: Cannot read properties of undefined (reading 'call').
PASS new Date(-400).toISOString() is '1969-12-31T23:59:59.600Z'
PASS new Date(0).toISOString() is '1970-01-01T00:00:00.000Z'
PASS new Date('1 January 1500 UTC').toISOString() is '1500-01-01T00:00:00.000Z'
PASS new Date('1 January 2000 UTC').toISOString() is '2000-01-01T00:00:00.000Z'
PASS new Date('1 January 4000 UTC').toISOString() is '4000-01-01T00:00:00.000Z'
PASS new Date('1 January 100000 UTC').toISOString() is '+100000-01-01T00:00:00.000Z'
FAIL new Date('1 January -1 UTC').toISOString() should be -000001-01-01T00:00:00.000Z. Threw exception RangeError: Invalid time value
PASS new Date('10 March 2000 UTC').toISOString() is '2000-03-10T00:00:00.000Z'
PASS throwsRangeError("new Date(NaN).toISOString()") is true
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,47 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description("Tests for Date.toISOString");
function throwsRangeError(str)
{
try {
eval(str);
} catch (e) {
return e instanceof RangeError;
}
return false;
}
shouldThrow("Date.toISOString.call({})");
shouldThrow("Date.toISOString.call(0)");
shouldBe("new Date(-400).toISOString()", "'1969-12-31T23:59:59.600Z'");
shouldBe("new Date(0).toISOString()", "'1970-01-01T00:00:00.000Z'");
shouldBe("new Date('1 January 1500 UTC').toISOString()", "'1500-01-01T00:00:00.000Z'");
shouldBe("new Date('1 January 2000 UTC').toISOString()", "'2000-01-01T00:00:00.000Z'");
shouldBe("new Date('1 January 4000 UTC').toISOString()", "'4000-01-01T00:00:00.000Z'");
shouldBe("new Date('1 January 100000 UTC').toISOString()", "'+100000-01-01T00:00:00.000Z'");
shouldBe("new Date('1 January -1 UTC').toISOString()", "'-000001-01-01T00:00:00.000Z'");
shouldBe("new Date('10 March 2000 UTC').toISOString()", "'2000-03-10T00:00:00.000Z'");
shouldBeTrue('throwsRangeError("new Date(NaN).toISOString()")');

View File

@ -0,0 +1,36 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This test how deep we can recurse, and that we get an exception when we do, as opposed to a stack overflow.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL msg should be RangeError: Maximum call stack size exceeded.. Was RangeError: Maximum call stack size exceeded.
FAIL msg should be RangeError: Maximum call stack size exceeded.. Was RangeError: Maximum call stack size exceeded.
FAIL msg should be RangeError: Maximum call stack size exceeded.. Was RangeError: Maximum call stack size exceeded.
FAIL msg should be RangeError: Maximum call stack size exceeded.. Was RangeError: Maximum call stack size exceeded.
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,81 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// This neuters too low stack size passed by the flag fuzzer.
// Flags: --stack-size=864
description("This test how deep we can recurse, and that we get an exception when we do, as opposed to a stack overflow.");
function simpleRecursion(depth) {
if (depth)
simpleRecursion(depth - 1);
}
try {
simpleRecursion(4000);
} catch (ex) {
debug("FAIL: " + ex);
}
try {
simpleRecursion(10000000);
} catch (ex) {
var msg = String(eval(ex));
shouldBe("msg", "'RangeError: Maximum call stack size exceeded.'");
}
try {
simpleRecursion(1000000000);
} catch (ex) {
var msg = String(eval(ex));
shouldBe("msg", "'RangeError: Maximum call stack size exceeded.'");
}
var tooFewArgsDepth = 0;
function tooFewArgsRecursion(a) {
if (tooFewArgsDepth) {
tooFewArgsDepth--;
tooFewArgsRecursion();
}
}
try {
tooFewArgsDepth = 10000000;
tooFewArgsRecursion();
} catch (ex) {
var msg = String(eval(ex));
shouldBe("msg", "'RangeError: Maximum call stack size exceeded.'");
}
function tooManyArgsRecursion(depth) {
if (depth)
tooManyArgsRecursion(depth - 1, 1);
}
try {
tooManyArgsRecursion(10000000, 1);
} catch (ex) {
var msg = String(eval(ex));
shouldBe("msg", "'RangeError: Maximum call stack size exceeded.'");
}

View File

@ -0,0 +1,33 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Test for bug 33641: Assertion failure in Lexer.cpp if input stream ends while in string escape.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Passed if no assertion failure.
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,31 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description('Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=33641">bug 33641</a>: Assertion failure in Lexer.cpp if input stream ends while in string escape.');
debug("Passed if no assertion failure.");
try {
eval('"\\');
} catch (ex) {
}

View File

@ -0,0 +1,36 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Test for correct properties on Error objects.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS enumerableProperties(error) is []
FAIL enumerableProperties(nativeError) should be stack,line,sourceURL. Was .
PASS Object.getPrototypeOf(nativeError).name is "RangeError"
PASS Object.getPrototypeOf(nativeError).message is ""
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,46 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description("Test for correct properties on Error objects.");
function enumerableProperties(object)
{
var result = [];
for (var i in object)
result.push(i);
return result;
}
try {
// generate a RangeError.
[].length = -1;
} catch (rangeError) {
var nativeError = rangeError;
var error = new Error("message");
shouldBe('enumerableProperties(error)', '[]');
shouldBe('enumerableProperties(nativeError)', '["stack", "line", "sourceURL"]');
shouldBe('Object.getPrototypeOf(nativeError).name', '"RangeError"');
shouldBe('Object.getPrototypeOf(nativeError).message', '""');
}

View File

@ -0,0 +1,32 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Test for REGRESSION(r60392): Registerfile can be unwound too far following an exception. If the test doesn't crash, you pass.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,31 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description(
"Test for <a href='https://bugs.webkit.org/show_bug.cgi?id=41948'>REGRESSION(r60392): Registerfile can be unwound too far following an exception</a>. If the test doesn't crash, you pass."
);
eval('try { throw 0; } catch(e) {}');
var x = new String();
'' + escape(x.substring(0, 1));

View File

@ -0,0 +1,35 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Test that we can handle excessively large initializer lists
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS new Function(initializerTestString)() is true
PASS new Function(declarationTestString)() is true
PASS new Function(commaExpressionTestString)() is true
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,43 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description("Test that we can handle excessively large initializer lists");
var initializerTestString = "var a=0";
for (var i = 0; i < 5000; i++)
initializerTestString += ",a"+i+"="+i;
initializerTestString += ";return true;";
var declarationTestString = "var a";
for (var i = 0; i < 5000; i++)
declarationTestString += ",a"+i;
declarationTestString += ";return true;";
var commaExpressionTestString = "1";
for (var i = 0; i < 2500; i++)
commaExpressionTestString += ",1";
commaExpressionTestString += ";return true;";
shouldBeTrue("new Function(initializerTestString)()");
shouldBeTrue("new Function(declarationTestString)()");
shouldBeTrue("new Function(commaExpressionTestString)()");

View File

@ -0,0 +1,66 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Tests to ensure that Function.apply works correctly for Arrays, arguments and array-like objects.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS argumentsApply1(1, 2, 3) is 1
PASS argumentsApply2(1, 2, 3) is 2
PASS argumentsApply3(1, 2, 3) is 3
PASS argumentsApplyLength(1, 2, 3) is 3
PASS argumentsApplyExcessArguments(1, 2, 3) is 3
PASS executedAdditionalArgument is true
PASS arrayApply1([1, 2, 3]) is 1
PASS arrayApply2([1, 2, 3]) is 2
PASS arrayApply3([1, 2, 3]) is 3
PASS arrayApplyLength([1, 2, 3]) is 3
PASS argumentsApplyDelete1(1, 2, 3) is 1
PASS argumentsApplyDelete2(1, 2, 3) is undefined
PASS argumentsApplyDelete3(1, 2, 3) is 3
PASS argumentsApplyDeleteLength(1, 2, 3) is 3
PASS arrayApplyDelete1([1, 2, 3]) is 1
PASS arrayApplyDelete2([1, 2, 3]) is undefined
PASS arrayApplyDelete3([1, 2, 3]) is 3
PASS arrayApplyDeleteLength([1, 2, 3]) is 3
PASS argumentsApplyChangeLength1(1) is 2
PASS argumentsApplyChangeLength2(1) is 2
PASS argumentsApplyChangeLength3(1) is 2
PASS argumentsApplyChangeLength4(1) is 0
PASS argumentsApplyChangeLength5(1) is 0
PASS arrayApplyChangeLength1() is 2
PASS arrayApplyChangeLength2() is 2
PASS arrayApplyChangeLength3() is 2
PASS arrayApplyChangeLength4() is 0
PASS var a = []; a.length = 0xFFFE; [].constructor.apply('', a).length is 0xFFFE
PASS var a = []; a.length = 0xFFFF; [].constructor.apply('', a).length is 0xFFFF
PASS var a = []; a.length = 0x10000; [].constructor.apply('', a).length is 0x10000
PASS var a = []; a.length = 0x10001; [].constructor.apply('', a).length is 0x10001
PASS var a = []; a.length = 0xFFFFFFFE; [].constructor.apply('', a).length threw exception RangeError: Invalid array length.
PASS var a = []; a.length = 0xFFFFFFFF; [].constructor.apply('', a).length threw exception RangeError: Invalid array length.
PASS (function(a,b,c,d){ return d ? -1 : (a+b+c); }).apply(undefined, {length:3, 0:100, 1:20, 2:3}) is 123
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,321 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// This neuters too low stack size passed by the flag fuzzer.
// Flags: --stack-size=864
description('Tests to ensure that Function.apply works correctly for Arrays, arguments and array-like objects.');
function argumentsApply1(a, b, c)
{
function t(a, b, c)
{
return a;
}
return t.apply(null, arguments);
}
function argumentsApply2(a, b, c)
{
function t(a, b, c)
{
return b;
}
return t.apply(null, arguments);
}
function argumentsApply3(a, b, c)
{
function t(a, b, c)
{
return c;
}
return t.apply(null, arguments);
}
function argumentsApplyLength(a, b, c)
{
function t(a, b, c)
{
return arguments.length;
}
return t.apply(null, arguments);
}
var executedAdditionalArgument = false;
function argumentsApplyExcessArguments(a, b, c)
{
function t(a, b, c)
{
return arguments.length;
}
return t.apply(null, arguments, executedAdditionalArgument = true);
}
shouldBe("argumentsApply1(1, 2, 3)", "1");
shouldBe("argumentsApply2(1, 2, 3)", "2");
shouldBe("argumentsApply3(1, 2, 3)", "3");
shouldBe("argumentsApplyLength(1, 2, 3)", "3");
shouldBe("argumentsApplyExcessArguments(1, 2, 3)", "3");
shouldBeTrue("executedAdditionalArgument");
function arrayApply1(array)
{
function t(a, b, c)
{
return a;
}
return t.apply(null, array);
}
function arrayApply2(array)
{
function t(a, b, c)
{
return b;
}
return t.apply(null, array);
}
function arrayApply3(array)
{
function t(a, b, c)
{
return c;
}
return t.apply(null, array);
}
function arrayApplyLength(array)
{
function t(a, b, c)
{
return arguments.length;
}
return t.apply(null, array);
}
shouldBe("arrayApply1([1, 2, 3])", "1");
shouldBe("arrayApply2([1, 2, 3])", "2");
shouldBe("arrayApply3([1, 2, 3])", "3");
shouldBe("arrayApplyLength([1, 2, 3])", "3");
function argumentsApplyDelete1(a, b, c)
{
function t(a, b, c)
{
return a;
}
delete arguments[1];
return t.apply(null, arguments);
}
function argumentsApplyDelete2(a, b, c)
{
function t(a, b, c)
{
return b;
}
delete arguments[1];
return t.apply(null, arguments);
}
function argumentsApplyDelete3(a, b, c)
{
function t(a, b, c)
{
return c;
}
delete arguments[1];
return t.apply(null, arguments);
}
function argumentsApplyDeleteLength(a, b, c)
{
function t(a, b, c)
{
return arguments.length;
}
delete arguments[1];
return t.apply(null, arguments);
}
shouldBe("argumentsApplyDelete1(1, 2, 3)", "1");
shouldBe("argumentsApplyDelete2(1, 2, 3)", "undefined");
shouldBe("argumentsApplyDelete3(1, 2, 3)", "3");
shouldBe("argumentsApplyDeleteLength(1, 2, 3)", "3");
function arrayApplyDelete1(array)
{
function t(a, b, c)
{
return a;
}
delete array[1];
return t.apply(null, array);
}
function arrayApplyDelete2(array)
{
function t(a, b, c)
{
return b;
}
delete array[1];
return t.apply(null, array);
}
function arrayApplyDelete3(array)
{
function t(a, b, c)
{
return c;
}
delete array[1];
return t.apply(null, array);
}
function arrayApplyDeleteLength(array)
{
function t(a, b, c)
{
return arguments.length;
}
delete array[1];
return t.apply(null, array);
}
shouldBe("arrayApplyDelete1([1, 2, 3])", "1");
shouldBe("arrayApplyDelete2([1, 2, 3])", "undefined");
shouldBe("arrayApplyDelete3([1, 2, 3])", "3");
shouldBe("arrayApplyDeleteLength([1, 2, 3])", "3");
function argumentsApplyChangeLength1()
{
function f() {
return arguments.length;
};
arguments.length = 2;
return f.apply(null, arguments);
}
function argumentsApplyChangeLength2()
{
function f(a) {
return arguments.length;
};
arguments.length = 2;
return f.apply(null, arguments);
}
function argumentsApplyChangeLength3()
{
function f(a, b, c) {
return arguments.length;
};
arguments.length = 2;
return f.apply(null, arguments);
};
function argumentsApplyChangeLength4()
{
function f() {
return arguments.length;
};
arguments.length = 0;
return f.apply(null, arguments);
};
function argumentsApplyChangeLength5()
{
function f() {
return arguments.length;
};
arguments.length = "Not A Number";
return f.apply(null, arguments);
}
shouldBe("argumentsApplyChangeLength1(1)", "2");
shouldBe("argumentsApplyChangeLength2(1)", "2");
shouldBe("argumentsApplyChangeLength3(1)", "2");
shouldBe("argumentsApplyChangeLength4(1)", "0");
shouldBe("argumentsApplyChangeLength5(1)", "0");
function arrayApplyChangeLength1()
{
function f() {
return arguments.length;
};
var array = [];
array.length = 2;
return f.apply(null, array);
}
function arrayApplyChangeLength2()
{
function f(a) {
return arguments.length;
};
var array = [];
array.length = 2;
return f.apply(null, array);
}
function arrayApplyChangeLength3()
{
function f(a, b, c) {
return arguments.length;
};
var array = [];
array.length = 2;
return f.apply(null, array);
}
function arrayApplyChangeLength4()
{
function f() {
return arguments.length;
};
var array = [1];
array.length = 0;
return f.apply(null, array);
};
shouldBe("arrayApplyChangeLength1()", "2");
shouldBe("arrayApplyChangeLength2()", "2");
shouldBe("arrayApplyChangeLength3()", "2");
shouldBe("arrayApplyChangeLength4()", "0");
shouldBe("var a = []; a.length = 0xFFFE; [].constructor.apply('', a).length", "0xFFFE");
shouldBe("var a = []; a.length = 0xFFFF; [].constructor.apply('', a).length", "0xFFFF");
shouldBe("var a = []; a.length = 0x10000; [].constructor.apply('', a).length", "0x10000");
shouldBe("var a = []; a.length = 0x10001; [].constructor.apply('', a).length", "0x10001");
shouldThrow("var a = []; a.length = 0xFFFFFFFE; [].constructor.apply('', a).length");
shouldThrow("var a = []; a.length = 0xFFFFFFFF; [].constructor.apply('', a).length");
// ES5 permits apply with array-like objects.
shouldBe("(function(a,b,c,d){ return d ? -1 : (a+b+c); }).apply(undefined, {length:3, 0:100, 1:20, 2:3})", '123');

View File

@ -0,0 +1,34 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This test checks that the Function constructor detects some syntax errors correctly (bug#59795).
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL Function('(i + (j)') should throw SyntaxError: Expected token ')'. Threw exception SyntaxError: Unexpected token '}'.
FAIL Function('return (i + (j)') should throw SyntaxError: Expected token ')'. Threw exception SyntaxError: Unexpected token '}'.
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,29 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description(
"This test checks that the Function constructor detects some syntax errors correctly (bug#59795)."
);
shouldThrow("Function('(i + (j)')", '"SyntaxError: Expected token \')\'"');
shouldThrow("Function('return (i + (j)')", '"SyntaxError: Expected token \')\'"');

View File

@ -0,0 +1,83 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This test checks toString() round-trip decompilation for binary and unary operators.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS decompiledFunction is 'function () { x + + y;}'
PASS decompiledFunction is 'function () { x + - y;}'
PASS decompiledFunction is 'function () { x - + y;}'
PASS decompiledFunction is 'function () { x - - y;}'
PASS decompiledFunction is 'function () { x * + y;}'
PASS decompiledFunction is 'function () { x * - y;}'
PASS decompiledFunction is 'function () { x / + y;}'
PASS decompiledFunction is 'function () { x / - y;}'
PASS decompiledFunction is 'function () { x % + y;}'
PASS decompiledFunction is 'function () { x % - y;}'
PASS decompiledFunction is 'function () { x++ + y;}'
PASS decompiledFunction is 'function () { x++ - y;}'
PASS decompiledFunction is 'function () { x++ * y;}'
PASS decompiledFunction is 'function () { x++ / y;}'
PASS decompiledFunction is 'function () { x-- + y;}'
PASS decompiledFunction is 'function () { x-- - y;}'
PASS decompiledFunction is 'function () { x-- * y;}'
PASS decompiledFunction is 'function () { x-- / y;}'
PASS decompiledFunction is 'function () { x + ++y;}'
PASS decompiledFunction is 'function () { x - ++y;}'
PASS decompiledFunction is 'function () { x * ++y;}'
PASS decompiledFunction is 'function () { x / ++y;}'
PASS decompiledFunction is 'function () { x + --y;}'
PASS decompiledFunction is 'function () { x - --y;}'
PASS decompiledFunction is 'function () { x * --y;}'
PASS decompiledFunction is 'function () { x / --y;}'
PASS decompiledFunction is 'function () { x++ + ++y;}'
PASS decompiledFunction is 'function () { x++ - ++y;}'
PASS decompiledFunction is 'function () { x++ * ++y;}'
PASS decompiledFunction is 'function () { x++ / ++y;}'
PASS decompiledFunction is 'function () { x-- + ++y;}'
PASS decompiledFunction is 'function () { x-- - ++y;}'
PASS decompiledFunction is 'function () { x-- * ++y;}'
PASS decompiledFunction is 'function () { x-- / ++y;}'
PASS decompiledFunction is 'function () { x++ + --y;}'
PASS decompiledFunction is 'function () { x++ - --y;}'
PASS decompiledFunction is 'function () { x++ * --y;}'
PASS decompiledFunction is 'function () { x++ / --y;}'
PASS decompiledFunction is 'function () { x-- + --y;}'
PASS decompiledFunction is 'function () { x-- - --y;}'
PASS decompiledFunction is 'function () { x-- * --y;}'
PASS decompiledFunction is 'function () { x-- / --y;}'
PASS decompiledFunction is 'function () { + + x;}'
PASS decompiledFunction is 'function () { + - x;}'
PASS decompiledFunction is 'function () { - + x;}'
PASS decompiledFunction is 'function () { - - x;}'
PASS decompiledFunction is 'function () { 1;}'
PASS decompiledFunction is 'function () { -1;}'
PASS decompiledFunction is 'function () { - -1;}'
PASS decompiledFunction is 'function () { - - 0;}'
PASS decompiledFunction is 'function () { - - NaN;}'
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,83 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description("This test checks toString() round-trip decompilation for binary and unary operators.");
var tests = [
"x + + y",
"x + - y",
"x - + y",
"x - - y",
"x * + y",
"x * - y",
"x / + y",
"x / - y",
"x % + y",
"x % - y",
"x++ + y",
"x++ - y",
"x++ * y",
"x++ / y",
"x-- + y",
"x-- - y",
"x-- * y",
"x-- / y",
"x + ++y",
"x - ++y",
"x * ++y",
"x / ++y",
"x + --y",
"x - --y",
"x * --y",
"x / --y",
"x++ + ++y",
"x++ - ++y",
"x++ * ++y",
"x++ / ++y",
"x-- + ++y",
"x-- - ++y",
"x-- * ++y",
"x-- / ++y",
"x++ + --y",
"x++ - --y",
"x++ * --y",
"x++ / --y",
"x-- + --y",
"x-- - --y",
"x-- * --y",
"x-- / --y",
"+ + x",
"+ - x",
"- + x",
"- - x",
"1",
"-1",
"- -1",
"- - 0",
"- - NaN"
];
for (test in tests) {
var decompiledFunction = eval("(function () { " + tests[test] + ";})").toString().replace(/\n/g, "");
shouldBe("decompiledFunction", "'function () { " + tests[test] + ";}'");
}

View File

@ -0,0 +1,525 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This test checks that parentheses are preserved when significant, and not added where inappropriate. We need this test because the JavaScriptCore parser removes all parentheses and the serializer then adds them back.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS compileAndSerialize('a * b * c') is 'a * b * c'
PASS compileAndSerialize('(a * b) * c') is '(a * b) * c'
PASS compileAndSerialize('a * (b * c)') is 'a * (b * c)'
PASS compileAndSerialize('a * b + c') is 'a * b + c'
PASS compileAndSerialize('(a * b) + c') is '(a * b) + c'
PASS compileAndSerialize('a * (b + c)') is 'a * (b + c)'
PASS compileAndSerialize('a * b - c') is 'a * b - c'
PASS compileAndSerialize('(a * b) - c') is '(a * b) - c'
PASS compileAndSerialize('a * (b - c)') is 'a * (b - c)'
PASS compileAndSerialize('a / b / c') is 'a / b / c'
PASS compileAndSerialize('(a / b) / c') is '(a / b) / c'
PASS compileAndSerialize('a / (b / c)') is 'a / (b / c)'
PASS compileAndSerialize('a * b / c') is 'a * b / c'
PASS compileAndSerialize('(a * b) / c') is '(a * b) / c'
PASS compileAndSerialize('a * (b / c)') is 'a * (b / c)'
PASS compileAndSerialize('a / b + c') is 'a / b + c'
PASS compileAndSerialize('(a / b) + c') is '(a / b) + c'
PASS compileAndSerialize('a / (b + c)') is 'a / (b + c)'
PASS compileAndSerialize('a % b % c') is 'a % b % c'
PASS compileAndSerialize('(a % b) % c') is '(a % b) % c'
PASS compileAndSerialize('a % (b % c)') is 'a % (b % c)'
PASS compileAndSerialize('a * b % c') is 'a * b % c'
PASS compileAndSerialize('(a * b) % c') is '(a * b) % c'
PASS compileAndSerialize('a * (b % c)') is 'a * (b % c)'
PASS compileAndSerialize('a % b + c') is 'a % b + c'
PASS compileAndSerialize('(a % b) + c') is '(a % b) + c'
PASS compileAndSerialize('a % (b + c)') is 'a % (b + c)'
PASS compileAndSerialize('a + b + c') is 'a + b + c'
PASS compileAndSerialize('(a + b) + c') is '(a + b) + c'
PASS compileAndSerialize('a + (b + c)') is 'a + (b + c)'
PASS compileAndSerialize('a + b << c') is 'a + b << c'
PASS compileAndSerialize('(a + b) << c') is '(a + b) << c'
PASS compileAndSerialize('a + (b << c)') is 'a + (b << c)'
PASS compileAndSerialize('a + b >> c') is 'a + b >> c'
PASS compileAndSerialize('(a + b) >> c') is '(a + b) >> c'
PASS compileAndSerialize('a + (b >> c)') is 'a + (b >> c)'
PASS compileAndSerialize('a + b >>> c') is 'a + b >>> c'
PASS compileAndSerialize('(a + b) >>> c') is '(a + b) >>> c'
PASS compileAndSerialize('a + (b >>> c)') is 'a + (b >>> c)'
PASS compileAndSerialize('a - b - c') is 'a - b - c'
PASS compileAndSerialize('(a - b) - c') is '(a - b) - c'
PASS compileAndSerialize('a - (b - c)') is 'a - (b - c)'
PASS compileAndSerialize('a + b - c') is 'a + b - c'
PASS compileAndSerialize('(a + b) - c') is '(a + b) - c'
PASS compileAndSerialize('a + (b - c)') is 'a + (b - c)'
PASS compileAndSerialize('a - b << c') is 'a - b << c'
PASS compileAndSerialize('(a - b) << c') is '(a - b) << c'
PASS compileAndSerialize('a - (b << c)') is 'a - (b << c)'
PASS compileAndSerialize('a << b << c') is 'a << b << c'
PASS compileAndSerialize('(a << b) << c') is '(a << b) << c'
PASS compileAndSerialize('a << (b << c)') is 'a << (b << c)'
PASS compileAndSerialize('a << b < c') is 'a << b < c'
PASS compileAndSerialize('(a << b) < c') is '(a << b) < c'
PASS compileAndSerialize('a << (b < c)') is 'a << (b < c)'
PASS compileAndSerialize('a << b > c') is 'a << b > c'
PASS compileAndSerialize('(a << b) > c') is '(a << b) > c'
PASS compileAndSerialize('a << (b > c)') is 'a << (b > c)'
PASS compileAndSerialize('a << b <= c') is 'a << b <= c'
PASS compileAndSerialize('(a << b) <= c') is '(a << b) <= c'
PASS compileAndSerialize('a << (b <= c)') is 'a << (b <= c)'
PASS compileAndSerialize('a << b >= c') is 'a << b >= c'
PASS compileAndSerialize('(a << b) >= c') is '(a << b) >= c'
PASS compileAndSerialize('a << (b >= c)') is 'a << (b >= c)'
PASS compileAndSerialize('a << b instanceof c') is 'a << b instanceof c'
PASS compileAndSerialize('(a << b) instanceof c') is '(a << b) instanceof c'
PASS compileAndSerialize('a << (b instanceof c)') is 'a << (b instanceof c)'
PASS compileAndSerialize('a << b in c') is 'a << b in c'
PASS compileAndSerialize('(a << b) in c') is '(a << b) in c'
PASS compileAndSerialize('a << (b in c)') is 'a << (b in c)'
PASS compileAndSerialize('a >> b >> c') is 'a >> b >> c'
PASS compileAndSerialize('(a >> b) >> c') is '(a >> b) >> c'
PASS compileAndSerialize('a >> (b >> c)') is 'a >> (b >> c)'
PASS compileAndSerialize('a << b >> c') is 'a << b >> c'
PASS compileAndSerialize('(a << b) >> c') is '(a << b) >> c'
PASS compileAndSerialize('a << (b >> c)') is 'a << (b >> c)'
PASS compileAndSerialize('a >> b < c') is 'a >> b < c'
PASS compileAndSerialize('(a >> b) < c') is '(a >> b) < c'
PASS compileAndSerialize('a >> (b < c)') is 'a >> (b < c)'
PASS compileAndSerialize('a >>> b >>> c') is 'a >>> b >>> c'
PASS compileAndSerialize('(a >>> b) >>> c') is '(a >>> b) >>> c'
PASS compileAndSerialize('a >>> (b >>> c)') is 'a >>> (b >>> c)'
PASS compileAndSerialize('a << b >>> c') is 'a << b >>> c'
PASS compileAndSerialize('(a << b) >>> c') is '(a << b) >>> c'
PASS compileAndSerialize('a << (b >>> c)') is 'a << (b >>> c)'
PASS compileAndSerialize('a >>> b < c') is 'a >>> b < c'
PASS compileAndSerialize('(a >>> b) < c') is '(a >>> b) < c'
PASS compileAndSerialize('a >>> (b < c)') is 'a >>> (b < c)'
PASS compileAndSerialize('a < b < c') is 'a < b < c'
PASS compileAndSerialize('(a < b) < c') is '(a < b) < c'
PASS compileAndSerialize('a < (b < c)') is 'a < (b < c)'
PASS compileAndSerialize('a < b == c') is 'a < b == c'
PASS compileAndSerialize('(a < b) == c') is '(a < b) == c'
PASS compileAndSerialize('a < (b == c)') is 'a < (b == c)'
PASS compileAndSerialize('a < b != c') is 'a < b != c'
PASS compileAndSerialize('(a < b) != c') is '(a < b) != c'
PASS compileAndSerialize('a < (b != c)') is 'a < (b != c)'
PASS compileAndSerialize('a < b === c') is 'a < b === c'
PASS compileAndSerialize('(a < b) === c') is '(a < b) === c'
PASS compileAndSerialize('a < (b === c)') is 'a < (b === c)'
PASS compileAndSerialize('a < b !== c') is 'a < b !== c'
PASS compileAndSerialize('(a < b) !== c') is '(a < b) !== c'
PASS compileAndSerialize('a < (b !== c)') is 'a < (b !== c)'
PASS compileAndSerialize('a > b > c') is 'a > b > c'
PASS compileAndSerialize('(a > b) > c') is '(a > b) > c'
PASS compileAndSerialize('a > (b > c)') is 'a > (b > c)'
PASS compileAndSerialize('a < b > c') is 'a < b > c'
PASS compileAndSerialize('(a < b) > c') is '(a < b) > c'
PASS compileAndSerialize('a < (b > c)') is 'a < (b > c)'
PASS compileAndSerialize('a > b == c') is 'a > b == c'
PASS compileAndSerialize('(a > b) == c') is '(a > b) == c'
PASS compileAndSerialize('a > (b == c)') is 'a > (b == c)'
PASS compileAndSerialize('a <= b <= c') is 'a <= b <= c'
PASS compileAndSerialize('(a <= b) <= c') is '(a <= b) <= c'
PASS compileAndSerialize('a <= (b <= c)') is 'a <= (b <= c)'
PASS compileAndSerialize('a < b <= c') is 'a < b <= c'
PASS compileAndSerialize('(a < b) <= c') is '(a < b) <= c'
PASS compileAndSerialize('a < (b <= c)') is 'a < (b <= c)'
PASS compileAndSerialize('a <= b == c') is 'a <= b == c'
PASS compileAndSerialize('(a <= b) == c') is '(a <= b) == c'
PASS compileAndSerialize('a <= (b == c)') is 'a <= (b == c)'
PASS compileAndSerialize('a >= b >= c') is 'a >= b >= c'
PASS compileAndSerialize('(a >= b) >= c') is '(a >= b) >= c'
PASS compileAndSerialize('a >= (b >= c)') is 'a >= (b >= c)'
PASS compileAndSerialize('a < b >= c') is 'a < b >= c'
PASS compileAndSerialize('(a < b) >= c') is '(a < b) >= c'
PASS compileAndSerialize('a < (b >= c)') is 'a < (b >= c)'
PASS compileAndSerialize('a >= b == c') is 'a >= b == c'
PASS compileAndSerialize('(a >= b) == c') is '(a >= b) == c'
PASS compileAndSerialize('a >= (b == c)') is 'a >= (b == c)'
PASS compileAndSerialize('a instanceof b instanceof c') is 'a instanceof b instanceof c'
PASS compileAndSerialize('(a instanceof b) instanceof c') is '(a instanceof b) instanceof c'
PASS compileAndSerialize('a instanceof (b instanceof c)') is 'a instanceof (b instanceof c)'
PASS compileAndSerialize('a < b instanceof c') is 'a < b instanceof c'
PASS compileAndSerialize('(a < b) instanceof c') is '(a < b) instanceof c'
PASS compileAndSerialize('a < (b instanceof c)') is 'a < (b instanceof c)'
PASS compileAndSerialize('a instanceof b == c') is 'a instanceof b == c'
PASS compileAndSerialize('(a instanceof b) == c') is '(a instanceof b) == c'
PASS compileAndSerialize('a instanceof (b == c)') is 'a instanceof (b == c)'
PASS compileAndSerialize('a in b in c') is 'a in b in c'
PASS compileAndSerialize('(a in b) in c') is '(a in b) in c'
PASS compileAndSerialize('a in (b in c)') is 'a in (b in c)'
PASS compileAndSerialize('a < b in c') is 'a < b in c'
PASS compileAndSerialize('(a < b) in c') is '(a < b) in c'
PASS compileAndSerialize('a < (b in c)') is 'a < (b in c)'
PASS compileAndSerialize('a in b == c') is 'a in b == c'
PASS compileAndSerialize('(a in b) == c') is '(a in b) == c'
PASS compileAndSerialize('a in (b == c)') is 'a in (b == c)'
PASS compileAndSerialize('a == b == c') is 'a == b == c'
PASS compileAndSerialize('(a == b) == c') is '(a == b) == c'
PASS compileAndSerialize('a == (b == c)') is 'a == (b == c)'
PASS compileAndSerialize('a == b & c') is 'a == b & c'
PASS compileAndSerialize('(a == b) & c') is '(a == b) & c'
PASS compileAndSerialize('a == (b & c)') is 'a == (b & c)'
PASS compileAndSerialize('a != b != c') is 'a != b != c'
PASS compileAndSerialize('(a != b) != c') is '(a != b) != c'
PASS compileAndSerialize('a != (b != c)') is 'a != (b != c)'
PASS compileAndSerialize('a == b != c') is 'a == b != c'
PASS compileAndSerialize('(a == b) != c') is '(a == b) != c'
PASS compileAndSerialize('a == (b != c)') is 'a == (b != c)'
PASS compileAndSerialize('a != b & c') is 'a != b & c'
PASS compileAndSerialize('(a != b) & c') is '(a != b) & c'
PASS compileAndSerialize('a != (b & c)') is 'a != (b & c)'
PASS compileAndSerialize('a === b === c') is 'a === b === c'
PASS compileAndSerialize('(a === b) === c') is '(a === b) === c'
PASS compileAndSerialize('a === (b === c)') is 'a === (b === c)'
PASS compileAndSerialize('a == b === c') is 'a == b === c'
PASS compileAndSerialize('(a == b) === c') is '(a == b) === c'
PASS compileAndSerialize('a == (b === c)') is 'a == (b === c)'
PASS compileAndSerialize('a === b & c') is 'a === b & c'
PASS compileAndSerialize('(a === b) & c') is '(a === b) & c'
PASS compileAndSerialize('a === (b & c)') is 'a === (b & c)'
PASS compileAndSerialize('a !== b !== c') is 'a !== b !== c'
PASS compileAndSerialize('(a !== b) !== c') is '(a !== b) !== c'
PASS compileAndSerialize('a !== (b !== c)') is 'a !== (b !== c)'
PASS compileAndSerialize('a == b !== c') is 'a == b !== c'
PASS compileAndSerialize('(a == b) !== c') is '(a == b) !== c'
PASS compileAndSerialize('a == (b !== c)') is 'a == (b !== c)'
PASS compileAndSerialize('a !== b & c') is 'a !== b & c'
PASS compileAndSerialize('(a !== b) & c') is '(a !== b) & c'
PASS compileAndSerialize('a !== (b & c)') is 'a !== (b & c)'
PASS compileAndSerialize('a & b & c') is 'a & b & c'
PASS compileAndSerialize('(a & b) & c') is '(a & b) & c'
PASS compileAndSerialize('a & (b & c)') is 'a & (b & c)'
PASS compileAndSerialize('a & b ^ c') is 'a & b ^ c'
PASS compileAndSerialize('(a & b) ^ c') is '(a & b) ^ c'
PASS compileAndSerialize('a & (b ^ c)') is 'a & (b ^ c)'
PASS compileAndSerialize('a ^ b ^ c') is 'a ^ b ^ c'
PASS compileAndSerialize('(a ^ b) ^ c') is '(a ^ b) ^ c'
PASS compileAndSerialize('a ^ (b ^ c)') is 'a ^ (b ^ c)'
PASS compileAndSerialize('a ^ b | c') is 'a ^ b | c'
PASS compileAndSerialize('(a ^ b) | c') is '(a ^ b) | c'
PASS compileAndSerialize('a ^ (b | c)') is 'a ^ (b | c)'
PASS compileAndSerialize('a | b | c') is 'a | b | c'
PASS compileAndSerialize('(a | b) | c') is '(a | b) | c'
PASS compileAndSerialize('a | (b | c)') is 'a | (b | c)'
PASS compileAndSerialize('a | b && c') is 'a | b && c'
PASS compileAndSerialize('(a | b) && c') is '(a | b) && c'
PASS compileAndSerialize('a | (b && c)') is 'a | (b && c)'
PASS compileAndSerialize('a && b && c') is 'a && b && c'
PASS compileAndSerialize('(a && b) && c') is '(a && b) && c'
PASS compileAndSerialize('a && (b && c)') is 'a && (b && c)'
PASS compileAndSerialize('a && b || c') is 'a && b || c'
PASS compileAndSerialize('(a && b) || c') is '(a && b) || c'
PASS compileAndSerialize('a && (b || c)') is 'a && (b || c)'
PASS compileAndSerialize('a || b || c') is 'a || b || c'
PASS compileAndSerialize('(a || b) || c') is '(a || b) || c'
PASS compileAndSerialize('a || (b || c)') is 'a || (b || c)'
PASS compileAndSerialize('a = b = c') is 'a = b = c'
FAIL compileAndSerialize('(a = b) = c') should be (a = b) = c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a = (b = c)') is 'a = (b = c)'
PASS compileAndSerialize('a = b + c') is 'a = b + c'
PASS compileAndSerialize('(a = b) + c') is '(a = b) + c'
PASS compileAndSerialize('a = (b + c)') is 'a = (b + c)'
PASS compileAndSerialize('a + b = c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(a + b) = c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('a + (b = c)') is 'a + (b = c)'
PASS compileAndSerialize('a *= b *= c') is 'a *= b *= c'
FAIL compileAndSerialize('(a *= b) *= c') should be (a *= b) *= c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a *= (b *= c)') is 'a *= (b *= c)'
PASS compileAndSerialize('a = b *= c') is 'a = b *= c'
FAIL compileAndSerialize('(a = b) *= c') should be (a = b) *= c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a = (b *= c)') is 'a = (b *= c)'
PASS compileAndSerialize('a *= b + c') is 'a *= b + c'
PASS compileAndSerialize('(a *= b) + c') is '(a *= b) + c'
PASS compileAndSerialize('a *= (b + c)') is 'a *= (b + c)'
PASS compileAndSerialize('a + b *= c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(a + b) *= c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('a + (b *= c)') is 'a + (b *= c)'
PASS compileAndSerialize('a /= b /= c') is 'a /= b /= c'
FAIL compileAndSerialize('(a /= b) /= c') should be (a /= b) /= c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a /= (b /= c)') is 'a /= (b /= c)'
PASS compileAndSerialize('a = b /= c') is 'a = b /= c'
FAIL compileAndSerialize('(a = b) /= c') should be (a = b) /= c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a = (b /= c)') is 'a = (b /= c)'
PASS compileAndSerialize('a /= b + c') is 'a /= b + c'
PASS compileAndSerialize('(a /= b) + c') is '(a /= b) + c'
PASS compileAndSerialize('a /= (b + c)') is 'a /= (b + c)'
PASS compileAndSerialize('a + b /= c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(a + b) /= c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('a + (b /= c)') is 'a + (b /= c)'
PASS compileAndSerialize('a %= b %= c') is 'a %= b %= c'
FAIL compileAndSerialize('(a %= b) %= c') should be (a %= b) %= c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a %= (b %= c)') is 'a %= (b %= c)'
PASS compileAndSerialize('a = b %= c') is 'a = b %= c'
FAIL compileAndSerialize('(a = b) %= c') should be (a = b) %= c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a = (b %= c)') is 'a = (b %= c)'
PASS compileAndSerialize('a %= b + c') is 'a %= b + c'
PASS compileAndSerialize('(a %= b) + c') is '(a %= b) + c'
PASS compileAndSerialize('a %= (b + c)') is 'a %= (b + c)'
PASS compileAndSerialize('a + b %= c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(a + b) %= c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('a + (b %= c)') is 'a + (b %= c)'
PASS compileAndSerialize('a += b += c') is 'a += b += c'
FAIL compileAndSerialize('(a += b) += c') should be (a += b) += c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a += (b += c)') is 'a += (b += c)'
PASS compileAndSerialize('a = b += c') is 'a = b += c'
FAIL compileAndSerialize('(a = b) += c') should be (a = b) += c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a = (b += c)') is 'a = (b += c)'
PASS compileAndSerialize('a += b + c') is 'a += b + c'
PASS compileAndSerialize('(a += b) + c') is '(a += b) + c'
PASS compileAndSerialize('a += (b + c)') is 'a += (b + c)'
PASS compileAndSerialize('a + b += c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(a + b) += c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('a + (b += c)') is 'a + (b += c)'
PASS compileAndSerialize('a -= b -= c') is 'a -= b -= c'
FAIL compileAndSerialize('(a -= b) -= c') should be (a -= b) -= c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a -= (b -= c)') is 'a -= (b -= c)'
PASS compileAndSerialize('a = b -= c') is 'a = b -= c'
FAIL compileAndSerialize('(a = b) -= c') should be (a = b) -= c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a = (b -= c)') is 'a = (b -= c)'
PASS compileAndSerialize('a -= b + c') is 'a -= b + c'
PASS compileAndSerialize('(a -= b) + c') is '(a -= b) + c'
PASS compileAndSerialize('a -= (b + c)') is 'a -= (b + c)'
PASS compileAndSerialize('a + b -= c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(a + b) -= c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('a + (b -= c)') is 'a + (b -= c)'
PASS compileAndSerialize('a <<= b <<= c') is 'a <<= b <<= c'
FAIL compileAndSerialize('(a <<= b) <<= c') should be (a <<= b) <<= c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a <<= (b <<= c)') is 'a <<= (b <<= c)'
PASS compileAndSerialize('a = b <<= c') is 'a = b <<= c'
FAIL compileAndSerialize('(a = b) <<= c') should be (a = b) <<= c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a = (b <<= c)') is 'a = (b <<= c)'
PASS compileAndSerialize('a <<= b + c') is 'a <<= b + c'
PASS compileAndSerialize('(a <<= b) + c') is '(a <<= b) + c'
PASS compileAndSerialize('a <<= (b + c)') is 'a <<= (b + c)'
PASS compileAndSerialize('a + b <<= c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(a + b) <<= c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('a + (b <<= c)') is 'a + (b <<= c)'
PASS compileAndSerialize('a >>= b >>= c') is 'a >>= b >>= c'
FAIL compileAndSerialize('(a >>= b) >>= c') should be (a >>= b) >>= c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a >>= (b >>= c)') is 'a >>= (b >>= c)'
PASS compileAndSerialize('a = b >>= c') is 'a = b >>= c'
FAIL compileAndSerialize('(a = b) >>= c') should be (a = b) >>= c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a = (b >>= c)') is 'a = (b >>= c)'
PASS compileAndSerialize('a >>= b + c') is 'a >>= b + c'
PASS compileAndSerialize('(a >>= b) + c') is '(a >>= b) + c'
PASS compileAndSerialize('a >>= (b + c)') is 'a >>= (b + c)'
PASS compileAndSerialize('a + b >>= c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(a + b) >>= c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('a + (b >>= c)') is 'a + (b >>= c)'
PASS compileAndSerialize('a >>>= b >>>= c') is 'a >>>= b >>>= c'
FAIL compileAndSerialize('(a >>>= b) >>>= c') should be (a >>>= b) >>>= c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a >>>= (b >>>= c)') is 'a >>>= (b >>>= c)'
PASS compileAndSerialize('a = b >>>= c') is 'a = b >>>= c'
FAIL compileAndSerialize('(a = b) >>>= c') should be (a = b) >>>= c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a = (b >>>= c)') is 'a = (b >>>= c)'
PASS compileAndSerialize('a >>>= b + c') is 'a >>>= b + c'
PASS compileAndSerialize('(a >>>= b) + c') is '(a >>>= b) + c'
PASS compileAndSerialize('a >>>= (b + c)') is 'a >>>= (b + c)'
PASS compileAndSerialize('a + b >>>= c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(a + b) >>>= c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('a + (b >>>= c)') is 'a + (b >>>= c)'
PASS compileAndSerialize('a &= b &= c') is 'a &= b &= c'
FAIL compileAndSerialize('(a &= b) &= c') should be (a &= b) &= c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a &= (b &= c)') is 'a &= (b &= c)'
PASS compileAndSerialize('a = b &= c') is 'a = b &= c'
FAIL compileAndSerialize('(a = b) &= c') should be (a = b) &= c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a = (b &= c)') is 'a = (b &= c)'
PASS compileAndSerialize('a &= b + c') is 'a &= b + c'
PASS compileAndSerialize('(a &= b) + c') is '(a &= b) + c'
PASS compileAndSerialize('a &= (b + c)') is 'a &= (b + c)'
PASS compileAndSerialize('a + b &= c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(a + b) &= c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('a + (b &= c)') is 'a + (b &= c)'
PASS compileAndSerialize('a ^= b ^= c') is 'a ^= b ^= c'
FAIL compileAndSerialize('(a ^= b) ^= c') should be (a ^= b) ^= c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a ^= (b ^= c)') is 'a ^= (b ^= c)'
PASS compileAndSerialize('a = b ^= c') is 'a = b ^= c'
FAIL compileAndSerialize('(a = b) ^= c') should be (a = b) ^= c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a = (b ^= c)') is 'a = (b ^= c)'
PASS compileAndSerialize('a ^= b + c') is 'a ^= b + c'
PASS compileAndSerialize('(a ^= b) + c') is '(a ^= b) + c'
PASS compileAndSerialize('a ^= (b + c)') is 'a ^= (b + c)'
PASS compileAndSerialize('a + b ^= c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(a + b) ^= c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('a + (b ^= c)') is 'a + (b ^= c)'
PASS compileAndSerialize('a |= b |= c') is 'a |= b |= c'
FAIL compileAndSerialize('(a |= b) |= c') should be (a |= b) |= c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a |= (b |= c)') is 'a |= (b |= c)'
PASS compileAndSerialize('a = b |= c') is 'a = b |= c'
FAIL compileAndSerialize('(a = b) |= c') should be (a = b) |= c. Threw exception SyntaxError: Invalid left-hand side in assignment
PASS compileAndSerialize('a = (b |= c)') is 'a = (b |= c)'
PASS compileAndSerialize('a |= b + c') is 'a |= b + c'
PASS compileAndSerialize('(a |= b) + c') is '(a |= b) + c'
PASS compileAndSerialize('a |= (b + c)') is 'a |= (b + c)'
PASS compileAndSerialize('a + b |= c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(a + b) |= c') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('a + (b |= c)') is 'a + (b |= c)'
PASS compileAndSerialize('delete a + b') is 'delete a + b'
PASS compileAndSerialize('(delete a) + b') is '(delete a) + b'
PASS compileAndSerialize('delete (a + b)') is 'delete (a + b)'
PASS compileAndSerialize('!delete a') is '!delete a'
PASS compileAndSerialize('!(delete a)') is '!(delete a)'
PASS compileAndSerialize('void a + b') is 'void a + b'
PASS compileAndSerialize('(void a) + b') is '(void a) + b'
PASS compileAndSerialize('void (a + b)') is 'void (a + b)'
PASS compileAndSerialize('!void a') is '!void a'
PASS compileAndSerialize('!(void a)') is '!(void a)'
PASS compileAndSerialize('typeof a + b') is 'typeof a + b'
PASS compileAndSerialize('(typeof a) + b') is '(typeof a) + b'
PASS compileAndSerialize('typeof (a + b)') is 'typeof (a + b)'
PASS compileAndSerialize('!typeof a') is '!typeof a'
PASS compileAndSerialize('!(typeof a)') is '!(typeof a)'
PASS compileAndSerialize('++a + b') is '++a + b'
PASS compileAndSerialize('(++a) + b') is '(++a) + b'
PASS compileAndSerialize('++(a + b)') threw exception SyntaxError: Invalid left-hand side expression in prefix operation.
PASS compileAndSerialize('!++a') is '!++a'
PASS compileAndSerialize('!(++a)') is '!(++a)'
PASS compileAndSerialize('--a + b') is '--a + b'
PASS compileAndSerialize('(--a) + b') is '(--a) + b'
PASS compileAndSerialize('--(a + b)') threw exception SyntaxError: Invalid left-hand side expression in prefix operation.
PASS compileAndSerialize('!--a') is '!--a'
PASS compileAndSerialize('!(--a)') is '!(--a)'
PASS compileAndSerialize('+ a + b') is '+ a + b'
PASS compileAndSerialize('(+ a) + b') is '(+ a) + b'
PASS compileAndSerialize('+ (a + b)') is '+ (a + b)'
PASS compileAndSerialize('!+ a') is '!+ a'
PASS compileAndSerialize('!(+ a)') is '!(+ a)'
PASS compileAndSerialize('- a + b') is '- a + b'
PASS compileAndSerialize('(- a) + b') is '(- a) + b'
PASS compileAndSerialize('- (a + b)') is '- (a + b)'
PASS compileAndSerialize('!- a') is '!- a'
PASS compileAndSerialize('!(- a)') is '!(- a)'
PASS compileAndSerialize('~a + b') is '~a + b'
PASS compileAndSerialize('(~a) + b') is '(~a) + b'
PASS compileAndSerialize('~(a + b)') is '~(a + b)'
PASS compileAndSerialize('!~a') is '!~a'
PASS compileAndSerialize('!(~a)') is '!(~a)'
PASS compileAndSerialize('!a + b') is '!a + b'
PASS compileAndSerialize('(!a) + b') is '(!a) + b'
PASS compileAndSerialize('!(a + b)') is '!(a + b)'
PASS compileAndSerialize('!!a') is '!!a'
PASS compileAndSerialize('!(!a)') is '!(!a)'
PASS compileAndSerialize('!a++') is '!a++'
PASS compileAndSerialize('!(a++)') is '!(a++)'
PASS compileAndSerialize('(!a)++') threw exception SyntaxError: Invalid left-hand side expression in postfix operation.
PASS compileAndSerialize('!a--') is '!a--'
PASS compileAndSerialize('!(a--)') is '!(a--)'
PASS compileAndSerialize('(!a)--') threw exception SyntaxError: Invalid left-hand side expression in postfix operation.
PASS compileAndSerialize('(-1)[a]') is '(-1)[a]'
PASS compileAndSerialize('(-1)[a] = b') is '(-1)[a] = b'
PASS compileAndSerialize('(-1)[a] += b') is '(-1)[a] += b'
PASS compileAndSerialize('(-1)[a]++') is '(-1)[a]++'
PASS compileAndSerialize('++(-1)[a]') is '++(-1)[a]'
PASS compileAndSerialize('(-1)[a]()') is '(-1)[a]()'
PASS compileAndSerialize('new (-1)()') is 'new (-1)()'
PASS compileAndSerialize('(-1).a') is '(-1).a'
PASS compileAndSerialize('(-1).a = b') is '(-1).a = b'
PASS compileAndSerialize('(-1).a += b') is '(-1).a += b'
PASS compileAndSerialize('(-1).a++') is '(-1).a++'
PASS compileAndSerialize('++(-1).a') is '++(-1).a'
PASS compileAndSerialize('(-1).a()') is '(-1).a()'
PASS compileAndSerialize('(- 0)[a]') is '(- 0)[a]'
PASS compileAndSerialize('(- 0)[a] = b') is '(- 0)[a] = b'
PASS compileAndSerialize('(- 0)[a] += b') is '(- 0)[a] += b'
PASS compileAndSerialize('(- 0)[a]++') is '(- 0)[a]++'
PASS compileAndSerialize('++(- 0)[a]') is '++(- 0)[a]'
PASS compileAndSerialize('(- 0)[a]()') is '(- 0)[a]()'
PASS compileAndSerialize('new (- 0)()') is 'new (- 0)()'
PASS compileAndSerialize('(- 0).a') is '(- 0).a'
PASS compileAndSerialize('(- 0).a = b') is '(- 0).a = b'
PASS compileAndSerialize('(- 0).a += b') is '(- 0).a += b'
PASS compileAndSerialize('(- 0).a++') is '(- 0).a++'
PASS compileAndSerialize('++(- 0).a') is '++(- 0).a'
PASS compileAndSerialize('(- 0).a()') is '(- 0).a()'
PASS compileAndSerialize('(1)[a]') is '(1)[a]'
PASS compileAndSerialize('(1)[a] = b') is '(1)[a] = b'
PASS compileAndSerialize('(1)[a] += b') is '(1)[a] += b'
PASS compileAndSerialize('(1)[a]++') is '(1)[a]++'
PASS compileAndSerialize('++(1)[a]') is '++(1)[a]'
PASS compileAndSerialize('(1)[a]()') is '(1)[a]()'
PASS compileAndSerialize('new (1)()') is 'new (1)()'
PASS compileAndSerialize('(1).a') is '(1).a'
PASS compileAndSerialize('(1).a = b') is '(1).a = b'
PASS compileAndSerialize('(1).a += b') is '(1).a += b'
PASS compileAndSerialize('(1).a++') is '(1).a++'
PASS compileAndSerialize('++(1).a') is '++(1).a'
PASS compileAndSerialize('(1).a()') is '(1).a()'
PASS compileAndSerialize('(-1) = a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(- 0) = a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('1 = a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(-1) *= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(- 0) *= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('1 *= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(-1) /= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(- 0) /= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('1 /= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(-1) %= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(- 0) %= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('1 %= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(-1) += a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(- 0) += a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('1 += a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(-1) -= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(- 0) -= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('1 -= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(-1) <<= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(- 0) <<= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('1 <<= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(-1) >>= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(- 0) >>= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('1 >>= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(-1) >>>= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(- 0) >>>= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('1 >>>= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(-1) &= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(- 0) &= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('1 &= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(-1) ^= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(- 0) ^= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('1 ^= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(-1) |= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('(- 0) |= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerialize('1 |= a') threw exception SyntaxError: Invalid left-hand side in assignment.
PASS compileAndSerializeLeftmostTest('({ }).x') is '({ }).x'
PASS compileAndSerializeLeftmostTest('x = { }') is 'x = { }'
PASS compileAndSerializeLeftmostTest('(function () { })()') is '(function () { })()'
PASS compileAndSerializeLeftmostTest('x = function () { }') is 'x = function () { }'
PASS compileAndSerializeLeftmostTest('var a') is 'var a'
PASS compileAndSerializeLeftmostTest('var a = 1') is 'var a = 1'
PASS compileAndSerializeLeftmostTest('var a, b') is 'var a, b'
PASS compileAndSerializeLeftmostTest('var a = 1, b = 2') is 'var a = 1, b = 2'
PASS compileAndSerializeLeftmostTest('var a, b, c') is 'var a, b, c'
PASS compileAndSerializeLeftmostTest('var a = 1, b = 2, c = 3') is 'var a = 1, b = 2, c = 3'
PASS compileAndSerializeLeftmostTest('const a = 1') is 'const a = 1'
PASS compileAndSerializeLeftmostTest('const a = (1, 2)') is 'const a = (1, 2)'
FAIL compileAndSerializeLeftmostTest('const a, b = 1') should be const a, b = 1. Threw exception SyntaxError: Missing initializer in const declaration
FAIL compileAndSerializeLeftmostTest('const a = 1, b') should be const a = 1, b. Threw exception SyntaxError: Missing initializer in const declaration
PASS compileAndSerializeLeftmostTest('const a = 1, b = 1') is 'const a = 1, b = 1'
PASS compileAndSerializeLeftmostTest('const a = (1, 2), b = 1') is 'const a = (1, 2), b = 1'
PASS compileAndSerializeLeftmostTest('const a = 1, b = (1, 2)') is 'const a = 1, b = (1, 2)'
PASS compileAndSerializeLeftmostTest('const a = (1, 2), b = (1, 2)') is 'const a = (1, 2), b = (1, 2)'
PASS compileAndSerialize('(function () { new (a.b()).c })') is '(function () { new (a.b()).c })'
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,237 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description(
"This test checks that parentheses are preserved when significant, and not added where inappropriate. " +
"We need this test because the JavaScriptCore parser removes all parentheses and the serializer then adds them back."
);
function compileAndSerialize(expression)
{
var f = eval("(function () { return " + expression + "; })");
var serializedString = f.toString();
serializedString = serializedString.replace(/[ \t\r\n]+/g, " ");
serializedString = serializedString.replace("function () { return ", "");
serializedString = serializedString.replace("; }", "");
return serializedString;
}
function compileAndSerializeLeftmostTest(expression)
{
var f = eval("(function () { " + expression + "; })");
var serializedString = f.toString();
serializedString = serializedString.replace(/[ \t\r\n]+/g, " ");
serializedString = serializedString.replace("function () { ", "");
serializedString = serializedString.replace("; }", "");
return serializedString;
}
var removesExtraParentheses = compileAndSerialize("(a + b) + c") == "a + b + c";
function testKeepParentheses(expression)
{
shouldBe("compileAndSerialize('" + expression + "')",
"'" + expression + "'");
}
function testOptionalParentheses(expression)
{
stripped_expression = removesExtraParentheses
? expression.replace(/\(/g, '').replace(/\)/g, '')
: expression;
shouldBe("compileAndSerialize('" + expression + "')",
"'" + stripped_expression + "'");
}
function testLeftAssociativeSame(opA, opB)
{
testKeepParentheses("a " + opA + " b " + opB + " c");
testOptionalParentheses("(a " + opA + " b) " + opB + " c");
testKeepParentheses("a " + opA + " (b " + opB + " c)");
}
function testRightAssociativeSame(opA, opB)
{
testKeepParentheses("a " + opA + " b " + opB + " c");
testKeepParentheses("(a " + opA + " b) " + opB + " c");
testOptionalParentheses("a " + opA + " (b " + opB + " c)");
}
function testHigherFirst(opHigher, opLower)
{
testKeepParentheses("a " + opHigher + " b " + opLower + " c");
testOptionalParentheses("(a " + opHigher + " b) " + opLower + " c");
testKeepParentheses("a " + opHigher + " (b " + opLower + " c)");
}
function testLowerFirst(opLower, opHigher)
{
testKeepParentheses("a " + opLower + " b " + opHigher + " c");
testKeepParentheses("(a " + opLower + " b) " + opHigher + " c");
testOptionalParentheses("a " + opLower + " (b " + opHigher + " c)");
}
var binaryOperators = [
[ "*", "/", "%" ], [ "+", "-" ],
[ "<<", ">>", ">>>" ],
[ "<", ">", "<=", ">=", "instanceof", "in" ],
[ "==", "!=", "===", "!==" ],
[ "&" ], [ "^" ], [ "|" ],
[ "&&" ], [ "||" ]
];
for (i = 0; i < binaryOperators.length; ++i) {
var ops = binaryOperators[i];
for (j = 0; j < ops.length; ++j) {
var op = ops[j];
testLeftAssociativeSame(op, op);
if (j != 0)
testLeftAssociativeSame(ops[0], op);
if (i < binaryOperators.length - 1) {
var nextOps = binaryOperators[i + 1];
if (j == 0)
for (k = 0; k < nextOps.length; ++k)
testHigherFirst(op, nextOps[k]);
else
testHigherFirst(op, nextOps[0]);
}
}
}
var assignmentOperators = [ "=", "*=", "/=" , "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|=" ];
for (i = 0; i < assignmentOperators.length; ++i) {
var op = assignmentOperators[i];
testRightAssociativeSame(op, op);
if (i != 0)
testRightAssociativeSame("=", op);
testLowerFirst(op, "+");
shouldThrow("compileAndSerialize('a + b " + op + " c')");
shouldThrow("compileAndSerialize('(a + b) " + op + " c')");
testKeepParentheses("a + (b " + op + " c)");
}
var prefixOperators = [ "delete", "void", "typeof", "++", "--", "+", "-", "~", "!" ];
var prefixOperatorSpace = [ " ", " ", " ", "", "", " ", " ", "", "" ];
for (i = 0; i < prefixOperators.length; ++i) {
var op = prefixOperators[i] + prefixOperatorSpace[i];
testKeepParentheses("" + op + "a + b");
testOptionalParentheses("(" + op + "a) + b");
if (prefixOperators[i] !== "++" && prefixOperators[i] !== "--")
testKeepParentheses("" + op + "(a + b)");
else
shouldThrow("compileAndSerialize('" + op + "(a + b)')");
testKeepParentheses("!" + op + "a");
testOptionalParentheses("!(" + op + "a)");
}
testKeepParentheses("!a++");
testOptionalParentheses("!(a++)");
shouldThrow("compileAndSerialize('(!a)++')");
testKeepParentheses("!a--");
testOptionalParentheses("!(a--)");
shouldThrow("compileAndSerialize('(!a)--')");
testKeepParentheses("(-1)[a]");
testKeepParentheses("(-1)[a] = b");
testKeepParentheses("(-1)[a] += b");
testKeepParentheses("(-1)[a]++");
testKeepParentheses("++(-1)[a]");
testKeepParentheses("(-1)[a]()");
testKeepParentheses("new (-1)()");
testKeepParentheses("(-1).a");
testKeepParentheses("(-1).a = b");
testKeepParentheses("(-1).a += b");
testKeepParentheses("(-1).a++");
testKeepParentheses("++(-1).a");
testKeepParentheses("(-1).a()");
testKeepParentheses("(- 0)[a]");
testKeepParentheses("(- 0)[a] = b");
testKeepParentheses("(- 0)[a] += b");
testKeepParentheses("(- 0)[a]++");
testKeepParentheses("++(- 0)[a]");
testKeepParentheses("(- 0)[a]()");
testKeepParentheses("new (- 0)()");
testKeepParentheses("(- 0).a");
testKeepParentheses("(- 0).a = b");
testKeepParentheses("(- 0).a += b");
testKeepParentheses("(- 0).a++");
testKeepParentheses("++(- 0).a");
testKeepParentheses("(- 0).a()");
testOptionalParentheses("(1)[a]");
testOptionalParentheses("(1)[a] = b");
testOptionalParentheses("(1)[a] += b");
testOptionalParentheses("(1)[a]++");
testOptionalParentheses("++(1)[a]");
shouldBe("compileAndSerialize('(1)[a]()')",
removesExtraParentheses ? "'1[a]()'" : "'(1)[a]()'");
shouldBe("compileAndSerialize('new (1)()')",
removesExtraParentheses ? "'new 1()'" : "'new (1)()'");
testKeepParentheses("(1).a");
testKeepParentheses("(1).a = b");
testKeepParentheses("(1).a += b");
testKeepParentheses("(1).a++");
testKeepParentheses("++(1).a");
testKeepParentheses("(1).a()");
for (i = 0; i < assignmentOperators.length; ++i) {
var op = assignmentOperators[i];
shouldThrow("compileAndSerialize('(-1) " + op + " a')");
shouldThrow("compileAndSerialize('(- 0) " + op + " a')");
shouldThrow("compileAndSerialize('1 " + op + " a')");
}
shouldBe("compileAndSerializeLeftmostTest('({ }).x')", "'({ }).x'");
shouldBe("compileAndSerializeLeftmostTest('x = { }')", "'x = { }'");
shouldBe("compileAndSerializeLeftmostTest('(function () { })()')", "'(function () { })()'");
shouldBe("compileAndSerializeLeftmostTest('x = function () { }')", "'x = function () { }'");
shouldBe("compileAndSerializeLeftmostTest('var a')", "'var a'");
shouldBe("compileAndSerializeLeftmostTest('var a = 1')", "'var a = 1'");
shouldBe("compileAndSerializeLeftmostTest('var a, b')", "'var a, b'");
shouldBe("compileAndSerializeLeftmostTest('var a = 1, b = 2')", "'var a = 1, b = 2'");
shouldBe("compileAndSerializeLeftmostTest('var a, b, c')", "'var a, b, c'");
shouldBe("compileAndSerializeLeftmostTest('var a = 1, b = 2, c = 3')", "'var a = 1, b = 2, c = 3'");
shouldBe("compileAndSerializeLeftmostTest('const a = 1')", "'const a = 1'");
shouldBe("compileAndSerializeLeftmostTest('const a = (1, 2)')", "'const a = (1, 2)'");
shouldBe("compileAndSerializeLeftmostTest('const a, b = 1')", "'const a, b = 1'");
shouldBe("compileAndSerializeLeftmostTest('const a = 1, b')", "'const a = 1, b'");
shouldBe("compileAndSerializeLeftmostTest('const a = 1, b = 1')", "'const a = 1, b = 1'");
shouldBe("compileAndSerializeLeftmostTest('const a = (1, 2), b = 1')", "'const a = (1, 2), b = 1'");
shouldBe("compileAndSerializeLeftmostTest('const a = 1, b = (1, 2)')", "'const a = 1, b = (1, 2)'");
shouldBe("compileAndSerializeLeftmostTest('const a = (1, 2), b = (1, 2)')", "'const a = (1, 2), b = (1, 2)'");
shouldBe("compileAndSerialize('(function () { new (a.b()).c })')", "'(function () { new (a.b()).c })'");

View File

@ -0,0 +1,40 @@
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This test checks that functions re-string-ify in a way that is syntactically compatible with concatenation.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL (function (){return}).toString() should be function () {return;}. Was function (){return}.
FAIL (function (){return }).toString() should be function () {return; }. Was function (){return }.
FAIL (function (){return
}).toString() should be function () {return;
}. Was function (){return
}.
FAIL (function (){}).toString() should be function () {}. Was function (){}.
FAIL (function (){ }).toString() should be function () { }. Was function (){ }.
PASS successfullyParsed is true
TEST COMPLETE

View File

@ -0,0 +1,33 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description(
"This test checks that functions re-string-ify in a way that is syntactically " +
"compatible with concatenation."
);
shouldBe("(function (){return}).toString()", "'function () {return;}'");
shouldBe("(function (){return }).toString()", "'function () {return; }'");
shouldBe("(function (){return" + "\n" + "}).toString()", "'function () {return;" + "\\n" + "}'");
shouldBe("(function (){}).toString()", "'function () {}'");
shouldBe("(function (){ }).toString()", "'function () { }'");

Some files were not shown because too many files have changed in this diff Show More