Skip to content
Snippets Groups Projects
Commit febe8b34 authored by David Fugate's avatar David Fugate
Browse files

Ported Sputnik changes over from the 'external' directory to...

Ported Sputnik changes over from the 'external' directory to 'test/suite/sputnik'.  Still need to convert
the tests over to test262 format.
parent a7e6453c
No related branches found
No related tags found
No related merge requests found
Showing
with 302 additions and 71 deletions
// Copyright 2009 the Sputnik authors. All rights reserved. // Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/** /**
* @name: S12.6.1_A1; * @name: S12.6.1_A1;
* @section: 12.6.1; * @section: 12.6.1;
* @assertion: When the production "do Statement while ( Expression )" is evaluated, Statement is evaluated first; * @assertion: When the production "do Statement while ( Expression )" is evaluated, Statement is evaluated first;
* @description: Evaluating various Expressions; * @description: Evaluating various Expressions;
*/ */
do __in__do=1; while ( false ); var __in__do;
////////////////////////////////////////////////////////////////////////////// do __in__do=1; while ( false );
//CHECK#1
if (__in__do!==1) { //////////////////////////////////////////////////////////////////////////////
$ERROR('#1: false evaluates to false'); //CHECK#1
} if (__in__do!==1) {
// $ERROR('#1: false evaluates to false');
////////////////////////////////////////////////////////////////////////////// }
//
do __in__do=2; while ( 0 ); //////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// do __in__do=2; while ( 0 );
//CHECK#2
if (__in__do!==2) { //////////////////////////////////////////////////////////////////////////////
$ERROR('#2: 0 evaluates to false'); //CHECK#2
} if (__in__do!==2) {
// $ERROR('#2: 0 evaluates to false');
////////////////////////////////////////////////////////////////////////////// }
//
do __in__do=3; while ( "" ); //////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// do __in__do=3; while ( "" );
//CHECK#3
if (__in__do!==3) { //////////////////////////////////////////////////////////////////////////////
$ERROR('#3: "" evaluates to false'); //CHECK#3
} if (__in__do!==3) {
// $ERROR('#3: "" evaluates to false');
////////////////////////////////////////////////////////////////////////////// }
//
//////////////////////////////////////////////////////////////////////////////
// Copyright 2009 the Sputnik authors. All rights reserved. // Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/** /**
* @name: S12.6.1_A13_T1; * @name: S12.6.1_A13_T1;
* @section: 12.6.1, 13; * @section: 12.6.1, 13;
* @assertion: FunctionDeclaration within a "do-while" Block is not allowed; * @assertion: FunctionDeclaration within a "do-while" Block in strict
* @description: Declaring function within a "do-while" loop; * code is not allowed;
* @negative; * @description: Declaring function within a "do-while" loop;
*/ * @negative SyntaxError;
*/
do{
function __func(){}; "use strict";
} while(0); if (!strict_mode) { throw new SyntaxError('unspecified case'); }
do{
function __func(){};
} while(0);
// Copyright 2009 the Sputnik authors. All rights reserved. // Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/** /**
* @name: S12.6.1_A13_T2; * @name: S12.6.1_A13_T2;
* @section: 12.6.1, 13; * @section: 12.6.1, 13;
* @assertion: FunctionDeclaration within a "do-while" Block is not allowed; * @assertion: FunctionDeclaration within a "do-while" Block in strict
* @description: Declaring a function within a "do-while" loop that is within a function call; * code is not allowed;
* @negative; * @description: Declaring a function within a "do-while" loop that is
*/ * within a strict function;
* @negative SyntaxError;
(function(){ */
do{ (function(){
function __func(){}; "use strict";
}while(0); do{
function __func(){};
})(); }while(0);
});
// 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.2_A12;
* @section: 15.2.4.2;
* @assertion: If the this value is undefined, return "[object Undefined]".
*/
if (Object.prototype.toString.call(undefined) !== "[object Undefined]") {
$ERROR('If the this value is undefined, return "[object Undefined]".');
}
// 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.2_A13;
* @section: 15.2.4.2;
* @assertion: If the this value is null, return "[object Null]".
*/
if (Object.prototype.toString.call(null) !== "[object Null]") {
$ERROR('If the this value is null, return "[object Null]".');
}
// 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.2_A14;
* @section: 15.2.4.2;
* @assertion: Let O be the result of calling ToObject passing the this
* value as the argument.
*/
if (Object.prototype.toString.call(33) !== "[object Number]") {
$ERROR('Let O be the result of calling ToObject passing the this ' +
'value as the argument.');
}
// 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.2_A15;
* @section: 15.2.4.2;
* @assertion: Let O be the result of calling ToObject passing the this
* value as the argument.
*/
if (Object.prototype.toString.call(true) !== "[object Boolean]") {
$ERROR('Let O be the result of calling ToObject passing the this ' +
'value as the argument.');
}
// 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.2_A16;
* @section: 15.2.4.2;
* @assertion: Let O be the result of calling ToObject passing the this
* value as the argument.
*/
if (Object.prototype.toString.call('foo') !== "[object String]") {
$ERROR('Let O be the result of calling ToObject passing the this ' +
'value as the argument.');
}
// 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.3_A12;
* @section: 15.2.4.3;
* @assertion: Let O be the result of calling ToObject passing the this
* value as the argument.
* @negative
*/
Object.prototype.toLocaleString.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.2.4.3_A13;
* @section: 15.2.4.3;
* @assertion: Let O be the result of calling ToObject passing the this
* value as the argument.
* @negative
*/
Object.prototype.toLocaleString.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.2.4.4_A12;
* @section: 15.2.4.4;
* @assertion: Let O be the result of calling ToObject passing the this
* value as the argument.
* @negative
*/
Object.prototype.valueOf.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.2.4.4_A13;
* @section: 15.2.4.4;
* @assertion: Let O be the result of calling ToObject passing the this
* value as the argument.
* @negative
*/
Object.prototype.valueOf.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.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.2.4.5_A12;
* @section: 15.2.4.5;
* @assertion: Let O be the result of calling ToObject passing the this
* value as the argument.
* @negative
*/
Object.prototype.hasOwnProperty.call(undefined, 'foo');
// 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.5_A13;
* @section: 15.2.4.5;
* @assertion: Let O be the result of calling ToObject passing the this
* value as the argument.
* @negative
*/
Object.prototype.hasOwnProperty.call(null, 'foo');
// 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.6_A12;
* @section: 15.2.4.6;
* @assertion: Let O be the result of calling ToObject passing the this
* value as the argument.
* @negative
*/
Object.prototype.isPrototypeOf.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.2.4.6_A13;
* @section: 15.2.4.6;
* @assertion: Let O be the result of calling ToObject passing the this
* value as the argument.
* @negative
*/
Object.prototype.isPrototypeOf.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.2.4.7_A12;
* @section: 15.2.4.7;
* @assertion: Let O be the result of calling ToObject passing the this
* value as the argument.
* @negative
*/
Object.prototype.propertyIsEnumerable.call(undefined, 'foo');
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