Bug 496923 - Import the ch14 tests from test262. r=generating-script-was-reviewed

--HG--
extra : rebase_source : 7146eb81941b66910c45fcc2491c2c2be28a597c
This commit is contained in:
Jeff Walden 2013-06-19 12:25:51 -07:00
parent 1c925b908b
commit 1d8fb877a4
30 changed files with 575 additions and 0 deletions

View File

@ -0,0 +1,35 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* FunctionExpression must be localed in a reacheable fragment of the program
*
* @path ch14/14.0/S14_A1.js
* @description Declaring a function within an "if" Expression
*/
var THERE = "I'm there";
var HERE = "I'm here";
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
if ( __func !== undefined) {
$ERROR('#1: __func === undefined. Actual: __func ==='+ __func );
}
//
//////////////////////////////////////////////////////////////////////////////
if (true){
var __func = function(){return HERE;};
} else {
var __func = function (){return THERE;};
};
//////////////////////////////////////////////////////////////////////////////
//CHECK#2
if (__func() !== HERE) {
$ERROR('#2: __func() === HERE. Actual: __func() ==='+ __func() );
}
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,31 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* FunctionDeclaration cannot be localed inside an Expression
*
* @path ch14/14.0/S14_A2.js
* @description Declaring a function within an "if" Expression
*/
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
if (typeof f !== 'undefined') {
$ERROR('#1: typeof f === \'undefined\'. Actual: typeof f ==='+ typeof f );
}
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//CHECK#2
if (function f(arg){
if (arg===0)
return 1;
else
return f(arg-1)*arg;
}(3)!==6) {
$ERROR('#2: FunctionDeclaration cannot be localed inside an Expression');
};
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,30 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* Global FunctionDeclaration cannot be defined within the body of another FunctionDeclaration
*
* @path ch14/14.0/S14_A3.js
* @description Declaring a function within the body of another function
*/
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
if (typeof __func !== "function") {
$ERROR('#1: typeof __func === "function". Actual: typeof __func ==='+ typeof __func );
}
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//CHECK#2
if (typeof __gunc !== "undefined") {
$ERROR('#2: typeof __gunc === "undefined". Actual: typeof __gunc ==='+ typeof __gunc );
}
//
//////////////////////////////////////////////////////////////////////////////
function __func(){
function __gunc(){return true};
}

View File

@ -0,0 +1,22 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* The Identifer within a FunctionDeclaration can be written in both letters and unicode
*
* @path ch14/14.0/S14_A5_T1.js
* @description Declaring a function with "function __\u0066\u0075\u006e\u0063(){return "both"}"
*/
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
if (__func() !== "both") {
$ERROR('#1: __func() === "both". Actual: __func() ==='+ __func() );
}
//
//////////////////////////////////////////////////////////////////////////////
function __func(){return "ascii"};
function \u005f\u005f\u0066\u0075\u006e\u0063(){return "unicode"};//__func in unicode
function __\u0066\u0075\u006e\u0063(){return "both"};//__func in unicode

View File

@ -0,0 +1,21 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* The Identifer within a FunctionDeclaration can be written in both letters and unicode
*
* @path ch14/14.0/S14_A5_T2.js
* @description Declaring a function with "function \u005f\u005f\u0066\u0075\u006e\u0063(){return "unicode"}"
*/
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
if (__func() !== "unicode") {
$ERROR('#1: __func() === "unicode". Actual: __func() ==='+ __func() );
}
//
//////////////////////////////////////////////////////////////////////////////
function __func(){return "ascii"};
function \u005f\u005f\u0066\u0075\u006e\u0063(){return "unicode"};//__func in unicode

View File

View File

@ -0,0 +1,23 @@
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
/// "Use Terms"). Any redistribution of this code must retain the above
/// copyright and this notice and otherwise comply with the Use Terms.
/**
* @path ch14/14.1/14.1-1-s.js
* @description 'use strict' directive - correct usage
* @noStrict
*/
function testcase() {
function foo()
{
'use strict';
return(this === undefined);
}
return foo.call(undefined);
}
runTestCase(testcase);

View File

@ -0,0 +1,24 @@
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
/// "Use Terms"). Any redistribution of this code must retain the above
/// copyright and this notice and otherwise comply with the Use Terms.
/**
* @path ch14/14.1/14.1-10-s.js
* @description other directives - may follow 'use strict' directive
* @noStrict
*/
function testcase() {
function foo()
{
"use strict";
"bogus directive";
return (this === undefined);
}
return foo.call(undefined);
}
runTestCase(testcase);

View File

@ -0,0 +1,26 @@
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
/// "Use Terms"). Any redistribution of this code must retain the above
/// copyright and this notice and otherwise comply with the Use Terms.
/**
* @path ch14/14.1/14.1-11-s.js
* @description comments may preceed 'use strict' directive
* @noStrict
*/
function testcase() {
function foo()
{
// comment
/* comment */ "use strict";
return(this === undefined);
}
return foo.call(undefined);
}
runTestCase(testcase);

View File

@ -0,0 +1,24 @@
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
/// "Use Terms"). Any redistribution of this code must retain the above
/// copyright and this notice and otherwise comply with the Use Terms.
/**
* @path ch14/14.1/14.1-12-s.js
* @description comments may follow 'use strict' directive
* @noStrict
*/
function testcase() {
function foo()
{
"use strict"; /* comment */ // comment
return (this === undefined);
}
return foo.call(undefined);
}
runTestCase(testcase);

View File

@ -0,0 +1,23 @@
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
/// "Use Terms"). Any redistribution of this code must retain the above
/// copyright and this notice and otherwise comply with the Use Terms.
/**
* @path ch14/14.1/14.1-13-s.js
* @description semicolon insertion works for'use strict' directive
* @noStrict
*/
function testcase() {
function foo()
{
"use strict"
return (this === undefined);
}
return foo.call(undefined);
}
runTestCase(testcase);

View File

@ -0,0 +1,24 @@
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
/// "Use Terms"). Any redistribution of this code must retain the above
/// copyright and this notice and otherwise comply with the Use Terms.
/**
* @path ch14/14.1/14.1-14-s.js
* @description semicolon insertion may come before 'use strict' directive
* @noStrict
*/
function testcase() {
function foo()
{
"another directive"
"use strict" ;
return (this === undefined);
}
return foo.call(undefined);
}
runTestCase(testcase);

View File

@ -0,0 +1,29 @@
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
/// "Use Terms"). Any redistribution of this code must retain the above
/// copyright and this notice and otherwise comply with the Use Terms.
/**
* @path ch14/14.1/14.1-15-s.js
* @description blank lines may come before 'use strict' directive
* @noStrict
*/
function testcase() {
function foo()
{
"use strict" ;
return (this === undefined);
}
return foo.call(undefined);
}
runTestCase(testcase);

View File

@ -0,0 +1,23 @@
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
/// "Use Terms"). Any redistribution of this code must retain the above
/// copyright and this notice and otherwise comply with the Use Terms.
/**
* @path ch14/14.1/14.1-16-s.js
* @description 'use strict' directive - not recognized if it follow an empty statement
* @noStrict
*/
function testcase() {
function foo()
{
; 'use strict';
return (this !== undefined);
}
return foo.call(undefined);
}
runTestCase(testcase);

View File

@ -0,0 +1,23 @@
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
/// "Use Terms"). Any redistribution of this code must retain the above
/// copyright and this notice and otherwise comply with the Use Terms.
/**
* @path ch14/14.1/14.1-17-s.js
* @description 'use strict' directive - not recognized if it follow some other statment empty statement
* @noStrict
*/
function testcase() {
function foo()
{
var x;
'use strict';
return (this !== undefined);
}
return foo.call(undefined);
}
runTestCase(testcase);

View File

@ -0,0 +1,23 @@
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
/// "Use Terms"). Any redistribution of this code must retain the above
/// copyright and this notice and otherwise comply with the Use Terms.
/**
* @path ch14/14.1/14.1-2-s.js
* @description "use strict" directive - correct usage double quotes
* @noStrict
*/
function testcase() {
function foo()
{
"use strict";
return (this === undefined);
}
return foo.call(undefined);
}
runTestCase(testcase);

View File

@ -0,0 +1,23 @@
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
/// "Use Terms"). Any redistribution of this code must retain the above
/// copyright and this notice and otherwise comply with the Use Terms.
/**
* @path ch14/14.1/14.1-3-s.js
* @description 'use strict' directive - not recognized if it contains extra whitespace
* @noStrict
*/
function testcase() {
function foo()
{
' use strict ';
return (this !== undefined);
}
return foo.call(undefined);
}
runTestCase(testcase);

View File

@ -0,0 +1,24 @@
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
/// "Use Terms"). Any redistribution of this code must retain the above
/// copyright and this notice and otherwise comply with the Use Terms.
/**
* @path ch14/14.1/14.1-4-s.js
* @description 'use strict' directive - not recognized if contains Line Continuation
* @noStrict
*/
function testcase() {
function foo()
{
'use str\
ict';
return (this !== undefined);
}
return foo.call(undefined);
}
runTestCase(testcase);

View File

@ -0,0 +1,14 @@
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
/// "Use Terms"). Any redistribution of this code must retain the above
/// copyright and this notice and otherwise comply with the Use Terms.
/**
* @path ch14/14.1/14.1-4gs.js
* @description StrictMode - a Use Strict Directive followed by a strict mode violation
* @onlyStrict
* @negative ^((?!NotEarlyError).)*$
*/
"use strict";
throw NotEarlyError;
eval = 42;

View File

@ -0,0 +1,23 @@
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
/// "Use Terms"). Any redistribution of this code must retain the above
/// copyright and this notice and otherwise comply with the Use Terms.
/**
* @path ch14/14.1/14.1-5-s.js
* @description 'use strict' directive - not recognized if contains a EscapeSequence
* @noStrict
*/
function testcase() {
function foo()
{
'use\u0020strict';
return(this !== undefined);
}
return foo.call(undefined);
}
runTestCase(testcase);

View File

@ -0,0 +1,16 @@
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
/// "Use Terms"). Any redistribution of this code must retain the above
/// copyright and this notice and otherwise comply with the Use Terms.
/**
* @path ch14/14.1/14.1-5gs.js
* @description StrictMode - a Use Strict Directive embedded in a directive prologue followed by a strict mode violation
* @onlyStrict
* @negative ^((?!NotEarlyError).)*$
*/
"a";
"use strict";
"c";
throw NotEarlyError;
eval = 42;

View File

@ -0,0 +1,23 @@
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
/// "Use Terms"). Any redistribution of this code must retain the above
/// copyright and this notice and otherwise comply with the Use Terms.
/**
* @path ch14/14.1/14.1-6-s.js
* @description 'use strict' directive - not recognized if contains a <TAB> instead of a space
* @noStrict
*/
function testcase() {
function foo()
{
'use strict';
return (this !== undefined);
}
return foo.call(undefined);
}
runTestCase(testcase);

View File

@ -0,0 +1,23 @@
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
/// "Use Terms"). Any redistribution of this code must retain the above
/// copyright and this notice and otherwise comply with the Use Terms.
/**
* @path ch14/14.1/14.1-7-s.js
* @description 'use strict' directive - not recognized if upper case
* @noStrict
*/
function testcase() {
function foo()
{
'Use Strict';
return (this !== undefined);
}
return foo.call(undefined);
}
runTestCase(testcase);

View File

@ -0,0 +1,24 @@
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
/// "Use Terms"). Any redistribution of this code must retain the above
/// copyright and this notice and otherwise comply with the Use Terms.
/**
* @path ch14/14.1/14.1-8-s.js
* @description 'use strict' directive - may follow other directives
* @noStrict
*/
function testcase() {
function foo()
{
"bogus directive";
"use strict";
return (this === undefined);
}
return foo.call(undefined);
}
runTestCase(testcase);

View File

@ -0,0 +1,24 @@
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
/// "Use Terms"). Any redistribution of this code must retain the above
/// copyright and this notice and otherwise comply with the Use Terms.
/**
* @path ch14/14.1/14.1-9-s.js
* @description 'use strict' directive - may occur multiple times
* @noStrict
*/
function testcase() {
function foo()
{
'use strict';
"use strict";
return (this === undefined);
}
return foo.call(undefined);
}
runTestCase(testcase);

View File

View File

View File