mirror of https://github.com/tc39/test262.git
Added all tests added to repairES5.js since the last time I contributed SES-relevant tests to test262.
This commit is contained in:
parent
db516d2a64
commit
9c33379225
|
@ -0,0 +1,19 @@
|
|||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description It should not be possible to change the [[Prototype]]
|
||||
* of a non-extensible object
|
||||
*/
|
||||
var x = Object.preventExtensions({});
|
||||
var y = {};
|
||||
try {
|
||||
x.__proto__ = y;
|
||||
} catch (err) {
|
||||
// As far as this test is concerned, we allow the above assignment
|
||||
// to fail. This failure does violate the spec and should probably
|
||||
// be tested separately.
|
||||
}
|
||||
if (Object.getPrototypeOf(x) !== Object.prototype) {
|
||||
$ERROR("Prototype of non-extensible object mutated");
|
||||
}
|
|
@ -4,9 +4,10 @@
|
|||
/**
|
||||
* @name: S10.2.2_A1.2_T11;
|
||||
* @section: 10.2.2;
|
||||
* @assertion: The scope chain is initialised to contain the same objects,
|
||||
* @assertion: The scope chain is initialised to contain the same objects,
|
||||
* in the same order, as the calling context's scope chain;
|
||||
* @description: eval within global execution context;
|
||||
* @noStrict
|
||||
*/
|
||||
|
||||
function f(){
|
||||
|
@ -14,14 +15,14 @@ function f(){
|
|||
var j;
|
||||
str1 = '';
|
||||
str2 = '';
|
||||
|
||||
|
||||
for(i in this){
|
||||
str1+=i;
|
||||
}
|
||||
|
||||
|
||||
eval('for(j in this){\nstr2+=j;\n}');
|
||||
|
||||
return (str1 === str2);
|
||||
return (str1 === str2);
|
||||
|
||||
this.x = 1;
|
||||
this.y = 2;
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description Strict indirect eval should not leak top level
|
||||
* declarations into the global scope
|
||||
* @strictOnly
|
||||
*/
|
||||
if (!('foo' in this)) {
|
||||
(1,eval)('"use strict"; var foo = 88;');
|
||||
if ('foo' in this) {
|
||||
$ERROR("Strict indirect eval leaked a top level declaration");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2011 Google, Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description When calling a strict anonymous function as a
|
||||
* function, "this" should be bound to undefined.
|
||||
* @strictOnly
|
||||
*/
|
||||
|
||||
var that = (function() { return this; })();
|
||||
if (that !== undefined) {
|
||||
$ERROR('#1: "this" leaked as: ' + that);
|
||||
}
|
|
@ -9,8 +9,8 @@
|
|||
*/
|
||||
|
||||
//CHECK#1
|
||||
obj = new Object();
|
||||
ref = obj;
|
||||
var obj = new Object();
|
||||
var ref = obj;
|
||||
delete ref;
|
||||
if (typeof obj !== "object") {
|
||||
$ERROR('#1: obj = new Object(); ref = obj; delete ref; typeof obj === "object". Actual: ' + (typeof obj));
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* A strict delete should either succeed, returning true, or it
|
||||
* should fail by throwing a TypeError. Under no circumstances
|
||||
* should a strict delete return false.
|
||||
*
|
||||
* @description See if a strict delete returns false when deleting a
|
||||
* non-standard property.
|
||||
* @strictOnly
|
||||
*/
|
||||
|
||||
var deleted = 'unassigned';
|
||||
try {
|
||||
deleted = delete RegExp.leftContext;
|
||||
} catch (err) {
|
||||
|
||||
}
|
||||
if (deleted === false) {
|
||||
$ERROR('Strict delete returned false');
|
||||
}
|
|
@ -26,7 +26,7 @@ with (__obj)
|
|||
var __func = function()
|
||||
{
|
||||
return a;
|
||||
}
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description check that all poisoning use the [[ThrowTypeError]]
|
||||
* function object.
|
||||
* @strictOnly
|
||||
*/
|
||||
var poison = Object.getOwnPropertyDescriptor(function() {}, 'caller').get;
|
||||
|
||||
if (typeof poison !== 'function') {
|
||||
$ERROR("#1: A strict function's .caller should be poisoned with a function");
|
||||
}
|
||||
var threw = null;
|
||||
try {
|
||||
poison();
|
||||
} catch (err) {
|
||||
threw = err;
|
||||
}
|
||||
if (!threw || !(threw instanceof TypeError)) {
|
||||
$ERROR("#2: Poisoned property should throw TypeError");
|
||||
}
|
||||
|
||||
function checkPoison(obj, name) {
|
||||
var desc = Object.getOwnPropertyDescriptor(obj, name);
|
||||
if (desc.enumerable) {
|
||||
$ERROR("#3: Poisoned " + name + " should not be enumerable");
|
||||
}
|
||||
if (desc.configurable) {
|
||||
$ERROR("#4: Poisoned " + name + " should not be configurable");
|
||||
}
|
||||
if (poison !== desc.get) {
|
||||
$ERROR("#5: " + name + "'s getter not poisoned with same poison");
|
||||
}
|
||||
if (poison !== desc.set) {
|
||||
$ERROR("#6: " + name + "'s setter not poisoned with same poison");
|
||||
}
|
||||
}
|
||||
|
||||
checkPoison(function() {}, 'caller');
|
||||
checkPoison(function() {}, 'arguments');
|
||||
checkPoison((function() { return arguments; })(), 'caller');
|
||||
checkPoison((function() { return arguments; })(), 'callee');
|
||||
checkPoison((function() {}).bind(null), 'caller');
|
||||
checkPoison((function() {}).bind(null), 'arguments');
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description check if "caller" poisoning poisons
|
||||
* getOwnPropertyDescriptor too
|
||||
* @strictOnly
|
||||
*/
|
||||
Object.getOwnPropertyDescriptor(function(){}, 'caller');
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description check if "arguments" poisoning poisons
|
||||
* getOwnPropertyDescriptor too
|
||||
* @strictOnly
|
||||
*/
|
||||
Object.getOwnPropertyDescriptor(function(){}, 'arguments');
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description check if "caller" poisoning poisons
|
||||
* hasOwnProperty too
|
||||
* @strictOnly
|
||||
*/
|
||||
(function(){}).hasOwnProperty('caller');
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description check if "arguments" poisoning poisons
|
||||
* hasOwnProperty too
|
||||
* @strictOnly
|
||||
*/
|
||||
(function(){}).hasOwnProperty('arguments');
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description check if "caller" poisoning poisons
|
||||
* "in" too
|
||||
* @strictOnly
|
||||
*/
|
||||
'caller' in function() {};
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description check if "arguments" poisoning poisons
|
||||
* "in" too
|
||||
* @strictOnly
|
||||
*/
|
||||
'arguments' in function() {};
|
||||
|
|
@ -2,34 +2,13 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @name: S15.1.2.2_A5.1_T1;
|
||||
* @section: 15.1.2.2;
|
||||
* @assertion: If the length of S is at least 1 and the first character of S is 0,
|
||||
* then at the implementation's discretion either let R = 8 or R = 10;
|
||||
* @description: Either R = 8, or R = 10;
|
||||
*/
|
||||
|
||||
//CHECK#
|
||||
var res8 = 1;
|
||||
var res10 = 1;
|
||||
if (parseInt("08") !== parseInt("08", 8)) {
|
||||
res8 = 0;
|
||||
}
|
||||
if (parseInt("08") !== parseInt("08", 10)) {
|
||||
res10 = 0;
|
||||
}
|
||||
if (parseInt("09") !== parseInt("09", 8)) {
|
||||
res8 = 0;
|
||||
}
|
||||
if (parseInt("09") !== parseInt("09", 10)) {
|
||||
res10 = 0;
|
||||
}
|
||||
if (parseInt("010") !== parseInt("010", 8)) {
|
||||
res8 = 0;
|
||||
}
|
||||
if (parseInt("010") !== parseInt("010", 10)) {
|
||||
res10 = 0;
|
||||
}
|
||||
if (res8 + res10 !== 1) {
|
||||
$ERROR('#1: If the length of S is at least 1 and the first character of S is 0, then at the implementation\'s discretion either let R = 8 or R = 10');
|
||||
}
|
||||
* parseInt is no longer allowed to treat a leading zero as indicating
|
||||
* octal. "If radix is undefined or 0, it is assumed to be 10 except
|
||||
* when the number begins with the character pairs 0x or 0X, in which
|
||||
* case a radix of 16 is assumed."
|
||||
*
|
||||
* @description Check if parseInt still accepts octal
|
||||
*/
|
||||
if (parseInt('010') !== 10) {
|
||||
$ERROR("parseInt should no longer accept octal");
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2011 Google, Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* Object.getOwnProperties and Object.prototype.hasOwnProperty should
|
||||
* agree on what the own properties are.
|
||||
*
|
||||
* @description Check that all the own property names reported by
|
||||
* Object.getOwnPropertyNames on a strict function are names that
|
||||
* hasOwnProperty agrees are own properties.
|
||||
* @strictOnly
|
||||
*/
|
||||
|
||||
function foo() {}
|
||||
|
||||
var names = Object.getOwnPropertyNames(foo);
|
||||
for (var i = 0, len = names.length; i < len; i++) {
|
||||
if (!foo.hasOwnProperty(names[i])) {
|
||||
$ERROR('Phantom own property: ' + names[i]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* If a particular API exists (document.createElement, as happens to
|
||||
* exist in a browser environment), check if the form objects it makes
|
||||
* obey the constraints that even host objects must obey. In this
|
||||
* case, that if defineProperty seems to have successfully installed a
|
||||
* non-configurable getter, that it is still there.
|
||||
*
|
||||
* @description Do getters on HTMLFormElements disappear?
|
||||
*/
|
||||
function getter() { return 'gotten'; }
|
||||
|
||||
if (typeof document !== 'undefined' &&
|
||||
typeof document.createElement === 'function') {
|
||||
var f = document.createElement("form");
|
||||
var refused = false;
|
||||
try {
|
||||
Object.defineProperty(f, 'foo', {
|
||||
get: getter,
|
||||
set: void 0
|
||||
});
|
||||
} catch (err) {
|
||||
// A host object may refuse to install the getter
|
||||
refused = true;
|
||||
}
|
||||
if (!refused) {
|
||||
var desc = Object.getOwnPropertyDescriptor(f, 'foo');
|
||||
if (desc.get !== getter) {
|
||||
$ERROR('Getter on HTMLFormElement disappears');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description Checks if an inherited accessor property appears to be
|
||||
* an own property.
|
||||
*/
|
||||
var base = {};
|
||||
var derived = Object.create(base);
|
||||
function getter() { return 'gotten'; }
|
||||
Object.defineProperty(base, 'foo', {get: getter});
|
||||
if (derived.hasOwnProperty('foo')) {
|
||||
$ERROR('Accessor properties inherit as own properties');
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2011 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @name: S15.2.4.4_A14;
|
||||
* @section: 15.2.4.4;
|
||||
* @assertion: Let O be the result of calling ToObject passing the this value as the argument.
|
||||
* @description: Checking Object.prototype.valueOf when called as a global function.
|
||||
* @negative
|
||||
*/
|
||||
|
||||
var v = Object.prototype.valueOf;
|
||||
v();
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* Detects whether the value of a function's "prototype" property
|
||||
* as seen by normal object operations might deviate from the value
|
||||
* as seem by Object.getOwnPropertyDescriptor
|
||||
*
|
||||
* @description Checks if reading a function's .prototype directly
|
||||
* agrees with reading it via Object.getOwnPropertyDescriptor, after
|
||||
* having set it by Object.defineProperty.
|
||||
*/
|
||||
|
||||
function foo() {}
|
||||
|
||||
Object.defineProperty(foo, 'prototype', { value: {} });
|
||||
if (foo.prototype !==
|
||||
Object.getOwnPropertyDescriptor(foo, 'prototype').value) {
|
||||
$ERROR("A function.prototype's descriptor lies");
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description Function.prototype.bind must exist
|
||||
*/
|
||||
|
||||
if (!('bind' in Function.prototype)) {
|
||||
$ERROR('Function.prototype.bind is missing');
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description Function.prototype.bind call the original's internal
|
||||
* [[Call]] method rather than its .apply method.
|
||||
*/
|
||||
|
||||
function foo() {}
|
||||
|
||||
var b = foo.bind(33, 44);
|
||||
foo.apply = function() {
|
||||
$ERROR("Function.prototype.bind called original's .apply method");
|
||||
};
|
||||
b(55, 66);
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description Function.prototype.bind must curry [[Construct]] as
|
||||
* well as [[Call]].
|
||||
*/
|
||||
function construct(f, args) {
|
||||
var bound = Function.prototype.bind.apply(f, [null].concat(args));
|
||||
return new bound();
|
||||
}
|
||||
var d = construct(Date, [1957, 5, 27]);
|
||||
if (Object.prototype.toString.call(d) !== '[object Date]') {
|
||||
$ERROR('Using the Date constructor via .bind did not create a Date.');
|
||||
}
|
Loading…
Reference in New Issue