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 115 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.3.4.5_A16;
* @section: 15.3.4.5;
* @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 bind should accept it as a valid this
* value.
*/
var re = (/x/);
if (typeof re === 'function') {
Function.prototype.bind.call(re, undefined);
} 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: "arguments" of bound function is poisoned (step 21);
* @description a bound function should fail to find the bound function
* "arguments";
* @negative TypeError;
*/
function foo() { return bar.arguments; }
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.4.4.11_A8;
* @section: 15.4.4.11;
* @assertion: Call the comparefn passing undefined as the this value
* (step 13b);
* @description: comparefn tests that its this value is undefined;
*/
var global = this;
[2,3].sort(function(x,y) {
"use strict";
if (this === global) {
$FAIL('#1: Sort leaks global');
}
if (this !== undefined) {
$FAIL('#2: Sort comparefn should be called with this===undefined. ' +
'Actual: ' + this);
}
return x - y;
});
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.4.4.18_A1;
* @section: 15.4.4.18;
* @assertion: array.forEach can be frozen while in progress
* @description: Freezes array.forEach during a forEach to see if it works
*/
['z'].forEach(function(){ Object.freeze(Array.prototype.forEach); });
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.4.4.18_A2;
* @section: 15.4.4.18;
* @assertion: array.forEach can be frozen while in progress
* @description: Freezes array.forEach during a forEach to see if it works
*/
function foo() {
['z'].forEach(function(){ Object.freeze(Array.prototype.forEach); });
}
foo();
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.5.4.11_A12;
* @section: 15.5.4.11;
* @assertion: Call replaceValue passing undefined as the this value;
* @description: replaceValue tests that its this value is undefined;
*/
var global = this;
'x'.replace(/x/, function() {
"use strict";
if (this === global) {
$FAIL('#1: String replace leaks global');
}
if (this !== undefined) {
$FAIL('#2: replaceValue should be called with this===undefined. ' +
'Actual: ' + this);
}
return 'y';
});
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