Skip to content
Snippets Groups Projects
Commit a7e6453c authored by Mark Miller's avatar Mark Miller
Browse files

Adding new files from sputniktests r97

parent a2306182
No related branches found
No related tags found
No related merge requests found
Showing
with 293 additions and 0 deletions
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.10.6.2_A12;
* @section: 15.10.6.2;
* @assertion: regExp exec() acts like regExp.exec('undefined') (step 2);
* @description: Checking RegExp.prototype.exec.length;
*/
(/foo/).test('xfoox');
var match = new RegExp('(.|\r|\n)*','').exec()[0];
if (match === 'xfoox') {
$FAIL('#1: regExp.exec() leaks match globally');
}
if (match !== 'undefined') {
$FAIL('#2: regExp.exec() must coerce absent first arg to "undefined"');
}
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.12.2_A1;
* @section: 15.12.2;
* @assertion: JSON.parse must create a property with the given
* property name;
* @description: Tests that JSON.parse treats "__proto__" as a regular
* property name;
*/
var x = JSON.parse('{"__proto__":[]}');
if (Object.getPrototypeOf(x) !== Object.prototype) {
$FAIL('#1: JSON.parse confused by "__proto__"');
}
if (!Array.isArray(x.__proto__)) {
$FAIL('#2: JSON.parse did not set "__proto__" as a regular property');
}
// 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.
* @negative
*/
(1,Object.prototype.valueOf)();
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.3.4.2_A12;
* @section: 15.3.4.2;
* @assertion: The Function.prototype.toString function is not generic;
* it throws a TypeError exception if its this value is not
* a Function object.
* @negative TypeError;
*/
Function.prototype.toString.call(undefined);
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.3.4.2_A13;
* @section: 15.3.4.2;
* @assertion: The toString function is not generic; it throws a
* TypeError exception if its this value is not a Function
* object.
* @negative TypeError;
*/
Function.prototype.toString.call(null);
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.3.4.2_A14;
* @section: 15.3.4.2;
* @assertion: The toString function is not generic; it throws a
* TypeError exception if its this value is not a Function
* object.
* @negative TypeError;
*/
Function.prototype.toString.call({});
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.3.4.2_A15;
* @section: 15.3.4.2;
* @assertion: The toString function is not generic; it throws a
* TypeError exception if its this value is not a Function
* object.
* @description: Whether or not they are callable, RegExp objects are
* not Function objects, so toString should throw a
* TypeError.
* @negative TypeError;
*/
Function.prototype.toString.call(/x/);
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.3.4.2_A16;
* @section: 15.3.4.2;
* @assertion: The toString function is not generic; it throws a
* TypeError exception if its this value is not a Function
* object.
* @description: The String constructor, given an object, should invoke
* that object's toString method as a method, i.e., with
* its this value bound to that object.
* @negative TypeError;
*/
var obj = {toString: Function.prototype.toString};
String(obj);
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.3.4.3_A13;
* @section: 15.3.4.3;
* @assertion: If IsCallable(func) is false, then throw a TypeError exception.
* @negative TypeError;
*/
Function.prototype.apply.call(undefined, {}, []);
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.3.4.3_A14;
* @section: 15.3.4.3;
* @assertion: If IsCallable(func) is false, then throw a TypeError exception.
* @negative TypeError;
*/
Function.prototype.apply.call(null, {}, []);
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.3.4.3_A15;
* @section: 15.3.4.3;
* @assertion: If IsCallable(func) is false, then throw a TypeError exception.
* @negative TypeError;
*/
Function.prototype.apply.call({}, {}, []);
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.3.4.3_A16;
* @section: 15.3.4.3;
* @assertion: If IsCallable(func) is false, then throw a TypeError exception.
* @description: A RegExp is not a function, but it may be
* callable. Iff it is, it's typeof should be 'function',
* in which case apply should accept it as a valid this
* value.
*/
var re = (/x/);
if (typeof re === 'function') {
Function.prototype.apply.call(re, undefined, ['x']);
} else {
try {
Function.prototype.bind.call(re, undefined);
$FAIL('#1: If IsCallable(func) is false, ' +
'then (bind should) throw a TypeError exception');
} catch (e) {
if (!(e instanceof TypeError)) {
$ERROR('#1: TypeError expected. Actual: ' + e);
}
}
}
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.3.4.4_A13;
* @section: 15.3.4.4;
* @assertion: If IsCallable(func) is false, then throw a TypeError exception.
* @negative TypeError;
*/
Function.prototype.call.call(undefined, {});
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.3.4.4_A14;
* @section: 15.3.4.4;
* @assertion: If IsCallable(func) is false, then throw a TypeError exception.
* @negative TypeError;
*/
Function.prototype.call.call(null, {});
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.3.4.4_A15;
* @section: 15.3.4.4;
* @assertion: If IsCallable(func) is false, then throw a TypeError exception.
* @negative TypeError;
*/
Function.prototype.call.call({}, {});
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.3.4.4_A16;
* @section: 15.3.4.4;
* @assertion: If IsCallable(func) is false, then throw a TypeError exception.
* @description: A RegExp is not a function, but it may be
* callable. Iff it is, it's typeof should be 'function',
* in which case call should accept it as a valid this
* value.
*/
var re = (/x/);
if (typeof re === 'function') {
Function.prototype.call.call(re, undefined, 'x');
} else {
try {
Function.prototype.bind.call(re, undefined);
$FAIL('#1: If IsCallable(func) is false, ' +
'then (bind should) throw a TypeError exception');
} catch (e) {
if (!(e instanceof TypeError)) {
$ERROR('#1: TypeError expected. Actual: ' + e);
}
}
}
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.3.4.5_A1;
* @section: 15.3.4.5;
* @assertion: "caller" of bound function is poisoned (step 20);
* @description A bound function should fail to find its "caller";
* @negative TypeError;
*/
function foo() { return bar.caller; }
var bar = foo.bind({});
function baz() { return bar(); }
baz();
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.3.4.5_A13;
* @section: 15.3.4.5;
* @assertion: If IsCallable(func) is false, then throw a TypeError exception.
* @negative TypeError;
*/
Function.prototype.bind.call(undefined, {});
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.3.4.5_A14;
* @section: 15.3.4.5;
* @assertion: If IsCallable(func) is false, then throw a TypeError exception.
* @negative TypeError;
*/
Function.prototype.bind.call(null, {});
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.3.4.5_A15;
* @section: 15.3.4.5;
* @assertion: If IsCallable(func) is false, then throw a TypeError exception.
* @negative TypeError;
*/
Function.prototype.bind.call({}, {});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment