Bug 1377007 - Tests: Parsing ECMA2-level tests with binjs;r=arai,jorendorff

MozReview-Commit-ID: 2DysquT2BdD

--HG--
extra : rebase_source : cd56946621b1000b9c66f8d18ba2d9278c96c7e1
This commit is contained in:
David Teller 2017-09-19 20:50:21 +02:00
parent a10a129c43
commit e60e582ffe
329 changed files with 10509 additions and 21 deletions

View File

@ -307,6 +307,7 @@ js/xpconnect/**
js/src/devtools/**
js/src/octane/**
js/src/jit-test/**
js/src/jsapi-tests/binast/**
js/src/tests/**
js/src/Y.js

View File

@ -0,0 +1,73 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* File Name: StrictEquality-001.js
* ECMA Section: 11.9.6.js
* Description:
*
* Author: christine@netscape.com
* Date: 4 september 1998
*/
var SECTION = "StrictEquality-001 - 11.9.6";
var VERSION = "ECMA_2";
var TITLE = "The strict equality operator ( === )";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// 1. If Type(x) is different from Type(y) return false
StrictEquality( true, new Boolean(true), false );
StrictEquality( new Boolean(), false, false );
StrictEquality( "", new String(), false );
StrictEquality( new String("hi"), "hi", false );
// 2. If Type(x) is not Number go to step 9.
// 3. If x is NaN, return false
StrictEquality( NaN, NaN, false );
StrictEquality( NaN, 0, false );
// 4. If y is NaN, return false.
StrictEquality( 0, NaN, false );
// 5. if x is the same number value as y, return true
// 6. If x is +0 and y is -0, return true
// 7. If x is -0 and y is +0, return true
// 8. Return false.
// 9. If Type(x) is String, then return true if x and y are exactly
// the same sequence of characters ( same length and same characters
// in corresponding positions.) Otherwise return false.
// 10. If Type(x) is Boolean, return true if x and y are both true or
// both false. otherwise return false.
// Return true if x and y refer to the same object. Otherwise return
// false.
// Return false.
test();
function StrictEquality( x, y, expect ) {
result = ( x === y );
new TestCase(
SECTION,
x +" === " + y,
expect,
result );
}

View File

@ -0,0 +1,29 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
print("STATUS: f.apply crash test.");
print("BUGNUMBER: 21836");
function f ()
{
}
var SECTION = "apply-001-n";
var VERSION = "ECMA_1";
startTest();
var TITLE = "f.apply(2,2) doesn't crash";
writeHeaderToLog( SECTION + " "+ TITLE);
DESCRIPTION = "f.apply(2,2) doesn't crash";
EXPECTED = "error";
new TestCase( SECTION, "f.apply(2,2) doesn't crash", "error", eval("f.apply(2,2)") );
test();

View File

@ -0,0 +1,47 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: boolean-001.js
Description: Corresponds to ecma/Boolean/15.6.4.2-4-n.js
The toString function is not generic; it generates
a runtime error if its this value is not a Boolean
object. Therefore it cannot be transferred to other
kinds of objects for use as a method.
Author: christine@netscape.com
Date: june 27, 1997
*/
var SECTION = "boolean-001.js";
var VERSION = "JS1_4";
var TITLE = "Boolean.prototype.toString()";
startTest();
writeHeaderToLog( SECTION +" "+ TITLE );
var exception = "No exception thrown";
var result = "Failed";
var TO_STRING = Boolean.prototype.toString;
try {
var s = new String("Not a Boolean");
s.toString = TO_STRING;
s.toString();
} catch ( e ) {
result = "Passed!";
exception = e.toString();
}
new TestCase(
SECTION,
"Assigning Boolean.prototype.toString to a String object "+
"(threw " +exception +")",
"Passed!",
result );
test();

View File

@ -0,0 +1,51 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: boolean-001.js
Description: Corresponds to ecma/Boolean/15.6.4.3-4-n.js
15.6.4.3 Boolean.prototype.valueOf()
Returns this boolean value.
The valueOf function is not generic; it generates
a runtime error if its this value is not a Boolean
object. Therefore it cannot be transferred to other
kinds of objects for use as a method.
Author: christine@netscape.com
Date: 09 september 1998
*/
var SECTION = "boolean-002.js";
var VERSION = "JS1_4";
var TITLE = "Boolean.prototype.valueOf()";
startTest();
writeHeaderToLog( SECTION +" "+ TITLE );
var exception = "No exception thrown";
var result = "Failed";
var VALUE_OF = Boolean.prototype.valueOf;
try {
var s = new String("Not a Boolean");
s.valueOf = VALUE_0F;
s.valueOf();
} catch ( e ) {
result = "Passed!";
exception = e.toString();
}
new TestCase(
SECTION,
"Assigning Boolean.prototype.valueOf to a String object "+
"(threw " +exception +")",
"Passed!",
result );
test();

Binary file not shown.

View File

@ -0,0 +1,42 @@
/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: call-1.js
Section: Function.prototype.call
Description:
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "call-1";
var VERSION = "ECMA_2";
var TITLE = "Function.prototype.call";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
new TestCase( SECTION,
"ConvertToString.call(this, this)",
GLOBAL,
ConvertToString.call(this, this));
new TestCase( SECTION,
"ConvertToString.call(Boolean, Boolean.prototype)",
"false",
ConvertToString.call(Boolean, Boolean.prototype));
new TestCase( SECTION,
"ConvertToString.call(Boolean, Boolean.prototype.valueOf())",
"false",
ConvertToString.call(Boolean, Boolean.prototype.valueOf()));
test();
function ConvertToString(obj) {
return obj +"";
}

View File

@ -0,0 +1,66 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* File Name: RegExp/constructor-001.js
* ECMA Section: 15.7.3.3
* Description: Based on ECMA 2 Draft 7 February 1999
*
* Author: christine@netscape.com
* Date: 19 February 1999
*/
var SECTION = "RegExp/constructor-001";
var VERSION = "ECMA_2";
var TITLE = "new RegExp()";
startTest();
/*
* for each test case, verify:
* - verify that [[Class]] property is RegExp
* - prototype property should be set to RegExp.prototype
* - source is set to the empty string
* - global property is set to false
* - ignoreCase property is set to false
* - multiline property is set to false
* - lastIndex property is set to 0
*/
RegExp.prototype.getClassProperty = Object.prototype.toString;
var re = new RegExp();
AddTestCase(
"RegExp.prototype.getClassProperty = Object.prototype.toString; " +
"(new RegExp()).getClassProperty()",
"[object RegExp]",
re.getClassProperty() );
AddTestCase(
"(new RegExp()).source",
"(?:)",
re.source );
AddTestCase(
"(new RegExp()).global",
false,
re.global );
AddTestCase(
"(new RegExp()).ignoreCase",
false,
re.ignoreCase );
AddTestCase(
"(new RegExp()).multiline",
false,
re.multiline );
AddTestCase(
"(new RegExp()).lastIndex",
0,
re.lastIndex );
test()

Binary file not shown.

View File

@ -0,0 +1,54 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: date-002.js
Corresponds To: 15.9.5.23-3-n.js
ECMA Section: 15.9.5.23
Description: Date.prototype.setTime
1. If the this value is not a Date object, generate a runtime error.
2. Call ToNumber(time).
3. Call TimeClip(Result(1)).
4. Set the [[Value]] property of the this value to Result(2).
5. Return the value of the [[Value]] property of the this value.
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "date-002";
var VERSION = "JS1_4";
var TITLE = "Date.prototype.setTime()";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var result = "Failed";
var exception = "No exception thrown";
var expect = "Passed";
try {
var MYDATE = new MyDate();
result = MYDATE.setTime(0);
} catch ( e ) {
result = expect;
exception = e.toString();
}
new TestCase(
SECTION,
"MYDATE = new MyDate(); MYDATE.setTime(0)" +
" (threw " + exception +")",
expect,
result );
test();
function MyDate(value) {
this.value = value;
this.setTime = Date.prototype.setTime;
return this;
}

Binary file not shown.

View File

@ -0,0 +1,56 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: date-003.js
Corresponds To 15.9.5.3-1.js
ECMA Section: 15.9.5.3-1 Date.prototype.valueOf
Description:
The valueOf function returns a number, which is this time value.
The valueOf function is not generic; it generates a runtime error if
its this value is not a Date object. Therefore it cannot be transferred
to other kinds of objects for use as a method.
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "date-003";
var VERSION = "JS1_4";
var TITLE = "Date.prototype.valueOf";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var result = "Failed";
var exception = "No exception thrown";
var expect = "Passed";
try {
var OBJ = new MyObject( new Date(0) );
result = OBJ.valueOf();
} catch ( e ) {
result = expect;
exception = e.toString();
}
new TestCase(
SECTION,
"OBJ = new MyObject( new Date(0)); OBJ.valueOf()" +
" (threw " + exception +")",
expect,
result );
test();
function MyObject( value ) {
this.value = value;
this.valueOf = Date.prototype.valueOf;
// The following line causes an infinte loop
// this.toString = new Function( "return this+\"\";");
return this;
}

Binary file not shown.

View File

@ -0,0 +1,50 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: date-004.js
Corresponds To: 15.9.5.4-2-n.js
ECMA Section: 15.9.5.4-1 Date.prototype.getTime
Description:
1. If the this value is not an object whose [[Class]] property is "Date",
generate a runtime error.
2. Return this time value.
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "date-004";
var VERSION = "JS1_4";
var TITLE = "Date.prototype.getTime";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var result = "Failed";
var exception = "No exception thrown";
var expect = "Passed";
try {
var MYDATE = new MyDate();
result = MYDATE.getTime();
} catch ( e ) {
result = expect;
exception = e.toString();
}
new TestCase(
SECTION,
"MYDATE = new MyDate(); MYDATE.getTime()" +
" (threw " + exception +")",
expect,
result );
test();
function MyDate( value ) {
this.value = value;
this.getTime = Date.prototype.getTime;
}

View File

@ -0,0 +1,44 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* File Name: dowhile-001
* ECMA Section:
* Description: do...while statements
*
*
*
* Author: christine@netscape.com
* Date: 11 August 1998
*/
var SECTION = "dowhile-002";
var VERSION = "ECMA_2";
var TITLE = "do...while with a labeled continue statement";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
LabeledContinue( 0, 1 );
LabeledContinue( 1, 1 );
LabeledContinue( -1, 1 );
LabeledContinue( 5, 5 );
test();
function LabeledContinue( limit, expect ) {
i = 0;
woohoo:
do {
i++;
continue woohoo;
} while ( i < limit );
new TestCase(
SECTION,
"do while ( " + i +" < " + limit +" )",
expect,
i );
}

View File

@ -0,0 +1,71 @@
/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* File Name: dowhile-002
* ECMA Section:
* Description: do...while statements
*
* Verify that code after a labeled break is not executed. Verify that
* a labeled break breaks you out of the whole labeled block, and not
* just the current iteration statement.
*
* Author: christine@netscape.com
* Date: 11 August 1998
*/
var SECTION = "dowhile-002";
var VERSION = "ECMA_2";
var TITLE = "do...while with a labeled continue statement";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
LabeledContinue( 0, 1 );
LabeledContinue( 1, 1 );
LabeledContinue( -1, 1 );
LabeledContinue( 5, 5 );
test();
// The labeled statement contains statements after the labeled break.
// Verify that the statements after the break are not executed.
function LabeledContinue( limit, expect ) {
i = 0;
result1 = "pass";
result2 = "pass";
woohoo: {
do {
i++;
if ( ! (i < limit) ) {
break woohoo;
result1 = "fail: evaluated statement after a labeled break";
}
} while ( true );
result2 = "failed: broke out of loop, but not out of labeled block";
}
new TestCase(
SECTION,
"do while ( " + i +" < " + limit +" )",
expect,
i );
new TestCase(
SECTION,
"breaking out of a do... while loop",
"pass",
result1 );
new TestCase(
SECTION,
"breaking out of a labeled do...while loop",
"pass",
result2 );
}

View File

@ -0,0 +1,63 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* File Name: dowhile-003
* ECMA Section:
* Description: do...while statements
*
* Test do while, when the while expression is a JavaScript Number object.
*
*
* Author: christine@netscape.com
* Date: 11 August 1998
*/
var SECTION = "dowhile-003";
var VERSION = "ECMA_2";
var TITLE = "do...while with a labeled continue statement";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
DoWhile( new DoWhileObject( 1, 1, 0 ));
DoWhile( new DoWhileObject( 1000, 1000, 0 ));
DoWhile( new DoWhileObject( 1001, 1001, 0 ));
DoWhile( new DoWhileObject( 1002, 1001, 1 ));
DoWhile( new DoWhileObject( -1, 1001, -1002 ));
test();
function DoWhileObject( value, iterations, endvalue ) {
this.value = value;
this.iterations = iterations;
this.endvalue = endvalue;
}
function DoWhile( object ) {
var i = 0;
do {
object.value = --object.value;
i++;
if ( i > 1000 )
break;
} while( object.value );
new TestCase(
SECTION,
"loop iterations",
object.iterations,
i
);
new TestCase(
SECTION,
"object.value",
object.endvalue,
Number( object.value )
);
}

View File

@ -0,0 +1,67 @@
/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* File Name: dowhile-004
* ECMA Section:
* Description: do...while statements
*
* Test a labeled do...while. Break out of the loop with no label
* should break out of the loop, but not out of the label.
*
* Author: christine@netscape.com
* Date: 11 August 1998
*/
var SECTION = "dowhile-004";
var VERSION = "ECMA_2";
var TITLE = "do...while with a labeled continue statement";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
DoWhile( 0, 1 );
DoWhile( 1, 1 );
DoWhile( -1, 1 );
DoWhile( 5, 5 );
test();
function DoWhile( limit, expect ) {
i = 0;
result1 = "pass";
result2 = "failed: broke out of labeled statement unexpectedly";
foo: {
do {
i++;
if ( ! (i < limit) ) {
break;
result1 = "fail: evaluated statement after a labeled break";
}
} while ( true );
result2 = "pass";
}
new TestCase(
SECTION,
"do while ( " + i +" < " + limit +" )",
expect,
i );
new TestCase(
SECTION,
"breaking out of a do... while loop",
"pass",
result1 );
new TestCase(
SECTION,
"breaking out of a labeled do...while loop",
"pass",
result2 );
}

View File

@ -0,0 +1,73 @@
/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* File Name: dowhile-005
* ECMA Section:
* Description: do...while statements
*
* Test a labeled do...while. Break out of the loop with no label
* should break out of the loop, but not out of the label.
*
* Currently causes an infinite loop in the monkey. Uncomment the
* print statement below and it works OK.
*
* Author: christine@netscape.com
* Date: 26 August 1998
*/
var SECTION = "dowhile-005";
var VERSION = "ECMA_2";
var TITLE = "do...while with a labeled continue statement";
var BUGNUMBER = "316293";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
NestedLabel();
test();
function NestedLabel() {
i = 0;
result1 = "pass";
result2 = "fail: did not hit code after inner loop";
result3 = "pass";
outer: {
do {
inner: {
// print( i );
break inner;
result1 = "fail: did break out of inner label";
}
result2 = "pass";
break outer;
print(i);
} while ( i++ < 100 );
}
result3 = "fail: did not break out of outer label";
new TestCase(
SECTION,
"number of loop iterations",
0,
i );
new TestCase(
SECTION,
"break out of inner loop",
"pass",
result1 );
new TestCase(
SECTION,
"break out of outer loop",
"pass",
result2 );
}

View File

@ -0,0 +1,89 @@
/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* File Name: dowhile-006
* ECMA Section:
* Description: do...while statements
*
* A general do...while test.
*
* Author: christine@netscape.com
* Date: 26 August 1998
*/
var SECTION = "dowhile-006";
var VERSION = "ECMA_2";
var TITLE = "do...while";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
DoWhile( new DoWhileObject( false, false, 10 ) );
DoWhile( new DoWhileObject( true, false, 2 ) );
DoWhile( new DoWhileObject( false, true, 3 ) );
DoWhile( new DoWhileObject( true, true, 4 ) );
test();
function looping( object ) {
object.iterations--;
if ( object.iterations <= 0 ) {
return false;
} else {
return true;
}
}
function DoWhileObject( breakOut, breakIn, iterations, loops ) {
this.iterations = iterations;
this.loops = loops;
this.breakOut = breakOut;
this.breakIn = breakIn;
this.looping = looping;
}
function DoWhile( object ) {
var result1 = false;
var result2 = false;
outie: {
innie: {
do {
if ( object.breakOut )
break outie;
if ( object.breakIn )
break innie;
} while ( looping(object) );
// statements should be executed if:
// do...while exits normally
// do...while exits abruptly with no label
result1 = true;
}
// statements should be executed if:
// do...while breaks out with label "innie"
// do...while exits normally
// do...while does not break out with "outie"
result2 = true;
}
new TestCase(
SECTION,
"hit code after loop in inner loop",
( object.breakIn || object.breakOut ) ? false : true ,
result1 );
new TestCase(
SECTION,
"hit code after loop in outer loop",
( object.breakOut ) ? false : true,
result2 );
}

View File

@ -0,0 +1,97 @@
/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* File Name: dowhile-007
* ECMA Section:
* Description: do...while statements
*
* A general do...while test.
*
* Author: christine@netscape.com
* Date: 26 August 1998
*/
var SECTION = "dowhile-007";
var VERSION = "ECMA_2";
var TITLE = "do...while";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
DoWhile( new DoWhileObject( false, false, false, false ));
DoWhile( new DoWhileObject( true, false, false, false ));
DoWhile( new DoWhileObject( true, true, false, false ));
DoWhile( new DoWhileObject( true, true, true, false ));
DoWhile( new DoWhileObject( true, true, true, true ));
DoWhile( new DoWhileObject( false, false, false, true ));
DoWhile( new DoWhileObject( false, false, true, true ));
DoWhile( new DoWhileObject( false, true, true, true ));
DoWhile( new DoWhileObject( false, false, true, false ));
test();
function DoWhileObject( out1, out2, out3, in1 ) {
this.breakOutOne = out1;
this.breakOutTwo = out2;
this.breakOutThree = out3;
this.breakIn = in1;
}
function DoWhile( object ) {
result1 = false;
result2 = false;
result3 = false;
result4 = false;
outie:
do {
if ( object.breakOutOne ) {
break outie;
}
result1 = true;
innie:
do {
if ( object.breakOutTwo ) {
break outie;
}
result2 = true;
if ( object.breakIn ) {
break innie;
}
result3 = true;
} while ( false );
if ( object.breakOutThree ) {
break outie;
}
result4 = true;
} while ( false );
new TestCase(
SECTION,
"break one: ",
(object.breakOutOne) ? false : true,
result1 );
new TestCase(
SECTION,
"break two: ",
(object.breakOutOne||object.breakOutTwo) ? false : true,
result2 );
new TestCase(
SECTION,
"break three: ",
(object.breakOutOne||object.breakOutTwo||object.breakIn) ? false : true,
result3 );
new TestCase(
SECTION,
"break four: ",
(object.breakOutOne||object.breakOutTwo||object.breakOutThree) ? false: true,
result4 );
}

View File

@ -0,0 +1,45 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* File Name: exception-001
* ECMA Section:
* Description: Tests for JavaScript Standard Exceptions
*
* Call error.
*
* Author: christine@netscape.com
* Date: 31 August 1998
*/
var SECTION = "exception-001";
var VERSION = "js1_4";
var TITLE = "Tests for JavaScript Standard Exceptions: CallError";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
Call_1();
test();
function Call_1() {
result = "failed: no exception thrown";
exception = null;
try {
Math();
} catch ( e ) {
result = "passed: threw exception",
exception = e.toString();
} finally {
new TestCase(
SECTION,
"Math() [ exception is " + exception +" ]",
"passed: threw exception",
result );
}
}

View File

@ -0,0 +1,45 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* File Name: exception-002
* ECMA Section:
* Description: Tests for JavaScript Standard Exceptions
*
* Construct error.
*
* Author: christine@netscape.com
* Date: 31 August 1998
*/
var SECTION = "exception-002";
var VERSION = "js1_4";
var TITLE = "Tests for JavaScript Standard Exceptions: ConstructError";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
Construct_1();
test();
function Construct_1() {
result = "failed: no exception thrown";
exception = null;
try {
result = new Math();
} catch ( e ) {
result = "passed: threw exception",
exception = e.toString();
} finally {
new TestCase(
SECTION,
"new Math() [ exception is " + exception +" ]",
"passed: threw exception",
result );
}
}

View File

@ -0,0 +1,49 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* File Name: exception-003
* ECMA Section:
* Description: Tests for JavaScript Standard Exceptions
*
* Target error.
*
* Author: christine@netscape.com
* Date: 31 August 1998
*/
var SECTION = "exception-003";
var VERSION = "js1_4";
var TITLE = "Tests for JavaScript Standard Exceptions: TargetError";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
Target_1();
test();
function Target_1() {
result = "failed: no exception thrown";
exception = null;
try {
string = new String("hi");
string.toString = Boolean.prototype.toString;
string.toString();
} catch ( e ) {
result = "passed: threw exception",
exception = e.toString();
} finally {
new TestCase(
SECTION,
"string = new String(\"hi\");"+
"string.toString = Boolean.prototype.toString" +
"string.toString() [ exception is " + exception +" ]",
"passed: threw exception",
result );
}
}

View File

@ -0,0 +1,45 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* File Name: exception-004
* ECMA Section:
* Description: Tests for JavaScript Standard Exceptions
*
* ToObject error.
*
* Author: christine@netscape.com
* Date: 31 August 1998
*/
var SECTION = "exception-004";
var VERSION = "js1_4";
var TITLE = "Tests for JavaScript Standard Exceptions: ToObjectError";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
ToObject_1();
test();
function ToObject_1() {
result = "failed: no exception thrown";
exception = null;
try {
result = foo["bar"];
} catch ( e ) {
result = "passed: threw exception",
exception = e.toString();
} finally {
new TestCase(
SECTION,
"foo[\"bar\"] [ exception is " + exception +" ]",
"passed: threw exception",
result );
}
}

View File

@ -0,0 +1,45 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* File Name: exception-005
* ECMA Section:
* Description: Tests for JavaScript Standard Exceptions
*
* ToObject error.
*
* Author: christine@netscape.com
* Date: 31 August 1998
*/
var SECTION = "exception-005";
var VERSION = "js1_4";
var TITLE = "Tests for JavaScript Standard Exceptions: ToObjectError";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
ToObject_1();
test();
function ToObject_1() {
result = "failed: no exception thrown";
exception = null;
try {
result = foo["bar"];
} catch ( e ) {
result = "passed: threw exception",
exception = e.toString();
} finally {
new TestCase(
SECTION,
"foo[\"bar\"] [ exception is " + exception +" ]",
"passed: threw exception",
result );
}
}

View File

@ -0,0 +1,56 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* File Name: exception-006
* ECMA Section:
* Description: Tests for JavaScript Standard Exceptions
*
* ToPrimitive error.
*
* Author: christine@netscape.com
* Date: 31 August 1998
*/
var SECTION = "exception-006";
var VERSION = "js1_4";
var TITLE = "Tests for JavaScript Standard Exceptions: TypeError";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
ToPrimitive_1();
test();
/**
* Getting the [[DefaultValue]] of any instances of MyObject
* should result in a runtime error in ToPrimitive.
*/
function MyObject() {
this.toString = void 0;
this.valueOf = void 0;
}
function ToPrimitive_1() {
result = "failed: no exception thrown";
exception = null;
try {
result = new MyObject() + new MyObject();
} catch ( e ) {
result = "passed: threw exception",
exception = e.toString();
} finally {
new TestCase(
SECTION,
"new MyObject() + new MyObject() [ exception is " + exception +" ]",
"passed: threw exception",
result );
}
}

View File

@ -0,0 +1,57 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* File Name: exception-007
* ECMA Section:
* Description: Tests for JavaScript Standard Exceptions
*
* DefaultValue error.
*
* Author: christine@netscape.com
* Date: 31 August 1998
*/
var SECTION = "exception-007";
var VERSION = "js1_4";
var TITLE = "Tests for JavaScript Standard Exceptions: TypeError";
var BUGNUMBER="318250";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
DefaultValue_1();
test();
/**
* Getting the [[DefaultValue]] of any instances of MyObject
* should result in a runtime error in ToPrimitive.
*/
function MyObject() {
this.toString = void 0;
this.valueOf = new Object();
}
function DefaultValue_1() {
result = "failed: no exception thrown";
exception = null;
try {
result = new MyObject() + new MyObject();
} catch ( e ) {
result = "passed: threw exception",
exception = e.toString();
} finally {
new TestCase(
SECTION,
"new MyObject() + new MyObject() [ exception is " + exception +" ]",
"passed: threw exception",
result );
}
}

View File

@ -0,0 +1,44 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* File Name: exception-008
* ECMA Section:
* Description: Tests for JavaScript Standard Exceptions
*
* SyntaxError.
*
* Author: christine@netscape.com
* Date: 31 August 1998
*/
var SECTION = "exception-008";
var VERSION = "js1_4";
var TITLE = "Tests for JavaScript Standard Exceptions: SyntaxError";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
Syntax_1();
test();
function Syntax_1() {
result = "failed: no exception thrown";
exception = null;
try {
result = eval("continue;");
} catch ( e ) {
result = "passed: threw exception",
exception = e.toString();
} finally {
new TestCase(
SECTION,
"eval(\"continue\") [ exception is " + exception +" ]",
"passed: threw exception",
result );
}
}

View File

@ -0,0 +1,53 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* File Name: exception-009
* ECMA Section:
* Description: Tests for JavaScript Standard Exceptions
*
* Regression test for nested try blocks.
*
* http://scopus.mcom.com/bugsplat/show_bug.cgi?id=312964
*
* Author: christine@netscape.com
* Date: 31 August 1998
*/
var SECTION = "exception-009";
var VERSION = "JS1_4";
var TITLE = "Tests for JavaScript Standard Exceptions: SyntaxError";
var BUGNUMBER= "312964";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
try {
expect = "passed: no exception thrown";
result = expect;
Nested_1();
} catch ( e ) {
result = "failed: threw " + e;
} finally {
new TestCase(
SECTION,
"nested try",
expect,
result );
}
test();
function Nested_1() {
try {
try {
} catch (a) {
} finally {
}
} catch (b) {
} finally {
}
}

View File

@ -0,0 +1,25 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var SECTION = "exception-010";
var VERSION = "ECMA_2";
startTest();
var TITLE = "Don't Crash throwing null";
writeHeaderToLog( SECTION + " "+ TITLE);
print("Null throw test.");
print("BUGNUMBER: 21799");
DESCRIPTION = "throw null";
EXPECTED = "error";
new TestCase( SECTION, "throw null", "error", eval("throw null" ));
test();
print("FAILED!: Should have exited with uncaught exception.");

View File

@ -0,0 +1,26 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var SECTION = "exception-011";
var VERSION = "ECMA_2";
startTest();
var TITLE = "Don't Crash throwing undefined";
writeHeaderToLog( SECTION + " "+ TITLE);
print("Undefined throw test.");
DESCRIPTION = "throw undefined";
EXPECTED = "error";
new TestCase( SECTION, "throw undefined", "error", eval("throw (void 0)") );
test();
print("FAILED!: Should have exited with uncaught exception.");

Binary file not shown.

View File

@ -0,0 +1,188 @@
/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* File Name: RegExp/exec-002.js
* ECMA Section: 15.7.5.3
* Description: Based on ECMA 2 Draft 7 February 1999
*
* Test cases provided by rogerl@netscape.com
*
* Author: christine@netscape.com
* Date: 19 February 1999
*/
var SECTION = "RegExp/exec-002";
var VERSION = "ECMA_2";
var TITLE = "RegExp.prototype.exec(string)";
startTest();
/*
* for each test case, verify:
* - type of object returned
* - length of the returned array
* - value of lastIndex
* - value of index
* - value of input
* - value of the array indices
*/
AddRegExpCases(
/(a|d|q|)x/i,
"bcaDxqy",
3,
["Dx", "D"] );
AddRegExpCases(
/(a|(e|q))(x|y)/,
"bcaddxqy",
6,
["qy","q","q","y"] );
AddRegExpCases(
/a+b+d/,
"aabbeeaabbs",
0,
null );
AddRegExpCases(
/a*b/,
"aaadaabaaa",
4,
["aab"] );
AddRegExpCases(
/a*b/,
"dddb",
3,
["b"] );
AddRegExpCases(
/a*b/,
"xxx",
0,
null );
AddRegExpCases(
/x\d\dy/,
"abcx45ysss235",
3,
["x45y"] );
AddRegExpCases(
/[^abc]def[abc]+/,
"abxdefbb",
2,
["xdefbb"] );
AddRegExpCases(
/(a*)baa/,
"ccdaaabaxaabaa",
9,
["aabaa", "aa"] );
AddRegExpCases(
/(a*)baa/,
"aabaa",
0,
["aabaa", "aa"] );
AddRegExpCases(
/q(a|b)*q/,
"xxqababqyy",
2,
["qababq", "b"] );
AddRegExpCases(
/(a(.|[^d])c)*/,
"adcaxc",
0,
["adcaxc", "axc", "x"] );
AddRegExpCases(
/(a*)b\1/,
"abaaaxaabaayy",
0,
["aba", "a"] );
AddRegExpCases(
/(a*)b\1/,
"abaaaxaabaayy",
0,
["aba", "a"] );
AddRegExpCases(
/(a*)b\1/,
"cccdaaabaxaabaayy",
6,
["aba", "a"] );
AddRegExpCases(
/(a*)b\1/,
"cccdaaabqxaabaayy",
7,
["b", ""] );
AddRegExpCases(
/"(.|[^"\\\\])*"/,
'xx\"makudonarudo\"yy',
2,
["\"makudonarudo\"", "o"] );
AddRegExpCases(
/"(.|[^"\\\\])*"/,
"xx\"ma\"yy",
2,
["\"ma\"", "a"] );
test();
function AddRegExpCases(
regexp, pattern, index, matches_array ) {
// prevent a runtime error
if ( regexp.exec(pattern) == null || matches_array == null ) {
AddTestCase(
regexp + ".exec(" + pattern +")",
matches_array,
regexp.exec(pattern) );
return;
}
AddTestCase(
regexp + ".exec(" + pattern +").length",
matches_array.length,
regexp.exec(pattern).length );
AddTestCase(
regexp + ".exec(" + pattern +").index",
index,
regexp.exec(pattern).index );
AddTestCase(
regexp + ".exec(" + pattern +").input",
pattern,
regexp.exec(pattern).input );
AddTestCase(
regexp + ".exec(" + pattern +").toString()",
matches_array.toString(),
regexp.exec(pattern).toString() );
/*
var limit = matches_array.length > regexp.exec(pattern).length
? matches_array.length
: regexp.exec(pattern).length;
for ( var matches = 0; matches < limit; matches++ ) {
AddTestCase(
regexp + ".exec(" + pattern +")[" + matches +"]",
matches_array[matches],
regexp.exec(pattern)[matches] );
}
*/
}

View File

@ -0,0 +1,50 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: expression-001.js
Corresponds to: ecma/Expressions/11.12-2-n.js
ECMA Section: 11.12
Description:
The grammar for a ConditionalExpression in ECMAScript is a little bit
different from that in C and Java, which each allow the second
subexpression to be an Expression but restrict the third expression to
be a ConditionalExpression. The motivation for this difference in
ECMAScript is to allow an assignment expression to be governed by either
arm of a conditional and to eliminate the confusing and fairly useless
case of a comma expression as the center expression.
Author: christine@netscape.com
Date: 09 september 1998
*/
var SECTION = "expression-001";
var VERSION = "JS1_4";
var TITLE = "Conditional operator ( ? : )"
startTest();
writeHeaderToLog( SECTION + " " + TITLE );
// the following expression should be an error in JS.
var result = "Failed"
var exception = "No exception was thrown";
try {
eval("var MY_VAR = true ? \"EXPR1\", \"EXPR2\" : \"EXPR3\"");
} catch ( e ) {
result = "Passed";
exception = e.toString();
}
new TestCase(
SECTION,
"comma expression in a conditional statement "+
"(threw "+ exception +")",
"Passed",
result );
test();

View File

@ -0,0 +1,60 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: expressions-002.js
Corresponds to: ecma/Expressions/11.2.1-3-n.js
ECMA Section: 11.2.1 Property Accessors
Description:
Try to access properties of an object whose value is undefined.
Author: christine@netscape.com
Date: 09 september 1998
*/
var SECTION = "expressions-002.js";
var VERSION = "JS1_4";
var TITLE = "Property Accessors";
writeHeaderToLog( SECTION + " "+TITLE );
startTest();
// go through all Native Function objects, methods, and properties and get their typeof.
var PROPERTY = new Array();
var p = 0;
// try to access properties of primitive types
OBJECT = new Property( "undefined", void 0, "undefined", NaN );
var result = "Failed";
var exception = "No exception thrown";
var expect = "Passed";
try {
result = OBJECT.value.valueOf();
} catch ( e ) {
result = expect;
exception = e.toString();
}
new TestCase(
SECTION,
"Get the value of an object whose value is undefined "+
"(threw " + exception +")",
expect,
result );
test();
function Property( object, value, string, number ) {
this.object = object;
this.string = String(value);
this.number = Number(value);
this.valueOf = value;
}

View File

@ -0,0 +1,55 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: expressions-003.js
Corresponds to: ecma/Expressions/11.2.1-3-n.js
ECMA Section: 11.2.1 Property Accessors
Description:
Try to access properties of an object whose value is undefined.
Author: christine@netscape.com
Date: 09 september 1998
*/
var SECTION = "expressions-003.js";
var VERSION = "JS1_4";
var TITLE = "Property Accessors";
writeHeaderToLog( SECTION + " "+TITLE );
startTest();
// try to access properties of primitive types
OBJECT = new Property( "undefined", void 0, "undefined", NaN );
var result = "Failed";
var exception = "No exception thrown";
var expect = "Passed";
try {
result = OBJECT.value.toString();
} catch ( e ) {
result = expect;
exception = e.toString();
}
new TestCase(
SECTION,
"Get the toString value of an object whose value is undefined "+
"(threw " + exception +")",
expect,
result );
test();
function Property( object, value, string, number ) {
this.object = object;
this.string = String(value);
this.number = Number(value);
this.value = value;
}

View File

@ -0,0 +1,49 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: expression-004.js
Corresponds To: 11.2.1-4-n.js
ECMA Section: 11.2.1 Property Accessors
Description:
Author: christine@netscape.com
Date: 09 september 1998
*/
var SECTION = "expression-004";
var VERSION = "JS1_4";
var TITLE = "Property Accessors";
writeHeaderToLog( SECTION + " "+TITLE );
startTest();
var OBJECT = new Property( "null", null, "null", 0 );
var result = "Failed";
var exception = "No exception thrown";
var expect = "Passed";
try {
result = OBJECT.value.toString();
} catch ( e ) {
result = expect;
exception = e.toString();
}
new TestCase(
SECTION,
"Get the toString value of an object whose value is null "+
"(threw " + exception +")",
expect,
result );
test();
function Property( object, value, string, number ) {
this.object = object;
this.string = String(value);
this.number = Number(value);
this.value = value;
}

View File

@ -0,0 +1,41 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: expression-005.js
Corresponds To: 11.2.2-10-n.js
ECMA Section: 11.2.2. The new operator
Description:
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "expression-005";
var VERSION = "JS1_4";
var TITLE = "The new operator";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var result = "Failed";
var expect = "Passed";
var exception = "No exception thrown";
try {
result = new Math();
} catch ( e ) {
result = expect;
exception = e.toString();
}
new TestCase(
SECTION,
"result= new Math() (threw " + exception + ")",
expect,
result );
test();

View File

@ -0,0 +1,46 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: expression-006.js
Corresponds to: 11.2.2-1-n.js
ECMA Section: 11.2.2. The new operator
Description:
http://scopus/bugsplat/show_bug.cgi?id=327765
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "expression-006.js";
var VERSION = "JS1_4";
var TITLE = "The new operator";
var BUGNUMBER="327765";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var result = "Failed";
var exception = "No exception thrown";
var expect = "Passed";
try {
var OBJECT = new Object();
result = new OBJECT();
} catch ( e ) {
result = expect;
exception = e.toString();
}
new TestCase(
SECTION,
"OBJECT = new Object; result = new OBJECT()" +
" (threw " + exception +")",
expect,
result );
test();

View File

@ -0,0 +1,44 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: expression-007.js
Corresponds To: 11.2.2-2-n.js
ECMA Section: 11.2.2. The new operator
Description:
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "expression-007";
var VERSION = "JS1_4";
var TITLE = "The new operator";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var result = "Failed";
var exception = "No exception thrown";
var expect = "Passed";
try {
UNDEFINED = void 0;
result = new UNDEFINED();
} catch ( e ) {
result = expect;
exception = e.toString();
}
new TestCase(
SECTION,
"UNDEFINED = void 0; result = new UNDEFINED()" +
" (threw " + exception +")",
expect,
result );
test();

View File

@ -0,0 +1,41 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: expression-008
Corresponds To: 11.2.2-3-n.js
ECMA Section: 11.2.2. The new operator
Description:
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "expression-008";
var VERSION = "JS1_4";
var TITLE = "The new operator";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var NULL = null;
var result = "Failed";
var exception = "No exception thrown";
var expect = "Passed";
try {
result = new NULL();
} catch ( e ) {
result = expect;
exception = e.toString();
}
new TestCase(
SECTION,
"NULL = null; result = new NULL()" +
" (threw " + exception +")",
expect,
result );
test();

View File

@ -0,0 +1,42 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: expression-009
Corresponds to: ecma/Expressions/11.2.2-4-n.js
ECMA Section: 11.2.2. The new operator
Description:
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "expression-009";
var VERSION = "JS1_4";
var TITLE = "The new operator";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var STRING = "";
var result = "Failed";
var exception = "No exception thrown";
var expect = "Passed";
try {
result = new STRING();
} catch ( e ) {
result = expect;
exception = e.toString();
}
new TestCase(
SECTION,
"STRING = ''; result = new STRING()" +
" (threw " + exception +")",
expect,
result );
test();

View File

@ -0,0 +1,43 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: expression-010.js
Corresponds To: 11.2.2-5-n.js
ECMA Section: 11.2.2. The new operator
Description:
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "expression-010";
var VERSION = "JS1_4";
var TITLE = "The new operator";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var NUMBER = 0;
var result = "Failed";
var exception = "No exception thrown";
var expect = "Passed";
try {
result = new NUMBER();
} catch ( e ) {
result = expect;
exception = e.toString();
}
new TestCase(
SECTION,
"NUMBER=0, result = new NUMBER()" +
" (threw " + exception +")",
expect,
result );
test();

View File

@ -0,0 +1,43 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: expression-011.js
Corresponds To: ecma/Expressions/11.2.2-6-n.js
ECMA Section: 11.2.2. The new operator
Description:
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "expression-011";
var VERSION = "JS1_4";
var TITLE = "The new operator";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var BOOLEAN = true;
var result = "Failed";
var exception = "No exception thrown";
var expect = "Passed";
try {
var OBJECT = new BOOLEAN();
} catch ( e ) {
result = expect;
exception = e.toString();
}
new TestCase(
SECTION,
"BOOLEAN = true; result = new BOOLEAN()" +
" (threw " + exception +")",
expect,
result );
test();

View File

@ -0,0 +1,44 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: expression-012.js
Corresponds To: ecma/Expressions/11.2.2-6-n.js
ECMA Section: 11.2.2. The new operator
Description:
http://scopus/bugsplat/show_bug.cgi?id=327765
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "expression-012";
var VERSION = "JS1_4";
var TITLE = "The new operator";
var BUGNUMBER= "327765";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var STRING = new String("hi");
var result = "Failed";
var exception = "No exception thrown";
var expect = "Passed";
try {
result = new STRING();
} catch ( e ) {
result = expect;
exception = e.toString();
}
new TestCase(
SECTION,
"STRING = new String(\"hi\"); result = new STRING()" +
" (threw " + exception +")",
expect,
result );
test();

View File

@ -0,0 +1,44 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: expression-013.js
Corresponds To: ecma/Expressions/11.2.2-8-n.js
ECMA Section: 11.2.2. The new operator
Description:
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "expression-013";
var VERSION = "JS1_4";
var TITLE = "The new operator";
var BUGNUMBER= "327765";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var NUMBER = new Number(1);
var result = "Failed";
var exception = "No exception thrown";
var expect = "Passed";
try {
result = new NUMBER();
} catch ( e ) {
result = expect;
exception = e.toString();
}
new TestCase(
SECTION,
"NUMBER = new Number(1); result = new NUMBER()" +
" (threw " + exception +")",
expect,
result );
test();

View File

@ -0,0 +1,46 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: expression-014.js
Corresponds To: ecma/Expressions/11.2.2-9-n.js
ECMA Section: 11.2.2. The new operator
Description:
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "expression-014.js";
var VERSION = "ECMA_1";
var TITLE = "The new operator";
var BUGNUMBER= "327765";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var BOOLEAN = new Boolean();
var result = "Failed";
var exception = "No exception thrown";
var expect = "Passed";
try {
result = new BOOLEAN();
} catch ( e ) {
result = expect;
exception = e.toString();
}
new TestCase(
SECTION,
"BOOLEAN = new Boolean(); result = new BOOLEAN()" +
" (threw " + exception +")",
expect,
result );
test();

View File

@ -0,0 +1,40 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: expression-015.js
Corresponds To: ecma/Expressions/11.2.3-2-n.js
ECMA Section: 11.2.3. Function Calls
Description:
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "expression-015";
var VERSION = "JS1_4";
var TITLE = "Function Calls";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var result = "Failed";
var exception = "No exception thrown";
var expect = "Passed";
try {
eval("result = 3.valueOf();");
} catch ( e ) {
result = expect;
exception = e.toString();
}
new TestCase(
SECTION,
"3.valueOf()" +
" (threw " + exception +")",
expect,
result );
test();

View File

@ -0,0 +1,40 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: expression-016.js
Corresponds To: ecma/Expressions/11.2.3-3-n.js
ECMA Section: 11.2.3. Function Calls
Description:
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "expression-016";
var VERSION = "JS1_4";
var TITLE = "Function Calls";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var result = "Failed";
var exception = "No exception thrown";
var expect = "Passed";
try {
result = (void 0).valueOf();
} catch ( e ) {
result = expect;
exception = e.toString();
}
new TestCase(
SECTION,
"(void 0).valueOf()" +
" (threw " + exception +")",
expect,
result );
test();

View File

@ -0,0 +1,40 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: expression-07.js
Corresponds To: ecma/Expressions/11.2.3-4-n.js
ECMA Section: 11.2.3. Function Calls
Description:
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "expression-017";
var VERSION = "JS1_4";
var TITLE = "Function Calls";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var result = "Failed";
var exception = "No exception thrown";
var expect = "Passed";
try {
result = nullvalueOf();
} catch ( e ) {
result = expect;
exception = e.toString();
}
new TestCase(
SECTION,
"null.valueOf()" +
" (threw " + exception +")",
expect,
result );
test();

View File

@ -0,0 +1,44 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
File Name: expression-019.js
Corresponds To: 11.2.2-7-n.js
ECMA Section: 11.2.2. The new operator
Description:
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "expression-019";
var VERSION = "JS1_4";
var TITLE = "The new operator";
var BUGNUMBER= "327765";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var result = "Failed";
var exception = "No exception thrown";
var expect = "Passed";
try {
var STRING = new String("hi");
result = new STRING();
} catch ( e ) {
result = expect;
exception = e.toString();
}
new TestCase(
SECTION,
"var STRING = new String(\"hi\"); result = new STRING();" +
" (threw " + exception + ")",
expect,
result );
test();

View File

@ -0,0 +1,297 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* File Name: forin-001.js
* ECMA Section:
* Description: The forin-001 statement
*
* Verify that the property name is assigned to the property on the left
* hand side of the for...in expression.
*
* Author: christine@netscape.com
* Date: 28 August 1998
*/
var SECTION = "forin-001";
var VERSION = "ECMA_2";
var TITLE = "The for...in statement";
var BUGNUMBER="330890";
var BUGNUMBER="http://scopus.mcom.com/bugsplat/show_bug.cgi?id=344855";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
ForIn_1( { length:4, company:"netscape", year:2000, 0:"zero" } );
ForIn_2( { length:4, company:"netscape", year:2000, 0:"zero" } );
ForIn_3( { length:4, company:"netscape", year:2000, 0:"zero" } );
// ForIn_6({ length:4, company:"netscape", year:2000, 0:"zero" });
// ForIn_7({ length:4, company:"netscape", year:2000, 0:"zero" });
ForIn_8({ length:4, company:"netscape", year:2000, 0:"zero" });
test();
/**
* Verify that the left side argument is evaluated with every iteration.
* Verify that the name of each property of the object is assigned to a
* a property.
*
*/
function ForIn_1( object ) {
PropertyArray = new Array();
ValueArray = new Array();
for ( PropertyArray[PropertyArray.length] in object ) {
ValueArray[ValueArray.length] =
object[PropertyArray[PropertyArray.length-1]];
}
for ( var i = 0; i < PropertyArray.length; i++ ) {
new TestCase(
SECTION,
"object[" + PropertyArray[i] +"]",
object[PropertyArray[i]],
ValueArray[i]
);
}
new TestCase(
SECTION,
"object.length",
PropertyArray.length,
object.length );
}
/**
* Similar to ForIn_1, except it should increment the counter variable
* every time the left hand expression is evaluated.
*/
function ForIn_2( object ) {
PropertyArray = new Array();
ValueArray = new Array();
var i = 0;
for ( PropertyArray[i++] in object ) {
ValueArray[ValueArray.length] =
object[PropertyArray[PropertyArray.length-1]];
}
for ( i = 0; i < PropertyArray.length; i++ ) {
new TestCase(
SECTION,
"object[" + PropertyArray[i] +"]",
object[PropertyArray[i]],
ValueArray[i]
);
}
new TestCase(
SECTION,
"object.length",
PropertyArray.length,
object.length );
}
/**
* Break out of a for...in loop
*
*
*/
function ForIn_3( object ) {
var checkBreak = "pass";
var properties = new Array();
var values = new Array();
for ( properties[properties.length] in object ) {
values[values.length] = object[properties[properties.length-1]];
break;
checkBreak = "fail";
}
new TestCase(
SECTION,
"check break out of for...in",
"pass",
checkBreak );
new TestCase(
SECTION,
"properties.length",
1,
properties.length );
new TestCase(
SECTION,
"object["+properties[0]+"]",
values[0],
object[properties[0]] );
}
/**
* Break out of a labeled for...in loop.
*/
function ForIn_4( object ) {
var result1 = 0;
var result2 = 0;
var result3 = 0;
var result4 = 0;
var i = 0;
var property = new Array();
butterbean: {
result1++;
for ( property[i++] in object ) {
result2++;
break;
result4++;
}
result3++;
}
new TestCase(
SECTION,
"verify labeled statement is only executed once",
true,
result1 == 1 );
new TestCase(
SECTION,
"verify statements in for loop are evaluated",
true,
result2 == i );
new TestCase(
SECTION,
"verify break out of labeled for...in loop",
true,
result4 == 0 );
new TestCase(
SECTION,
"verify break out of labeled block",
true,
result3 == 0 );
}
/**
* Labeled break out of a labeled for...in loop.
*/
function ForIn_5 (object) {
var result1 = 0;
var result2 = 0;
var result3 = 0;
var result4 = 0;
var i = 0;
var property = new Array();
bigredbird: {
result1++;
for ( property[i++] in object ) {
result2++;
break bigredbird;
result4++;
}
result3++;
}
new TestCase(
SECTION,
"verify labeled statement is only executed once",
true,
result1 == 1 );
new TestCase(
SECTION,
"verify statements in for loop are evaluated",
true,
result2 == i );
new TestCase(
SECTION,
"verify break out of labeled for...in loop",
true,
result4 == 0 );
new TestCase(
SECTION,
"verify break out of labeled block",
true,
result3 == 0 );
}
/**
* Labeled continue from a labeled for...in loop
*/
function ForIn_7( object ) {
var result1 = 0;
var result2 = 0;
var result3 = 0;
var result4 = 0;
var i = 0;
var property = new Array();
bigredbird:
for ( property[i++] in object ) {
result2++;
continue bigredbird;
result4++;
}
new TestCase(
SECTION,
"verify statements in for loop are evaluated",
true,
result2 == i );
new TestCase(
SECTION,
"verify break out of labeled for...in loop",
true,
result4 == 0 );
new TestCase(
SECTION,
"verify break out of labeled block",
true,
result3 == 1 );
}
/**
* continue in a for...in loop
*
*/
function ForIn_8( object ) {
var checkBreak = "pass";
var properties = new Array();
var values = new Array();
for ( properties[properties.length] in object ) {
values[values.length] = object[properties[properties.length-1]];
break;
checkBreak = "fail";
}
new TestCase(
SECTION,
"check break out of for...in",
"pass",
checkBreak );
new TestCase(
SECTION,
"properties.length",
1,
properties.length );
new TestCase(
SECTION,
"object["+properties[0]+"]",
values[0],
object[properties[0]] );
}

View File

@ -0,0 +1,77 @@
// |reftest| skip-if(Android) -- bug - nsIDOMWindow.crypto throws NS_ERROR_NOT_IMPLEMENTED on Android
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* File Name: forin-002.js
* ECMA Section:
* Description: The forin-001 statement
*
* Verify that the property name is assigned to the property on the left
* hand side of the for...in expression.
*
* Author: christine@netscape.com
* Date: 28 August 1998
*/
var SECTION = "forin-002";
var VERSION = "ECMA_2";
var TITLE = "The for...in statement";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
function MyObject( value ) {
this.value = value;
this.valueOf = new Function ( "return this.value" );
this.toString = new Function ( "return this.value + \"\"" );
this.toNumber = new Function ( "return this.value + 0" );
this.toBoolean = new Function ( "return Boolean( this.value )" );
}
ForIn_1(this);
ForIn_2(this);
ForIn_1(new MyObject(true));
ForIn_2(new MyObject(new Boolean(true)));
ForIn_2(3);
test();
/**
* For ... In in a With Block
*
*/
function ForIn_1( object) {
with ( object ) {
for ( property in object ) {
new TestCase(
SECTION,
"with loop in a for...in loop. ("+object+")["+property +"] == "+
"eval ( " + property +" )",
true,
object[property] == eval(property) );
}
}
}
/**
* With block in a For...In loop
*
*/
function ForIn_2(object) {
for ( property in object ) {
with ( object ) {
new TestCase(
SECTION,
"with loop in a for...in loop. ("+object+")["+property +"] == "+
"eval ( " + property +" )",
true,
object[property] == eval(property) );
}
}
}

View File

@ -0,0 +1,41 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* File Name: RegExp/function-001.js
* ECMA Section: 15.7.2.1
* Description: Based on ECMA 2 Draft 7 February 1999
*
* Author: christine@netscape.com
* Date: 19 February 1999
*/
var SECTION = "RegExp/function-001";
var VERSION = "ECMA_2";
var TITLE = "RegExp( pattern, flags )";
startTest();
/*
* for each test case, verify:
* - verify that [[Class]] property is RegExp
* - prototype property should be set to RegExp.prototype
* - source is set to the empty string
* - global property is set to false
* - ignoreCase property is set to false
* - multiline property is set to false
* - lastIndex property is set to 0
*/
RegExp.prototype.getClassProperty = Object.prototype.toString;
var re = new RegExp();
AddTestCase(
"new RegExp().__proto__",
RegExp.prototype,
re.__proto__
);
test()

Some files were not shown because too many files have changed in this diff Show More