diff --git a/js/tests/js1_2/Array/array_split_1.js b/js/tests/js1_2/Array/array_split_1.js
new file mode 100644
index 00000000000..d246a7047a6
--- /dev/null
+++ b/js/tests/js1_2/Array/array_split_1.js
@@ -0,0 +1,69 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: array_split_1.js
+ ECMA Section: Array.split()
+ Description:
+
+ These are tests from free perl suite.
+
+ Author: christine@netscape.com
+ Date: 12 november 1997
+*/
+
+ var SECTION = "Free Perl";
+ var VERSION = "JS1_2";
+ var TITLE = "Array.split()";
+
+ startTest();
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = new Array();
+
+
+ testcases[tc++] = new TestCase( SECTION,
+ "('a,b,c'.split(',')).length",
+ 3,
+ ('a,b,c'.split(',')).length );
+
+ testcases[tc++] = new TestCase( SECTION,
+ "('a,b'.split(',')).length",
+ 2,
+ ('a,b'.split(',')).length );
+
+ testcases[tc++] = new TestCase( SECTION,
+ "('a'.split(',')).length",
+ 1,
+ ('a'.split(',')).length );
+
+/*
+ * Deviate from ECMA by never splitting an empty string by any separator
+ * string into a non-empty array (an array of length 1 that contains the
+ * empty string).
+ */
+ testcases[tc++] = new TestCase( SECTION,
+ "(''.split(',')).length",
+ 0,
+ (''.split(',')).length );
+
+
+
+
+ test();
diff --git a/js/tests/js1_2/Array/general1.js b/js/tests/js1_2/Array/general1.js
new file mode 100644
index 00000000000..be37b507d6a
--- /dev/null
+++ b/js/tests/js1_2/Array/general1.js
@@ -0,0 +1,59 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: general1.js
+ Description: 'This tests out some of the functionality on methods on the Array objects'
+
+ Author: Nick Lerissa
+ Date: Fri Feb 13 09:58:28 PST 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'String:push,unshift,shift';
+
+ writeHeaderToLog('Executing script: general1.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ var array1 = [];
+
+ array1.push(123); //array1 = [123]
+ array1.push("dog"); //array1 = [123,dog]
+ array1.push(-99); //array1 = [123,dog,-99]
+ array1.push("cat"); //array1 = [123,dog,-99,cat]
+ testcases[count++] = new TestCase( SECTION, "array1.pop()", array1.pop(),'cat');
+ //array1 = [123,dog,-99]
+ array1.push("mouse"); //array1 = [123,dog,-99,mouse]
+ testcases[count++] = new TestCase( SECTION, "array1.shift()", array1.shift(),123);
+ //array1 = [dog,-99,mouse]
+ array1.unshift(96); //array1 = [96,dog,-99,mouse]
+ testcases[count++] = new TestCase( SECTION, "state of array", String([96,"dog",-99,"mouse"]), String(array1));
+ testcases[count++] = new TestCase( SECTION, "array1.length", array1.length,4);
+ array1.shift(); //array1 = [dog,-99,mouse]
+ array1.shift(); //array1 = [-99,mouse]
+ array1.shift(); //array1 = [mouse]
+ testcases[count++] = new TestCase( SECTION, "array1.shift()", array1.shift(),"mouse");
+ testcases[count++] = new TestCase( SECTION, "array1.shift()", "undefined", String(array1.shift()));
+
+ test();
+
diff --git a/js/tests/js1_2/Array/general2.js b/js/tests/js1_2/Array/general2.js
new file mode 100644
index 00000000000..92debbeb899
--- /dev/null
+++ b/js/tests/js1_2/Array/general2.js
@@ -0,0 +1,75 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: general2.js
+ Description: 'This tests out some of the functionality on methods on the Array objects'
+
+ Author: Nick Lerissa
+ Date: Fri Feb 13 09:58:28 PST 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'String:push,splice,concat,unshift,sort';
+
+ writeHeaderToLog('Executing script: general2.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+
+ array1 = new Array();
+ array2 = [];
+ size = 10;
+
+ // this for loop populates array1 and array2 as follows:
+ // array1 = [0,1,2,3,4,....,size - 2,size - 1]
+ // array2 = [size - 1, size - 2,...,4,3,2,1,0]
+ for (var i = 0; i < size; i++)
+ {
+ array1.push(i);
+ array2.push(size - 1 - i);
+ }
+
+ // the following for loop reverses the order of array1 so
+ // that it should be similarly ordered to array2
+ for (i = array1.length; i > 0; i--)
+ {
+ array3 = array1.slice(1,i);
+ array1.splice(1,i-1);
+ array1 = array3.concat(array1);
+ }
+
+ // the following for loop reverses the order of array1
+ // and array2
+ for (i = 0; i < size; i++)
+ {
+ array1.push(array1.shift());
+ array2.unshift(array2.pop());
+ }
+
+ testcases[count++] = new TestCase( SECTION, "Array.push,pop,shift,unshift,slice,splice", true,String(array1) == String(array2));
+ array1.sort();
+ array2.sort();
+ testcases[count++] = new TestCase( SECTION, "Array.sort", true,String(array1) == String(array2));
+
+ test();
+
diff --git a/js/tests/js1_2/Array/slice.js b/js/tests/js1_2/Array/slice.js
new file mode 100644
index 00000000000..9cf3f4287e1
--- /dev/null
+++ b/js/tests/js1_2/Array/slice.js
@@ -0,0 +1,120 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: slice.js
+ Description: 'This tests out some of the functionality on methods on the Array objects'
+
+ Author: Nick Lerissa
+ Date: Fri Feb 13 09:58:28 PST 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'String:slice';
+
+ writeHeaderToLog('Executing script: slice.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+
+ function mySlice(a, from, to)
+ {
+ var from2 = from;
+ var to2 = to;
+ var returnArray = [];
+ var i;
+
+ if (from2 < 0) from2 = a.length + from;
+ if (to2 < 0) to2 = a.length + to;
+
+ if ((to2 > from2)&&(to2 > 0)&&(from2 < a.length))
+ {
+ if (from2 < 0) from2 = 0;
+ if (to2 > a.length) to2 = a.length;
+
+ for (i = from2; i < to2; ++i) returnArray.push(a[i]);
+ }
+ return returnArray;
+ }
+
+ // This function tests the slice command on an Array
+ // passed in. The arguments passed into slice range in
+ // value from -5 to the length of the array + 4. Every
+ // combination of the two arguments is tested. The expected
+ // result of the slice(...) method is calculated and
+ // compared to the actual result from the slice(...) method.
+ // If the Arrays are not similar false is returned.
+ function exhaustiveSliceTest(testname, a)
+ {
+ var x = 0;
+ var y = 0;
+ var errorMessage;
+ var reason = "";
+ var passed = true;
+
+ for (x = -(2 + a.length); x <= (2 + a.length); x++)
+ for (y = (2 + a.length); y >= -(2 + a.length); y--)
+ {
+ var b = a.slice(x,y);
+ var c = mySlice(a,x,y);
+
+ if (String(b) != String(c))
+ {
+ errorMessage =
+ "ERROR: 'TEST FAILED' ERROR: 'TEST FAILED' ERROR: 'TEST FAILED'\n" +
+ " test: " + "a.slice(" + x + "," + y + ")\n" +
+ " a: " + String(a) + "\n" +
+ " actual result: " + String(b) + "\n" +
+ " expected result: " + String(c) + "\n";
+ writeHeaderToLog(errorMessage);
+ reason = reason + errorMessage;
+ passed = false;
+ }
+ }
+ var testCase = new TestCase(SECTION, testname, true, passed);
+ if (passed == false)
+ testCase.reason = reason;
+ return testCase;
+ }
+
+ var a = ['a','test string',456,9.34,new String("string object"),[],['h','i','j','k']];
+ var b = [1,2,3,4,5,6,7,8,9,0];
+
+ testcases[count++] = exhaustiveSliceTest("exhaustive slice test 1", a);
+ testcases[count++] = exhaustiveSliceTest("exhaustive slice test 2", b);
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
+
diff --git a/js/tests/js1_2/Array/splice1.js b/js/tests/js1_2/Array/splice1.js
new file mode 100644
index 00000000000..24064709f22
--- /dev/null
+++ b/js/tests/js1_2/Array/splice1.js
@@ -0,0 +1,149 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: splice1.js
+ Description: 'Tests Array.splice(x,y) w/no var args'
+
+ Author: Nick Lerissa
+ Date: Fri Feb 13 09:58:28 PST 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'String:splice 1';
+ var BUGNUMBER="123795";
+
+ writeHeaderToLog('Executing script: splice1.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+
+ function mySplice(testArray, splicedArray, first, len, elements)
+ {
+ var removedArray = [];
+ var adjustedFirst = first;
+ var adjustedLen = len;
+
+ if (adjustedFirst < 0) adjustedFirst = testArray.length + first;
+ if (adjustedFirst < 0) adjustedFirst = 0;
+
+ if (adjustedLen < 0) adjustedLen = 0;
+
+ for (i = 0; (i < adjustedFirst)&&(i < testArray.length); ++i)
+ splicedArray.push(testArray[i]);
+
+ if (adjustedFirst < testArray.length)
+ for (i = adjustedFirst; (i < adjustedFirst + adjustedLen) &&
+ (i < testArray.length); ++i)
+ {
+ removedArray.push(testArray[i]);
+ }
+
+ for (i = 0; i < elements.length; i++) splicedArray.push(elements[i]);
+
+ for (i = adjustedFirst + adjustedLen; i < testArray.length; i++)
+ splicedArray.push(testArray[i]);
+
+ return removedArray;
+ }
+
+ function exhaustiveSpliceTest(testname, testArray)
+ {
+ var errorMessage;
+ var passed = true;
+ var reason = "";
+
+ for (var first = -(testArray.length+2); first <= 2 + testArray.length; first++)
+ {
+ var actualSpliced = [];
+ var expectedSpliced = [];
+ var actualRemoved = [];
+ var expectedRemoved = [];
+
+ for (var len = 0; len < testArray.length + 2; len++)
+ {
+ actualSpliced = [];
+ expectedSpliced = [];
+
+ for (var i = 0; i < testArray.length; ++i)
+ actualSpliced.push(testArray[i]);
+
+ actualRemoved = actualSpliced.splice(first,len);
+ expectedRemoved = mySplice(testArray,expectedSpliced,first,len,[]);
+
+ var adjustedFirst = first;
+ if (adjustedFirst < 0) adjustedFirst = testArray.length + first;
+ if (adjustedFirst < 0) adjustedFirst = 0;
+
+ if ( (String(actualSpliced) != String(expectedSpliced))
+ ||(String(actualRemoved) != String(expectedRemoved)))
+ {
+ if ( (String(actualSpliced) == String(expectedSpliced))
+ &&(String(actualRemoved) != String(expectedRemoved)) )
+ {
+ if ( (expectedRemoved.length == 1)
+ &&(String(actualRemoved) == String(expectedRemoved[0]))) continue;
+ if ( expectedRemoved.length == 0 && actualRemoved == void 0) continue;
+ }
+
+ errorMessage =
+ "ERROR: 'TEST FAILED'\n" +
+ " test: " + "a.splice(" + first + "," + len + ",-97,new String('test arg'),[],9.8)\n" +
+ " a: " + String(testArray) + "\n" +
+ " actual spliced: " + String(actualSpliced) + "\n" +
+ " expected spliced: " + String(expectedSpliced) + "\n" +
+ " actual removed: " + String(actualRemoved) + "\n" +
+ " expected removed: " + String(expectedRemoved) + "\n";
+ writeHeaderToLog(errorMessage);
+ reason = reason + errorMessage;
+ passed = false;
+ }
+ }
+ }
+ var testcase = new TestCase( SECTION, testname, true, passed);
+ if (!passed)
+ testcase.reason = reason;
+ return testcase;
+ }
+
+ var a = ['a','test string',456,9.34,new String("string object"),[],['h','i','j','k']];
+ var b = [1,2,3,4,5,6,7,8,9,0];
+
+ testcases[count++] = exhaustiveSpliceTest("exhaustive splice w/no optional args 1",a);
+ testcases[count++] = exhaustiveSpliceTest("exhaustive splice w/no optional args 1",b);
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
+
diff --git a/js/tests/js1_2/Array/splice2.js b/js/tests/js1_2/Array/splice2.js
new file mode 100644
index 00000000000..00d0adbfaec
--- /dev/null
+++ b/js/tests/js1_2/Array/splice2.js
@@ -0,0 +1,147 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: splice2.js
+ Description: 'Tests Array.splice(x,y) w/4 var args'
+
+ Author: Nick Lerissa
+ Date: Fri Feb 13 09:58:28 PST 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'String:splice 2';
+ var BUGNUMBER="123795";
+
+ writeHeaderToLog('Executing script: splice2.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+
+ function mySplice(testArray, splicedArray, first, len, elements)
+ {
+ var removedArray = [];
+ var adjustedFirst = first;
+ var adjustedLen = len;
+
+ if (adjustedFirst < 0) adjustedFirst = testArray.length + first;
+ if (adjustedFirst < 0) adjustedFirst = 0;
+
+ if (adjustedLen < 0) adjustedLen = 0;
+
+ for (i = 0; (i < adjustedFirst)&&(i < testArray.length); ++i)
+ splicedArray.push(testArray[i]);
+
+ if (adjustedFirst < testArray.length)
+ for (i = adjustedFirst; (i < adjustedFirst + adjustedLen) && (i < testArray.length); ++i)
+ removedArray.push(testArray[i]);
+
+ for (i = 0; i < elements.length; i++) splicedArray.push(elements[i]);
+
+ for (i = adjustedFirst + adjustedLen; i < testArray.length; i++)
+ splicedArray.push(testArray[i]);
+
+ return removedArray;
+ }
+
+ function exhaustiveSpliceTestWithArgs(testname, testArray)
+ {
+ var passed = true;
+ var errorMessage;
+ var reason = "";
+ for (var first = -(testArray.length+2); first <= 2 + testArray.length; first++)
+ {
+ var actualSpliced = [];
+ var expectedSpliced = [];
+ var actualRemoved = [];
+ var expectedRemoved = [];
+
+ for (var len = 0; len < testArray.length + 2; len++)
+ {
+ actualSpliced = [];
+ expectedSpliced = [];
+
+ for (var i = 0; i < testArray.length; ++i)
+ actualSpliced.push(testArray[i]);
+
+ actualRemoved = actualSpliced.splice(first,len,-97,new String("test arg"),[],9.8);
+ expectedRemoved = mySplice(testArray,expectedSpliced,first,len,[-97,new String("test arg"),[],9.8]);
+
+ var adjustedFirst = first;
+ if (adjustedFirst < 0) adjustedFirst = testArray.length + first;
+ if (adjustedFirst < 0) adjustedFirst = 0;
+
+
+ if ( (String(actualSpliced) != String(expectedSpliced))
+ ||(String(actualRemoved) != String(expectedRemoved)))
+ {
+ if ( (String(actualSpliced) == String(expectedSpliced))
+ &&(String(actualRemoved) != String(expectedRemoved)) )
+ {
+
+ if ( (expectedRemoved.length == 1)
+ &&(String(actualRemoved) == String(expectedRemoved[0]))) continue;
+ if ( expectedRemoved.length == 0 && actualRemoved == void 0 ) continue;
+ }
+
+ errorMessage =
+ "ERROR: 'TEST FAILED' ERROR: 'TEST FAILED' ERROR: 'TEST FAILED'\n" +
+ " test: " + "a.splice(" + first + "," + len + ",-97,new String('test arg'),[],9.8)\n" +
+ " a: " + String(testArray) + "\n" +
+ " actual spliced: " + String(actualSpliced) + "\n" +
+ " expected spliced: " + String(expectedSpliced) + "\n" +
+ " actual removed: " + String(actualRemoved) + "\n" +
+ " expected removed: " + String(expectedRemoved);
+ reason = reason + errorMessage;
+ writeHeaderToLog(errorMessage);
+ passed = false;
+ }
+ }
+ }
+ var testcase = new TestCase(SECTION, testname, true, passed);
+ if (!passed) testcase.reason = reason;
+ return testcase;
+ }
+
+
+ var a = ['a','test string',456,9.34,new String("string object"),[],['h','i','j','k']];
+ var b = [1,2,3,4,5,6,7,8,9,0];
+
+ testcases[count++] = exhaustiveSpliceTestWithArgs("exhaustive splice w/2 optional args 1",a);
+ testcases[count++] = exhaustiveSpliceTestWithArgs("exhaustive splice w/2 optional args 2",b);
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
+
diff --git a/js/tests/js1_2/Array/tostring_1.js b/js/tests/js1_2/Array/tostring_1.js
new file mode 100644
index 00000000000..fb2a0938e6b
--- /dev/null
+++ b/js/tests/js1_2/Array/tostring_1.js
@@ -0,0 +1,117 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: tostring_1.js
+ ECMA Section: Array.toString()
+ Description:
+
+ This checks the ToString value of Array objects under JavaScript 1.2.
+
+ Author: christine@netscape.com
+ Date: 12 november 1997
+*/
+
+ var SECTION = "JS1_2";
+ var VERSION = "JS1_2";
+ startTest();
+ var TITLE = "Array.toString()";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = new Array();
+
+ var a = new Array();
+
+ var version;
+ if ( !version ) {
+ function version() { return 0; };
+ }
+
+ testcases[tc++] = new TestCase ( SECTION,
+ "var a = new Array(); a.toString()",
+ ( version() == 120 ? "[]" : "" ),
+ a.toString() );
+
+ a[0] = void 0;
+
+ testcases[tc++] = new TestCase ( SECTION,
+ "a[0] = void 0; a.toString()",
+ ( version() == 120 ? "[, ]" : "" ),
+ a.toString() );
+
+
+ testcases[tc++] = new TestCase( SECTION,
+ "a.length",
+ 1,
+ a.length );
+
+ a[1] = void 0;
+
+ testcases[tc++] = new TestCase( SECTION,
+ "a[1] = void 0; a.toString()",
+ ( version() == 120 ? "[, , ]" : "," ),
+ a.toString() );
+
+ a[1] = "hi";
+
+ testcases[tc++] = new TestCase( SECTION,
+ "a[1] = \"hi\"; a.toString()",
+ ( version() == 120 ? "[, \"hi\"]" : ",hi" ),
+ a.toString() );
+
+ a[2] = void 0;
+
+ testcases[tc++] = new TestCase( SECTION,
+ "a[2] = void 0; a.toString()",
+ ( version() == 120 ?"[, \"hi\", , ]":",hi,"),
+ a.toString() );
+
+ var b = new Array(1000);
+ var bstring = "";
+ for ( blen=0; blen<999; blen++) {
+ bstring += ",";
+ }
+
+
+ testcases[tc++] = new TestCase ( SECTION,
+ "var b = new Array(1000); b.toString()",
+ ( version() == 120 ? "[1000]" : bstring ),
+ b.toString() );
+
+
+ testcases[tc++] = new TestCase( SECTION,
+ "b.length",
+ ( version() == 120 ? 1 : 1000 ),
+ b.length );
+
+ test();
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/js1_2/Array/tostring_2.js b/js/tests/js1_2/Array/tostring_2.js
new file mode 100644
index 00000000000..d08f7005642
--- /dev/null
+++ b/js/tests/js1_2/Array/tostring_2.js
@@ -0,0 +1,74 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: tostring_2.js
+ Reference: http://scopus.mcom.com/bugsplat/show_bug.cgi?id=114564
+ Description: toString in version 120
+
+
+ Author: christine@netscape.com
+ Date: 15 June 1998
+*/
+
+ var SECTION = "Array/tostring_2.js";
+ var VERSION = "JS_12";
+ startTest();
+ var TITLE = "Array.toString";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = new Array();
+
+ var a = [];
+
+ var version;
+ if ( !version ) {
+ function version() { return 0; };
+ }
+
+ testcases[tc++] = new TestCase ( SECTION,
+ "a.toString()",
+ ( version() == 120 ? "[]" : "" ),
+ a.toString() );
+
+ testcases[tc++] = new TestCase ( SECTION,
+ "String( a )",
+ ( version() == 120 ? "[]" : "" ),
+ String( a ) );
+
+ testcases[tc++] = new TestCase ( SECTION,
+ "a +''",
+ ( version() == 120 ? "[]" : "" ),
+ a+"" );
+
+ test();
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/js1_2/Objects/toString-001.js b/js/tests/js1_2/Objects/toString-001.js
new file mode 100644
index 00000000000..73e0c4ab80e
--- /dev/null
+++ b/js/tests/js1_2/Objects/toString-001.js
@@ -0,0 +1,114 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: toString_1.js
+ ECMA Section: Object.toString()
+ Description:
+
+ This checks the ToString value of Object objects under JavaScript 1.2.
+
+ In JavaScript 1.2, Object.toString()
+
+ Author: christine@netscape.com
+ Date: 12 november 1997
+*/
+
+ var SECTION = "JS1_2";
+ var VERSION = "JS1_2";
+ startTest();
+ var TITLE = "Object.toString()";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = new Array();
+
+ var o = new Object();
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "var o = new Object(); o.toString()",
+ "{}",
+ o.toString() );
+
+ o = {};
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "o = {}; o.toString()",
+ "{}",
+ o.toString() );
+
+ o = { name:"object", length:0, value:"hello" }
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "o = { name:\"object\", length:0, value:\"hello\" }; o.toString()",
+ true,
+ checkObjectToString(o.toString(), ['name:"object"', 'length:0',
+ 'value:"hello"']));
+
+ o = { name:"object", length:0, value:"hello",
+ toString:new Function( "return this.value+''" ) }
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "o = { name:\"object\", length:0, value:\"hello\", "+
+ "toString:new Function( \"return this.value+''\" ) }; o.toString()",
+ "hello",
+ o.toString() );
+
+
+
+ test();
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
+
+/**
+ * checkObjectToString
+ *
+ * In JS1.2, Object.prototype.toString returns a representation of the
+ * object's properties as a string. However, the order of the properties
+ * in the resulting string is not specified. This function compares the
+ * resulting string with an array of strings to make sure that the
+ * resulting string is some permutation of the strings in the array.
+ */
+function checkObjectToString(s, a) {
+ var m = /^{(.*)\}$/(s);
+ if (!m)
+ return false; // should begin and end with curly brackets
+ var a2 = m[1].split(", ");
+ if (a.length != a2.length)
+ return false; // should be same length
+ a.sort();
+ a2.sort();
+ for (var i=0; i < a.length; i++) {
+ if (a[i] != a2[i])
+ return false; // should have identical elements
+ }
+ return true;
+}
+
diff --git a/js/tests/js1_2/String/charCodeAt.js b/js/tests/js1_2/String/charCodeAt.js
new file mode 100644
index 00000000000..d347fc4fd84
--- /dev/null
+++ b/js/tests/js1_2/String/charCodeAt.js
@@ -0,0 +1,68 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: charCodeAt.js
+ Description: 'This tests new String object method: charCodeAt'
+
+ Author: Nick Lerissa
+ Date: Fri Feb 13 09:58:28 PST 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'String:charCodeAt';
+
+ writeHeaderToLog('Executing script: charCodeAt.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+
+ var aString = new String("tEs5");
+
+ testcases[count++] = new TestCase( SECTION, "aString.charCodeAt(-2)", NaN, aString.charCodeAt(-2));
+ testcases[count++] = new TestCase( SECTION, "aString.charCodeAt(-1)", NaN, aString.charCodeAt(-1));
+ testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( 0)", 116, aString.charCodeAt( 0));
+ testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( 1)", 69, aString.charCodeAt( 1));
+ testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( 2)", 115, aString.charCodeAt( 2));
+ testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( 3)", 53, aString.charCodeAt( 3));
+ testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( 4)", NaN, aString.charCodeAt( 4));
+ testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( 5)", NaN, aString.charCodeAt( 5));
+ testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( Infinity)", NaN, aString.charCodeAt( Infinity));
+ testcases[count++] = new TestCase( SECTION, "aString.charCodeAt(-Infinity)", NaN, aString.charCodeAt(-Infinity));
+ //testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( )", 116, aString.charCodeAt( ));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
+
diff --git a/js/tests/js1_2/String/concat.js b/js/tests/js1_2/String/concat.js
new file mode 100644
index 00000000000..bfa0c615814
--- /dev/null
+++ b/js/tests/js1_2/String/concat.js
@@ -0,0 +1,79 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: concat.js
+ Description: 'This tests the new String object method: concat'
+
+ Author: NickLerissa
+ Date: Fri Feb 13 09:58:28 PST 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'String:concat';
+
+ writeHeaderToLog('Executing script: concat.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+
+ var aString = new String("test string");
+ var bString = new String(" another ");
+
+ testcases[count++] = new TestCase( SECTION, "aString.concat(' more')", "test string more", aString.concat(' more').toString());
+ testcases[count++] = new TestCase( SECTION, "aString.concat(bString)", "test string another ", aString.concat(bString).toString());
+ testcases[count++] = new TestCase( SECTION, "aString ", "test string", aString.toString());
+ testcases[count++] = new TestCase( SECTION, "bString ", " another ", bString.toString());
+ testcases[count++] = new TestCase( SECTION, "aString.concat(345) ", "test string345", aString.concat(345).toString());
+ testcases[count++] = new TestCase( SECTION, "aString.concat(true) ", "test stringtrue", aString.concat(true).toString());
+ testcases[count++] = new TestCase( SECTION, "aString.concat(null) ", "test stringnull", aString.concat(null).toString());
+ testcases[count++] = new TestCase( SECTION, "aString.concat([]) ", "test string[]", aString.concat([]).toString());
+ testcases[count++] = new TestCase( SECTION, "aString.concat([1,2,3])", "test string[1, 2, 3]", aString.concat([1,2,3]).toString());
+
+ testcases[count++] = new TestCase( SECTION, "'abcde'.concat(' more')", "abcde more", 'abcde'.concat(' more').toString());
+ testcases[count++] = new TestCase( SECTION, "'abcde'.concat(bString)", "abcde another ", 'abcde'.concat(bString).toString());
+ testcases[count++] = new TestCase( SECTION, "'abcde' ", "abcde", 'abcde');
+ testcases[count++] = new TestCase( SECTION, "'abcde'.concat(345) ", "abcde345", 'abcde'.concat(345).toString());
+ testcases[count++] = new TestCase( SECTION, "'abcde'.concat(true) ", "abcdetrue", 'abcde'.concat(true).toString());
+ testcases[count++] = new TestCase( SECTION, "'abcde'.concat(null) ", "abcdenull", 'abcde'.concat(null).toString());
+ testcases[count++] = new TestCase( SECTION, "'abcde'.concat([]) ", "abcde[]", 'abcde'.concat([]).toString());
+ testcases[count++] = new TestCase( SECTION, "'abcde'.concat([1,2,3])", "abcde[1, 2, 3]", 'abcde'.concat([1,2,3]).toString());
+
+ //what should this do:
+ testcases[count++] = new TestCase( SECTION, "'abcde'.concat() ", "abcde", 'abcde'.concat().toString());
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
+
diff --git a/js/tests/js1_2/String/match.js b/js/tests/js1_2/String/match.js
new file mode 100644
index 00000000000..5dd94d375b1
--- /dev/null
+++ b/js/tests/js1_2/String/match.js
@@ -0,0 +1,59 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: match.js
+ Description: 'This tests the new String object method: match'
+
+ Author: NickLerissa
+ Date: Fri Feb 13 09:58:28 PST 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'String:match';
+
+ writeHeaderToLog('Executing script: match.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+
+ var aString = new String("this is a test string");
+
+ testcases[count++] = new TestCase( SECTION, "aString.match(/is.*test/) ", String(["is is a test"]), String(aString.match(/is.*test/)));
+ testcases[count++] = new TestCase( SECTION, "aString.match(/s.*s/) ", String(["s is a test s"]), String(aString.match(/s.*s/)));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
+
diff --git a/js/tests/js1_2/String/slice.js b/js/tests/js1_2/String/slice.js
new file mode 100644
index 00000000000..3203aeb74db
--- /dev/null
+++ b/js/tests/js1_2/String/slice.js
@@ -0,0 +1,120 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: slice.js
+ Description: 'This tests the String object method: slice'
+
+ Author: Nick Lerissa
+ Date: Fri Feb 13 09:58:28 PST 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'String.slice';
+
+ writeHeaderToLog('Executing script: slice.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+
+ function myStringSlice(a, from, to)
+ {
+ var from2 = from;
+ var to2 = to;
+ var returnString = new String("");
+ var i;
+
+ if (from2 < 0) from2 = a.length + from;
+ if (to2 < 0) to2 = a.length + to;
+
+ if ((to2 > from2)&&(to2 > 0)&&(from2 < a.length))
+ {
+ if (from2 < 0) from2 = 0;
+ if (to2 > a.length) to2 = a.length;
+
+ for (i = from2; i < to2; ++i) returnString += a.charAt(i);
+ }
+ return returnString;
+ }
+
+ // This function tests the slice command on a String
+ // passed in. The arguments passed into slice range in
+ // value from -5 to the length of the array + 4. Every
+ // combination of the two arguments is tested. The expected
+ // result of the slice(...) method is calculated and
+ // compared to the actual result from the slice(...) method.
+ // If the Strings are not similar false is returned.
+ function exhaustiveStringSliceTest(testname, a)
+ {
+ var x = 0;
+ var y = 0;
+ var errorMessage;
+ var reason = "";
+ var passed = true;
+
+ for (x = -(2 + a.length); x <= (2 + a.length); x++)
+ for (y = (2 + a.length); y >= -(2 + a.length); y--)
+ {
+ var b = a.slice(x,y);
+ var c = myStringSlice(a,x,y);
+
+ if (String(b) != String(c))
+ {
+ errorMessage =
+ "ERROR: 'TEST FAILED' ERROR: 'TEST FAILED' ERROR: 'TEST FAILED'\n" +
+ " test: " + "a.slice(" + x + "," + y + ")\n" +
+ " a: " + String(a) + "\n" +
+ " actual result: " + String(b) + "\n" +
+ " expected result: " + String(c) + "\n";
+ writeHeaderToLog(errorMessage);
+ reason = reason + errorMessage;
+ passed = false;
+ }
+ }
+ var testCase = new TestCase(SECTION, testname, true, passed);
+ if (passed == false)
+ testCase.reason = reason;
+ return testCase;
+ }
+
+ var a = new String("abcdefghijklmnopqrstuvwxyz1234567890");
+ var b = new String("this is a test string");
+
+ testcases[count++] = exhaustiveStringSliceTest("exhaustive String.slice test 1", a);
+ testcases[count++] = exhaustiveStringSliceTest("exhaustive String.slice test 2", b);
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
+
diff --git a/js/tests/js1_2/browser.js b/js/tests/js1_2/browser.js
new file mode 100644
index 00000000000..ee6e595472a
--- /dev/null
+++ b/js/tests/js1_2/browser.js
@@ -0,0 +1,80 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/*
+ * JavaScript test library shared functions file for running the tests
+ * in the browser. Overrides the shell's print function with document.write
+ * and make everything HTML pretty.
+ *
+ * To run the tests in the browser, use the mkhtml.pl script to generate
+ * html pages that include the shell.js, browser.js (this file), and the
+ * test js file in script tags.
+ *
+ * The source of the page that is generated should look something like this:
+ *
+ *
+ *
+ */
+
+onerror = err;
+
+var GLOBAL = "[object Window]";
+
+function startTest() {
+ writeHeaderToLog( SECTION + " "+ TITLE);
+ if ( BUGNUMBER ) {
+ writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
+ }
+
+ testcases = new Array();
+ tc = 0;
+}
+
+function writeLineToLog( string ) {
+ document.write( string + "
\n");
+}
+function writeHeaderToLog( string ) {
+ document.write( "
" + string + "
" );
+}
+function stopTest() {
+ var gc;
+ if ( gc != undefined ) {
+ gc();
+ }
+ document.write( "
" );
+}
+function writeFormattedResult( expect, actual, string, passed ) {
+ var s = ""+ string ;
+ s += "" ;
+ s += ( passed ) ? " " + PASSED
+ : " " + FAILED + expect + "";
+ writeLineToLog( s + "" );
+ return passed;
+}
+function err ( msg, page, line ) {
+ writeLineToLog( "Test " + page + " failed on line " + line +" with the message: " + msg );
+
+ testcases[tc].actual = "error";
+ testcases[tc].reason = msg;
+ writeTestCaseResult( testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+ testcases[tc].actual +
+ ": " + testcases[tc].reason );
+ stopTest();
+ return true;
+}
diff --git a/js/tests/js1_2/function/Function_object.js b/js/tests/js1_2/function/Function_object.js
new file mode 100644
index 00000000000..b24f1de32d3
--- /dev/null
+++ b/js/tests/js1_2/function/Function_object.js
@@ -0,0 +1,82 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: Function_object.js
+ Description: 'Testing Function objects'
+
+ Author: Nick Lerissa
+ Date: April 17, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'functions: Function_object';
+
+ writeHeaderToLog('Executing script: Function_object.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+
+ function a_test_function(a,b,c)
+ {
+ return a + b + c;
+ }
+
+ f = a_test_function;
+
+
+ testcases[count++] = new TestCase( SECTION, "f.name",
+ 'a_test_function', f.name);
+
+ testcases[count++] = new TestCase( SECTION, "f.length",
+ 3, f.length);
+
+ testcases[count++] = new TestCase( SECTION, "f.arity",
+ 3, f.arity);
+
+ testcases[count++] = new TestCase( SECTION, "f(2,3,4)",
+ 9, f(2,3,4));
+
+ var fnName = version() == 120 ? '' : 'anonymous';
+
+ testcases[count++] = new TestCase( SECTION, "(new Function()).name",
+ fnName, (new Function()).name);
+
+ testcases[count++] = new TestCase( SECTION, "(new Function()).toString()",
+ '\nfunction ' + fnName + '() {\n}\n', (new Function()).toString());
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
+
diff --git a/js/tests/js1_2/function/Number.js b/js/tests/js1_2/function/Number.js
new file mode 100644
index 00000000000..b4f7b582b43
--- /dev/null
+++ b/js/tests/js1_2/function/Number.js
@@ -0,0 +1,80 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: Number.js
+ Description: 'This tests the function Number(Object)'
+
+ Author: Nick Lerissa
+ Date: Fri Feb 13 09:58:28 PST 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'functions: Number';
+ var BUGNUMBER="123435";
+
+ writeHeaderToLog('Executing script: Number.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+
+ date = new Date(2200);
+
+ testcases[count++] = new TestCase( SECTION, "Number(new Date(2200)) ",
+ 2200, (Number(date)));
+ testcases[count++] = new TestCase( SECTION, "Number(true) ",
+ 1, (Number(true)));
+ testcases[count++] = new TestCase( SECTION, "Number(false) ",
+ 0, (Number(false)));
+ testcases[count++] = new TestCase( SECTION, "Number('124') ",
+ 124, (Number('124')));
+ testcases[count++] = new TestCase( SECTION, "Number('1.23') ",
+ 1.23, (Number('1.23')));
+ testcases[count++] = new TestCase( SECTION, "Number({p:1}) ",
+ NaN, (Number({p:1})));
+ testcases[count++] = new TestCase( SECTION, "Number(null) ",
+ 0, (Number(null)));
+ testcases[count++] = new TestCase( SECTION, "Number(-45) ",
+ -45, (Number(-45)));
+
+ // http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123435
+ // under js1.2, Number([1,2,3]) should return 3.
+
+ testcases[count++] = new TestCase( SECTION, "Number([1,2,3]) ",
+ 3, (Number([1,2,3])));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
+
diff --git a/js/tests/js1_2/function/String.js b/js/tests/js1_2/function/String.js
new file mode 100644
index 00000000000..76511cd8a2d
--- /dev/null
+++ b/js/tests/js1_2/function/String.js
@@ -0,0 +1,70 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: String.js
+ Description: 'This tests the function String(Object)'
+
+ Author: Nick Lerissa
+ Date: Fri Feb 13 09:58:28 PST 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'functions: String';
+
+ writeHeaderToLog('Executing script: String.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+
+ testcases[count++] = new TestCase( SECTION, "String(true) ",
+ 'true', (String(true)));
+ testcases[count++] = new TestCase( SECTION, "String(false) ",
+ 'false', (String(false)));
+ testcases[count++] = new TestCase( SECTION, "String(-124) ",
+ '-124', (String(-124)));
+ testcases[count++] = new TestCase( SECTION, "String(1.23) ",
+ '1.23', (String(1.23)));
+ testcases[count++] = new TestCase( SECTION, "String({p:1}) ",
+ '{p:1}', (String({p:1})));
+ testcases[count++] = new TestCase( SECTION, "String(null) ",
+ 'null', (String(null)));
+ testcases[count++] = new TestCase( SECTION, "String([1,2,3]) ",
+ '[1, 2, 3]', (String([1,2,3])));
+
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
+
diff --git a/js/tests/js1_2/function/definition-1.js b/js/tests/js1_2/function/definition-1.js
new file mode 100644
index 00000000000..701a2f86250
--- /dev/null
+++ b/js/tests/js1_2/function/definition-1.js
@@ -0,0 +1,70 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: definition-1.js
+ Reference: http://scopus.mcom.com/bugsplat/show_bug.cgi?id=111284
+ Description: Regression test for declaring functions.
+
+ Author: christine@netscape.com
+ Date: 15 June 1998
+*/
+
+ var SECTION = "function/definition-1.js";
+ var VERSION = "JS_12";
+ startTest();
+ var TITLE = "Regression test for 111284";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = new Array();
+
+ f1 = function() { return "passed!" }
+
+ function f2() { f3 = function() { return "passed!" }; return f3(); }
+
+ testcases[tc++] = new TestCase( SECTION,
+ 'f1 = function() { return "passed!" }; f1()',
+ "passed!",
+ f1() );
+
+ testcases[tc++] = new TestCase( SECTION,
+ 'function f2() { f3 = function { return "passed!" }; return f3() }; f2()',
+ "passed!",
+ f2() );
+
+ testcases[tc++] = new TestCase( SECTION,
+ 'f3()',
+ "passed!",
+ f3() );
+
+ test();
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/js1_2/function/function-001-n.js b/js/tests/js1_2/function/function-001-n.js
new file mode 100644
index 00000000000..e12143dc032
--- /dev/null
+++ b/js/tests/js1_2/function/function-001-n.js
@@ -0,0 +1,71 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ * File Name: boolean-001.js
+ * Description:
+ *
+ * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=99232
+ *
+ * eval("function f(){}function g(){}") at top level is an error for JS1.2
+ * and above (missing ; between named function expressions), but declares f
+ * and g as functions below 1.2.
+ *
+ * Fails to produce error regardless of version:
+ * js> version(100)
+ * 120
+ * js> eval("function f(){}function g(){}")
+ * js> version(120);
+ * 100
+ * js> eval("function f(){}function g(){}")
+ * js>
+ * Author: christine@netscape.com
+ * Date: 11 August 1998
+ */
+ var SECTION = "function-001.js";
+ var VERSION = "JS1_1";
+ startTest();
+ var TITLE = "functions not separated by semicolons are errors in version 120 and higher";
+ var BUGNUMBER="99232";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = new Array();
+
+ testcases[tc++] = new TestCase(
+ SECTION,
+ "eval(\"function f(){}function g(){}\")",
+ "error",
+ eval("function f(){}function g(){}") );
+
+ test();
+
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/js1_2/function/length.js b/js/tests/js1_2/function/length.js
new file mode 100644
index 00000000000..a9c5de1ab1f
--- /dev/null
+++ b/js/tests/js1_2/function/length.js
@@ -0,0 +1,90 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: 15.3.5.1.js
+ ECMA Section: Function.length
+ Description:
+
+ The value of the length property is usually an integer that indicates the
+ "typical" number of arguments expected by the function. However, the
+ language permits the function to be invoked with some other number of
+ arguments. The behavior of a function when invoked on a number of arguments
+ other than the number specified by its length property depends on the function.
+
+ This checks the pre-ecma behavior Function.length.
+
+ http://scopus.mcom.com/bugsplat/show_bug.cgi?id=104204
+
+
+ Author: christine@netscape.com
+ Date: 12 november 1997
+*/
+
+ var SECTION = "function/length.js";
+ var VERSION = "ECMA_1";
+ startTest();
+ var TITLE = "Function.length";
+ var BUGNUMBER="104204";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = new Array();
+
+ var f = new Function( "a","b", "c", "return f.length");
+
+ if ( version() <= 120 ) {
+
+ testcases[tc++] = new TestCase( SECTION,
+ 'var f = new Function( "a","b", "c", "return f.length"); f()',
+ 0,
+ f() );
+
+ testcases[tc++] = new TestCase( SECTION,
+ 'var f = new Function( "a","b", "c", "return f.length"); f(1,2,3,4,5)',
+ 5,
+ f(1,2,3,4,5) );
+ } else {
+
+ testcases[tc++] = new TestCase( SECTION,
+ 'var f = new Function( "a","b", "c", "return f.length"); f()',
+ 3,
+ f() );
+
+ testcases[tc++] = new TestCase( SECTION,
+ 'var f = new Function( "a","b", "c", "return f.length"); f(1,2,3,4,5)',
+ 3,
+ f(1,2,3,4,5) );
+
+
+ }
+ test();
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/js1_2/function/nesting-1.js b/js/tests/js1_2/function/nesting-1.js
new file mode 100644
index 00000000000..d8acb7d9b84
--- /dev/null
+++ b/js/tests/js1_2/function/nesting-1.js
@@ -0,0 +1,58 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: nesting-1.js
+ Reference: http://scopus.mcom.com/bugsplat/show_bug.cgi?id=122040
+ Description: Regression test for a nested function
+
+ Author: christine@netscape.com
+ Date: 15 June 1998
+*/
+
+ var SECTION = "function/nesting-1.js";
+ var VERSION = "JS_12";
+ startTest();
+ var TITLE = "Regression test for 122040";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = new Array();
+
+ function f(a) {function g(b) {return a+b;}; return g;}; f(7)
+
+ testcases[tc++] = new TestCase( SECTION,
+ 'function f(a) {function g(b) {return a+b;}; return g;}; typeof f(7)',
+ "function",
+ typeof f(7) );
+
+ test();
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/js1_2/function/nesting.js b/js/tests/js1_2/function/nesting.js
new file mode 100644
index 00000000000..91d9cf2e74b
--- /dev/null
+++ b/js/tests/js1_2/function/nesting.js
@@ -0,0 +1,80 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: nesting.js
+ Description: 'This tests the nesting of functions'
+
+ Author: Nick Lerissa
+ Date: Fri Feb 13 09:58:28 PST 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'functions: nesting';
+
+ writeHeaderToLog('Executing script: nesting.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+
+ function outer_func(x)
+ {
+ var y = "outer";
+
+ testcases[count++] = new TestCase( SECTION, "outer:x ",
+ 1111, x);
+ testcases[count++] = new TestCase( SECTION, "outer:y ",
+ 'outer', y);
+ function inner_func(x)
+ {
+ var y = "inner";
+ testcases[count++] = new TestCase( SECTION, "inner:x ",
+ 2222, x);
+ testcases[count++] = new TestCase( SECTION, "inner:y ",
+ 'inner', y);
+ };
+
+ inner_func(2222);
+ testcases[count++] = new TestCase( SECTION, "outer:x ",
+ 1111, x);
+ testcases[count++] = new TestCase( SECTION, "outer:y ",
+ 'outer', y);
+ }
+
+ outer_func(1111);
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
+
diff --git a/js/tests/js1_2/function/regexparg-1.js b/js/tests/js1_2/function/regexparg-1.js
new file mode 100644
index 00000000000..f0c38899f24
--- /dev/null
+++ b/js/tests/js1_2/function/regexparg-1.js
@@ -0,0 +1,95 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: regexparg-1.js
+ Description:
+
+ Regression test for
+ http://scopus/bugsplat/show_bug.cgi?id=122787
+ Passing a regular expression as the first constructor argument fails
+
+ Author: christine@netscape.com
+ Date: 15 June 1998
+*/
+
+ var SECTION = "JS_1.2";
+ var VERSION = "JS_1.2";
+ startTest();
+ var TITLE = "The variable statment";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = new Array();
+
+ function f(x) {return x;}
+
+ x = f(/abc/);
+
+ testcases[tc++] = new TestCase( SECTION,
+ "function f(x) {return x;}; f()",
+ void 0,
+ f() );
+
+ testcases[tc++] = new TestCase( SECTION,
+ "f(\"hi\")",
+ "hi",
+ f("hi") );
+
+ testcases[tc++] = new TestCase( SECTION,
+ "new f(/abc/) +''",
+ "/abc/",
+ new f(/abc/) +"" );
+
+ testcases[tc++] = new TestCase( SECTION,
+ "f(/abc/)+'')",
+ "/abc/",
+ f(/abc/) +'');
+
+ testcases[tc++] = new TestCase( SECTION,
+ "typeof f(/abc/)",
+ "function",
+ typeof f(/abc/) );
+
+ testcases[tc++] = new TestCase( SECTION,
+ "typeof new f(/abc/)",
+ "function",
+ typeof new f(/abc/) );
+
+ testcases[tc++] = new TestCase( SECTION,
+ "x = new f(/abc/); x(\"hi\")",
+ null,
+ x("hi") );
+
+
+ // js> x()
+ test();
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/js1_2/function/regexparg-2-n.js b/js/tests/js1_2/function/regexparg-2-n.js
new file mode 100644
index 00000000000..ca5c07c0407
--- /dev/null
+++ b/js/tests/js1_2/function/regexparg-2-n.js
@@ -0,0 +1,63 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: regexparg-1.js
+ Description:
+
+ Regression test for
+ http://scopus/bugsplat/show_bug.cgi?id=122787
+ Passing a regular expression as the first constructor argument fails
+
+ Author: christine@netscape.com
+ Date: 15 June 1998
+*/
+
+ var SECTION = "JS_1.2";
+ var VERSION = "JS_1.2";
+ startTest();
+ var TITLE = "The variable statment";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = new Array();
+
+ function f(x) {return x;}
+
+ x = f(/abc/);
+
+ testcases[tc++] = new TestCase( SECTION,
+ "function f(x) {return x;}; x = f(/abc/); x()",
+ "error",
+ x() );
+
+ test();
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/js1_2/function/tostring-1.js b/js/tests/js1_2/function/tostring-1.js
new file mode 100644
index 00000000000..1b8415b217f
--- /dev/null
+++ b/js/tests/js1_2/function/tostring-1.js
@@ -0,0 +1,140 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: tostring-1.js
+ Section: Function.toString
+ Description:
+
+ Since the behavior of Function.toString() is implementation-dependent,
+ toString tests for function are not in the ECMA suite.
+
+ Currently, an attempt to parse the toString output for some functions
+ and verify that the result is something reasonable.
+
+ Author: christine@netscape.com
+ Date: 12 november 1997
+*/
+
+ var SECTION = "tostring-1";
+ var VERSION = "JS1_2";
+ startTest();
+ var TITLE = "Function.toString()";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = new Array();
+
+ var tab = " ";
+
+ t1 = new TestFunction( "stub", "value", tab + "return value;" );
+
+ t2 = new TestFunction( "ToString", "object", tab+"return object + \"\";" );
+
+ t3 = new TestFunction( "Add", "a, b, c, d, e", tab +"var s = a + b + c + d + e;\n" +
+ tab + "return s;" );
+
+ t4 = new TestFunction( "noop", "value" );
+
+ t5 = new TestFunction( "anonymous", "", tab+"return \"hello!\";" );
+
+ var f = new Function( "return \"hello!\"");
+
+ testcases[tc++] = new TestCase( SECTION,
+ "stub.toString()",
+ t1.valueOf(),
+ stub.toString() );
+
+ testcases[tc++] = new TestCase( SECTION,
+ "ToString.toString()",
+ t2.valueOf(),
+ ToString.toString() );
+
+ testcases[tc++] = new TestCase( SECTION,
+ "Add.toString()",
+ t3.valueOf(),
+ Add.toString() );
+
+ testcases[tc++] = new TestCase( SECTION,
+ "noop.toString()",
+ t4.toString(),
+ noop.toString() );
+
+ testcases[tc++] = new TestCase( SECTION,
+ "f.toString()",
+ t5.toString(),
+ f.toString() );
+ test();
+
+function noop( value ) {
+}
+function Add( a, b, c, d, e ) {
+ var s = a + b + c + d + e;
+ return s;
+}
+function stub( value ) {
+ return value;
+}
+function ToString( object ) {
+ return object + "";
+}
+
+function ToBoolean( value ) {
+ if ( value == 0 || value == NaN || value == false ) {
+ return false;
+ } else {
+ return true;
+ }
+}
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
+
+function TestFunction( name, args, body ) {
+ if ( name == "anonymous" && version() == 120 ) {
+ name = "";
+ }
+
+ this.name = name;
+ this.arguments = args.toString();
+ this.body = body;
+
+ /* the format of Function.toString() in JavaScript 1.2 is:
+ /n
+ function name ( arguments ) {
+ body
+ }
+ */
+ this.value = "\nfunction " + (name ? name : "" )+
+ "("+args+") {\n"+ (( body ) ? body +"\n" : "") + "}\n";
+
+ this.toString = new Function( "return this.value" );
+ this.valueOf = new Function( "return this.value" );
+ return this;
+}
diff --git a/js/tests/js1_2/function/tostring-2.js b/js/tests/js1_2/function/tostring-2.js
new file mode 100644
index 00000000000..03b94dff237
--- /dev/null
+++ b/js/tests/js1_2/function/tostring-2.js
@@ -0,0 +1,182 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: tostring-1.js
+ Section: Function.toString
+ Description:
+
+ Since the behavior of Function.toString() is implementation-dependent,
+ toString tests for function are not in the ECMA suite.
+
+ Currently, an attempt to parse the toString output for some functions
+ and verify that the result is something reasonable.
+
+ This verifies
+ http://scopus.mcom.com/bugsplat/show_bug.cgi?id=99212
+
+ Author: christine@netscape.com
+ Date: 12 november 1997
+*/
+
+ var SECTION = "tostring-2";
+ var VERSION = "JS1_2";
+ startTest();
+ var TITLE = "Function.toString()";
+ var BUGNUMBER="123444";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = new Array();
+
+ var tab = " ";
+
+
+var equals = new TestFunction( "Equals", "a, b", tab+ "return a == b;" );
+function Equals (a, b) {
+ return a == b;
+}
+
+var reallyequals = new TestFunction( "ReallyEquals", "a, b",
+ ( version() <= 120 ) ? tab +"return a == b;" : tab +"return a === b;" );
+function ReallyEquals( a, b ) {
+ return a === b;
+}
+
+var doesntequal = new TestFunction( "DoesntEqual", "a, b", tab + "return a != b;" );
+function DoesntEqual( a, b ) {
+ return a != b;
+}
+
+var reallydoesntequal = new TestFunction( "ReallyDoesntEqual", "a, b",
+ ( version() <= 120 ) ? tab +"return a != b;" : tab +"return a !== b;" );
+function ReallyDoesntEqual( a, b ) {
+ return a !== b;
+}
+
+var testor = new TestFunction( "TestOr", "a", tab+"if (a == null || a == void 0) {\n"+
+ tab +tab+"return 0;\n"+tab+"} else {\n"+tab+tab+"return a;\n"+tab+"}" );
+function TestOr( a ) {
+ if ( a == null || a == void 0 )
+ return 0;
+ else
+ return a;
+}
+
+var testand = new TestFunction( "TestAnd", "a", tab+"if (a != null && a != void 0) {\n"+
+ tab+tab+"return a;\n" + tab+ "} else {\n"+tab+tab+"return 0;\n"+tab+"}" );
+function TestAnd( a ) {
+ if ( a != null && a != void 0 )
+ return a;
+ else
+ return 0;
+}
+
+var or = new TestFunction( "Or", "a, b", tab + "return a | b;" );
+function Or( a, b ) {
+ return a | b;
+}
+
+var and = new TestFunction( "And", "a, b", tab + "return a & b;" );
+function And( a, b ) {
+ return a & b;
+}
+
+var xor = new TestFunction( "XOr", "a, b", tab + "return a ^ b;" );
+function XOr( a, b ) {
+ return a ^ b;
+}
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "Equals.toString()",
+ equals.valueOf(),
+ Equals.toString() );
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "ReallyEquals.toString()",
+ reallyequals.valueOf(),
+ ReallyEquals.toString() );
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "DoesntEqual.toString()",
+ doesntequal.valueOf(),
+ DoesntEqual.toString() );
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "ReallyDoesntEqual.toString()",
+ reallydoesntequal.valueOf(),
+ ReallyDoesntEqual.toString() );
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "TestOr.toString()",
+ testor.valueOf(),
+ TestOr.toString() );
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "TestAnd.toString()",
+ testand.valueOf(),
+ TestAnd.toString() );
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "Or.toString()",
+ or.valueOf(),
+ Or.toString() );
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "And.toString()",
+ and.valueOf(),
+ And.toString() );
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "XOr.toString()",
+ xor.valueOf(),
+ XOr.toString() );
+
+ test();
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
+function TestFunction( name, args, body ) {
+ this.name = name;
+ this.arguments = args.toString();
+ this.body = body;
+
+ /* the format of Function.toString() in JavaScript 1.2 is:
+ /n
+ function name ( arguments ) {
+ body
+ }
+ */
+ this.value = "\nfunction " + (name ? name : "anonymous" )+
+ "("+args+") {\n"+ (( body ) ? body +"\n" : "") + "}\n";
+
+ this.toString = new Function( "return this.value" );
+ this.valueOf = new Function( "return this.value" );
+ return this;
+}
diff --git a/js/tests/js1_2/jsref.js b/js/tests/js1_2/jsref.js
new file mode 100644
index 00000000000..cf8893ce9e5
--- /dev/null
+++ b/js/tests/js1_2/jsref.js
@@ -0,0 +1,223 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+var completed = false;
+var testcases;
+var tc = 0;
+
+SECTION = "";
+VERSION = "";
+BUGNUMBER = "";
+EXCLUDE = "";
+
+/*
+ * constant strings
+ */
+var GLOBAL = "[object global]";
+var PASSED = " PASSED!"
+var FAILED = " FAILED! expected: ";
+
+var DEBUG = false;
+
+version("120");
+/*
+ * change this for date tests if you're not in PST
+ */
+
+TZ_DIFF = -8;
+/* wrapper for test cas constructor that doesn't require the SECTION
+ * argument.
+ */
+
+function AddTestCase( description, expect, actual ) {
+ testcases[tc++] = new TestCase( SECTION, description, expect, actual );
+}
+function TestCase( n, d, e, a ) {
+ this.name = n;
+ this.description = d;
+ this.expect = e;
+ this.actual = a;
+ this.passed = true;
+ this.reason = "";
+ this.bugnumber = BUGNUMBER;
+
+ this.passed = getTestCaseResult( this.expect, this.actual );
+}
+function startTest() {
+ // JavaScript 1.3 is supposed to be compliant ecma version 1.0
+ if ( VERSION == "ECMA_1" ) {
+ version ( "130" );
+ }
+ if ( VERSION == "JS_1.3" ) {
+ version ( "130" );
+ }
+ if ( VERSION == "JS_1.2" ) {
+ version ( "120" );
+ }
+ if ( VERSION == "JS_1.1" ) {
+ version ( "110" );
+ }
+ // for ecma version 2.0, we will leave the javascript version to
+ // the default ( for now ).
+ // print out bugnumber
+
+ if ( BUGNUMBER ) {
+ writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
+ }
+
+ testcases = new Array();
+ tc = 0;
+
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
+function getTestCaseResult( expect, actual ) {
+ // because ( NaN == NaN ) always returns false, need to do
+ // a special compare to see if we got the right result.
+ if ( actual != actual ) {
+ if ( typeof actual == "object" ) {
+ actual = "NaN object";
+ } else {
+ actual = "NaN number";
+ }
+ }
+ if ( expect != expect ) {
+ if ( typeof expect == "object" ) {
+ expect = "NaN object";
+ } else {
+ expect = "NaN number";
+ }
+ }
+
+ var passed = ( expect == actual ) ? true : false;
+
+ // if both objects are numbers, give a little leeway for rounding.
+ if ( !passed
+ && typeof(actual) == "number"
+ && typeof(expect) == "number"
+ ) {
+ if ( Math.abs(actual-expect) < 0.0000001 ) {
+ passed = true;
+ }
+ }
+
+ // verify type is the same
+ if ( typeof(expect) != typeof(actual) ) {
+ passed = false;
+ }
+
+ return passed;
+}
+/*
+ * Begin printing functions. These functions use the shell's
+ * print function. When running tests in the browser, these
+ * functions, override these functions with functions that use
+ * document.write.
+ */
+
+function writeTestCaseResult( expect, actual, string ) {
+ var passed = getTestCaseResult( expect, actual );
+ writeFormattedResult( expect, actual, string, passed );
+ return passed;
+}
+function writeFormattedResult( expect, actual, string, passed ) {
+ var s = string ;
+ s += ( passed ) ? PASSED : FAILED + expect;
+ writeLineToLog( s);
+ return passed;
+}
+function writeLineToLog( string ) {
+ print( string );
+}
+function writeHeaderToLog( string ) {
+ print( string );
+}
+/* end of print functions */
+
+
+function stopTest() {
+ var sizeTag = "<#TEST CASES SIZE>";
+ var doneTag = "<#TEST CASES DONE>";
+ var beginTag = "<#TEST CASE ";
+ var endTag = ">";
+
+ print(sizeTag);
+ print(testcases.length);
+ for (tc = 0; tc < testcases.length; tc++)
+ {
+ print(beginTag + 'PASSED' + endTag);
+ print(testcases[tc].passed);
+ print(beginTag + 'NAME' + endTag);
+ print(testcases[tc].name);
+ print(beginTag + 'EXPECTED' + endTag);
+ print(testcases[tc].expect);
+ print(beginTag + 'ACTUAL' + endTag);
+ print(testcases[tc].actual);
+ print(beginTag + 'DESCRIPTION' + endTag);
+ print(testcases[tc].description);
+ print(beginTag + 'REASON' + endTag);
+ print(( testcases[tc].passed ) ? "" : "wrong value ");
+ print(beginTag + 'BUGNUMBER' + endTag);
+ print( BUGNUMBER );
+ }
+ print(doneTag);
+ gc();
+}
+
+function getFailedCases() {
+ for ( var i = 0; i < testcases.length; i++ ) {
+ if ( ! testcases[i].passed ) {
+ print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect );
+ }
+ }
+}
+function err( msg, page, line ) {
+ testcases[tc].actual = "error";
+ testcases[tc].reason = msg;
+ writeTestCaseResult( testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+ testcases[tc].actual +
+ ": " + testcases[tc].reason );
+ stopTest();
+ return true;
+}
+function Enumerate ( o ) {
+ var p;
+ for ( p in o ) {
+ print( p +": " + o[p] );
+ }
+}
+function GetContext() {
+ return Packages.com.netscape.javascript.Context.getCurrentContext();
+}
+function OptLevel( i ) {
+ i = Number(i);
+ var cx = GetContext();
+ cx.setOptimizationLevel(i);
+}
diff --git a/js/tests/js1_2/operator/equality.js b/js/tests/js1_2/operator/equality.js
new file mode 100644
index 00000000000..173b128b3c8
--- /dev/null
+++ b/js/tests/js1_2/operator/equality.js
@@ -0,0 +1,69 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: equality.js
+ Description: 'This tests the operator =='
+
+ Author: Nick Lerissa
+ Date: Fri Feb 13 09:58:28 PST 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'operator "=="';
+
+ writeHeaderToLog('Executing script: equality.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+
+ // the following two tests are incorrect
+ //testcases[count++] = new TestCase( SECTION, "(new String('') == new String('')) ",
+ // true, (new String('') == new String('')));
+
+ //testcases[count++] = new TestCase( SECTION, "(new Boolean(true) == new Boolean(true)) ",
+ // true, (new Boolean(true) == new Boolean(true)));
+
+ testcases[count++] = new TestCase( SECTION, "(new String('x') == 'x') ",
+ false, (new String('x') == 'x'));
+
+ testcases[count++] = new TestCase( SECTION, "('x' == new String('x')) ",
+ false, ('x' == new String('x')));
+
+
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
+
diff --git a/js/tests/js1_2/operator/strictEquality.js b/js/tests/js1_2/operator/strictEquality.js
new file mode 100644
index 00000000000..59189a866de
--- /dev/null
+++ b/js/tests/js1_2/operator/strictEquality.js
@@ -0,0 +1,89 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: strictEquality.js
+ Description: 'This tests the operator ==='
+
+ Author: Nick Lerissa
+ Date: Fri Feb 13 09:58:28 PST 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'operator "==="';
+
+ writeHeaderToLog('Executing script: strictEquality.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+
+ testcases[count++] = new TestCase( SECTION, "('8' === 8) ",
+ false, ('8' === 8));
+
+ testcases[count++] = new TestCase( SECTION, "(8 === 8) ",
+ true, (8 === 8));
+
+ testcases[count++] = new TestCase( SECTION, "(8 === true) ",
+ false, (8 === true));
+
+ testcases[count++] = new TestCase( SECTION, "(new String('') === new String('')) ",
+ false, (new String('') === new String('')));
+
+ testcases[count++] = new TestCase( SECTION, "(new Boolean(true) === new Boolean(true))",
+ false, (new Boolean(true) === new Boolean(true)));
+
+ var anObject = { one:1 , two:2 };
+
+ testcases[count++] = new TestCase( SECTION, "(anObject === anObject) ",
+ true, (anObject === anObject));
+
+ testcases[count++] = new TestCase( SECTION, "(anObject === { one:1 , two:2 }) ",
+ false, (anObject === { one:1 , two:2 }));
+
+ testcases[count++] = new TestCase( SECTION, "({ one:1 , two:2 } === anObject) ",
+ false, ({ one:1 , two:2 } === anObject));
+
+ testcases[count++] = new TestCase( SECTION, "(null === null) ",
+ true, (null === null));
+
+ testcases[count++] = new TestCase( SECTION, "(null === 0) ",
+ false, (null === 0));
+
+ testcases[count++] = new TestCase( SECTION, "(true === !false) ",
+ true, (true === !false));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
+
diff --git a/js/tests/js1_2/regexp/RegExp_dollar_number.js b/js/tests/js1_2/regexp/RegExp_dollar_number.js
new file mode 100644
index 00000000000..c51095a7fde
--- /dev/null
+++ b/js/tests/js1_2/regexp/RegExp_dollar_number.js
@@ -0,0 +1,105 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: RegExp_dollar_number.js
+ Description: 'Tests RegExps $1, ..., $9 properties'
+
+ Author: Nick Lerissa
+ Date: March 12, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: $1, ..., $9';
+ var BUGNUMBER="123802";
+
+ writeHeaderToLog('Executing script: RegExp_dollar_number.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$1
+ 'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/);
+ testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$1",
+ 'abcdefghi', RegExp.$1);
+
+ // 'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$2
+ testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$2",
+ 'bcdefgh', RegExp.$2);
+
+ // 'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$3
+ testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$3",
+ 'cdefg', RegExp.$3);
+
+ // 'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$4
+ testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$4",
+ 'def', RegExp.$4);
+
+ // 'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$5
+ testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$5",
+ 'e', RegExp.$5);
+
+ // 'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$6
+ testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$6",
+ '', RegExp.$6);
+
+ var a_to_z = 'abcdefghijklmnopqrstuvwxyz';
+ var regexp1 = /(a)b(c)d(e)f(g)h(i)j(k)l(m)n(o)p(q)r(s)t(u)v(w)x(y)z/
+ // 'abcdefghijklmnopqrstuvwxyz'.match(/(a)b(c)d(e)f(g)h(i)j(k)l(m)n(o)p(q)r(s)t(u)v(w)x(y)z/); RegExp.$1
+ a_to_z.match(regexp1);
+
+ testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$1",
+ 'a', RegExp.$1);
+ testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$2",
+ 'c', RegExp.$2);
+ testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$3",
+ 'e', RegExp.$3);
+ testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$4",
+ 'g', RegExp.$4);
+ testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$5",
+ 'i', RegExp.$5);
+ testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$6",
+ 'k', RegExp.$6);
+ testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$7",
+ 'm', RegExp.$7);
+ testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$8",
+ 'o', RegExp.$8);
+ testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$9",
+ 'q', RegExp.$9);
+/*
+ testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$10",
+ 's', RegExp.$10);
+*/
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/RegExp_input.js b/js/tests/js1_2/regexp/RegExp_input.js
new file mode 100644
index 00000000000..aaec857b136
--- /dev/null
+++ b/js/tests/js1_2/regexp/RegExp_input.js
@@ -0,0 +1,99 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: RegExp_input.js
+ Description: 'Tests RegExps input property'
+
+ Author: Nick Lerissa
+ Date: March 13, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: input';
+
+ writeHeaderToLog('Executing script: RegExp_input.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ RegExp.input = "abcd12357efg";
+
+ // RegExp.input = "abcd12357efg"; RegExp.input
+ RegExp.input = "abcd12357efg";
+ testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; RegExp.input",
+ "abcd12357efg", RegExp.input);
+
+ // RegExp.input = "abcd12357efg"; /\d+/.exec('2345')
+ RegExp.input = "abcd12357efg";
+ testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /\\d+/.exec('2345')",
+ String(["2345"]), String(/\d+/.exec('2345')));
+
+ // RegExp.input = "abcd12357efg"; /\d+/.exec()
+ RegExp.input = "abcd12357efg";
+ testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /\\d+/.exec()",
+ String(["12357"]), String(/\d+/.exec()));
+
+ // RegExp.input = "abcd12357efg"; /[h-z]+/.exec()
+ RegExp.input = "abcd12357efg";
+ testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /[h-z]+/.exec()",
+ null, /[h-z]+/.exec());
+
+ // RegExp.input = "abcd12357efg"; /\d+/.test('2345')
+ RegExp.input = "abcd12357efg";
+ testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /\\d+/.test('2345')",
+ true, /\d+/.test('2345'));
+
+ // RegExp.input = "abcd12357efg"; /\d+/.test()
+ RegExp.input = "abcd12357efg";
+ testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /\\d+/.test()",
+ true, /\d+/.test());
+
+ // RegExp.input = "abcd12357efg"; (new RegExp('d+')).test()
+ RegExp.input = "abcd12357efg";
+ testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; (new RegExp('d+')).test()",
+ true, (new RegExp('d+')).test());
+
+ // RegExp.input = "abcd12357efg"; /[h-z]+/.test()
+ RegExp.input = "abcd12357efg";
+ testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /[h-z]+/.test()",
+ false, /[h-z]+/.test());
+
+ // RegExp.input = "abcd12357efg"; (new RegExp('[h-z]+')).test()
+ RegExp.input = "abcd12357efg";
+ testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; (new RegExp('[h-z]+')).test()",
+ false, (new RegExp('[h-z]+')).test());
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/RegExp_input_as_array.js b/js/tests/js1_2/regexp/RegExp_input_as_array.js
new file mode 100644
index 00000000000..449f85d327f
--- /dev/null
+++ b/js/tests/js1_2/regexp/RegExp_input_as_array.js
@@ -0,0 +1,99 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: RegExp_input_as_array.js
+ Description: 'Tests RegExps $_ property (same tests as RegExp_input.js but using $_)'
+
+ Author: Nick Lerissa
+ Date: March 13, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: input';
+
+ writeHeaderToLog('Executing script: RegExp_input.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ RegExp['$_'] = "abcd12357efg";
+
+ // RegExp['$_'] = "abcd12357efg"; RegExp['$_']
+ RegExp['$_'] = "abcd12357efg";
+ testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; RegExp['$_']",
+ "abcd12357efg", RegExp['$_']);
+
+ // RegExp['$_'] = "abcd12357efg"; /\d+/.exec('2345')
+ RegExp['$_'] = "abcd12357efg";
+ testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /\\d+/.exec('2345')",
+ String(["2345"]), String(/\d+/.exec('2345')));
+
+ // RegExp['$_'] = "abcd12357efg"; /\d+/.exec()
+ RegExp['$_'] = "abcd12357efg";
+ testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /\\d+/.exec()",
+ String(["12357"]), String(/\d+/.exec()));
+
+ // RegExp['$_'] = "abcd12357efg"; /[h-z]+/.exec()
+ RegExp['$_'] = "abcd12357efg";
+ testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /[h-z]+/.exec()",
+ null, /[h-z]+/.exec());
+
+ // RegExp['$_'] = "abcd12357efg"; /\d+/.test('2345')
+ RegExp['$_'] = "abcd12357efg";
+ testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /\\d+/.test('2345')",
+ true, /\d+/.test('2345'));
+
+ // RegExp['$_'] = "abcd12357efg"; /\d+/.test()
+ RegExp['$_'] = "abcd12357efg";
+ testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /\\d+/.test()",
+ true, /\d+/.test());
+
+ // RegExp['$_'] = "abcd12357efg"; /[h-z]+/.test()
+ RegExp['$_'] = "abcd12357efg";
+ testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /[h-z]+/.test()",
+ false, /[h-z]+/.test());
+
+ // RegExp['$_'] = "abcd12357efg"; (new RegExp('\d+')).test()
+ RegExp['$_'] = "abcd12357efg";
+ testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; (new RegExp('\d+')).test()",
+ true, (new RegExp('\d+')).test());
+
+ // RegExp['$_'] = "abcd12357efg"; (new RegExp('[h-z]+')).test()
+ RegExp['$_'] = "abcd12357efg";
+ testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; (new RegExp('[h-z]+')).test()",
+ false, (new RegExp('[h-z]+')).test());
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/RegExp_lastIndex.js b/js/tests/js1_2/regexp/RegExp_lastIndex.js
new file mode 100644
index 00000000000..f8fdcc5c8f5
--- /dev/null
+++ b/js/tests/js1_2/regexp/RegExp_lastIndex.js
@@ -0,0 +1,80 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: RegExp_lastIndex.js
+ Description: 'Tests RegExps lastIndex property'
+
+ Author: Nick Lerissa
+ Date: March 17, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: lastIndex';
+ var BUGNUMBER="123802";
+
+ writeHeaderToLog('Executing script: RegExp_lastIndex.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // re=/x./g; re.lastIndex=4; re.exec('xyabcdxa');
+ re=/x./g;
+ re.lastIndex=4;
+ testcases[count++] = new TestCase ( SECTION, "re=/x./g; re.lastIndex=4; re.exec('xyabcdxa')",
+ '["xa"]', String(re.exec('xyabcdxa')));
+
+ // re.lastIndex
+ testcases[count++] = new TestCase ( SECTION, "re.lastIndex",
+ 8, re.lastIndex);
+
+ // re.exec('xyabcdef');
+ testcases[count++] = new TestCase ( SECTION, "re.exec('xyabcdef')",
+ null, re.exec('xyabcdef'));
+
+ // re.lastIndex
+ testcases[count++] = new TestCase ( SECTION, "re.lastIndex",
+ 0, re.lastIndex);
+
+ // re.exec('xyabcdef');
+ testcases[count++] = new TestCase ( SECTION, "re.exec('xyabcdef')",
+ '["xy"]', String(re.exec('xyabcdef')));
+
+ // re.lastIndex=30; re.exec('123xaxbxc456');
+ re.lastIndex=30;
+ testcases[count++] = new TestCase ( SECTION, "re.lastIndex=30; re.exec('123xaxbxc456')",
+ null, re.exec('123xaxbxc456'));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/RegExp_lastMatch.js b/js/tests/js1_2/regexp/RegExp_lastMatch.js
new file mode 100644
index 00000000000..0b58c714dff
--- /dev/null
+++ b/js/tests/js1_2/regexp/RegExp_lastMatch.js
@@ -0,0 +1,82 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: RegExp_lastMatch.js
+ Description: 'Tests RegExps lastMatch property'
+
+ Author: Nick Lerissa
+ Date: March 12, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: lastMatch';
+
+ writeHeaderToLog('Executing script: RegExp_lastMatch.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'foo'.match(/foo/); RegExp.lastMatch
+ 'foo'.match(/foo/);
+ testcases[count++] = new TestCase ( SECTION, "'foo'.match(/foo/); RegExp.lastMatch",
+ 'foo', RegExp.lastMatch);
+
+ // 'foo'.match(new RegExp('foo')); RegExp.lastMatch
+ 'foo'.match(new RegExp('foo'));
+ testcases[count++] = new TestCase ( SECTION, "'foo'.match(new RegExp('foo')); RegExp.lastMatch",
+ 'foo', RegExp.lastMatch);
+
+ // 'xxx'.match(/bar/); RegExp.lastMatch
+ 'xxx'.match(/bar/);
+ testcases[count++] = new TestCase ( SECTION, "'xxx'.match(/bar/); RegExp.lastMatch",
+ 'foo', RegExp.lastMatch);
+
+ // 'xxx'.match(/$/); RegExp.lastMatch
+ 'xxx'.match(/$/);
+ testcases[count++] = new TestCase ( SECTION, "'xxx'.match(/$/); RegExp.lastMatch",
+ '', RegExp.lastMatch);
+
+ // 'abcdefg'.match(/^..(cd)[a-z]+/); RegExp.lastMatch
+ 'abcdefg'.match(/^..(cd)[a-z]+/);
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/^..(cd)[a-z]+/); RegExp.lastMatch",
+ 'abcdefg', RegExp.lastMatch);
+
+ // 'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/); RegExp.lastMatch
+ 'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/);
+ testcases[count++] = new TestCase ( SECTION, "'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\\1/); RegExp.lastMatch",
+ 'abcdefgabcdefg', RegExp.lastMatch);
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/RegExp_lastMatch_as_array.js b/js/tests/js1_2/regexp/RegExp_lastMatch_as_array.js
new file mode 100644
index 00000000000..5da58dbd068
--- /dev/null
+++ b/js/tests/js1_2/regexp/RegExp_lastMatch_as_array.js
@@ -0,0 +1,82 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: RegExp_lastMatch_as_array.js
+ Description: 'Tests RegExps $& property (same tests as RegExp_lastMatch.js but using $&)'
+
+ Author: Nick Lerissa
+ Date: March 13, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: $&';
+
+ writeHeaderToLog('Executing script: RegExp_lastMatch_as_array.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'foo'.match(/foo/); RegExp['$&']
+ 'foo'.match(/foo/);
+ testcases[count++] = new TestCase ( SECTION, "'foo'.match(/foo/); RegExp['$&']",
+ 'foo', RegExp['$&']);
+
+ // 'foo'.match(new RegExp('foo')); RegExp['$&']
+ 'foo'.match(new RegExp('foo'));
+ testcases[count++] = new TestCase ( SECTION, "'foo'.match(new RegExp('foo')); RegExp['$&']",
+ 'foo', RegExp['$&']);
+
+ // 'xxx'.match(/bar/); RegExp['$&']
+ 'xxx'.match(/bar/);
+ testcases[count++] = new TestCase ( SECTION, "'xxx'.match(/bar/); RegExp['$&']",
+ 'foo', RegExp['$&']);
+
+ // 'xxx'.match(/$/); RegExp['$&']
+ 'xxx'.match(/$/);
+ testcases[count++] = new TestCase ( SECTION, "'xxx'.match(/$/); RegExp['$&']",
+ '', RegExp['$&']);
+
+ // 'abcdefg'.match(/^..(cd)[a-z]+/); RegExp['$&']
+ 'abcdefg'.match(/^..(cd)[a-z]+/);
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/^..(cd)[a-z]+/); RegExp['$&']",
+ 'abcdefg', RegExp['$&']);
+
+ // 'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/); RegExp['$&']
+ 'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/);
+ testcases[count++] = new TestCase ( SECTION, "'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\\1/); RegExp['$&']",
+ 'abcdefgabcdefg', RegExp['$&']);
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/RegExp_lastParen.js b/js/tests/js1_2/regexp/RegExp_lastParen.js
new file mode 100644
index 00000000000..dccce257225
--- /dev/null
+++ b/js/tests/js1_2/regexp/RegExp_lastParen.js
@@ -0,0 +1,97 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: RegExp_lastParen.js
+ Description: 'Tests RegExps lastParen property'
+
+ Author: Nick Lerissa
+ Date: March 12, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: lastParen';
+
+ writeHeaderToLog('Executing script: RegExp_lastParen.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'abcd'.match(/(abc)d/); RegExp.lastParen
+ 'abcd'.match(/(abc)d/);
+ testcases[count++] = new TestCase ( SECTION, "'abcd'.match(/(abc)d/); RegExp.lastParen",
+ 'abc', RegExp.lastParen);
+
+ // 'abcd'.match(new RegExp('(abc)d')); RegExp.lastParen
+ 'abcd'.match(new RegExp('(abc)d'));
+ testcases[count++] = new TestCase ( SECTION, "'abcd'.match(new RegExp('(abc)d')); RegExp.lastParen",
+ 'abc', RegExp.lastParen);
+
+ // 'abcd'.match(/(bcd)e/); RegExp.lastParen
+ 'abcd'.match(/(bcd)e/);
+ testcases[count++] = new TestCase ( SECTION, "'abcd'.match(/(bcd)e/); RegExp.lastParen",
+ 'abc', RegExp.lastParen);
+
+ // 'abcdefg'.match(/(a(b(c(d)e)f)g)/); RegExp.lastParen
+ 'abcdefg'.match(/(a(b(c(d)e)f)g)/);
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(a(b(c(d)e)f)g)/); RegExp.lastParen",
+ 'd', RegExp.lastParen);
+
+ // 'abcdefg'.match(/(a(b)c)(d(e)f)/); RegExp.lastParen
+ 'abcdefg'.match(/(a(b)c)(d(e)f)/);
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(a(b)c)(d(e)f)/); RegExp.lastParen",
+ 'e', RegExp.lastParen);
+
+ // 'abcdefg'.match(/(^)abc/); RegExp.lastParen
+ 'abcdefg'.match(/(^)abc/);
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(^)abc/); RegExp.lastParen",
+ '', RegExp.lastParen);
+
+ // 'abcdefg'.match(/(^a)bc/); RegExp.lastParen
+ 'abcdefg'.match(/(^a)bc/);
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(^a)bc/); RegExp.lastParen",
+ 'a', RegExp.lastParen);
+
+ // 'abcdefg'.match(new RegExp('(^a)bc')); RegExp.lastParen
+ 'abcdefg'.match(new RegExp('(^a)bc'));
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('(^a)bc')); RegExp.lastParen",
+ 'a', RegExp.lastParen);
+
+ // 'abcdefg'.match(/bc/); RegExp.lastParen
+ 'abcdefg'.match(/bc/);
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/bc/); RegExp.lastParen",
+ '', RegExp.lastParen);
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/RegExp_lastParen_as_array.js b/js/tests/js1_2/regexp/RegExp_lastParen_as_array.js
new file mode 100644
index 00000000000..11c247e886b
--- /dev/null
+++ b/js/tests/js1_2/regexp/RegExp_lastParen_as_array.js
@@ -0,0 +1,97 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: RegExp_lastParen_as_array.js
+ Description: 'Tests RegExps $+ property (same tests as RegExp_lastParen.js but using $+)'
+
+ Author: Nick Lerissa
+ Date: March 13, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: $+';
+
+ writeHeaderToLog('Executing script: RegExp_lastParen_as_array.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'abcd'.match(/(abc)d/); RegExp['$+']
+ 'abcd'.match(/(abc)d/);
+ testcases[count++] = new TestCase ( SECTION, "'abcd'.match(/(abc)d/); RegExp['$+']",
+ 'abc', RegExp['$+']);
+
+ // 'abcd'.match(/(bcd)e/); RegExp['$+']
+ 'abcd'.match(/(bcd)e/);
+ testcases[count++] = new TestCase ( SECTION, "'abcd'.match(/(bcd)e/); RegExp['$+']",
+ 'abc', RegExp['$+']);
+
+ // 'abcdefg'.match(/(a(b(c(d)e)f)g)/); RegExp['$+']
+ 'abcdefg'.match(/(a(b(c(d)e)f)g)/);
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(a(b(c(d)e)f)g)/); RegExp['$+']",
+ 'd', RegExp['$+']);
+
+ // 'abcdefg'.match(new RegExp('(a(b(c(d)e)f)g)')); RegExp['$+']
+ 'abcdefg'.match(new RegExp('(a(b(c(d)e)f)g)'));
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('(a(b(c(d)e)f)g)')); RegExp['$+']",
+ 'd', RegExp['$+']);
+
+ // 'abcdefg'.match(/(a(b)c)(d(e)f)/); RegExp['$+']
+ 'abcdefg'.match(/(a(b)c)(d(e)f)/);
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(a(b)c)(d(e)f)/); RegExp['$+']",
+ 'e', RegExp['$+']);
+
+ // 'abcdefg'.match(/(^)abc/); RegExp['$+']
+ 'abcdefg'.match(/(^)abc/);
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(^)abc/); RegExp['$+']",
+ '', RegExp['$+']);
+
+ // 'abcdefg'.match(/(^a)bc/); RegExp['$+']
+ 'abcdefg'.match(/(^a)bc/);
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(^a)bc/); RegExp['$+']",
+ 'a', RegExp['$+']);
+
+ // 'abcdefg'.match(new RegExp('(^a)bc')); RegExp['$+']
+ 'abcdefg'.match(new RegExp('(^a)bc'));
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('(^a)bc')); RegExp['$+']",
+ 'a', RegExp['$+']);
+
+ // 'abcdefg'.match(/bc/); RegExp['$+']
+ 'abcdefg'.match(/bc/);
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/bc/); RegExp['$+']",
+ '', RegExp['$+']);
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/RegExp_leftContext.js b/js/tests/js1_2/regexp/RegExp_leftContext.js
new file mode 100644
index 00000000000..8d3cd0438d2
--- /dev/null
+++ b/js/tests/js1_2/regexp/RegExp_leftContext.js
@@ -0,0 +1,87 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: RegExp_leftContext.js
+ Description: 'Tests RegExps leftContext property'
+
+ Author: Nick Lerissa
+ Date: March 12, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: leftContext';
+
+ writeHeaderToLog('Executing script: RegExp_leftContext.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'abc123xyz'.match(/123/); RegExp.leftContext
+ 'abc123xyz'.match(/123/);
+ testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/123/); RegExp.leftContext",
+ 'abc', RegExp.leftContext);
+
+ // 'abc123xyz'.match(/456/); RegExp.leftContext
+ 'abc123xyz'.match(/456/);
+ testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/456/); RegExp.leftContext",
+ 'abc', RegExp.leftContext);
+
+ // 'abc123xyz'.match(/abc123xyz/); RegExp.leftContext
+ 'abc123xyz'.match(/abc123xyz/);
+ testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/abc123xyz/); RegExp.leftContext",
+ '', RegExp.leftContext);
+
+ // 'xxxx'.match(/$/); RegExp.leftContext
+ 'xxxx'.match(/$/);
+ testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(/$/); RegExp.leftContext",
+ 'xxxx', RegExp.leftContext);
+
+ // 'test'.match(/^/); RegExp.leftContext
+ 'test'.match(/^/);
+ testcases[count++] = new TestCase ( SECTION, "'test'.match(/^/); RegExp.leftContext",
+ '', RegExp.leftContext);
+
+ // 'xxxx'.match(new RegExp('$')); RegExp.leftContext
+ 'xxxx'.match(new RegExp('$'));
+ testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(new RegExp('$')); RegExp.leftContext",
+ 'xxxx', RegExp.leftContext);
+
+ // 'test'.match(new RegExp('^')); RegExp.leftContext
+ 'test'.match(new RegExp('^'));
+ testcases[count++] = new TestCase ( SECTION, "'test'.match(new RegExp('^')); RegExp.leftContext",
+ '', RegExp.leftContext);
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/RegExp_leftContext_as_array.js b/js/tests/js1_2/regexp/RegExp_leftContext_as_array.js
new file mode 100644
index 00000000000..f79f4915aca
--- /dev/null
+++ b/js/tests/js1_2/regexp/RegExp_leftContext_as_array.js
@@ -0,0 +1,87 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: RegExp_leftContext_as_array.js
+ Description: 'Tests RegExps leftContext property (same tests as RegExp_leftContext.js but using $`)'
+
+ Author: Nick Lerissa
+ Date: March 12, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: $`';
+
+ writeHeaderToLog('Executing script: RegExp_leftContext_as_array.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'abc123xyz'.match(/123/); RegExp['$`']
+ 'abc123xyz'.match(/123/);
+ testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/123/); RegExp['$`']",
+ 'abc', RegExp['$`']);
+
+ // 'abc123xyz'.match(/456/); RegExp['$`']
+ 'abc123xyz'.match(/456/);
+ testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/456/); RegExp['$`']",
+ 'abc', RegExp['$`']);
+
+ // 'abc123xyz'.match(/abc123xyz/); RegExp['$`']
+ 'abc123xyz'.match(/abc123xyz/);
+ testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/abc123xyz/); RegExp['$`']",
+ '', RegExp['$`']);
+
+ // 'xxxx'.match(/$/); RegExp['$`']
+ 'xxxx'.match(/$/);
+ testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(/$/); RegExp['$`']",
+ 'xxxx', RegExp['$`']);
+
+ // 'test'.match(/^/); RegExp['$`']
+ 'test'.match(/^/);
+ testcases[count++] = new TestCase ( SECTION, "'test'.match(/^/); RegExp['$`']",
+ '', RegExp['$`']);
+
+ // 'xxxx'.match(new RegExp('$')); RegExp['$`']
+ 'xxxx'.match(new RegExp('$'));
+ testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(new RegExp('$')); RegExp['$`']",
+ 'xxxx', RegExp['$`']);
+
+ // 'test'.match(new RegExp('^')); RegExp['$`']
+ 'test'.match(new RegExp('^'));
+ testcases[count++] = new TestCase ( SECTION, "'test'.match(new RegExp('^')); RegExp['$`']",
+ '', RegExp['$`']);
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/RegExp_multiline.js b/js/tests/js1_2/regexp/RegExp_multiline.js
new file mode 100644
index 00000000000..ea20d4b6f9e
--- /dev/null
+++ b/js/tests/js1_2/regexp/RegExp_multiline.js
@@ -0,0 +1,126 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: RegExp_multiline.js
+ Description: 'Tests RegExps multiline property'
+
+ Author: Nick Lerissa
+ Date: March 12, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: multiline';
+
+ writeHeaderToLog('Executing script: RegExp_multiline.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // First we do a series of tests with RegExp.multiline set to false (default value)
+ // Following this we do the same tests with RegExp.multiline set true(**).
+ // RegExp.multiline
+ testcases[count++] = new TestCase ( SECTION, "RegExp.multiline",
+ false, RegExp.multiline);
+
+ // (multiline == false) '123\n456'.match(/^4../)
+ testcases[count++] = new TestCase ( SECTION, "(multiline == false) '123\\n456'.match(/^4../)",
+ null, '123\n456'.match(/^4../));
+
+ // (multiline == false) 'a11\na22\na23\na24'.match(/^a../g)
+ testcases[count++] = new TestCase ( SECTION, "(multiline == false) 'a11\\na22\\na23\\na24'.match(/^a../g)",
+ String(['a11']), String('a11\na22\na23\na24'.match(/^a../g)));
+
+ // (multiline == false) 'a11\na22'.match(/^.+^./)
+ testcases[count++] = new TestCase ( SECTION, "(multiline == false) 'a11\na22'.match(/^.+^./)",
+ null, 'a11\na22'.match(/^.+^./));
+
+ // (multiline == false) '123\n456'.match(/.3$/)
+ testcases[count++] = new TestCase ( SECTION, "(multiline == false) '123\\n456'.match(/.3$/)",
+ null, '123\n456'.match(/.3$/));
+
+ // (multiline == false) 'a11\na22\na23\na24'.match(/a..$/g)
+ testcases[count++] = new TestCase ( SECTION, "(multiline == false) 'a11\\na22\\na23\\na24'.match(/a..$/g)",
+ String(['a24']), String('a11\na22\na23\na24'.match(/a..$/g)));
+
+ // (multiline == false) 'abc\ndef'.match(/c$...$/)
+ testcases[count++] = new TestCase ( SECTION, "(multiline == false) 'abc\ndef'.match(/c$...$/)",
+ null, 'abc\ndef'.match(/c$...$/));
+
+ // (multiline == false) 'a11\na22\na23\na24'.match(new RegExp('a..$','g'))
+ testcases[count++] = new TestCase ( SECTION, "(multiline == false) 'a11\\na22\\na23\\na24'.match(new RegExp('a..$','g'))",
+ String(['a24']), String('a11\na22\na23\na24'.match(new RegExp('a..$','g'))));
+
+ // (multiline == false) 'abc\ndef'.match(new RegExp('c$...$'))
+ testcases[count++] = new TestCase ( SECTION, "(multiline == false) 'abc\ndef'.match(new RegExp('c$...$'))",
+ null, 'abc\ndef'.match(new RegExp('c$...$')));
+
+ // **Now we do the tests with RegExp.multiline set to true
+ // RegExp.multiline = true; RegExp.multiline
+ RegExp.multiline = true;
+ testcases[count++] = new TestCase ( SECTION, "RegExp.multiline = true; RegExp.multiline",
+ true, RegExp.multiline);
+
+ // (multiline == true) '123\n456'.match(/^4../)
+ testcases[count++] = new TestCase ( SECTION, "(multiline == true) '123\\n456'.match(/^4../)",
+ String(['456']), String('123\n456'.match(/^4../)));
+
+ // (multiline == true) 'a11\na22\na23\na24'.match(/^a../g)
+ testcases[count++] = new TestCase ( SECTION, "(multiline == true) 'a11\\na22\\na23\\na24'.match(/^a../g)",
+ String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(/^a../g)));
+
+ // (multiline == true) 'a11\na22'.match(/^.+^./)
+ //testcases[count++] = new TestCase ( SECTION, "(multiline == true) 'a11\na22'.match(/^.+^./)",
+ // String(['a11\na']), String('a11\na22'.match(/^.+^./)));
+
+ // (multiline == true) '123\n456'.match(/.3$/)
+ testcases[count++] = new TestCase ( SECTION, "(multiline == true) '123\\n456'.match(/.3$/)",
+ String(['23']), String('123\n456'.match(/.3$/)));
+
+ // (multiline == true) 'a11\na22\na23\na24'.match(/a..$/g)
+ testcases[count++] = new TestCase ( SECTION, "(multiline == true) 'a11\\na22\\na23\\na24'.match(/a..$/g)",
+ String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(/a..$/g)));
+
+ // (multiline == true) 'a11\na22\na23\na24'.match(new RegExp('a..$','g'))
+ testcases[count++] = new TestCase ( SECTION, "(multiline == true) 'a11\\na22\\na23\\na24'.match(new RegExp('a..$','g'))",
+ String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(new RegExp('a..$','g'))));
+
+ // (multiline == true) 'abc\ndef'.match(/c$....$/)
+ //testcases[count++] = new TestCase ( SECTION, "(multiline == true) 'abc\ndef'.match(/c$.+$/)",
+ // 'c\ndef', String('abc\ndef'.match(/c$.+$/)));
+
+ RegExp.multiline = false;
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/RegExp_multiline_as_array.js b/js/tests/js1_2/regexp/RegExp_multiline_as_array.js
new file mode 100644
index 00000000000..ff820a867bd
--- /dev/null
+++ b/js/tests/js1_2/regexp/RegExp_multiline_as_array.js
@@ -0,0 +1,126 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: RegExp_multiline_as_array.js
+ Description: 'Tests RegExps $* property (same tests as RegExp_multiline.js but using $*)'
+
+ Author: Nick Lerissa
+ Date: March 13, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: $*';
+
+ writeHeaderToLog('Executing script: RegExp_multiline_as_array.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // First we do a series of tests with RegExp['$*'] set to false (default value)
+ // Following this we do the same tests with RegExp['$*'] set true(**).
+ // RegExp['$*']
+ testcases[count++] = new TestCase ( SECTION, "RegExp['$*']",
+ false, RegExp['$*']);
+
+ // (['$*'] == false) '123\n456'.match(/^4../)
+ testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) '123\\n456'.match(/^4../)",
+ null, '123\n456'.match(/^4../));
+
+ // (['$*'] == false) 'a11\na22\na23\na24'.match(/^a../g)
+ testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'a11\\na22\\na23\\na24'.match(/^a../g)",
+ String(['a11']), String('a11\na22\na23\na24'.match(/^a../g)));
+
+ // (['$*'] == false) 'a11\na22'.match(/^.+^./)
+ testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'a11\na22'.match(/^.+^./)",
+ null, 'a11\na22'.match(/^.+^./));
+
+ // (['$*'] == false) '123\n456'.match(/.3$/)
+ testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) '123\\n456'.match(/.3$/)",
+ null, '123\n456'.match(/.3$/));
+
+ // (['$*'] == false) 'a11\na22\na23\na24'.match(/a..$/g)
+ testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'a11\\na22\\na23\\na24'.match(/a..$/g)",
+ String(['a24']), String('a11\na22\na23\na24'.match(/a..$/g)));
+
+ // (['$*'] == false) 'abc\ndef'.match(/c$...$/)
+ testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'abc\ndef'.match(/c$...$/)",
+ null, 'abc\ndef'.match(/c$...$/));
+
+ // (['$*'] == false) 'a11\na22\na23\na24'.match(new RegExp('a..$','g'))
+ testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'a11\\na22\\na23\\na24'.match(new RegExp('a..$','g'))",
+ String(['a24']), String('a11\na22\na23\na24'.match(new RegExp('a..$','g'))));
+
+ // (['$*'] == false) 'abc\ndef'.match(new RegExp('c$...$'))
+ testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'abc\ndef'.match(new RegExp('c$...$'))",
+ null, 'abc\ndef'.match(new RegExp('c$...$')));
+
+ // **Now we do the tests with RegExp['$*'] set to true
+ // RegExp['$*'] = true; RegExp['$*']
+ RegExp['$*'] = true;
+ testcases[count++] = new TestCase ( SECTION, "RegExp['$*'] = true; RegExp['$*']",
+ true, RegExp['$*']);
+
+ // (['$*'] == true) '123\n456'.match(/^4../)
+ testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) '123\\n456'.match(/^4../)",
+ String(['456']), String('123\n456'.match(/^4../)));
+
+ // (['$*'] == true) 'a11\na22\na23\na24'.match(/^a../g)
+ testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) 'a11\\na22\\na23\\na24'.match(/^a../g)",
+ String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(/^a../g)));
+
+ // (['$*'] == true) 'a11\na22'.match(/^.+^./)
+ //testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) 'a11\na22'.match(/^.+^./)",
+ // String(['a11\na']), String('a11\na22'.match(/^.+^./)));
+
+ // (['$*'] == true) '123\n456'.match(/.3$/)
+ testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) '123\\n456'.match(/.3$/)",
+ String(['23']), String('123\n456'.match(/.3$/)));
+
+ // (['$*'] == true) 'a11\na22\na23\na24'.match(/a..$/g)
+ testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) 'a11\\na22\\na23\\na24'.match(/a..$/g)",
+ String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(/a..$/g)));
+
+ // (['$*'] == true) 'a11\na22\na23\na24'.match(new RegExp('a..$','g'))
+ testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) 'a11\\na22\\na23\\na24'.match(new RegExp('a..$','g'))",
+ String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(new RegExp('a..$','g'))));
+
+ // (['$*'] == true) 'abc\ndef'.match(/c$....$/)
+ //testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) 'abc\ndef'.match(/c$.+$/)",
+ // 'c\ndef', String('abc\ndef'.match(/c$.+$/)));
+
+ RegExp['$*'] = false;
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/RegExp_object.js b/js/tests/js1_2/regexp/RegExp_object.js
new file mode 100644
index 00000000000..ef50fa2c932
--- /dev/null
+++ b/js/tests/js1_2/regexp/RegExp_object.js
@@ -0,0 +1,85 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: RegExp_object.js
+ Description: 'Tests regular expressions creating RexExp Objects'
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: object';
+
+ writeHeaderToLog('Executing script: RegExp_object.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ var SSN_pattern = new RegExp("\\d{3}-\\d{2}-\\d{4}");
+
+ // testing SSN pattern
+ testcases[count++] = new TestCase ( SECTION, "'Test SSN is 123-34-4567'.match(SSN_pattern))",
+ String(["123-34-4567"]), String('Test SSN is 123-34-4567'.match(SSN_pattern)));
+
+ // testing SSN pattern
+ testcases[count++] = new TestCase ( SECTION, "'Test SSN is 123-34-4567'.match(SSN_pattern))",
+ String(["123-34-4567"]), String('Test SSN is 123-34-4567'.match(SSN_pattern)));
+
+ var PHONE_pattern = new RegExp("\\(?(\\d{3})\\)?-?(\\d{3})-(\\d{4})");
+ // testing PHONE pattern
+ testcases[count++] = new TestCase ( SECTION, "'Our phone number is (408)345-2345.'.match(PHONE_pattern))",
+ String(["(408)345-2345","408","345","2345"]), String('Our phone number is (408)345-2345.'.match(PHONE_pattern)));
+
+ // testing PHONE pattern
+ testcases[count++] = new TestCase ( SECTION, "'The phone number is 408-345-2345!'.match(PHONE_pattern))",
+ String(["408-345-2345","408","345","2345"]), String('The phone number is 408-345-2345!'.match(PHONE_pattern)));
+
+ // testing PHONE pattern
+ testcases[count++] = new TestCase ( SECTION, "String(PHONE_pattern.toString())",
+ "/\\(?(\\d{3})\\)?-?(\\d{3})-(\\d{4})/", String(PHONE_pattern.toString()));
+
+ // testing conversion to String
+ testcases[count++] = new TestCase ( SECTION, "PHONE_pattern + ' is the string'",
+ "/\\(?(\\d{3})\\)?-?(\\d{3})-(\\d{4})/ is the string",PHONE_pattern + ' is the string');
+
+ // testing conversion to int
+ testcases[count++] = new TestCase ( SECTION, "SSN_pattern - 8",
+ NaN,SSN_pattern - 8);
+
+ var testPattern = new RegExp("(\\d+)45(\\d+)90");
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/RegExp_rightContext.js b/js/tests/js1_2/regexp/RegExp_rightContext.js
new file mode 100644
index 00000000000..353677315dc
--- /dev/null
+++ b/js/tests/js1_2/regexp/RegExp_rightContext.js
@@ -0,0 +1,87 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: RegExp_rightContext.js
+ Description: 'Tests RegExps rightContext property'
+
+ Author: Nick Lerissa
+ Date: March 12, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: rightContext';
+
+ writeHeaderToLog('Executing script: RegExp_rightContext.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'abc123xyz'.match(/123/); RegExp.rightContext
+ 'abc123xyz'.match(/123/);
+ testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/123/); RegExp.rightContext",
+ 'xyz', RegExp.rightContext);
+
+ // 'abc123xyz'.match(/456/); RegExp.rightContext
+ 'abc123xyz'.match(/456/);
+ testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/456/); RegExp.rightContext",
+ 'xyz', RegExp.rightContext);
+
+ // 'abc123xyz'.match(/abc123xyz/); RegExp.rightContext
+ 'abc123xyz'.match(/abc123xyz/);
+ testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/abc123xyz/); RegExp.rightContext",
+ '', RegExp.rightContext);
+
+ // 'xxxx'.match(/$/); RegExp.rightContext
+ 'xxxx'.match(/$/);
+ testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(/$/); RegExp.rightContext",
+ '', RegExp.rightContext);
+
+ // 'test'.match(/^/); RegExp.rightContext
+ 'test'.match(/^/);
+ testcases[count++] = new TestCase ( SECTION, "'test'.match(/^/); RegExp.rightContext",
+ 'test', RegExp.rightContext);
+
+ // 'xxxx'.match(new RegExp('$')); RegExp.rightContext
+ 'xxxx'.match(new RegExp('$'));
+ testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(new RegExp('$')); RegExp.rightContext",
+ '', RegExp.rightContext);
+
+ // 'test'.match(new RegExp('^')); RegExp.rightContext
+ 'test'.match(new RegExp('^'));
+ testcases[count++] = new TestCase ( SECTION, "'test'.match(new RegExp('^')); RegExp.rightContext",
+ 'test', RegExp.rightContext);
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/RegExp_rightContext_as_array.js b/js/tests/js1_2/regexp/RegExp_rightContext_as_array.js
new file mode 100644
index 00000000000..5b07eec2b69
--- /dev/null
+++ b/js/tests/js1_2/regexp/RegExp_rightContext_as_array.js
@@ -0,0 +1,87 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: RegExp_rightContext_as_array.js
+ Description: 'Tests RegExps $\' property (same tests as RegExp_rightContext.js but using $\)'
+
+ Author: Nick Lerissa
+ Date: March 12, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: $\'';
+
+ writeHeaderToLog('Executing script: RegExp_rightContext.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'abc123xyz'.match(/123/); RegExp['$\'']
+ 'abc123xyz'.match(/123/);
+ testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/123/); RegExp['$\'']",
+ 'xyz', RegExp['$\'']);
+
+ // 'abc123xyz'.match(/456/); RegExp['$\'']
+ 'abc123xyz'.match(/456/);
+ testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/456/); RegExp['$\'']",
+ 'xyz', RegExp['$\'']);
+
+ // 'abc123xyz'.match(/abc123xyz/); RegExp['$\'']
+ 'abc123xyz'.match(/abc123xyz/);
+ testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/abc123xyz/); RegExp['$\'']",
+ '', RegExp['$\'']);
+
+ // 'xxxx'.match(/$/); RegExp['$\'']
+ 'xxxx'.match(/$/);
+ testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(/$/); RegExp['$\'']",
+ '', RegExp['$\'']);
+
+ // 'test'.match(/^/); RegExp['$\'']
+ 'test'.match(/^/);
+ testcases[count++] = new TestCase ( SECTION, "'test'.match(/^/); RegExp['$\'']",
+ 'test', RegExp['$\'']);
+
+ // 'xxxx'.match(new RegExp('$')); RegExp['$\'']
+ 'xxxx'.match(new RegExp('$'));
+ testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(new RegExp('$')); RegExp['$\'']",
+ '', RegExp['$\'']);
+
+ // 'test'.match(new RegExp('^')); RegExp['$\'']
+ 'test'.match(new RegExp('^'));
+ testcases[count++] = new TestCase ( SECTION, "'test'.match(new RegExp('^')); RegExp['$\'']",
+ 'test', RegExp['$\'']);
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/alphanumeric.js b/js/tests/js1_2/regexp/alphanumeric.js
new file mode 100644
index 00000000000..7e3d0d314ce
--- /dev/null
+++ b/js/tests/js1_2/regexp/alphanumeric.js
@@ -0,0 +1,126 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: alphanumeric.js
+ Description: 'Tests regular expressions with \w and \W special characters'
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: \\w and \\W';
+
+ writeHeaderToLog('Executing script: alphanumeric.js');
+ writeHeaderToLog( SECTION + " " + TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ var non_alphanumeric = "~`!@#$%^&*()-+={[}]|\\:;'<,>./?\f\n\r\t\v " + '"';
+ var alphanumeric = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+
+ // be sure all alphanumerics are matched by \w
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + alphanumeric + "'.match(new RegExp('\\w+'))",
+ String([alphanumeric]), String(alphanumeric.match(new RegExp('\\w+'))));
+
+ // be sure all non-alphanumerics are matched by \W
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + non_alphanumeric + "'.match(new RegExp('\\W+'))",
+ String([non_alphanumeric]), String(non_alphanumeric.match(new RegExp('\\W+'))));
+
+ // be sure all non-alphanumerics are not matched by \w
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + non_alphanumeric + "'.match(new RegExp('\\w'))",
+ null, non_alphanumeric.match(new RegExp('\\w')));
+
+ // be sure all alphanumerics are not matched by \W
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + alphanumeric + "'.match(new RegExp('\\W'))",
+ null, alphanumeric.match(new RegExp('\\W')));
+
+ var s = non_alphanumeric + alphanumeric;
+
+ // be sure all alphanumerics are matched by \w
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(new RegExp('\\w+'))",
+ String([alphanumeric]), String(s.match(new RegExp('\\w+'))));
+
+ s = alphanumeric + non_alphanumeric;
+
+ // be sure all non-alphanumerics are matched by \W
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(new RegExp('\\W+'))",
+ String([non_alphanumeric]), String(s.match(new RegExp('\\W+'))));
+
+ // be sure all alphanumerics are matched by \w (using literals)
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(/\w+/)",
+ String([alphanumeric]), String(s.match(/\w+/)));
+
+ s = alphanumeric + non_alphanumeric;
+
+ // be sure all non-alphanumerics are matched by \W (using literals)
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(/\W+/)",
+ String([non_alphanumeric]), String(s.match(/\W+/)));
+
+ s = 'abcd*&^%$$';
+ // be sure the following test behaves consistently
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(/(\w+)...(\W+)/)",
+ String([s , 'abcd' , '%$$']), String(s.match(/(\w+)...(\W+)/)));
+
+ var i;
+
+ // be sure all alphanumeric characters match individually
+ for (i = 0; i < alphanumeric.length; ++i)
+ {
+ s = '#$' + alphanumeric[i] + '%^';
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(new RegExp('\\w'))",
+ String([alphanumeric[i]]), String(s.match(new RegExp('\\w'))));
+ }
+ // be sure all non_alphanumeric characters match individually
+ for (i = 0; i < non_alphanumeric.length; ++i)
+ {
+ s = 'sd' + non_alphanumeric[i] + String((i+10) * (i+10) - 2 * (i+10));
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(new RegExp('\\W'))",
+ String([non_alphanumeric[i]]), String(s.match(new RegExp('\\W'))));
+ }
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/asterisk.js b/js/tests/js1_2/regexp/asterisk.js
new file mode 100644
index 00000000000..a32545b7f64
--- /dev/null
+++ b/js/tests/js1_2/regexp/asterisk.js
@@ -0,0 +1,102 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: asterisk.js
+ Description: 'Tests regular expressions containing *'
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: *';
+
+ writeHeaderToLog('Executing script: aterisk.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'abcddddefg'.match(new RegExp('d*'))
+ testcases[count++] = new TestCase ( SECTION, "'abcddddefg'.match(new RegExp('d*'))",
+ String([""]), String('abcddddefg'.match(new RegExp('d*'))));
+
+ // 'abcddddefg'.match(new RegExp('cd*'))
+ testcases[count++] = new TestCase ( SECTION, "'abcddddefg'.match(new RegExp('cd*'))",
+ String(["cdddd"]), String('abcddddefg'.match(new RegExp('cd*'))));
+
+ // 'abcdefg'.match(new RegExp('cx*d'))
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('cx*d'))",
+ String(["cd"]), String('abcdefg'.match(new RegExp('cx*d'))));
+
+ // 'xxxxxxx'.match(new RegExp('(x*)(x+)'))
+ testcases[count++] = new TestCase ( SECTION, "'xxxxxxx'.match(new RegExp('(x*)(x+)'))",
+ String(["xxxxxxx","xxxxxx","x"]), String('xxxxxxx'.match(new RegExp('(x*)(x+)'))));
+
+ // '1234567890'.match(new RegExp('(\\d*)(\\d+)'))
+ testcases[count++] = new TestCase ( SECTION, "'1234567890'.match(new RegExp('(\\d*)(\\d+)'))",
+ String(["1234567890","123456789","0"]),
+ String('1234567890'.match(new RegExp('(\\d*)(\\d+)'))));
+
+ // '1234567890'.match(new RegExp('(\\d*)\\d(\\d+)'))
+ testcases[count++] = new TestCase ( SECTION, "'1234567890'.match(new RegExp('(\\d*)\\d(\\d+)'))",
+ String(["1234567890","12345678","0"]),
+ String('1234567890'.match(new RegExp('(\\d*)\\d(\\d+)'))));
+
+ // 'xxxxxxx'.match(new RegExp('(x+)(x*)'))
+ testcases[count++] = new TestCase ( SECTION, "'xxxxxxx'.match(new RegExp('(x+)(x*)'))",
+ String(["xxxxxxx","xxxxxxx",""]), String('xxxxxxx'.match(new RegExp('(x+)(x*)'))));
+
+ // 'xxxxxxyyyyyy'.match(new RegExp('x*y+$'))
+ testcases[count++] = new TestCase ( SECTION, "'xxxxxxyyyyyy'.match(new RegExp('x*y+$'))",
+ String(["xxxxxxyyyyyy"]), String('xxxxxxyyyyyy'.match(new RegExp('x*y+$'))));
+
+ // 'abcdef'.match(/[\d]*[\s]*bc./)
+ testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(/[\\d]*[\\s]*bc./)",
+ String(["bcd"]), String('abcdef'.match(/[\d]*[\s]*bc./)));
+
+ // 'abcdef'.match(/bc..[\d]*[\s]*/)
+ testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(/bc..[\\d]*[\\s]*/)",
+ String(["bcde"]), String('abcdef'.match(/bc..[\d]*[\s]*/)));
+
+ // 'a1b2c3'.match(/.*/)
+ testcases[count++] = new TestCase ( SECTION, "'a1b2c3'.match(/.*/)",
+ String(["a1b2c3"]), String('a1b2c3'.match(/.*/)));
+
+ // 'a0.b2.c3'.match(/[xyz]*1/)
+ testcases[count++] = new TestCase ( SECTION, "'a0.b2.c3'.match(/[xyz]*1/)",
+ null, 'a0.b2.c3'.match(/[xyz]*1/));
+
+function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/backslash.js b/js/tests/js1_2/regexp/backslash.js
new file mode 100644
index 00000000000..6716a3ee5b2
--- /dev/null
+++ b/js/tests/js1_2/regexp/backslash.js
@@ -0,0 +1,76 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: backslash.js
+ Description: 'Tests regular expressions containing \'
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: \\';
+
+ writeHeaderToLog('Executing script: backslash.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'abcde'.match(new RegExp('\e'))
+ testcases[count++] = new TestCase ( SECTION, "'abcde'.match(new RegExp('\e'))",
+ String(["e"]), String('abcde'.match(new RegExp('\e'))));
+
+ // 'ab\\cde'.match(new RegExp('\\\\'))
+ testcases[count++] = new TestCase ( SECTION, "'ab\\cde'.match(new RegExp('\\\\'))",
+ String(["\\"]), String('ab\\cde'.match(new RegExp('\\\\'))));
+
+ // 'ab\\cde'.match(/\\/) (using literal)
+ testcases[count++] = new TestCase ( SECTION, "'ab\\cde'.match(/\\\\/)",
+ String(["\\"]), String('ab\\cde'.match(/\\/)));
+
+ // 'before ^$*+?.()|{}[] after'.match(new RegExp('\^\$\*\+\?\.\(\)\|\{\}\[\]'))
+ testcases[count++] = new TestCase ( SECTION,
+ "'before ^$*+?.()|{}[] after'.match(new RegExp('\\^\\$\\*\\+\\?\\.\\(\\)\\|\\{\\}\\[\\]'))",
+ String(["^$*+?.()|{}[]"]),
+ String('before ^$*+?.()|{}[] after'.match(new RegExp('\\^\\$\\*\\+\\?\\.\\(\\)\\|\\{\\}\\[\\]'))));
+
+ // 'before ^$*+?.()|{}[] after'.match(/\^\$\*\+\?\.\(\)\|\{\}\[\]/) (using literal)
+ testcases[count++] = new TestCase ( SECTION,
+ "'before ^$*+?.()|{}[] after'.match(/\\^\\$\\*\\+\\?\\.\\(\\)\\|\\{\\}\\[\\]/)",
+ String(["^$*+?.()|{}[]"]),
+ String('before ^$*+?.()|{}[] after'.match(/\^\$\*\+\?\.\(\)\|\{\}\[\]/)));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/backspace.js b/js/tests/js1_2/regexp/backspace.js
new file mode 100644
index 00000000000..fcc93afece2
--- /dev/null
+++ b/js/tests/js1_2/regexp/backspace.js
@@ -0,0 +1,76 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: backspace.js
+ Description: 'Tests regular expressions containing [\b]'
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: [\b]';
+
+ writeHeaderToLog('Executing script: backspace.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'abc\bdef'.match(new RegExp('.[\b].'))
+ testcases[count++] = new TestCase ( SECTION, "'abc\bdef'.match(new RegExp('.[\\b].'))",
+ String(["c\bd"]), String('abc\bdef'.match(new RegExp('.[\\b].'))));
+
+ // 'abc\\bdef'.match(new RegExp('.[\b].'))
+ testcases[count++] = new TestCase ( SECTION, "'abc\\bdef'.match(new RegExp('.[\\b].'))",
+ null, 'abc\\bdef'.match(new RegExp('.[\\b].')));
+
+ // 'abc\b\b\bdef'.match(new RegExp('c[\b]{3}d'))
+ testcases[count++] = new TestCase ( SECTION, "'abc\b\b\bdef'.match(new RegExp('c[\\b]{3}d'))",
+ String(["c\b\b\bd"]), String('abc\b\b\bdef'.match(new RegExp('c[\\b]{3}d'))));
+
+ // 'abc\bdef'.match(new RegExp('[^\\[\b\\]]+'))
+ testcases[count++] = new TestCase ( SECTION, "'abc\bdef'.match(new RegExp('[^\\[\\b\\]]+'))",
+ String(["abc"]), String('abc\bdef'.match(new RegExp('[^\\[\\b\\]]+'))));
+
+ // 'abcdef'.match(new RegExp('[^\\[\b\\]]+'))
+ testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(new RegExp('[^\\[\\b\\]]+'))",
+ String(["abcdef"]), String('abcdef'.match(new RegExp('[^\\[\\b\\]]+'))));
+
+ // 'abcdef'.match(/[^\[\b\]]+/)
+ testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(/[^\\[\\b\\]]+/)",
+ String(["abcdef"]), String('abcdef'.match(/[^\[\b\]]+/)));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/beginLine.js b/js/tests/js1_2/regexp/beginLine.js
new file mode 100644
index 00000000000..31349d054d6
--- /dev/null
+++ b/js/tests/js1_2/regexp/beginLine.js
@@ -0,0 +1,77 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: beginLine.js
+ Description: 'Tests regular expressions containing ^'
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: ^';
+
+ writeHeaderToLog('Executing script: beginLine.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'abcde'.match(new RegExp('^ab'))
+ testcases[count++] = new TestCase ( SECTION, "'abcde'.match(new RegExp('^ab'))",
+ String(["ab"]), String('abcde'.match(new RegExp('^ab'))));
+
+ // 'ab\ncde'.match(new RegExp('^..^e'))
+ testcases[count++] = new TestCase ( SECTION, "'ab\ncde'.match(new RegExp('^..^e'))",
+ null, 'ab\ncde'.match(new RegExp('^..^e')));
+
+ // 'yyyyy'.match(new RegExp('^xxx'))
+ testcases[count++] = new TestCase ( SECTION, "'yyyyy'.match(new RegExp('^xxx'))",
+ null, 'yyyyy'.match(new RegExp('^xxx')));
+
+ // '^^^x'.match(new RegExp('^\\^+'))
+ testcases[count++] = new TestCase ( SECTION, "'^^^x'.match(new RegExp('^\\^+'))",
+ String(['^^^']), String('^^^x'.match(new RegExp('^\\^+'))));
+
+ // '^^^x'.match(/^\^+/)
+ testcases[count++] = new TestCase ( SECTION, "'^^^x'.match(/^\\^+/)",
+ String(['^^^']), String('^^^x'.match(/^\^+/)));
+
+ RegExp.multiline = true;
+ // 'abc\n123xyz'.match(new RegExp('^\d+'))
+ testcases[count++] = new TestCase ( SECTION, "'abc\n123xyz'.match(new RegExp('^\\d+'))",
+ String(['123']), String('abc\n123xyz'.match(new RegExp('^\\d+'))));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/character_class.js b/js/tests/js1_2/regexp/character_class.js
new file mode 100644
index 00000000000..162a60001e1
--- /dev/null
+++ b/js/tests/js1_2/regexp/character_class.js
@@ -0,0 +1,104 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: character_class.js
+ Description: 'Tests regular expressions containing []'
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: []';
+
+ writeHeaderToLog('Executing script: character_class.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'abcde'.match(new RegExp('ab[ercst]de'))
+ testcases[count++] = new TestCase ( SECTION, "'abcde'.match(new RegExp('ab[ercst]de'))",
+ String(["abcde"]), String('abcde'.match(new RegExp('ab[ercst]de'))));
+
+ // 'abcde'.match(new RegExp('ab[erst]de'))
+ testcases[count++] = new TestCase ( SECTION, "'abcde'.match(new RegExp('ab[erst]de'))",
+ null, 'abcde'.match(new RegExp('ab[erst]de')));
+
+ // 'abcdefghijkl'.match(new RegExp('[d-h]+'))
+ testcases[count++] = new TestCase ( SECTION, "'abcdefghijkl'.match(new RegExp('[d-h]+'))",
+ String(["defgh"]), String('abcdefghijkl'.match(new RegExp('[d-h]+'))));
+
+ // 'abc6defghijkl'.match(new RegExp('[1234567].{2}'))
+ testcases[count++] = new TestCase ( SECTION, "'abc6defghijkl'.match(new RegExp('[1234567].{2}'))",
+ String(["6de"]), String('abc6defghijkl'.match(new RegExp('[1234567].{2}'))));
+
+ // '\n\n\abc324234\n'.match(new RegExp('[a-c\d]+'))
+ testcases[count++] = new TestCase ( SECTION, "'\n\n\abc324234\n'.match(new RegExp('[a-c\\d]+'))",
+ String(["abc324234"]), String('\n\n\abc324234\n'.match(new RegExp('[a-c\\d]+'))));
+
+ // 'abc'.match(new RegExp('ab[.]?c'))
+ testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('ab[.]?c'))",
+ String(["abc"]), String('abc'.match(new RegExp('ab[.]?c'))));
+
+ // 'abc'.match(new RegExp('a[b]c'))
+ testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('a[b]c'))",
+ String(["abc"]), String('abc'.match(new RegExp('a[b]c'))));
+
+ // 'a1b b2c c3d def f4g'.match(new RegExp('[a-z][^1-9][a-z]'))
+ testcases[count++] = new TestCase ( SECTION, "'a1b b2c c3d def f4g'.match(new RegExp('[a-z][^1-9][a-z]'))",
+ String(["def"]), String('a1b b2c c3d def f4g'.match(new RegExp('[a-z][^1-9][a-z]'))));
+
+ // '123*&$abc'.match(new RegExp('[*&$]{3}'))
+ testcases[count++] = new TestCase ( SECTION, "'123*&$abc'.match(new RegExp('[*&$]{3}'))",
+ String(["*&$"]), String('123*&$abc'.match(new RegExp('[*&$]{3}'))));
+
+ // 'abc'.match(new RegExp('a[^1-9]c'))
+ testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('a[^1-9]c'))",
+ String(["abc"]), String('abc'.match(new RegExp('a[^1-9]c'))));
+
+ // 'abc'.match(new RegExp('a[^b]c'))
+ testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('a[^b]c'))",
+ null, 'abc'.match(new RegExp('a[^b]c')));
+
+ // 'abc#$%def%&*@ghi)(*&'.match(new RegExp('[^a-z]{4}'))
+ testcases[count++] = new TestCase ( SECTION, "'abc#$%def%&*@ghi)(*&'.match(new RegExp('[^a-z]{4}'))",
+ String(["%&*@"]), String('abc#$%def%&*@ghi)(*&'.match(new RegExp('[^a-z]{4}'))));
+
+ // 'abc#$%def%&*@ghi)(*&'.match(/[^a-z]{4}/)
+ testcases[count++] = new TestCase ( SECTION, "'abc#$%def%&*@ghi)(*&'.match(/[^a-z]{4}/)",
+ String(["%&*@"]), String('abc#$%def%&*@ghi)(*&'.match(/[^a-z]{4}/)));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/compile.js b/js/tests/js1_2/regexp/compile.js
new file mode 100644
index 00000000000..172f6a3a3b8
--- /dev/null
+++ b/js/tests/js1_2/regexp/compile.js
@@ -0,0 +1,91 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: compile.js
+ Description: 'Tests regular expressions method compile'
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: compile';
+
+ writeHeaderToLog('Executing script: compile.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ var regularExpression = new RegExp();
+
+ regularExpression.compile("[0-9]{3}x[0-9]{4}","i");
+
+ testcases[count++] = new TestCase ( SECTION,
+ "(compile '[0-9]{3}x[0-9]{4}','i')",
+ String(["456X7890"]), String('234X456X7890'.match(regularExpression)));
+
+ testcases[count++] = new TestCase ( SECTION,
+ "source of (compile '[0-9]{3}x[0-9]{4}','i')",
+ "[0-9]{3}x[0-9]{4}", regularExpression.source);
+
+ testcases[count++] = new TestCase ( SECTION,
+ "global of (compile '[0-9]{3}x[0-9]{4}','i')",
+ false, regularExpression.global);
+
+ testcases[count++] = new TestCase ( SECTION,
+ "ignoreCase of (compile '[0-9]{3}x[0-9]{4}','i')",
+ true, regularExpression.ignoreCase);
+
+ regularExpression.compile("[0-9]{3}X[0-9]{3}","g");
+
+ testcases[count++] = new TestCase ( SECTION,
+ "(compile '[0-9]{3}X[0-9]{3}','g')",
+ String(["234X456"]), String('234X456X7890'.match(regularExpression)));
+
+ testcases[count++] = new TestCase ( SECTION,
+ "source of (compile '[0-9]{3}X[0-9]{3}','g')",
+ "[0-9]{3}X[0-9]{3}", regularExpression.source);
+
+ testcases[count++] = new TestCase ( SECTION,
+ "global of (compile '[0-9]{3}X[0-9]{3}','g')",
+ true, regularExpression.global);
+
+ testcases[count++] = new TestCase ( SECTION,
+ "ignoreCase of (compile '[0-9]{3}X[0-9]{3}','g')",
+ false, regularExpression.ignoreCase);
+
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/control_characters.js b/js/tests/js1_2/regexp/control_characters.js
new file mode 100644
index 00000000000..2161312d799
--- /dev/null
+++ b/js/tests/js1_2/regexp/control_characters.js
@@ -0,0 +1,68 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: control_characters.js
+ Description: 'Tests regular expressions containing .'
+
+ Author: Nick Lerissa
+ Date: April 8, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: .';
+ var BUGNUMBER="123802";
+
+ writeHeaderToLog('Executing script: control_characters.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'àOÐ ê:i¢Ø'.match(new RegExp('.+'))
+ testcases[count++] = new TestCase ( SECTION, "'àOÐ ê:i¢Ø'.match(new RegExp('.+'))",
+ String(['àOÐ ê:i¢Ø']), String('àOÐ ê:i¢Ø'.match(new RegExp('.+'))));
+
+ // string1.match(new RegExp(string1))
+ var string1 = 'àOÐ ê:i¢Ø';
+ testcases[count++] = new TestCase ( SECTION, "string1 = " + string1 + " string1.match(string1)",
+ String([string1]), String(string1.match(string1)));
+
+ string1 = "";
+ for (var i = 0; i < 32; i++)
+ string1 += String.fromCharCode(i);
+ testcases[count++] = new TestCase ( SECTION, "string1 = " + string1 + " string1.match(string1)",
+ String([string1]), String(string1.match(string1)));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/digit.js b/js/tests/js1_2/regexp/digit.js
new file mode 100644
index 00000000000..de6cfcf8a10
--- /dev/null
+++ b/js/tests/js1_2/regexp/digit.js
@@ -0,0 +1,116 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: digit.js
+ Description: 'Tests regular expressions containing \d'
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: \\d';
+
+ writeHeaderToLog('Executing script: digit.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ var non_digits = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\f\n\r\t\v~`!@#$%^&*()-+={[}]|\\:;'<,>./? " + '"';
+
+ var digits = "1234567890";
+
+ // be sure all digits are matched by \d
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + digits + "'.match(new RegExp('\\d+'))",
+ String([digits]), String(digits.match(new RegExp('\\d+'))));
+
+ // be sure all non-digits are matched by \D
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + non_digits + "'.match(new RegExp('\\D+'))",
+ String([non_digits]), String(non_digits.match(new RegExp('\\D+'))));
+
+ // be sure all non-digits are not matched by \d
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + non_digits + "'.match(new RegExp('\\d'))",
+ null, non_digits.match(new RegExp('\\d')));
+
+ // be sure all digits are not matched by \D
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + digits + "'.match(new RegExp('\\D'))",
+ null, digits.match(new RegExp('\\D')));
+
+ var s = non_digits + digits;
+
+ // be sure all digits are matched by \d
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(new RegExp('\\d+'))",
+ String([digits]), String(s.match(new RegExp('\\d+'))));
+
+ var s = digits + non_digits;
+
+ // be sure all non-digits are matched by \D
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(new RegExp('\\D+'))",
+ String([non_digits]), String(s.match(new RegExp('\\D+'))));
+
+ var i;
+
+ // be sure all digits match individually
+ for (i = 0; i < digits.length; ++i)
+ {
+ s = 'ab' + digits[i] + 'cd';
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(new RegExp('\\d'))",
+ String([digits[i]]), String(s.match(new RegExp('\\d'))));
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(/\\d/)",
+ String([digits[i]]), String(s.match(/\d/)));
+ }
+ // be sure all non_digits match individually
+ for (i = 0; i < non_digits.length; ++i)
+ {
+ s = '12' + non_digits[i] + '34';
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(new RegExp('\\D'))",
+ String([non_digits[i]]), String(s.match(new RegExp('\\D'))));
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(/\\D/)",
+ String([non_digits[i]]), String(s.match(/\D/)));
+ }
+
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/dot.js b/js/tests/js1_2/regexp/dot.js
new file mode 100644
index 00000000000..ce0b0e8c622
--- /dev/null
+++ b/js/tests/js1_2/regexp/dot.js
@@ -0,0 +1,92 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: dot.js
+ Description: 'Tests regular expressions containing .'
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: .';
+
+ writeHeaderToLog('Executing script: dot.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'abcde'.match(new RegExp('ab.de'))
+ testcases[count++] = new TestCase ( SECTION, "'abcde'.match(new RegExp('ab.de'))",
+ String(["abcde"]), String('abcde'.match(new RegExp('ab.de'))));
+
+ // 'line 1\nline 2'.match(new RegExp('.+'))
+ testcases[count++] = new TestCase ( SECTION, "'line 1\nline 2'.match(new RegExp('.+'))",
+ String(["line 1"]), String('line 1\nline 2'.match(new RegExp('.+'))));
+
+ // 'this is a test'.match(new RegExp('.*a.*'))
+ testcases[count++] = new TestCase ( SECTION, "'this is a test'.match(new RegExp('.*a.*'))",
+ String(["this is a test"]), String('this is a test'.match(new RegExp('.*a.*'))));
+
+ // 'this is a *&^%$# test'.match(new RegExp('.+'))
+ testcases[count++] = new TestCase ( SECTION, "'this is a *&^%$# test'.match(new RegExp('.+'))",
+ String(["this is a *&^%$# test"]), String('this is a *&^%$# test'.match(new RegExp('.+'))));
+
+ // '....'.match(new RegExp('.+'))
+ testcases[count++] = new TestCase ( SECTION, "'....'.match(new RegExp('.+'))",
+ String(["...."]), String('....'.match(new RegExp('.+'))));
+
+ // 'abcdefghijklmnopqrstuvwxyz'.match(new RegExp('.+'))
+ testcases[count++] = new TestCase ( SECTION, "'abcdefghijklmnopqrstuvwxyz'.match(new RegExp('.+'))",
+ String(["abcdefghijklmnopqrstuvwxyz"]), String('abcdefghijklmnopqrstuvwxyz'.match(new RegExp('.+'))));
+
+ // 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.match(new RegExp('.+'))
+ testcases[count++] = new TestCase ( SECTION, "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.match(new RegExp('.+'))",
+ String(["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]), String('ABCDEFGHIJKLMNOPQRSTUVWXYZ'.match(new RegExp('.+'))));
+
+ // '`1234567890-=~!@#$%^&*()_+'.match(new RegExp('.+'))
+ testcases[count++] = new TestCase ( SECTION, "'`1234567890-=~!@#$%^&*()_+'.match(new RegExp('.+'))",
+ String(["`1234567890-=~!@#$%^&*()_+"]), String('`1234567890-=~!@#$%^&*()_+'.match(new RegExp('.+'))));
+
+ // '|\\[{]};:"\',<>.?/'.match(new RegExp('.+'))
+ testcases[count++] = new TestCase ( SECTION, "'|\\[{]};:\"\',<>.?/'.match(new RegExp('.+'))",
+ String(["|\\[{]};:\"\',<>.?/"]), String('|\\[{]};:\"\',<>.?/'.match(new RegExp('.+'))));
+
+ // '|\\[{]};:"\',<>.?/'.match(/.+/)
+ testcases[count++] = new TestCase ( SECTION, "'|\\[{]};:\"\',<>.?/'.match(/.+/)",
+ String(["|\\[{]};:\"\',<>.?/"]), String('|\\[{]};:\"\',<>.?/'.match(/.+/)));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/endLine.js b/js/tests/js1_2/regexp/endLine.js
new file mode 100644
index 00000000000..0de37561a63
--- /dev/null
+++ b/js/tests/js1_2/regexp/endLine.js
@@ -0,0 +1,77 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: endLine.js
+ Description: 'Tests regular expressions containing $'
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: $';
+
+ writeHeaderToLog('Executing script: endLine.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'abcde'.match(new RegExp('de$'))
+ testcases[count++] = new TestCase ( SECTION, "'abcde'.match(new RegExp('de$'))",
+ String(["de"]), String('abcde'.match(new RegExp('de$'))));
+
+ // 'ab\ncde'.match(new RegExp('..$e$'))
+ testcases[count++] = new TestCase ( SECTION, "'ab\ncde'.match(new RegExp('..$e$'))",
+ null, 'ab\ncde'.match(new RegExp('..$e$')));
+
+ // 'yyyyy'.match(new RegExp('xxx$'))
+ testcases[count++] = new TestCase ( SECTION, "'yyyyy'.match(new RegExp('xxx$'))",
+ null, 'yyyyy'.match(new RegExp('xxx$')));
+
+ // 'a$$$'.match(new RegExp('\\$+$'))
+ testcases[count++] = new TestCase ( SECTION, "'a$$$'.match(new RegExp('\\$+$'))",
+ String(['$$$']), String('a$$$'.match(new RegExp('\\$+$'))));
+
+ // 'a$$$'.match(/\$+$/)
+ testcases[count++] = new TestCase ( SECTION, "'a$$$'.match(/\\$+$/)",
+ String(['$$$']), String('a$$$'.match(/\$+$/)));
+
+ RegExp.multiline = true;
+ // 'abc\n123xyz890\nxyz'.match(new RegExp('\d+$'))
+ testcases[count++] = new TestCase ( SECTION, "'abc\n123xyz890\nxyz'.match(new RegExp('\\d+$'))",
+ String(['890']), String('abc\n123xyz890\nxyz'.match(new RegExp('\\d+$'))));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/everything.js b/js/tests/js1_2/regexp/everything.js
new file mode 100644
index 00000000000..430c8f11529
--- /dev/null
+++ b/js/tests/js1_2/regexp/everything.js
@@ -0,0 +1,77 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: everything.js
+ Description: 'Tests regular expressions'
+
+ Author: Nick Lerissa
+ Date: March 24, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp';
+
+ writeHeaderToLog('Executing script: everything.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'Sally and Fred are sure to come.'.match(/^[a-z\s]*/i)
+ testcases[count++] = new TestCase ( SECTION, "'Sally and Fred are sure to come'.match(/^[a-z\\s]*/i)",
+ String(["Sally and Fred are sure to come"]), String('Sally and Fred are sure to come'.match(/^[a-z\s]*/i)));
+
+ // 'test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$'))
+ testcases[count++] = new TestCase ( SECTION, "'test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$'))",
+ String(["test123W+xyz","xyz"]), String('test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$'))));
+
+ // 'number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/)
+ testcases[count++] = new TestCase ( SECTION, "'number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/)",
+ String(["12365 number two 9898","12365","9898"]), String('number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/)));
+
+ var simpleSentence = /(\s?[^\!\?\.]+[\!\?\.])+/;
+ // 'See Spot run.'.match(simpleSentence)
+ testcases[count++] = new TestCase ( SECTION, "'See Spot run.'.match(simpleSentence)",
+ String(["See Spot run.","See Spot run."]), String('See Spot run.'.match(simpleSentence)));
+
+ // 'I like it. What's up? I said NO!'.match(simpleSentence)
+ testcases[count++] = new TestCase ( SECTION, "'I like it. What's up? I said NO!'.match(simpleSentence)",
+ String(["I like it. What's up? I said NO!",' I said NO!']), String('I like it. What\'s up? I said NO!'.match(simpleSentence)));
+
+ // 'the quick brown fox jumped over the lazy dogs'.match(/((\w+)\s*)+/)
+ testcases[count++] = new TestCase ( SECTION, "'the quick brown fox jumped over the lazy dogs'.match(/((\\w+)\\s*)+/)",
+ String(['the quick brown fox jumped over the lazy dogs','dogs','dogs']),String('the quick brown fox jumped over the lazy dogs'.match(/((\w+)\s*)+/)));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/exec.js b/js/tests/js1_2/regexp/exec.js
new file mode 100644
index 00000000000..4460645c624
--- /dev/null
+++ b/js/tests/js1_2/regexp/exec.js
@@ -0,0 +1,74 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: exec.js
+ Description: 'Tests regular expressions exec compile'
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: exec';
+
+ writeHeaderToLog('Executing script: exec.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ testcases[count++] = new TestCase ( SECTION,
+ "/[0-9]{3}/.exec('23 2 34 678 9 09')",
+ String(["678"]), String(/[0-9]{3}/.exec('23 2 34 678 9 09')));
+
+ testcases[count++] = new TestCase ( SECTION,
+ "/3.{4}8/.exec('23 2 34 678 9 09')",
+ String(["34 678"]), String(/3.{4}8/.exec('23 2 34 678 9 09')));
+
+ var re = new RegExp('3.{4}8');
+ testcases[count++] = new TestCase ( SECTION,
+ "re.exec('23 2 34 678 9 09')",
+ String(["34 678"]), String(re.exec('23 2 34 678 9 09')));
+
+ testcases[count++] = new TestCase ( SECTION,
+ "(/3.{4}8/.exec('23 2 34 678 9 09').length",
+ 1, (/3.{4}8/.exec('23 2 34 678 9 09')).length);
+
+ re = new RegExp('3.{4}8');
+ testcases[count++] = new TestCase ( SECTION,
+ "(re.exec('23 2 34 678 9 09').length",
+ 1, (re.exec('23 2 34 678 9 09')).length);
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/flags.js b/js/tests/js1_2/regexp/flags.js
new file mode 100644
index 00000000000..f46c67400a7
--- /dev/null
+++ b/js/tests/js1_2/regexp/flags.js
@@ -0,0 +1,81 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: regexp.js
+ Description: 'Tests regular expressions using flags "i" and "g"'
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'regular expression flags with flags "i" and "g"';
+
+ writeHeaderToLog('Executing script: flags.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // testing optional flag 'i'
+ testcases[count++] = new TestCase ( SECTION, "'aBCdEfGHijKLmno'.match(/fghijk/i)",
+ String(["fGHijK"]), String('aBCdEfGHijKLmno'.match(/fghijk/i)));
+
+ testcases[count++] = new TestCase ( SECTION, "'aBCdEfGHijKLmno'.match(new RegExp('fghijk','i'))",
+ String(["fGHijK"]), String('aBCdEfGHijKLmno'.match(new RegExp("fghijk","i"))));
+
+ // testing optional flag 'g'
+ testcases[count++] = new TestCase ( SECTION, "'xa xb xc xd xe xf'.match(/x./g)",
+ String(["xa","xb","xc","xd","xe","xf"]), String('xa xb xc xd xe xf'.match(/x./g)));
+
+ testcases[count++] = new TestCase ( SECTION, "'xa xb xc xd xe xf'.match(new RegExp('x.','g'))",
+ String(["xa","xb","xc","xd","xe","xf"]), String('xa xb xc xd xe xf'.match(new RegExp('x.','g'))));
+
+ // testing optional flags 'g' and 'i'
+ testcases[count++] = new TestCase ( SECTION, "'xa Xb xc xd Xe xf'.match(/x./gi)",
+ String(["xa","Xb","xc","xd","Xe","xf"]), String('xa Xb xc xd Xe xf'.match(/x./gi)));
+
+ testcases[count++] = new TestCase ( SECTION, "'xa Xb xc xd Xe xf'.match(new RegExp('x.','gi'))",
+ String(["xa","Xb","xc","xd","Xe","xf"]), String('xa Xb xc xd Xe xf'.match(new RegExp('x.','gi'))));
+
+ testcases[count++] = new TestCase ( SECTION, "'xa Xb xc xd Xe xf'.match(/x./ig)",
+ String(["xa","Xb","xc","xd","Xe","xf"]), String('xa Xb xc xd Xe xf'.match(/x./ig)));
+
+ testcases[count++] = new TestCase ( SECTION, "'xa Xb xc xd Xe xf'.match(new RegExp('x.','ig'))",
+ String(["xa","Xb","xc","xd","Xe","xf"]), String('xa Xb xc xd Xe xf'.match(new RegExp('x.','ig'))));
+
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
+
diff --git a/js/tests/js1_2/regexp/global.js b/js/tests/js1_2/regexp/global.js
new file mode 100644
index 00000000000..02678e7e822
--- /dev/null
+++ b/js/tests/js1_2/regexp/global.js
@@ -0,0 +1,92 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: global.js
+ Description: 'Tests RegExp attribute global'
+
+ Author: Nick Lerissa
+ Date: March 13, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: global';
+
+ writeHeaderToLog('Executing script: global.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // /xyz/g.global
+ testcases[count++] = new TestCase ( SECTION, "/xyz/g.global",
+ true, /xyz/g.global);
+
+ // /xyz/.global
+ testcases[count++] = new TestCase ( SECTION, "/xyz/.global",
+ false, /xyz/.global);
+
+ // '123 456 789'.match(/\d+/g)
+ testcases[count++] = new TestCase ( SECTION, "'123 456 789'.match(/\\d+/g)",
+ String(["123","456","789"]), String('123 456 789'.match(/\d+/g)));
+
+ // '123 456 789'.match(/(\d+)/g)
+ testcases[count++] = new TestCase ( SECTION, "'123 456 789'.match(/(\\d+)/g)",
+ String(["123","456","789"]), String('123 456 789'.match(/(\d+)/g)));
+
+ // '123 456 789'.match(/\d+/)
+ testcases[count++] = new TestCase ( SECTION, "'123 456 789'.match(/\\d+/)",
+ String(["123"]), String('123 456 789'.match(/\d+/)));
+
+ // (new RegExp('[a-z]','g')).global
+ testcases[count++] = new TestCase ( SECTION, "(new RegExp('[a-z]','g')).global",
+ true, (new RegExp('[a-z]','g')).global);
+
+ // (new RegExp('[a-z]','i')).global
+ testcases[count++] = new TestCase ( SECTION, "(new RegExp('[a-z]','i')).global",
+ false, (new RegExp('[a-z]','i')).global);
+
+ // '123 456 789'.match(new RegExp('\\d+','g'))
+ testcases[count++] = new TestCase ( SECTION, "'123 456 789'.match(new RegExp('\\\\d+','g'))",
+ String(["123","456","789"]), String('123 456 789'.match(new RegExp('\\d+','g'))));
+
+ // '123 456 789'.match(new RegExp('(\\d+)','g'))
+ testcases[count++] = new TestCase ( SECTION, "'123 456 789'.match(new RegExp('(\\\\d+)','g'))",
+ String(["123","456","789"]), String('123 456 789'.match(new RegExp('(\\d+)','g'))));
+
+ // '123 456 789'.match(new RegExp('\\d+','i'))
+ testcases[count++] = new TestCase ( SECTION, "'123 456 789'.match(new RegExp('\\\\d+','i'))",
+ String(["123"]), String('123 456 789'.match(new RegExp('\\d+','i'))));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/hexadecimal.js b/js/tests/js1_2/regexp/hexadecimal.js
new file mode 100644
index 00000000000..e65240710f1
--- /dev/null
+++ b/js/tests/js1_2/regexp/hexadecimal.js
@@ -0,0 +1,105 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: hexadecimal.js
+ Description: 'Tests regular expressions containing \ '
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: \x# (hex) ';
+
+ writeHeaderToLog('Executing script: hexadecimal.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+
+ var testPattern = '\\x41\\x42\\x43\\x44\\x45\\x46\\x47\\x48\\x49\\x4A\\x4B\\x4C\\x4D\\x4E\\x4F\\x50\\x51\\x52\\x53\\x54\\x55\\x56\\x57\\x58\\x59\\x5A';
+
+ var testString = "12345ABCDEFGHIJKLMNOPQRSTUVWXYZ67890";
+
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + testString + "'.match(new RegExp('" + testPattern + "'))",
+ String(["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]), String(testString.match(new RegExp(testPattern))));
+
+ testPattern = '\\x61\\x62\\x63\\x64\\x65\\x66\\x67\\x68\\x69\\x6A\\x6B\\x6C\\x6D\\x6E\\x6F\\x70\\x71\\x72\\x73\\x74\\x75\\x76\\x77\\x78\\x79\\x7A';
+
+ testString = "12345AabcdefghijklmnopqrstuvwxyzZ67890";
+
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + testString + "'.match(new RegExp('" + testPattern + "'))",
+ String(["abcdefghijklmnopqrstuvwxyz"]), String(testString.match(new RegExp(testPattern))));
+
+ testPattern = '\\x20\\x21\\x22\\x23\\x24\\x25\\x26\\x27\\x28\\x29\\x2A\\x2B\\x2C\\x2D\\x2E\\x2F\\x30\\x31\\x32\\x33';
+
+ testString = "abc !\"#$%&'()*+,-./0123ZBC";
+
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + testString + "'.match(new RegExp('" + testPattern + "'))",
+ String([" !\"#$%&'()*+,-./0123"]), String(testString.match(new RegExp(testPattern))));
+
+ testPattern = '\\x34\\x35\\x36\\x37\\x38\\x39\\x3A\\x3B\\x3C\\x3D\\x3E\\x3F\\x40';
+
+ testString = "123456789:;<=>?@ABC";
+
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + testString + "'.match(new RegExp('" + testPattern + "'))",
+ String(["456789:;<=>?@"]), String(testString.match(new RegExp(testPattern))));
+
+ testPattern = '\\x7B\\x7C\\x7D\\x7E';
+
+ testString = "1234{|}~ABC";
+
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + testString + "'.match(new RegExp('" + testPattern + "'))",
+ String(["{|}~"]), String(testString.match(new RegExp(testPattern))));
+
+ testcases[count++] = new TestCase ( SECTION,
+ "'canthisbeFOUND'.match(new RegExp('[A-\\x5A]+'))",
+ String(["FOUND"]), String('canthisbeFOUND'.match(new RegExp('[A-\\x5A]+'))));
+
+ testcases[count++] = new TestCase ( SECTION,
+ "'canthisbeFOUND'.match(new RegExp('[\\x61-\\x7A]+'))",
+ String(["canthisbe"]), String('canthisbeFOUND'.match(new RegExp('[\\x61-\\x7A]+'))));
+
+ testcases[count++] = new TestCase ( SECTION,
+ "'canthisbeFOUND'.match(/[\\x61-\\x7A]+/)",
+ String(["canthisbe"]), String('canthisbeFOUND'.match(/[\x61-\x7A]+/)));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/ignoreCase.js b/js/tests/js1_2/regexp/ignoreCase.js
new file mode 100644
index 00000000000..ad69ce64dee
--- /dev/null
+++ b/js/tests/js1_2/regexp/ignoreCase.js
@@ -0,0 +1,108 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: ignoreCase.js
+ Description: 'Tests RegExp attribute ignoreCase'
+
+ Author: Nick Lerissa
+ Date: March 13, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: ignoreCase';
+
+ writeHeaderToLog('Executing script: ignoreCase.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // /xyz/i.ignoreCase
+ testcases[count++] = new TestCase ( SECTION, "/xyz/i.ignoreCase",
+ true, /xyz/i.ignoreCase);
+
+ // /xyz/.ignoreCase
+ testcases[count++] = new TestCase ( SECTION, "/xyz/.ignoreCase",
+ false, /xyz/.ignoreCase);
+
+ // 'ABC def ghi'.match(/[a-z]+/ig)
+ testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(/[a-z]+/ig)",
+ String(["ABC","def","ghi"]), String('ABC def ghi'.match(/[a-z]+/ig)));
+
+ // 'ABC def ghi'.match(/[a-z]+/i)
+ testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(/[a-z]+/i)",
+ String(["ABC"]), String('ABC def ghi'.match(/[a-z]+/i)));
+
+ // 'ABC def ghi'.match(/([a-z]+)/ig)
+ testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(/([a-z]+)/ig)",
+ String(["ABC","def","ghi"]), String('ABC def ghi'.match(/([a-z]+)/ig)));
+
+ // 'ABC def ghi'.match(/([a-z]+)/i)
+ testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(/([a-z]+)/i)",
+ String(["ABC","ABC"]), String('ABC def ghi'.match(/([a-z]+)/i)));
+
+ // 'ABC def ghi'.match(/[a-z]+/)
+ testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(/[a-z]+/)",
+ String(["def"]), String('ABC def ghi'.match(/[a-z]+/)));
+
+ // (new RegExp('xyz','i')).ignoreCase
+ testcases[count++] = new TestCase ( SECTION, "(new RegExp('xyz','i')).ignoreCase",
+ true, (new RegExp('xyz','i')).ignoreCase);
+
+ // (new RegExp('xyz')).ignoreCase
+ testcases[count++] = new TestCase ( SECTION, "(new RegExp('xyz')).ignoreCase",
+ false, (new RegExp('xyz')).ignoreCase);
+
+ // 'ABC def ghi'.match(new RegExp('[a-z]+','ig'))
+ testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(new RegExp('[a-z]+','ig'))",
+ String(["ABC","def","ghi"]), String('ABC def ghi'.match(new RegExp('[a-z]+','ig'))));
+
+ // 'ABC def ghi'.match(new RegExp('[a-z]+','i'))
+ testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(new RegExp('[a-z]+','i'))",
+ String(["ABC"]), String('ABC def ghi'.match(new RegExp('[a-z]+','i'))));
+
+ // 'ABC def ghi'.match(new RegExp('([a-z]+)','ig'))
+ testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(new RegExp('([a-z]+)','ig'))",
+ String(["ABC","def","ghi"]), String('ABC def ghi'.match(new RegExp('([a-z]+)','ig'))));
+
+ // 'ABC def ghi'.match(new RegExp('([a-z]+)','i'))
+ testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(new RegExp('([a-z]+)','i'))",
+ String(["ABC","ABC"]), String('ABC def ghi'.match(new RegExp('([a-z]+)','i'))));
+
+ // 'ABC def ghi'.match(new RegExp('[a-z]+'))
+ testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(new RegExp('[a-z]+'))",
+ String(["def"]), String('ABC def ghi'.match(new RegExp('[a-z]+'))));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/interval.js b/js/tests/js1_2/regexp/interval.js
new file mode 100644
index 00000000000..1ffee1166bf
--- /dev/null
+++ b/js/tests/js1_2/regexp/interval.js
@@ -0,0 +1,112 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: interval.js
+ Description: 'Tests regular expressions containing {}'
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: {}';
+
+ writeHeaderToLog('Executing script: interval.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'aaabbbbcccddeeeefffff'.match(new RegExp('b{2}c'))
+ testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{2}c'))",
+ String(["bbc"]), String('aaabbbbcccddeeeefffff'.match(new RegExp('b{2}c'))));
+
+ // 'aaabbbbcccddeeeefffff'.match(new RegExp('b{8}'))
+ testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{8}'))",
+ null, 'aaabbbbcccddeeeefffff'.match(new RegExp('b{8}')));
+
+ // 'aaabbbbcccddeeeefffff'.match(new RegExp('b{2,}c'))
+ testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{2,}c'))",
+ String(["bbbbc"]), String('aaabbbbcccddeeeefffff'.match(new RegExp('b{2,}c'))));
+
+ // 'aaabbbbcccddeeeefffff'.match(new RegExp('b{8,}c'))
+ testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{8,}c'))",
+ null, 'aaabbbbcccddeeeefffff'.match(new RegExp('b{8,}c')));
+
+ // 'aaabbbbcccddeeeefffff'.match(new RegExp('b{2,3}c'))
+ testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{2,3}c'))",
+ String(["bbbc"]), String('aaabbbbcccddeeeefffff'.match(new RegExp('b{2,3}c'))));
+
+ // 'aaabbbbcccddeeeefffff'.match(new RegExp('b{42,93}c'))
+ testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{42,93}c'))",
+ null, 'aaabbbbcccddeeeefffff'.match(new RegExp('b{42,93}c')));
+
+ // 'aaabbbbcccddeeeefffff'.match(new RegExp('b{0,93}c'))
+ testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{0,93}c'))",
+ String(["bbbbc"]), String('aaabbbbcccddeeeefffff'.match(new RegExp('b{0,93}c'))));
+
+ // 'aaabbbbcccddeeeefffff'.match(new RegExp('bx{0,93}c'))
+ testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('bx{0,93}c'))",
+ String(["bc"]), String('aaabbbbcccddeeeefffff'.match(new RegExp('bx{0,93}c'))));
+
+ // 'weirwerdf'.match(new RegExp('.{0,93}'))
+ testcases[count++] = new TestCase ( SECTION, "'weirwerdf'.match(new RegExp('.{0,93}'))",
+ String(["weirwerdf"]), String('weirwerdf'.match(new RegExp('.{0,93}'))));
+
+ // 'wqe456646dsff'.match(new RegExp('\d{1,}'))
+ testcases[count++] = new TestCase ( SECTION, "'wqe456646dsff'.match(new RegExp('\\d{1,}'))",
+ String(["456646"]), String('wqe456646dsff'.match(new RegExp('\\d{1,}'))));
+
+ // '123123'.match(new RegExp('(123){1,}'))
+ testcases[count++] = new TestCase ( SECTION, "'123123'.match(new RegExp('(123){1,}'))",
+ String(["123123","123"]), String('123123'.match(new RegExp('(123){1,}'))));
+
+ // '123123x123'.match(new RegExp('(123){1,}x\1'))
+ testcases[count++] = new TestCase ( SECTION, "'123123x123'.match(new RegExp('(123){1,}x\\1'))",
+ String(["123123x123","123"]), String('123123x123'.match(new RegExp('(123){1,}x\\1'))));
+
+ // '123123x123'.match(/(123){1,}x\1/)
+ testcases[count++] = new TestCase ( SECTION, "'123123x123'.match(/(123){1,}x\\1/)",
+ String(["123123x123","123"]), String('123123x123'.match(/(123){1,}x\1/)));
+
+ // 'xxxxxxx'.match(new RegExp('x{1,2}x{1,}'))
+ testcases[count++] = new TestCase ( SECTION, "'xxxxxxx'.match(new RegExp('x{1,2}x{1,}'))",
+ String(["xxxxxxx"]), String('xxxxxxx'.match(new RegExp('x{1,2}x{1,}'))));
+
+ // 'xxxxxxx'.match(/x{1,2}x{1,}/)
+ testcases[count++] = new TestCase ( SECTION, "'xxxxxxx'.match(/x{1,2}x{1,}/)",
+ String(["xxxxxxx"]), String('xxxxxxx'.match(/x{1,2}x{1,}/)));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/octal.js b/js/tests/js1_2/regexp/octal.js
new file mode 100644
index 00000000000..210861133cd
--- /dev/null
+++ b/js/tests/js1_2/regexp/octal.js
@@ -0,0 +1,105 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: octal.js
+ Description: 'Tests regular expressions containing \ '
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: \# (octal) ';
+
+ writeHeaderToLog('Executing script: octal.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+
+ var testPattern = '\\101\\102\\103\\104\\105\\106\\107\\110\\111\\112\\113\\114\\115\\116\\117\\120\\121\\122\\123\\124\\125\\126\\127\\130\\131\\132';
+
+ var testString = "12345ABCDEFGHIJKLMNOPQRSTUVWXYZ67890";
+
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + testString + "'.match(new RegExp('" + testPattern + "'))",
+ String(["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]), String(testString.match(new RegExp(testPattern))));
+
+ testPattern = '\\141\\142\\143\\144\\145\\146\\147\\150\\151\\152\\153\\154\\155\\156\\157\\160\\161\\162\\163\\164\\165\\166\\167\\170\\171\\172';
+
+ testString = "12345AabcdefghijklmnopqrstuvwxyzZ67890";
+
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + testString + "'.match(new RegExp('" + testPattern + "'))",
+ String(["abcdefghijklmnopqrstuvwxyz"]), String(testString.match(new RegExp(testPattern))));
+
+ testPattern = '\\40\\41\\42\\43\\44\\45\\46\\47\\50\\51\\52\\53\\54\\55\\56\\57\\60\\61\\62\\63';
+
+ testString = "abc !\"#$%&'()*+,-./0123ZBC";
+
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + testString + "'.match(new RegExp('" + testPattern + "'))",
+ String([" !\"#$%&'()*+,-./0123"]), String(testString.match(new RegExp(testPattern))));
+
+ testPattern = '\\64\\65\\66\\67\\70\\71\\72\\73\\74\\75\\76\\77\\100';
+
+ testString = "123456789:;<=>?@ABC";
+
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + testString + "'.match(new RegExp('" + testPattern + "'))",
+ String(["456789:;<=>?@"]), String(testString.match(new RegExp(testPattern))));
+
+ testPattern = '\\173\\174\\175\\176';
+
+ testString = "1234{|}~ABC";
+
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + testString + "'.match(new RegExp('" + testPattern + "'))",
+ String(["{|}~"]), String(testString.match(new RegExp(testPattern))));
+
+ testcases[count++] = new TestCase ( SECTION,
+ "'canthisbeFOUND'.match(new RegExp('[A-\\132]+'))",
+ String(["FOUND"]), String('canthisbeFOUND'.match(new RegExp('[A-\\132]+'))));
+
+ testcases[count++] = new TestCase ( SECTION,
+ "'canthisbeFOUND'.match(new RegExp('[\\141-\\172]+'))",
+ String(["canthisbe"]), String('canthisbeFOUND'.match(new RegExp('[\\141-\\172]+'))));
+
+ testcases[count++] = new TestCase ( SECTION,
+ "'canthisbeFOUND'.match(/[\\141-\\172]+/)",
+ String(["canthisbe"]), String('canthisbeFOUND'.match(/[\141-\172]+/)));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/parentheses.js b/js/tests/js1_2/regexp/parentheses.js
new file mode 100644
index 00000000000..6016102f18c
--- /dev/null
+++ b/js/tests/js1_2/regexp/parentheses.js
@@ -0,0 +1,104 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: parentheses.js
+ Description: 'Tests regular expressions containing ()'
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: ()';
+
+ writeHeaderToLog('Executing script: parentheses.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'abc'.match(new RegExp('(abc)'))
+ testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('(abc)'))",
+ String(["abc","abc"]), String('abc'.match(new RegExp('(abc)'))));
+
+ // 'abcdefg'.match(new RegExp('a(bc)d(ef)g'))
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('a(bc)d(ef)g'))",
+ String(["abcdefg","bc","ef"]), String('abcdefg'.match(new RegExp('a(bc)d(ef)g'))));
+
+ // 'abcdefg'.match(new RegExp('(.{3})(.{4})'))
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('(.{3})(.{4})'))",
+ String(["abcdefg","abc","defg"]), String('abcdefg'.match(new RegExp('(.{3})(.{4})'))));
+
+ // 'aabcdaabcd'.match(new RegExp('(aa)bcd\1'))
+ testcases[count++] = new TestCase ( SECTION, "'aabcdaabcd'.match(new RegExp('(aa)bcd\\1'))",
+ String(["aabcdaa","aa"]), String('aabcdaabcd'.match(new RegExp('(aa)bcd\\1'))));
+
+ // 'aabcdaabcd'.match(new RegExp('(aa).+\1'))
+ testcases[count++] = new TestCase ( SECTION, "'aabcdaabcd'.match(new RegExp('(aa).+\\1'))",
+ String(["aabcdaa","aa"]), String('aabcdaabcd'.match(new RegExp('(aa).+\\1'))));
+
+ // 'aabcdaabcd'.match(new RegExp('(.{2}).+\1'))
+ testcases[count++] = new TestCase ( SECTION, "'aabcdaabcd'.match(new RegExp('(.{2}).+\\1'))",
+ String(["aabcdaa","aa"]), String('aabcdaabcd'.match(new RegExp('(.{2}).+\\1'))));
+
+ // '123456123456'.match(new RegExp('(\d{3})(\d{3})\1\2'))
+ testcases[count++] = new TestCase ( SECTION, "'123456123456'.match(new RegExp('(\\d{3})(\\d{3})\\1\\2'))",
+ String(["123456123456","123","456"]), String('123456123456'.match(new RegExp('(\\d{3})(\\d{3})\\1\\2'))));
+
+ // 'abcdefg'.match(new RegExp('a(..(..)..)'))
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('a(..(..)..)'))",
+ String(["abcdefg","bcdefg","de"]), String('abcdefg'.match(new RegExp('a(..(..)..)'))));
+
+ // 'abcdefg'.match(/a(..(..)..)/)
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/a(..(..)..)/)",
+ String(["abcdefg","bcdefg","de"]), String('abcdefg'.match(/a(..(..)..)/)));
+
+ // 'xabcdefg'.match(new RegExp('(a(b(c)))(d(e(f)))'))
+ testcases[count++] = new TestCase ( SECTION, "'xabcdefg'.match(new RegExp('(a(b(c)))(d(e(f)))'))",
+ String(["abcdef","abc","bc","c","def","ef","f"]), String('xabcdefg'.match(new RegExp('(a(b(c)))(d(e(f)))'))));
+
+ // 'xabcdefbcefg'.match(new RegExp('(a(b(c)))(d(e(f)))\2\5'))
+ testcases[count++] = new TestCase ( SECTION, "'xabcdefbcefg'.match(new RegExp('(a(b(c)))(d(e(f)))\\2\\5'))",
+ String(["abcdefbcef","abc","bc","c","def","ef","f"]), String('xabcdefbcefg'.match(new RegExp('(a(b(c)))(d(e(f)))\\2\\5'))));
+
+ // 'abcd'.match(new RegExp('a(.?)b\1c\1d\1'))
+ testcases[count++] = new TestCase ( SECTION, "'abcd'.match(new RegExp('a(.?)b\\1c\\1d\\1'))",
+ String(["abcd",""]), String('abcd'.match(new RegExp('a(.?)b\\1c\\1d\\1'))));
+
+ // 'abcd'.match(/a(.?)b\1c\1d\1/)
+ testcases[count++] = new TestCase ( SECTION, "'abcd'.match(/a(.?)b\\1c\\1d\\1/)",
+ String(["abcd",""]), String('abcd'.match(/a(.?)b\1c\1d\1/)));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/plus.js b/js/tests/js1_2/regexp/plus.js
new file mode 100644
index 00000000000..a3111d0c650
--- /dev/null
+++ b/js/tests/js1_2/regexp/plus.js
@@ -0,0 +1,84 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: plus.js
+ Description: 'Tests regular expressions containing +'
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: +';
+
+ writeHeaderToLog('Executing script: plus.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'abcdddddefg'.match(new RegExp('d+'))
+ testcases[count++] = new TestCase ( SECTION, "'abcdddddefg'.match(new RegExp('d+'))",
+ String(["ddddd"]), String('abcdddddefg'.match(new RegExp('d+'))));
+
+ // 'abcdefg'.match(new RegExp('o+'))
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('o+'))",
+ null, 'abcdefg'.match(new RegExp('o+')));
+
+ // 'abcdefg'.match(new RegExp('d+'))
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('d+'))",
+ String(['d']), String('abcdefg'.match(new RegExp('d+'))));
+
+ // 'abbbbbbbc'.match(new RegExp('(b+)(b+)(b+)'))
+ testcases[count++] = new TestCase ( SECTION, "'abbbbbbbc'.match(new RegExp('(b+)(b+)(b+)'))",
+ String(["bbbbbbb","bbbbb","b","b"]), String('abbbbbbbc'.match(new RegExp('(b+)(b+)(b+)'))));
+
+ // 'abbbbbbbc'.match(new RegExp('(b+)(b*)'))
+ testcases[count++] = new TestCase ( SECTION, "'abbbbbbbc'.match(new RegExp('(b+)(b*)'))",
+ String(["bbbbbbb","bbbbbbb",""]), String('abbbbbbbc'.match(new RegExp('(b+)(b*)'))));
+
+ // 'abbbbbbbc'.match(new RegExp('b*b+'))
+ testcases[count++] = new TestCase ( SECTION, "'abbbbbbbc'.match(new RegExp('b*b+'))",
+ String(['bbbbbbb']), String('abbbbbbbc'.match(new RegExp('b*b+'))));
+
+ // 'abbbbbbbc'.match(/(b+)(b*)/)
+ testcases[count++] = new TestCase ( SECTION, "'abbbbbbbc'.match(/(b+)(b*)/)",
+ String(["bbbbbbb","bbbbbbb",""]), String('abbbbbbbc'.match(/(b+)(b*)/)));
+
+ // 'abbbbbbbc'.match(new RegExp('b*b+'))
+ testcases[count++] = new TestCase ( SECTION, "'abbbbbbbc'.match(/b*b+/)",
+ String(['bbbbbbb']), String('abbbbbbbc'.match(/b*b+/)));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/question_mark.js b/js/tests/js1_2/regexp/question_mark.js
new file mode 100644
index 00000000000..100b7e6b295
--- /dev/null
+++ b/js/tests/js1_2/regexp/question_mark.js
@@ -0,0 +1,96 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: question_mark.js
+ Description: 'Tests regular expressions containing ?'
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: ?';
+
+ writeHeaderToLog('Executing script: question_mark.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'abcdef'.match(new RegExp('cd?e'))
+ testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(new RegExp('cd?e'))",
+ String(["cde"]), String('abcdef'.match(new RegExp('cd?e'))));
+
+ // 'abcdef'.match(new RegExp('cdx?e'))
+ testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(new RegExp('cdx?e'))",
+ String(["cde"]), String('abcdef'.match(new RegExp('cdx?e'))));
+
+ // 'pqrstuvw'.match(new RegExp('o?pqrst'))
+ testcases[count++] = new TestCase ( SECTION, "'pqrstuvw'.match(new RegExp('o?pqrst'))",
+ String(["pqrst"]), String('pqrstuvw'.match(new RegExp('o?pqrst'))));
+
+ // 'abcd'.match(new RegExp('x?y?z?'))
+ testcases[count++] = new TestCase ( SECTION, "'abcd'.match(new RegExp('x?y?z?'))",
+ String([""]), String('abcd'.match(new RegExp('x?y?z?'))));
+
+ // 'abcd'.match(new RegExp('x?ay?bz?c'))
+ testcases[count++] = new TestCase ( SECTION, "'abcd'.match(new RegExp('x?ay?bz?c'))",
+ String(["abc"]), String('abcd'.match(new RegExp('x?ay?bz?c'))));
+
+ // 'abcd'.match(/x?ay?bz?c/)
+ testcases[count++] = new TestCase ( SECTION, "'abcd'.match(/x?ay?bz?c/)",
+ String(["abc"]), String('abcd'.match(/x?ay?bz?c/)));
+
+ // 'abbbbc'.match(new RegExp('b?b?b?b'))
+ testcases[count++] = new TestCase ( SECTION, "'abbbbc'.match(new RegExp('b?b?b?b'))",
+ String(["bbbb"]), String('abbbbc'.match(new RegExp('b?b?b?b'))));
+
+ // '123az789'.match(new RegExp('ab?c?d?x?y?z'))
+ testcases[count++] = new TestCase ( SECTION, "'123az789'.match(new RegExp('ab?c?d?x?y?z'))",
+ String(["az"]), String('123az789'.match(new RegExp('ab?c?d?x?y?z'))));
+
+ // '123az789'.match(/ab?c?d?x?y?z/)
+ testcases[count++] = new TestCase ( SECTION, "'123az789'.match(/ab?c?d?x?y?z/)",
+ String(["az"]), String('123az789'.match(/ab?c?d?x?y?z/)));
+
+ // '?????'.match(new RegExp('\\??\\??\\??\\??\\??'))
+ testcases[count++] = new TestCase ( SECTION, "'?????'.match(new RegExp('\\??\\??\\??\\??\\??'))",
+ String(["?????"]), String('?????'.match(new RegExp('\\??\\??\\??\\??\\??'))));
+
+ // 'test'.match(new RegExp('.?.?.?.?.?.?.?'))
+ testcases[count++] = new TestCase ( SECTION, "'test'.match(new RegExp('.?.?.?.?.?.?.?'))",
+ String(["test"]), String('test'.match(new RegExp('.?.?.?.?.?.?.?'))));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/simple_form.js b/js/tests/js1_2/regexp/simple_form.js
new file mode 100644
index 00000000000..37eeed4db06
--- /dev/null
+++ b/js/tests/js1_2/regexp/simple_form.js
@@ -0,0 +1,87 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: simple_form.js
+ Description: 'Tests regular expressions using simple form: re(...)'
+
+ Author: Nick Lerissa
+ Date: March 19, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: simple form';
+
+ writeHeaderToLog('Executing script: simple_form.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ testcases[count++] = new TestCase ( SECTION,
+ "/[0-9]{3}/('23 2 34 678 9 09')",
+ String(["678"]), String(/[0-9]{3}/('23 2 34 678 9 09')));
+
+ testcases[count++] = new TestCase ( SECTION,
+ "/3.{4}8/('23 2 34 678 9 09')",
+ String(["34 678"]), String(/3.{4}8/('23 2 34 678 9 09')));
+
+ testcases[count++] = new TestCase ( SECTION,
+ "(/3.{4}8/('23 2 34 678 9 09').length",
+ 1, (/3.{4}8/('23 2 34 678 9 09')).length);
+
+ var re = /[0-9]{3}/;
+ testcases[count++] = new TestCase ( SECTION,
+ "re('23 2 34 678 9 09')",
+ String(["678"]), String(re('23 2 34 678 9 09')));
+
+ re = /3.{4}8/;
+ testcases[count++] = new TestCase ( SECTION,
+ "re('23 2 34 678 9 09')",
+ String(["34 678"]), String(re('23 2 34 678 9 09')));
+
+ testcases[count++] = new TestCase ( SECTION,
+ "/3.{4}8/('23 2 34 678 9 09')",
+ String(["34 678"]), String(/3.{4}8/('23 2 34 678 9 09')));
+
+ re =/3.{4}8/;
+ testcases[count++] = new TestCase ( SECTION,
+ "(re('23 2 34 678 9 09').length",
+ 1, (re('23 2 34 678 9 09')).length);
+
+ testcases[count++] = new TestCase ( SECTION,
+ "(/3.{4}8/('23 2 34 678 9 09').length",
+ 1, (/3.{4}8/('23 2 34 678 9 09')).length);
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/source.js b/js/tests/js1_2/regexp/source.js
new file mode 100644
index 00000000000..d53d573b536
--- /dev/null
+++ b/js/tests/js1_2/regexp/source.js
@@ -0,0 +1,84 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: source.js
+ Description: 'Tests RegExp attribute source'
+
+ Author: Nick Lerissa
+ Date: March 13, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: source';
+
+ writeHeaderToLog('Executing script: source.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // /xyz/g.source
+ testcases[count++] = new TestCase ( SECTION, "/xyz/g.source",
+ "xyz", /xyz/g.source);
+
+ // /xyz/.source
+ testcases[count++] = new TestCase ( SECTION, "/xyz/.source",
+ "xyz", /xyz/.source);
+
+ // /abc\\def/.source
+ testcases[count++] = new TestCase ( SECTION, "/abc\\\\def/.source",
+ "abc\\\\def", /abc\\def/.source);
+
+ // /abc[\b]def/.source
+ testcases[count++] = new TestCase ( SECTION, "/abc[\\b]def/.source",
+ "abc[\\b]def", /abc[\b]def/.source);
+
+ // (new RegExp('xyz')).source
+ testcases[count++] = new TestCase ( SECTION, "(new RegExp('xyz')).source",
+ "xyz", (new RegExp('xyz')).source);
+
+ // (new RegExp('xyz','g')).source
+ testcases[count++] = new TestCase ( SECTION, "(new RegExp('xyz','g')).source",
+ "xyz", (new RegExp('xyz','g')).source);
+
+ // (new RegExp('abc\\\\def')).source
+ testcases[count++] = new TestCase ( SECTION, "(new RegExp('abc\\\\\\\\def')).source",
+ "abc\\\\def", (new RegExp('abc\\\\def')).source);
+
+ // (new RegExp('abc[\\b]def')).source
+ testcases[count++] = new TestCase ( SECTION, "(new RegExp('abc[\\\\b]def')).source",
+ "abc[\\b]def", (new RegExp('abc[\\b]def')).source);
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/special_characters.js b/js/tests/js1_2/regexp/special_characters.js
new file mode 100644
index 00000000000..61bd31bd8e7
--- /dev/null
+++ b/js/tests/js1_2/regexp/special_characters.js
@@ -0,0 +1,154 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: special_characters.js
+ Description: 'Tests regular expressions containing special characters'
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: special_charaters';
+
+ writeHeaderToLog('Executing script: special_characters.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // testing backslash '\'
+ testcases[count++] = new TestCase ( SECTION, "'^abcdefghi'.match(/\^abc/)", String(["^abc"]), String('^abcdefghi'.match(/\^abc/)));
+
+ // testing beginning of line '^'
+ testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/^abc/)", String(["abc"]), String('abcdefghi'.match(/^abc/)));
+
+ // testing end of line '$'
+ testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/fghi$/)", String(["ghi"]), String('abcdefghi'.match(/ghi$/)));
+
+ // testing repeat '*'
+ testcases[count++] = new TestCase ( SECTION, "'eeeefghi'.match(/e*/)", String(["eeee"]), String('eeeefghi'.match(/e*/)));
+
+ // testing repeat 1 or more times '+'
+ testcases[count++] = new TestCase ( SECTION, "'abcdeeeefghi'.match(/e+/)", String(["eeee"]), String('abcdeeeefghi'.match(/e+/)));
+
+ // testing repeat 0 or 1 time '?'
+ testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/abc?de/)", String(["abcde"]), String('abcdefghi'.match(/abc?de/)));
+
+ // testing any character '.'
+ testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/c.e/)", String(["cde"]), String('abcdefghi'.match(/c.e/)));
+
+ // testing remembering ()
+ testcases[count++] = new TestCase ( SECTION, "'abcewirjskjdabciewjsdf'.match(/(abc).+\\1'/)",
+ String(["abcewirjskjdabc","abc"]), String('abcewirjskjdabciewjsdf'.match(/(abc).+\1/)));
+
+ // testing or match '|'
+ testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/xyz|def/)", String(["def"]), String('abcdefghi'.match(/xyz|def/)));
+
+ // testing repeat n {n}
+ testcases[count++] = new TestCase ( SECTION, "'abcdeeeefghi'.match(/e{3}/)", String(["eee"]), String('abcdeeeefghi'.match(/e{3}/)));
+
+ // testing min repeat n {n,}
+ testcases[count++] = new TestCase ( SECTION, "'abcdeeeefghi'.match(/e{3,}/)", String(["eeee"]), String('abcdeeeefghi'.match(/e{3,}/)));
+
+ // testing min/max repeat {min, max}
+ testcases[count++] = new TestCase ( SECTION, "'abcdeeeefghi'.match(/e{2,8}/)", String(["eeee"]), String('abcdeeeefghi'.match(/e{2,8}/)));
+
+ // testing any in set [abc...]
+ testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/cd[xey]fgh/)", String(["cdefgh"]), String('abcdefghi'.match(/cd[xey]fgh/)));
+
+ // testing any in set [a-z]
+ testcases[count++] = new TestCase ( SECTION, "'netscape inc'.match(/t[r-v]ca/)", String(["tsca"]), String('netscape inc'.match(/t[r-v]ca/)));
+
+ // testing any not in set [^abc...]
+ testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/cd[^xy]fgh/)", String(["cdefgh"]), String('abcdefghi'.match(/cd[^xy]fgh/)));
+
+ // testing any not in set [^a-z]
+ testcases[count++] = new TestCase ( SECTION, "'netscape inc'.match(/t[^a-c]ca/)", String(["tsca"]), String('netscape inc'.match(/t[^a-c]ca/)));
+
+ // testing backspace [\b]
+ testcases[count++] = new TestCase ( SECTION, "'this is b\ba test'.match(/is b[\b]a test/)",
+ String(["is b\ba test"]), String('this is b\ba test'.match(/is b[\b]a test/)));
+
+ // testing word boundary \b
+ testcases[count++] = new TestCase ( SECTION, "'today is now - day is not now'.match(/\bday.*now/)",
+ String(["day is not now"]), String('today is now - day is not now'.match(/\bday.*now/)));
+
+ // control characters???
+
+ // testing any digit \d
+ testcases[count++] = new TestCase ( SECTION, "'a dog - 1 dog'.match(/\d dog/)", String(["1 dog"]), String('a dog - 1 dog'.match(/\d dog/)));
+
+ // testing any non digit \d
+ testcases[count++] = new TestCase ( SECTION, "'a dog - 1 dog'.match(/\D dog/)", String(["a dog"]), String('a dog - 1 dog'.match(/\D dog/)));
+
+ // testing form feed '\f'
+ testcases[count++] = new TestCase ( SECTION, "'a b a\fb'.match(/a\fb/)", String(["a\fb"]), String('a b a\fb'.match(/a\fb/)));
+
+ // testing line feed '\n'
+ testcases[count++] = new TestCase ( SECTION, "'a b a\nb'.match(/a\nb/)", String(["a\nb"]), String('a b a\nb'.match(/a\nb/)));
+
+ // testing carriage return '\r'
+ testcases[count++] = new TestCase ( SECTION, "'a b a\rb'.match(/a\rb/)", String(["a\rb"]), String('a b a\rb'.match(/a\rb/)));
+
+ // testing whitespace '\s'
+ testcases[count++] = new TestCase ( SECTION, "'xa\f\n\r\t\vbz'.match(/a\s+b/)", String(["a\f\n\r\t\vb"]), String('xa\f\n\r\t\vbz'.match(/a\s+b/)));
+
+ // testing non whitespace '\S'
+ testcases[count++] = new TestCase ( SECTION, "'a\tb a b a-b'.match(/a\Sb/)", String(["a-b"]), String('a\tb a b a-b'.match(/a\Sb/)));
+
+ // testing tab '\t'
+ testcases[count++] = new TestCase ( SECTION, "'a\t\tb a b'.match(/a\t{2}/)", String(["a\t\t"]), String('a\t\tb a b'.match(/a\t{2}/)));
+
+ // testing vertical tab '\v'
+ testcases[count++] = new TestCase ( SECTION, "'a\v\vb a b'.match(/a\v{2}/)", String(["a\v\v"]), String('a\v\vb a b'.match(/a\v{2}/)));
+
+ // testing alphnumeric characters '\w'
+ testcases[count++] = new TestCase ( SECTION, "'%AZaz09_$'.match(/\w+/)", String(["AZaz09_"]), String('%AZaz09_$'.match(/\w+/)));
+
+ // testing non alphnumeric characters '\W'
+ testcases[count++] = new TestCase ( SECTION, "'azx$%#@*4534'.match(/\W+/)", String(["$%#@*"]), String('azx$%#@*4534'.match(/\W+/)));
+
+ // testing back references '\'
+ testcases[count++] = new TestCase ( SECTION, "'test'.match(/(t)es\\1/)", String(["test","t"]), String('test'.match(/(t)es\1/)));
+
+ // testing hex excaping with '\'
+ testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(/\x63\x64/)", String(["cd"]), String('abcdef'.match(/\x63\x64/)));
+
+ // testing oct excaping with '\'
+ testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(/\\143\\144/)", String(["cd"]), String('abcdef'.match(/\143\144/)));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
+
diff --git a/js/tests/js1_2/regexp/string_replace.js b/js/tests/js1_2/regexp/string_replace.js
new file mode 100644
index 00000000000..e05e2968c8f
--- /dev/null
+++ b/js/tests/js1_2/regexp/string_replace.js
@@ -0,0 +1,77 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: string_replace.js
+ Description: 'Tests the replace method on Strings using regular expressions'
+
+ Author: Nick Lerissa
+ Date: March 11, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'String: replace';
+
+ writeHeaderToLog('Executing script: string_replace.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'adddb'.replace(/ddd/,"XX")
+ testcases[count++] = new TestCase ( SECTION, "'adddb'.replace(/ddd/,'XX')",
+ "aXXb", 'adddb'.replace(/ddd/,'XX'));
+
+ // 'adddb'.replace(/eee/,"XX")
+ testcases[count++] = new TestCase ( SECTION, "'adddb'.replace(/eee/,'XX')",
+ 'adddb', 'adddb'.replace(/eee/,'XX'));
+
+ // '34 56 78b 12'.replace(new RegExp('[0-9]+b'),'**')
+ testcases[count++] = new TestCase ( SECTION, "'34 56 78b 12'.replace(new RegExp('[0-9]+b'),'**')",
+ "34 56 ** 12", '34 56 78b 12'.replace(new RegExp('[0-9]+b'),'**'));
+
+ // '34 56 78b 12'.replace(new RegExp('[0-9]+c'),'XX')
+ testcases[count++] = new TestCase ( SECTION, "'34 56 78b 12'.replace(new RegExp('[0-9]+c'),'XX')",
+ "34 56 78b 12", '34 56 78b 12'.replace(new RegExp('[0-9]+c'),'XX'));
+
+ // 'original'.replace(new RegExp(),'XX')
+ testcases[count++] = new TestCase ( SECTION, "'original'.replace(new RegExp(),'XX')",
+ "XXoriginal", 'original'.replace(new RegExp(),'XX'));
+
+ // 'qwe ert x\t\n 345654AB'.replace(new RegExp('x\s*\d+(..)$'),'****')
+ testcases[count++] = new TestCase ( SECTION, "'qwe ert x\t\n 345654AB'.replace(new RegExp('x\\s*\\d+(..)$'),'****')",
+ "qwe ert ****", 'qwe ert x\t\n 345654AB'.replace(new RegExp('x\\s*\\d+(..)$'),'****'));
+
+
+function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/string_search.js b/js/tests/js1_2/regexp/string_search.js
new file mode 100644
index 00000000000..13371488492
--- /dev/null
+++ b/js/tests/js1_2/regexp/string_search.js
@@ -0,0 +1,84 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: string_search.js
+ Description: 'Tests the search method on Strings using regular expressions'
+
+ Author: Nick Lerissa
+ Date: March 12, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'String: search';
+
+ writeHeaderToLog('Executing script: string_search.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'abcdefg'.search(/d/)
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.search(/d/)",
+ 3, 'abcdefg'.search(/d/));
+
+ // 'abcdefg'.search(/x/)
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg'.search(/x/)",
+ -1, 'abcdefg'.search(/x/));
+
+ // 'abcdefg123456hijklmn'.search(/\d+/)
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg123456hijklmn'.search(/\d+/)",
+ 7, 'abcdefg123456hijklmn'.search(/\d+/));
+
+ // 'abcdefg123456hijklmn'.search(new RegExp())
+ testcases[count++] = new TestCase ( SECTION, "'abcdefg123456hijklmn'.search(new RegExp())",
+ 0, 'abcdefg123456hijklmn'.search(new RegExp()));
+
+ // 'abc'.search(new RegExp('$'))
+ testcases[count++] = new TestCase ( SECTION, "'abc'.search(new RegExp('$'))",
+ 3, 'abc'.search(new RegExp('$')));
+
+ // 'abc'.search(new RegExp('^'))
+ testcases[count++] = new TestCase ( SECTION, "'abc'.search(new RegExp('^'))",
+ 0, 'abc'.search(new RegExp('^')));
+
+ // 'abc1'.search(/.\d/)
+ testcases[count++] = new TestCase ( SECTION, "'abc1'.search(/.\d/)",
+ 2, 'abc1'.search(/.\d/));
+
+ // 'abc1'.search(/\d{2}/)
+ testcases[count++] = new TestCase ( SECTION, "'abc1'.search(/\d{2}/)",
+ -1, 'abc1'.search(/\d{2}/));
+
+function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/string_split.js b/js/tests/js1_2/regexp/string_split.js
new file mode 100644
index 00000000000..e8254930ae7
--- /dev/null
+++ b/js/tests/js1_2/regexp/string_split.js
@@ -0,0 +1,88 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: string_split.js
+ Description: 'Tests the split method on Strings using regular expressions'
+
+ Author: Nick Lerissa
+ Date: March 11, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'String: split';
+
+ writeHeaderToLog('Executing script: string_split.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'a b c de f'.split(/\s/)
+ testcases[count++] = new TestCase ( SECTION, "'a b c de f'.split(/\s/)",
+ String(["a","b","c","de","f"]), String('a b c de f'.split(/\s/)));
+
+ // 'a b c de f'.split(/\s/,3)
+ testcases[count++] = new TestCase ( SECTION, "'a b c de f'.split(/\s/,3)",
+ String(["a","b","c"]), String('a b c de f'.split(/\s/,3)));
+
+ // 'a b c de f'.split(/X/)
+ testcases[count++] = new TestCase ( SECTION, "'a b c de f'.split(/X/)",
+ String(["a b c de f"]), String('a b c de f'.split(/X/)));
+
+ // 'dfe23iu 34 =+65--'.split(/\d+/)
+ testcases[count++] = new TestCase ( SECTION, "'dfe23iu 34 =+65--'.split(/\d+/)",
+ String(["dfe","iu "," =+","--"]), String('dfe23iu 34 =+65--'.split(/\d+/)));
+
+ // 'dfe23iu 34 =+65--'.split(new RegExp('\d+'))
+ testcases[count++] = new TestCase ( SECTION, "'dfe23iu 34 =+65--'.split(new RegExp('\\d+'))",
+ String(["dfe","iu "," =+","--"]), String('dfe23iu 34 =+65--'.split(new RegExp('\\d+'))));
+
+ // 'abc'.split(/[a-z]/)
+ testcases[count++] = new TestCase ( SECTION, "'abc'.split(/[a-z]/)",
+ String(["","",""]), String('abc'.split(/[a-z]/)));
+
+ // 'abc'.split(/[a-z]/)
+ testcases[count++] = new TestCase ( SECTION, "'abc'.split(/[a-z]/)",
+ String(["","",""]), String('abc'.split(/[a-z]/)));
+
+ // 'abc'.split(new RegExp('[a-z]'))
+ testcases[count++] = new TestCase ( SECTION, "'abc'.split(new RegExp('[a-z]'))",
+ String(["","",""]), String('abc'.split(new RegExp('[a-z]'))));
+
+ // 'abc'.split(new RegExp('[a-z]'))
+ testcases[count++] = new TestCase ( SECTION, "'abc'.split(new RegExp('[a-z]'))",
+ String(["","",""]), String('abc'.split(new RegExp('[a-z]'))));
+
+function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/test.js b/js/tests/js1_2/regexp/test.js
new file mode 100644
index 00000000000..c20e4702306
--- /dev/null
+++ b/js/tests/js1_2/regexp/test.js
@@ -0,0 +1,84 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: test.js
+ Description: 'Tests regular expressions method compile'
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: test';
+
+ writeHeaderToLog('Executing script: test.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ testcases[count++] = new TestCase ( SECTION,
+ "/[0-9]{3}/.test('23 2 34 678 9 09')",
+ true, /[0-9]{3}/.test('23 2 34 678 9 09'));
+
+ testcases[count++] = new TestCase ( SECTION,
+ "/[0-9]{3}/.test('23 2 34 78 9 09')",
+ false, /[0-9]{3}/.test('23 2 34 78 9 09'));
+
+ testcases[count++] = new TestCase ( SECTION,
+ "/\w+ \w+ \w+/.test('do a test')",
+ true, /\w+ \w+ \w+/.test("do a test"));
+
+ testcases[count++] = new TestCase ( SECTION,
+ "/\w+ \w+ \w+/.test('a test')",
+ false, /\w+ \w+ \w+/.test("a test"));
+
+ testcases[count++] = new TestCase ( SECTION,
+ "(new RegExp('[0-9]{3}')).test('23 2 34 678 9 09')",
+ true, (new RegExp('[0-9]{3}')).test('23 2 34 678 9 09'));
+
+ testcases[count++] = new TestCase ( SECTION,
+ "(new RegExp('[0-9]{3}')).test('23 2 34 78 9 09')",
+ false, (new RegExp('[0-9]{3}')).test('23 2 34 78 9 09'));
+
+ testcases[count++] = new TestCase ( SECTION,
+ "(new RegExp('\\\\w+ \\\\w+ \\\\w+')).test('do a test')",
+ true, (new RegExp('\\w+ \\w+ \\w+')).test("do a test"));
+
+ testcases[count++] = new TestCase ( SECTION,
+ "(new RegExp('\\\\w+ \\\\w+ \\\\w+')).test('a test')",
+ false, (new RegExp('\\w+ \\w+ \\w+')).test("a test"));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/toString.js b/js/tests/js1_2/regexp/toString.js
new file mode 100644
index 00000000000..55ba7904712
--- /dev/null
+++ b/js/tests/js1_2/regexp/toString.js
@@ -0,0 +1,72 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: toString.js
+ Description: 'Tests RegExp method toString'
+
+ Author: Nick Lerissa
+ Date: March 13, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: toString';
+
+ writeHeaderToLog('Executing script: toString.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // var re = new RegExp(); re.toString()
+ var re = new RegExp();
+ testcases[count++] = new TestCase ( SECTION, "var re = new RegExp(); re.toString()",
+ '//', re.toString());
+
+ // re = /.+/; re.toString();
+ re = /.+/;
+ testcases[count++] = new TestCase ( SECTION, "re = /.+/; re.toString()",
+ '/.+/', re.toString());
+
+ // re = /test/gi; re.toString()
+ re = /test/gi;
+ testcases[count++] = new TestCase ( SECTION, "re = /test/gi; re.toString()",
+ '/test/gi', re.toString());
+
+ // re = /test2/ig; re.toString()
+ re = /test2/ig;
+ testcases[count++] = new TestCase ( SECTION, "re = /test2/ig; re.toString()",
+ '/test2/gi', re.toString());
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/vertical_bar.js b/js/tests/js1_2/regexp/vertical_bar.js
new file mode 100644
index 00000000000..f9def2ec642
--- /dev/null
+++ b/js/tests/js1_2/regexp/vertical_bar.js
@@ -0,0 +1,92 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: vertical_bar.js
+ Description: 'Tests regular expressions containing |'
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: |';
+
+ writeHeaderToLog('Executing script: vertical_bar.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'abc'.match(new RegExp('xyz|abc'))
+ testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('xyz|abc'))",
+ String(["abc"]), String('abc'.match(new RegExp('xyz|abc'))));
+
+ // 'this is a test'.match(new RegExp('quiz|exam|test|homework'))
+ testcases[count++] = new TestCase ( SECTION, "'this is a test'.match(new RegExp('quiz|exam|test|homework'))",
+ String(["test"]), String('this is a test'.match(new RegExp('quiz|exam|test|homework'))));
+
+ // 'abc'.match(new RegExp('xyz|...'))
+ testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('xyz|...'))",
+ String(["abc"]), String('abc'.match(new RegExp('xyz|...'))));
+
+ // 'abc'.match(new RegExp('(.)..|abc'))
+ testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('(.)..|abc'))",
+ String(["abc","a"]), String('abc'.match(new RegExp('(.)..|abc'))));
+
+ // 'color: grey'.match(new RegExp('.+: gr(a|e)y'))
+ testcases[count++] = new TestCase ( SECTION, "'color: grey'.match(new RegExp('.+: gr(a|e)y'))",
+ String(["color: grey","e"]), String('color: grey'.match(new RegExp('.+: gr(a|e)y'))));
+
+ // 'no match'.match(new RegExp('red|white|blue'))
+ testcases[count++] = new TestCase ( SECTION, "'no match'.match(new RegExp('red|white|blue'))",
+ null, 'no match'.match(new RegExp('red|white|blue')));
+
+ // 'Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)'))
+ testcases[count++] = new TestCase ( SECTION, "'Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)'))",
+ String(["Bob","","Bob"]), String('Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)'))));
+
+ // 'abcdef'.match(new RegExp('abc|bcd|cde|def'))
+ testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(new RegExp('abc|bcd|cde|def'))",
+ String(["abc"]), String('abcdef'.match(new RegExp('abc|bcd|cde|def'))));
+
+ // 'Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/)
+ testcases[count++] = new TestCase ( SECTION, "'Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/)",
+ String(["Bob","","Bob"]), String('Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/)));
+
+ // 'abcdef'.match(/abc|bcd|cde|def/)
+ testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(/abc|bcd|cde|def/)",
+ String(["abc"]), String('abcdef'.match(/abc|bcd|cde|def/)));
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/whitespace.js b/js/tests/js1_2/regexp/whitespace.js
new file mode 100644
index 00000000000..e891f8d38f8
--- /dev/null
+++ b/js/tests/js1_2/regexp/whitespace.js
@@ -0,0 +1,119 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: whitespace.js
+ Description: 'Tests regular expressions containing \f\n\r\t\v\s\S\ '
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: \\f\\n\\r\\t\\v\\s\\S ';
+
+ writeHeaderToLog('Executing script: whitespace.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ var non_whitespace = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~`!@#$%^&*()-+={[}]|\\:;'<,>./?1234567890" + '"';
+ var whitespace = "\f\n\r\t\v ";
+
+ // be sure all whitespace is matched by \s
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + whitespace + "'.match(new RegExp('\\s+'))",
+ String([whitespace]), String(whitespace.match(new RegExp('\\s+'))));
+
+ // be sure all non-whitespace is matched by \S
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + non_whitespace + "'.match(new RegExp('\\S+'))",
+ String([non_whitespace]), String(non_whitespace.match(new RegExp('\\S+'))));
+
+ // be sure all non-whitespace is not matched by \s
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + non_whitespace + "'.match(new RegExp('\\s'))",
+ null, non_whitespace.match(new RegExp('\\s')));
+
+ // be sure all whitespace is not matched by \S
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + whitespace + "'.match(new RegExp('\\S'))",
+ null, whitespace.match(new RegExp('\\S')));
+
+ var s = non_whitespace + whitespace;
+
+ // be sure all digits are matched by \s
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(new RegExp('\\s+'))",
+ String([whitespace]), String(s.match(new RegExp('\\s+'))));
+
+ s = whitespace + non_whitespace;
+
+ // be sure all non-whitespace are matched by \S
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(new RegExp('\\S+'))",
+ String([non_whitespace]), String(s.match(new RegExp('\\S+'))));
+
+ // '1233345find me345'.match(new RegExp('[a-z\\s][a-z\\s]+'))
+ testcases[count++] = new TestCase ( SECTION, "'1233345find me345'.match(new RegExp('[a-z\\s][a-z\\s]+'))",
+ String(["find me"]), String('1233345find me345'.match(new RegExp('[a-z\\s][a-z\\s]+'))));
+
+ var i;
+
+ // be sure all whitespace characters match individually
+ for (i = 0; i < whitespace.length; ++i)
+ {
+ s = 'ab' + whitespace[i] + 'cd';
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(new RegExp('\\\\s'))",
+ String([whitespace[i]]), String(s.match(new RegExp('\\s'))));
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(/\s/)",
+ String([whitespace[i]]), String(s.match(/\s/)));
+ }
+ // be sure all non_whitespace characters match individually
+ for (i = 0; i < non_whitespace.length; ++i)
+ {
+ s = ' ' + non_whitespace[i] + ' ';
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(new RegExp('\\\\S'))",
+ String([non_whitespace[i]]), String(s.match(new RegExp('\\S'))));
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(/\S/)",
+ String([non_whitespace[i]]), String(s.match(/\S/)));
+ }
+
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/regexp/word_boundary.js b/js/tests/js1_2/regexp/word_boundary.js
new file mode 100644
index 00000000000..26b589dc712
--- /dev/null
+++ b/js/tests/js1_2/regexp/word_boundary.js
@@ -0,0 +1,116 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: word_boundary.js
+ Description: 'Tests regular expressions containing \b and \B'
+
+ Author: Nick Lerissa
+ Date: March 10, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'RegExp: \\b and \\B';
+
+ writeHeaderToLog('Executing script: word_boundary.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // 'cowboy boyish boy'.match(new RegExp('\bboy\b'))
+ testcases[count++] = new TestCase ( SECTION, "'cowboy boyish boy'.match(new RegExp('\\bboy\\b'))",
+ String(["boy"]), String('cowboy boyish boy'.match(new RegExp('\\bboy\\b'))));
+
+ var boundary_characters = "\f\n\r\t\v~`!@#$%^&*()-+={[}]|\\:;'<,>./? " + '"';
+ var non_boundary_characters = '1234567890_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+ var s = '';
+ var i;
+
+ // testing whether all boundary characters are matched when they should be
+ for (i = 0; i < boundary_characters.length; ++i)
+ {
+ s = '123ab' + boundary_characters.charAt(i) + '123c' + boundary_characters.charAt(i);
+
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(new RegExp('\\b123[a-z]\\b'))",
+ String(["123c"]), String(s.match(new RegExp('\\b123[a-z]\\b'))));
+ }
+
+ // testing whether all non-boundary characters are matched when they should be
+ for (i = 0; i < non_boundary_characters.length; ++i)
+ {
+ s = '123ab' + non_boundary_characters.charAt(i) + '123c' + non_boundary_characters.charAt(i);
+
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(new RegExp('\\B123[a-z]\\B'))",
+ String(["123c"]), String(s.match(new RegExp('\\B123[a-z]\\B'))));
+ }
+
+ s = '';
+
+ // testing whether all boundary characters are not matched when they should not be
+ for (i = 0; i < boundary_characters.length; ++i)
+ {
+ s += boundary_characters[i] + "a" + i + "b";
+ }
+ s += "xa1111bx";
+
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(new RegExp('\\Ba\\d+b\\B'))",
+ String(["a1111b"]), String(s.match(new RegExp('\\Ba\\d+b\\B'))));
+
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(/\\Ba\\d+b\\B/)",
+ String(["a1111b"]), String(s.match(/\Ba\d+b\B/)));
+
+ s = '';
+
+ // testing whether all non-boundary characters are not matched when they should not be
+ for (i = 0; i < non_boundary_characters.length; ++i)
+ {
+ s += non_boundary_characters[i] + "a" + i + "b";
+ }
+ s += "(a1111b)";
+
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(new RegExp('\\ba\\d+b\\b'))",
+ String(["a1111b"]), String(s.match(new RegExp('\\ba\\d+b\\b'))));
+
+ testcases[count++] = new TestCase ( SECTION,
+ "'" + s + "'.match(/\\ba\\d+b\\b/)",
+ String(["a1111b"]), String(s.match(/\ba\d+b\b/)));
+
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/shell.js b/js/tests/js1_2/shell.js
new file mode 100644
index 00000000000..2a9edbac9e2
--- /dev/null
+++ b/js/tests/js1_2/shell.js
@@ -0,0 +1,162 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+var completed = false;
+var testcases;
+
+
+SECTION = "";
+VERSION = "";
+ startTest();
+BUGNUMBER = "";
+
+var GLOBAL = "[object global]";
+var PASSED = " PASSED!"
+var FAILED = " FAILED! expected: ";
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
+/* wrapper for test cas constructor that doesn't require the SECTION
+ * argument.
+ */
+
+function AddTestCase( description, expect, actual ) {
+ testcases[tc++] = new TestCase( SECTION, description, expect, actual );
+}
+
+
+function TestCase( n, d, e, a ) {
+ this.name = n;
+ this.description = d;
+ this.expect = e;
+ this.actual = a;
+ this.passed = true;
+ this.reason = "";
+
+ this.passed = getTestCaseResult( this.expect, this.actual );
+}
+/*
+ // JavaScript 1.3 is supposed to be compliant ecma version 1.0
+ if ( VERSION == "ECMA_1" ) {
+ startTest();
+ version ( "130" );
+ }
+ if ( VERSION == "JS_1.3" ) {
+ startTest();
+ version ( "130" );
+ }
+ if ( VERSION == "JS_1.2" ) {
+ startTest();
+ version ( "120" );
+ }
+ if ( VERSION == "JS_1.1" ) {
+ startTest();
+ version ( "110" );
+ }
+ // for ecma version 2.0, we will leave the javascript version to
+ // the default ( for now ).
+*/
+
+ if ( BUGNUMBER ) {
+ writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
+ }
+
+ testcases = new Array();
+ tc = 0;
+
+}
+function getTestCaseResult( expect, actual ) {
+ // because ( NaN == NaN ) always returns false, need to do
+ // a special compare to see if we got the right result.
+ if ( actual != actual ) {
+ if ( typeof actual == "object" ) {
+ actual = "NaN object";
+ } else {
+ actual = "NaN number";
+ }
+ }
+ if ( expect != expect ) {
+ if ( typeof expect == "object" ) {
+ expect = "NaN object";
+ } else {
+ expect = "NaN number";
+ }
+ }
+
+ var passed = ( expect == actual ) ? true : false;
+
+ // if both objects are numbers, give a little leeway for rounding.
+ if ( !passed
+ && typeof(actual) == "number"
+ && typeof(expect) == "number"
+ ) {
+ if ( Math.abs(actual-expect) < 0.0000001 ) {
+ passed = true;
+ }
+ }
+
+ // verify type is the same
+ if ( typeof(expect) != typeof(actual) ) {
+ passed = false;
+ }
+
+ return passed;
+}
+/*
+ * Begin printing functions. These functions use the shell's
+ * print function. When running tests in the browser, these
+ * functions, override these functions with functions that use
+ * document.write.
+ */
+
+function writeTestCaseResult( expect, actual, string ) {
+ var passed = getTestCaseResult( expect, actual );
+ writeFormattedResult( expect, actual, string, passed );
+ return passed;
+}
+function writeFormattedResult( expect, actual, string, passed ) {
+ var s = string ;
+ s += ( passed ) ? PASSED : FAILED + expect;
+ writeLineToLog( s);
+ return passed;
+}
+function writeLineToLog( string ) {
+ print( string );
+}
+function writeHeaderToLog( string ) {
+ print( string );
+}
+/* end of print functions */
+
+function stopTest() {
+ var gc;
+ if ( gc != undefined ) {
+ gc();
+ }
+}
diff --git a/js/tests/js1_2/statements/break.js b/js/tests/js1_2/statements/break.js
new file mode 100644
index 00000000000..ad724e9b979
--- /dev/null
+++ b/js/tests/js1_2/statements/break.js
@@ -0,0 +1,159 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: break.js
+ Description: 'Tests the break statement'
+
+ Author: Nick Lerissa
+ Date: March 18, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'statements: break';
+
+ writeHeaderToLog("Executing script: break.js");
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ var i,j;
+
+ for (i = 0; i < 1000; i++)
+ {
+ if (i == 100) break;
+ }
+
+ // 'breaking out of "for" loop'
+ testcases[count++] = new TestCase ( SECTION, 'breaking out of "for" loop',
+ 100, i);
+
+ j = 2000;
+
+ out1:
+ for (i = 0; i < 1000; i++)
+ {
+ if (i == 100)
+ {
+ out2:
+ for (j = 0; j < 1000; j++)
+ {
+ if (j == 500) break out1;
+ }
+ j = 2001;
+ }
+ j = 2002;
+ }
+
+ // 'breaking out of a "for" loop with a "label"'
+ testcases[count++] = new TestCase ( SECTION, 'breaking out of a "for" loop with a "label"',
+ 500, j);
+
+ i = 0;
+
+ while (i < 1000)
+ {
+ if (i == 100) break;
+ i++;
+ }
+
+ // 'breaking out of a "while" loop'
+ testcases[count++] = new TestCase ( SECTION, 'breaking out of a "while" loop',
+ 100, i );
+
+
+ j = 2000;
+ i = 0;
+
+ out3:
+ while (i < 1000)
+ {
+ if (i == 100)
+ {
+ j = 0;
+ out4:
+ while (j < 1000)
+ {
+ if (j == 500) break out3;
+ j++;
+ }
+ j = 2001;
+ }
+ j = 2002;
+ i++;
+ }
+
+ // 'breaking out of a "while" loop with a "label"'
+ testcases[count++] = new TestCase ( SECTION, 'breaking out of a "while" loop with a "label"',
+ 500, j);
+
+ i = 0;
+
+ do
+ {
+ if (i == 100) break;
+ i++;
+ } while (i < 1000);
+
+ // 'breaking out of a "do" loop'
+ testcases[count++] = new TestCase ( SECTION, 'breaking out of a "do" loop',
+ 100, i );
+
+ j = 2000;
+ i = 0;
+
+ out5:
+ do
+ {
+ if (i == 100)
+ {
+ j = 0;
+ out6:
+ do
+ {
+ if (j == 500) break out5;
+ j++;
+ }while (j < 1000);
+ j = 2001;
+ }
+ j = 2002;
+ i++;
+ }while (i < 1000);
+
+ // 'breaking out of a "do" loop with a "label"'
+ testcases[count++] = new TestCase ( SECTION, 'breaking out of a "do" loop with a "label"',
+ 500, j);
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/statements/continue.js b/js/tests/js1_2/statements/continue.js
new file mode 100644
index 00000000000..96aa6e5530a
--- /dev/null
+++ b/js/tests/js1_2/statements/continue.js
@@ -0,0 +1,172 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: continue.js
+ Description: 'Tests the continue statement'
+
+ Author: Nick Lerissa
+ Date: March 18, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'statements: continue';
+
+ writeHeaderToLog("Executing script: continue.js");
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ var i,j;
+
+ j = 0;
+ for (i = 0; i < 200; i++)
+ {
+ if (i == 100)
+ continue;
+ j++;
+ }
+
+ // '"continue" in a "for" loop'
+ testcases[count++] = new TestCase ( SECTION, '"continue" in "for" loop',
+ 199, j);
+
+
+ j = 0;
+ out1:
+ for (i = 0; i < 1000; i++)
+ {
+ if (i == 100)
+ {
+ out2:
+ for (var k = 0; k < 1000; k++)
+ {
+ if (k == 500) continue out1;
+ }
+ j = 3000;
+ }
+ j++;
+ }
+
+ // '"continue" in a "for" loop with a "label"'
+ testcases[count++] = new TestCase ( SECTION, '"continue" in "for" loop with a "label"',
+ 999, j);
+
+ i = 0;
+ j = 1;
+
+ while (i != j)
+ {
+ i++;
+ if (i == 100) continue;
+ j++;
+ }
+
+ // '"continue" in a "while" loop'
+ testcases[count++] = new TestCase ( SECTION, '"continue" in a "while" loop',
+ 100, j );
+
+ j = 0;
+ i = 0;
+ out3:
+ while (i < 1000)
+ {
+ if (i == 100)
+ {
+ var k = 0;
+ out4:
+ while (k < 1000)
+ {
+ if (k == 500)
+ {
+ i++;
+ continue out3;
+ }
+ k++;
+ }
+ j = 3000;
+ }
+ j++;
+ i++;
+ }
+
+ // '"continue" in a "while" loop with a "label"'
+ testcases[count++] = new TestCase ( SECTION, '"continue" in a "while" loop with a "label"',
+ 999, j);
+
+ i = 0;
+ j = 1;
+
+ do
+ {
+ i++;
+ if (i == 100) continue;
+ j++;
+ } while (i != j);
+
+
+ // '"continue" in a "do" loop'
+ testcases[count++] = new TestCase ( SECTION, '"continue" in a "do" loop',
+ 100, j );
+
+ j = 0;
+ i = 0;
+ out5:
+ do
+ {
+ if (i == 100)
+ {
+ var k = 0;
+ out6:
+ do
+ {
+ if (k == 500)
+ {
+ i++;
+ continue out5;
+ }
+ k++;
+ }while (k < 1000);
+ j = 3000;
+ }
+ j++;
+ i++;
+ }while (i < 1000);
+
+ // '"continue" in a "do" loop with a "label"'
+ testcases[count++] = new TestCase ( SECTION, '"continue" in a "do" loop with a "label"',
+ 999, j);
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/statements/do_while.js b/js/tests/js1_2/statements/do_while.js
new file mode 100644
index 00000000000..f2e5c61fd7a
--- /dev/null
+++ b/js/tests/js1_2/statements/do_while.js
@@ -0,0 +1,65 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: do_while.js
+ Description: 'This tests the new do_while loop'
+
+ Author: Nick Lerissa
+ Date: Fri Feb 13 09:58:28 PST 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'statements: do_while';
+
+ writeHeaderToLog('Executing script: do_while.js');
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+
+ var done = false;
+ var x = 0;
+ do
+ {
+ if (x++ == 3) done = true;
+ } while (!done);
+
+ testcases[count++] = new TestCase( SECTION, "do_while ",
+ 4, x);
+
+ //load('d:/javascript/tests/output/statements/do_while.js')
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
+
diff --git a/js/tests/js1_2/statements/switch.js b/js/tests/js1_2/statements/switch.js
new file mode 100644
index 00000000000..8ff04294f50
--- /dev/null
+++ b/js/tests/js1_2/statements/switch.js
@@ -0,0 +1,124 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: switch.js
+ Description: 'Tests the switch statement'
+
+ http://scopus.mcom.com/bugsplat/show_bug.cgi?id=323696
+
+ Author: Nick Lerissa
+ Date: March 19, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'statements: switch';
+ var BUGNUMBER="323696";
+
+ writeHeaderToLog("Executing script: switch.js");
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ var var1 = "match string";
+ var match1 = false;
+ var match2 = false;
+ var match3 = false;
+
+ switch (var1)
+ {
+ case "match string":
+ match1 = true;
+ case "bad string 1":
+ match2 = true;
+ break;
+ case "bad string 2":
+ match3 = true;
+ }
+
+ testcases[count++] = new TestCase ( SECTION, 'switch statement',
+ true, match1);
+
+ testcases[count++] = new TestCase ( SECTION, 'switch statement',
+ true, match2);
+
+ testcases[count++] = new TestCase ( SECTION, 'switch statement',
+ false, match3);
+
+ var var2 = 3;
+
+ var match1 = false;
+ var match2 = false;
+ var match3 = false;
+ var match4 = false;
+ var match5 = false;
+
+ switch (var2)
+ {
+ case 1:
+/* switch (var1)
+ {
+ case "foo":
+ match1 = true;
+ break;
+ case 3:
+ match2 = true;
+ break;
+ }*/
+ match3 = true;
+ break;
+ case 2:
+ match4 = true;
+ break;
+ case 3:
+ match5 = true;
+ break;
+ }
+ testcases[count++] = new TestCase ( SECTION, 'switch statement',
+ false, match1);
+
+ testcases[count++] = new TestCase ( SECTION, 'switch statement',
+ false, match2);
+
+ testcases[count++] = new TestCase ( SECTION, 'switch statement',
+ false, match3);
+
+ testcases[count++] = new TestCase ( SECTION, 'switch statement',
+ false, match4);
+
+ testcases[count++] = new TestCase ( SECTION, 'switch statement',
+ true, match5);
+
+ function test()
+ {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
+
+ test();
diff --git a/js/tests/js1_2/statements/switch2.js b/js/tests/js1_2/statements/switch2.js
new file mode 100644
index 00000000000..159222b14a2
--- /dev/null
+++ b/js/tests/js1_2/statements/switch2.js
@@ -0,0 +1,185 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Filename: switch2.js
+ Description: 'Tests the switch statement'
+
+ http://scopus.mcom.com/bugsplat/show_bug.cgi?id=323696
+
+ Author: Norris Boyd
+ Date: July 31, 1998
+*/
+
+ var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
+ var VERSION = 'no version';
+ startTest();
+ var TITLE = 'statements: switch';
+ var BUGNUMBER="323626";
+
+ writeHeaderToLog("Executing script: switch2.js");
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var count = 0;
+ var testcases = new Array();
+
+ // test defaults not at the end; regression test for a bug that
+ // nearly made it into 4.06
+ function f0(i) {
+ switch(i) {
+ default:
+ case "a":
+ case "b":
+ return "ab*"
+ case "c":
+ return "c";
+ case "d":
+ return "d";
+ }
+ return "";
+ }
+ testcases[count++] = new TestCase(SECTION, 'switch statement',
+ f0("a"), "ab*");
+
+ testcases[count++] = new TestCase(SECTION, 'switch statement',
+ f0("b"), "ab*");
+
+ testcases[count++] = new TestCase(SECTION, 'switch statement',
+ f0("*"), "ab*");
+
+ testcases[count++] = new TestCase(SECTION, 'switch statement',
+ f0("c"), "c");
+
+ testcases[count++] = new TestCase(SECTION, 'switch statement',
+ f0("d"), "d");
+
+ function f1(i) {
+ switch(i) {
+ case "a":
+ case "b":
+ default:
+ return "ab*"
+ case "c":
+ return "c";
+ case "d":
+ return "d";
+ }
+ return "";
+ }
+
+ testcases[count++] = new TestCase(SECTION, 'switch statement',
+ f1("a"), "ab*");
+
+ testcases[count++] = new TestCase(SECTION, 'switch statement',
+ f1("b"), "ab*");
+
+ testcases[count++] = new TestCase(SECTION, 'switch statement',
+ f1("*"), "ab*");
+
+ testcases[count++] = new TestCase(SECTION, 'switch statement',
+ f1("c"), "c");
+
+ testcases[count++] = new TestCase(SECTION, 'switch statement',
+ f1("d"), "d");
+
+ // Switch on integer; will use TABLESWITCH opcode in C engine
+ function f2(i) {
+ switch (i) {
+ case 0:
+ case 1:
+ return 1;
+ case 2:
+ return 2;
+ }
+ // with no default, control will fall through
+ return 3;
+ }
+
+ testcases[count++] = new TestCase(SECTION, 'switch statement',
+ f2(0), 1);
+
+ testcases[count++] = new TestCase(SECTION, 'switch statement',
+ f2(1), 1);
+
+ testcases[count++] = new TestCase(SECTION, 'switch statement',
+ f2(2), 2);
+
+ testcases[count++] = new TestCase(SECTION, 'switch statement',
+ f2(3), 3);
+
+ // empty switch: make sure expression is evaluated
+ var se = 0;
+ switch (se = 1) {
+ }
+ testcases[count++] = new TestCase(SECTION, 'switch statement',
+ se, 1);
+
+ // only default
+ se = 0;
+ switch (se) {
+ default:
+ se = 1;
+ }
+ testcases[count++] = new TestCase(SECTION, 'switch statement',
+ se, 1);
+
+ // in loop, break should only break out of switch
+ se = 0;
+ for (var i=0; i < 2; i++) {
+ switch (i) {
+ case 0:
+ case 1:
+ break;
+ }
+ se = 1;
+ }
+ testcases[count++] = new TestCase(SECTION, 'switch statement',
+ se, 1);
+
+ // test "fall through"
+ se = 0;
+ i = 0;
+ switch (i) {
+ case 0:
+ se++;
+ /* fall through */
+ case 1:
+ se++;
+ break;
+ }
+ testcases[count++] = new TestCase(SECTION, 'switch statement',
+ se, 2);
+
+ test();
+
+ // Needed: tests for evaluation time of case expressions.
+ // This issue was under debate at ECMA, so postponing for now.
+
+ function test() {
+ writeLineToLog("hi");
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+ }
diff --git a/js/tests/lc2/Arrays/array-001.js b/js/tests/lc2/Arrays/array-001.js
new file mode 100644
index 00000000000..25c152db93d
--- /dev/null
+++ b/js/tests/lc2/Arrays/array-001.js
@@ -0,0 +1,156 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+ /**
+ File Name: array-001.js
+ Description:
+
+ When accessing a Java field whose value is a java.lang.Array,
+ or if a java method returns a java.lang.Array, JavaScript should
+ read the value as the JavaScript JavaArray, an object whose class
+ is JavaArray.
+
+ To test this:
+
+ 1. Call a java method that returns a java.lang.Array
+ 2. Check the value of the returned object, which should be the value
+ of the array. Iterate through the array indices.
+ 3. Check the type of the returned object, which should be "object"
+ 4. Check the class of the object, using Object.prototype.toString,
+ which should be "[object JavaArray]"
+ 5. Check the class of the JavaArray, using getClass, and compare
+ it to java.lang.Class.forName("java.lang.Array");
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "Java Array to JavaScript JavaArray object";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // In all test cases, the expected type is "object, and the expected
+ // class is "Number"
+
+ var E_TYPE = "object";
+ var E_CLASS = "[object JavaArray]";
+ var test_array = new Array();
+
+ // Create arrays of actual results (java_array) and expected results
+ // (test_array).
+
+ var java_array = new Array();
+
+ var i = 0;
+
+ // byte[]
+
+ var byte_array = ( new java.lang.String("hello") ).getBytes();
+
+ java_array[i] = new JavaValue( byte_array );
+ test_array[i] = new TestValue( "( new java.lang.String('hello') ).getBytes()",
+ ["h".charCodeAt(0),
+ "e".charCodeAt(0),
+ "l".charCodeAt(0),
+ "l".charCodeAt(0),
+ "o".charCodeAt(0) ],
+ "[B"
+ );
+ i++;
+
+ // char[]
+ var char_array = ( new java.lang.String("rhino") ).toCharArray();
+
+ java_array[i] = new JavaValue( char_array );
+ test_array[i] = new TestValue( "( new java.lang.String('rhino') ).toCharArray()",
+ [ "r".charCodeAt(0),
+ "h".charCodeAt(0),
+ "i".charCodeAt(0),
+ "n".charCodeAt(0),
+ "o".charCodeAt(0)],
+ "[C");
+ i++;
+
+
+ for ( i = 0; i < java_array.length; i++ ) {
+ CompareValues( java_array[i], test_array[i] );
+ }
+
+ test();
+
+function CompareValues( javaval, testval ) {
+ // Check value
+
+ for ( var i = 0; i < testval.value.length; i++ ) {
+ testcases[testcases.length] = new TestCase( SECTION,
+ "("+ testval.description +")["+i+"]",
+ testval.value[i],
+ javaval.value[i] );
+ }
+
+ // Check type
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +")",
+ testval.type,
+ javaval.type );
+
+
+ // Check class
+ testcases[testcases.length ] = new TestCase( SECTION,
+ "The Java Class of ( "+ testval.description +" )",
+ testval.lcclass +"",
+ javaval.lcclass +"");
+
+}
+function JavaValue( value ) {
+ this.value = value;
+ this.type = typeof value;
+ this.classname = this.value.getClass();
+
+ jlo_class = java.lang.Class.forName("java.lang.Object")
+ jlo_getClass_method = jlo_class.getMethod("getClass", null)
+ this.lcclass = jlo_getClass_method.invoke(value, null );
+
+ return this;
+}
+function TestValue( description, value, lcclass ) {
+ this.lcclass = java.lang.Class.forName( lcclass );
+ this.description = description;
+ this.value = value;
+ this.type = E_TYPE;
+ this.classname = E_CLASS;
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Arrays/array-002.js b/js/tests/lc2/Arrays/array-002.js
new file mode 100644
index 00000000000..677073f8526
--- /dev/null
+++ b/js/tests/lc2/Arrays/array-002.js
@@ -0,0 +1,115 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+ /**
+ File Name: array-002.js
+ Description:
+
+ JavaArrays should have a length property that specifies the number of
+ elements in the array.
+
+ JavaArray elements can be referenced with the [] array index operator.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "Java Array to JavaScript JavaArray object";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // In all test cases, the expected type is "object, and the expected
+ // class is "JavaArray"
+
+ var E_TYPE = "object";
+ var E_CLASS = "[object JavaArray]";
+
+ // Create arrays of actual results (java_array) and expected results
+ // (test_array).
+
+ var java_array = new Array();
+ var test_array = new Array();
+
+ var i = 0;
+
+ // byte[]
+
+ var byte_array = ( new java.lang.String("ABCDEFGHIJKLMNOPQRSTUVWXYZ") ).getBytes();
+
+ java_array[i] = new JavaValue( byte_array );
+ test_array[i] = new TestValue( "( new java.lang.String('ABCDEFGHIJKLMNOPQRSTUVWXYZ') ).getBytes()",
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ".length
+ );
+ i++;
+
+
+ // char[]
+ var char_array = ( new java.lang.String("rhino") ).toCharArray();
+
+ java_array[i] = new JavaValue( char_array );
+ test_array[i] = new TestValue( "( new java.lang.String('rhino') ).toCharArray()",
+ "rhino".length );
+ i++;
+
+
+ for ( i = 0; i < java_array.length; i++ ) {
+ CompareValues( java_array[i], test_array[i] );
+ }
+
+ test();
+
+function CompareValues( javaval, testval ) {
+ // Check length
+ testcases[testcases.length] = new TestCase( SECTION,
+ "("+ testval.description +").length",
+ testval.value,
+ javaval.length );
+}
+function JavaValue( value ) {
+ this.value = value;
+ this.length = value.length;
+ this.type = typeof value;
+ this.classname = this.value.toString();
+
+ return this;
+}
+function TestValue( description, value ) {
+ this.description = description;
+ this.length = value
+ this.value = value;
+ this.type = E_TYPE;
+ this.classname = E_CLASS;
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Arrays/array-003.js b/js/tests/lc2/Arrays/array-003.js
new file mode 100644
index 00000000000..3a634f8809d
--- /dev/null
+++ b/js/tests/lc2/Arrays/array-003.js
@@ -0,0 +1,156 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+ /**
+ File Name: array-003.js
+ Description:
+
+ JavaArray elements should be enumerable using a for/in loop.
+
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "Java Array to JavaScript JavaArray object";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // In all test cases, the expected type is "object, and the expected
+ // class is "Number"
+
+ var E_TYPE = "object";
+ var E_CLASS = "[object JavaArray]";
+
+ // Create arrays of actual results (java_array) and expected results
+ // (test_array).
+
+ var java_array = new Array();
+ var test_array = new Array();
+
+ var i = 0;
+
+ // byte[]
+
+ var byte_array = ( new java.lang.String("hello") ).getBytes();
+
+ java_array[i] = new JavaValue( byte_array );
+ test_array[i] = new TestValue( "( new java.lang.String('hello') ).getBytes()",
+ ["h".charCodeAt(0),
+ "e".charCodeAt(0),
+ "l".charCodeAt(0),
+ "l".charCodeAt(0),
+ "o".charCodeAt(0) ],
+ "[B"
+ );
+ i++;
+
+
+ // char[]
+ var char_array = ( new java.lang.String("rhino") ).toCharArray();
+
+ java_array[i] = new JavaValue( char_array );
+ test_array[i] = new TestValue( "( new java.lang.String('rhino') ).toCharArray()",
+ [ "r".charCodeAt(0),
+ "h".charCodeAt(0),
+ "i".charCodeAt(0),
+ "n".charCodeAt(0),
+ "o".charCodeAt(0) ],
+ "[C" );
+ i++;
+
+ for ( i = 0; i < java_array.length; i++ ) {
+ CompareValues( java_array[i], test_array[i] );
+ }
+
+ test();
+
+function CompareValues( javaval, testval ) {
+ // Check value
+
+ var p;
+ var e = 0;
+
+ for ( p in javaval.value ) {
+ testcases[testcases.length] = new TestCase( SECTION,
+ "("+ testval.description +")["+p+"]",
+ testval.value[p],
+ javaval.value[p] );
+ e++;
+
+ }
+
+ /* Number of elements enumerated should be same as number of elements in
+ * the array
+ */
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "number of elements enumerated:",
+ testval.length,
+ e );
+
+
+ // Check type
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +")",
+ testval.type,
+ javaval.type );
+
+ // Check class.
+ testcases[testcases.length ] = new TestCase( SECTION,
+ "The Java Class of ( "+ testval.description +" )",
+ testval.lcclass,
+ javaval.lcclass );
+
+}
+function JavaValue( value ) {
+ this.value = value;
+ this.type = typeof value;
+ this.classname = this.value.toString();
+
+ jlo_class = java.lang.Class.forName("java.lang.Object")
+ jlo_getClass_method = jlo_class.getMethod("getClass", null)
+ this.lcclass = jlo_getClass_method.invoke(value, null );
+
+ return this;
+}
+function TestValue( description, value, lcclass ) {
+ this.lcclass = java.lang.Class.forName( lcclass );
+ this.description = description;
+ this.length = value.length;
+ this.value = value;
+ this.type = E_TYPE;
+ this.classname = E_CLASS;
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Arrays/array-004.js b/js/tests/lc2/Arrays/array-004.js
new file mode 100644
index 00000000000..dbce13396d8
--- /dev/null
+++ b/js/tests/lc2/Arrays/array-004.js
@@ -0,0 +1,127 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+ /**
+ File Name: array-004.js
+ Description:
+
+ Access array indices that are out of bounds.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "Java Array to JavaScript JavaArray object";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // In all test cases, the expected type is "object, and the expected
+ // class is "JavaArray"
+
+ var E_TYPE = "object";
+ var E_CLASS = "[object JavaArray]";
+
+ // Create arrays of actual results (java_array) and expected results
+ // (test_array).
+
+ var java_array = new Array();
+ var test_array = new Array();
+
+ var i = 0;
+
+ // byte[]
+
+ var byte_array = ( new java.lang.String("ABCDEFGHIJKLMNOPQRSTUVWXYZ") ).getBytes();
+
+ java_array[i] = new JavaValue( byte_array );
+ test_array[i] = new TestValue( "( new java.lang.String('ABCDEFGHIJKLMNOPQRSTUVWXYZ') ).getBytes()",
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ".length
+ );
+ i++;
+
+
+ // char[]
+ var char_array = ( new java.lang.String("rhino") ).toCharArray();
+
+ java_array[i] = new JavaValue( char_array );
+ test_array[i] = new TestValue( "( new java.lang.String('rhino') ).toCharArray()",
+ "rhino".length );
+ i++;
+
+
+ for ( i = 0; i < java_array.length; i++ ) {
+ CompareValues( java_array[i], test_array[i] );
+ }
+
+ test();
+
+function CompareValues( javaval, testval ) {
+ // Check length
+ testcases[testcases.length] = new TestCase( SECTION,
+ "("+ testval.description +").length",
+ testval.value,
+ javaval.length );
+ // access element [-1]
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "("+testval.description+")[-1]",
+ void 0,
+ javaval[-1] );
+
+ // access element [length]
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "("+testval.description+")["+testval.value+"]",
+ void 0,
+ javaval[testval.value] );
+
+
+}
+function JavaValue( value ) {
+ this.value = value;
+ this.length = value.length;
+ this.type = typeof value;
+ this.classname = this.value.toString();
+
+ return this;
+}
+function TestValue( description, value ) {
+ this.description = description;
+ this.length = value
+ this.value = value;
+ this.type = E_TYPE;
+ this.classname = E_CLASS;
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Arrays/array-005.js b/js/tests/lc2/Arrays/array-005.js
new file mode 100644
index 00000000000..904c1b56c83
--- /dev/null
+++ b/js/tests/lc2/Arrays/array-005.js
@@ -0,0 +1,119 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+ /**
+ File Name: array-005.js
+ Description:
+
+ Put and Get JavaArray Elements
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "Java Array to JavaScript JavaArray object";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // In all test cases, the expected type is "object, and the expected
+ // class is "JavaArray"
+
+ var E_TYPE = "object";
+ var E_CLASS = "[object JavaArray]";
+
+ var byte_array = ( new java.lang.String("hi") ).getBytes();
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "byte_array = new java.lang.String(\"hi\")).getBytes(); delete byte_array.length",
+ false,
+ delete byte_array.length );
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "byte_array[0]",
+ ("hi").charCodeAt(0),
+ byte_array[0]);
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "byte_array[1]",
+ ("hi").charCodeAt(1),
+ byte_array[1]);
+
+ byte_array.length = 0;
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "byte_array.length = 0; byte_array.length",
+ 2,
+ byte_array.length );
+
+ var properties = "";
+ for ( var p in byte_array ) {
+ properties += ( p == "length" ) ? p : "";
+ }
+
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "for ( var p in byte_array ) { properties += p ==\"length\" ? p : \"\" }; properties",
+ "",
+ properties );
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "byte_array[\"length\"]",
+ 2,
+ byte_array["length"] );
+
+ byte_array["0"] = 127;
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "byte_array[\"0\"] = 127; byte_array[0]",
+ 127,
+ byte_array[0] );
+
+ byte_array[1] = 99;
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "byte_array[1] = 99; byte_array[\"1\"]",
+ 99,
+ byte_array["1"] );
+
+ test();
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Arrays/array-006-n.js b/js/tests/lc2/Arrays/array-006-n.js
new file mode 100644
index 00000000000..ecebc967555
--- /dev/null
+++ b/js/tests/lc2/Arrays/array-006-n.js
@@ -0,0 +1,65 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+ /**
+ File Name: array-005.js
+ Description:
+
+ Put and Get JavaArray Elements
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "Java Array to JavaScript JavaArray object";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // In all test cases, the expected type is "object, and the expected
+ // class is "JavaArray"
+
+ var E_TYPE = "object";
+ var E_CLASS = "[object JavaArray]";
+
+ var byte_array = ( new java.lang.String("hi") ).getBytes();
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "byte_array[\"foo\"]",
+ void 0,
+ byte_array["foo"] );
+
+ test();
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Arrays/array-007-n.js b/js/tests/lc2/Arrays/array-007-n.js
new file mode 100644
index 00000000000..357e7f6168f
--- /dev/null
+++ b/js/tests/lc2/Arrays/array-007-n.js
@@ -0,0 +1,69 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+ /**
+ File Name: array-005.js
+ Description:
+
+ Put and Get JavaArray Elements
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "Java Array to JavaScript JavaArray object";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // In all test cases, the expected type is "object, and the expected
+ // class is "JavaArray"
+
+ var E_TYPE = "object";
+ var E_CLASS = "[object JavaArray]";
+
+ var byte_array = ( new java.lang.String("hi") ).getBytes();
+
+ byte_array.name = "name";
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "byte_array.name = \"name\"; byte_array.name",
+ void 0,
+ byte_array.name );
+
+ byte_array["0"] = 127;
+
+ test();
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Arrays/array-008-n.js b/js/tests/lc2/Arrays/array-008-n.js
new file mode 100644
index 00000000000..c94e884fa19
--- /dev/null
+++ b/js/tests/lc2/Arrays/array-008-n.js
@@ -0,0 +1,66 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+ /**
+ File Name: array-008-n.js
+ Description:
+
+ JavaArrays should have a length property that specifies the number of
+ elements in the array.
+
+ JavaArray elements can be referenced with the [] array index operator.
+
+ This attempts to access an array index that is out of bounds. It should
+ fail with a JS runtime error.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "Java Array to JavaScript JavaArray object";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ dt = new Packages.com.netscape.javascript.qa.liveconnect.DataTypeClass;
+
+ var ba_length = dt.PUB_ARRAY_BYTE.length;
+
+ testcases[tc++] = new TestCase(
+ SECTION,
+ "dt.PUB_ARRAY_BYTE.length = "+ ba_length,
+ "error",
+ dt.PUB_ARRAY_BYTE[ba_length] );
+
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Classes/class-001.js b/js/tests/lc2/Classes/class-001.js
new file mode 100644
index 00000000000..8abdafedc8e
--- /dev/null
+++ b/js/tests/lc2/Classes/class-001.js
@@ -0,0 +1,151 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: class-001.js
+ Description:
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect Classes";
+ var VERSION = "1_3";
+ var TITLE = "JavaClass objects";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // All packages are of the type "function", since they implement [[Construct]]
+ // and [[Call]]
+
+ var E_TYPE = "function";
+
+ // The JavaScript [[Class]] property for all Classes is "[object JavaClass]"
+ var E_JSCLASS = "[object JavaClass]";
+
+ // Create arrays of actual results (java_array) and
+ // expected results (test_array).
+
+ var java_array = new Array();
+ var test_array = new Array();
+
+ var i = 0;
+
+ java_array[i] = new JavaValue( java.awt.Image );
+ test_array[i] = new TestValue( "java.awt.Image" );
+ i++;
+
+ java_array[i] = new JavaValue( java.beans.Beans );
+ test_array[i] = new TestValue( "java.beans.Beans" );
+ i++;
+
+ java_array[i] = new JavaValue( java.io.File );
+ test_array[i] = new TestValue( "java.io.File" );
+ i++;
+
+ java_array[i] = new JavaValue( java.lang.String );
+ test_array[i] = new TestValue( "java.lang.String" );
+ i++;
+
+ java_array[i] = new JavaValue( java.math.BigDecimal );
+ test_array[i] = new TestValue( "java.math.BigDecimal" );
+ i++;
+
+ java_array[i] = new JavaValue( java.net.URL );
+ test_array[i] = new TestValue( "java.net.URL" );
+ i++;
+
+ java_array[i] = new JavaValue( java.rmi.RMISecurityManager );
+ test_array[i] = new TestValue( "java.rmi.RMISecurityManager" );
+ i++;
+
+ java_array[i] = new JavaValue( java.text.DateFormat );
+ test_array[i] = new TestValue( "java.text.DateFormat" );
+ i++;
+
+ java_array[i] = new JavaValue( java.util.Vector );
+ test_array[i] = new TestValue( "java.util.Vector" );
+ i++;
+/*
+ java_array[i] = new JavaValue( Packages.com.netscape.javascript.Context );
+ test_array[i] = new TestValue( "Packages.com.netscape.javascript.Context" );
+ i++;
+*/
+ for ( i = 0; i < java_array.length; i++ ) {
+ CompareValues( java_array[i], test_array[i] );
+ }
+
+ test();
+function CompareValues( javaval, testval ) {
+ // Check type, which should be E_TYPE
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +")",
+ testval.type,
+ javaval.type );
+/*
+ // Check JavaScript class, which should be E_JSCLASS
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +".)getJSClass()",
+ testval.jsclass,
+ javaval.jsclass );
+*/
+ // Check the class's name, which should be the description, minus the "Package." part.
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +") +''",
+ testval.classname,
+ javaval.classname );
+}
+function JavaValue( value ) {
+ // Object.prototype.toString will show its JavaScript wrapper object.
+// value.__proto__.getJSClass = Object.prototype.toString;
+// this.jsclass = value.getJSClass();
+
+ this.classname = value +"";
+ this.type = typeof value;
+ return this;
+}
+function TestValue( description, value ) {
+ this.description = description;
+ this.type = E_TYPE;
+ this.jclass = E_JSCLASS;
+ this.lcclass = java.lang.Class.forName( description );
+
+ this.classname = "[JavaClass " +
+ ( ( description.substring(0,9) == "Packages." )
+ ? description.substring(9,description.length)
+ : description
+ ) + "]"
+
+
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Classes/class-002.js b/js/tests/lc2/Classes/class-002.js
new file mode 100644
index 00000000000..f7c10a3dd8c
--- /dev/null
+++ b/js/tests/lc2/Classes/class-002.js
@@ -0,0 +1,152 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: class-001.js
+ Description:
+
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect Classes";
+ var VERSION = "1_3";
+ var TITLE = "JavaClass objects";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // All packages are of the type "function", since they implement [[Construct]]
+ // and [[Call]]
+
+ var E_TYPE = "function";
+
+ // The JavaScript [[Class]] property for all Classes is "[object JavaClass]"
+ var E_JSCLASS = "[object JavaClass]";
+
+ // Create arrays of actual results (java_array) and
+ // expected results (test_array).
+
+ var java_array = new Array();
+ var test_array = new Array();
+
+ var i = 0;
+
+ java_array[i] = new JavaValue( java.awt.Image );
+ test_array[i] = new TestValue( "java.awt.Image" );
+ i++;
+
+ java_array[i] = new JavaValue( java.beans.Beans );
+ test_array[i] = new TestValue( "java.beans.Beans" );
+ i++;
+
+ java_array[i] = new JavaValue( java.io.File );
+ test_array[i] = new TestValue( "java.io.File" );
+ i++;
+
+ java_array[i] = new JavaValue( java.lang.String );
+ test_array[i] = new TestValue( "java.lang.String" );
+ i++;
+
+ java_array[i] = new JavaValue( java.math.BigDecimal );
+ test_array[i] = new TestValue( "java.math.BigDecimal" );
+ i++;
+
+ java_array[i] = new JavaValue( java.net.URL );
+ test_array[i] = new TestValue( "java.net.URL" );
+ i++;
+
+ java_array[i] = new JavaValue( java.rmi.RMISecurityManager );
+ test_array[i] = new TestValue( "java.rmi.RMISecurityManager" );
+ i++;
+
+ java_array[i] = new JavaValue( java.text.DateFormat );
+ test_array[i] = new TestValue( "java.text.DateFormat" );
+ i++;
+
+ java_array[i] = new JavaValue( java.util.Vector );
+ test_array[i] = new TestValue( "java.util.Vector" );
+ i++;
+/*
+ works for rhino only
+ java_array[i] = new JavaValue( Packages.com.netscape.javascript.Context );
+ test_array[i] = new TestValue( "Packages.com.netscape.javascript.Context" );
+ i++;
+*/
+ for ( i = 0; i < java_array.length; i++ ) {
+ CompareValues( java_array[i], test_array[i] );
+ }
+
+ test();
+function CompareValues( javaval, testval ) {
+ // Check type, which should be E_TYPE
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +")",
+ testval.type,
+ javaval.type );
+/*
+ // Check JavaScript class, which should be E_JSCLASS
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +").getJSClass()",
+ testval.jsclass,
+ javaval.jsclass );
+*/
+ // Check the class's name, which should be the description, minus the "Package." part.
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +") +''",
+ testval.classname,
+ javaval.classname );
+}
+function JavaValue( value ) {
+// this suceeds in LC1, but fails in LC2
+// Object.prototype.toString will show its JavaScript wrapper object.
+// value.__proto__.getJSClass = Object.prototype.toString;
+// this.jsclass = value.getJSClass();
+ this.classname = value +"";
+ this.type = typeof value;
+ return this;
+}
+function TestValue( description, value ) {
+ this.description = description;
+ this.type = E_TYPE;
+ this.jsclass = E_JSCLASS;
+
+ this.classname = "[JavaClass " +
+ ( ( description.substring(0,9) == "Packages." )
+ ? description.substring(9,description.length)
+ : description
+ ) + "]"
+
+
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JSToJava/character-001.js b/js/tests/lc2/JSToJava/character-001.js
new file mode 100644
index 00000000000..a980be73a6b
--- /dev/null
+++ b/js/tests/lc2/JSToJava/character-001.js
@@ -0,0 +1,142 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Template for LiveConnect Tests
+
+ File Name: number-006.js
+ Description:
+
+ When setting the value of a Java field with a JavaScript number or
+ when passing a JavaScript number to a Java method as an argument,
+ LiveConnect should be able to convert the number to any one of the
+ following types:
+
+ byte
+ short
+ int
+ long
+ float
+ double
+ char
+ java.lang.Double
+
+ Note that the value of the Java field may not be as precise as the
+ JavaScript value's number, if for example, you pass a large number to
+ a short or byte, or a float to integer.
+
+ JavaScript numbers cannot be converted to instances of java.lang.Float
+ or java.lang.Integer.
+
+ This test does not cover the cases in which a Java method returns one
+ of the above primitive Java types.
+
+ Currently split up into numerous tests, since rhino live connect fails
+ to translate numbers into the correct types.
+
+ test for creating java.lang.Short objects.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // typeof all resulting objects is "object";
+ var E_TYPE = "object";
+
+ // JS class of all resulting objects is "JavaObject";
+ var E_JSCLASS = "[object JavaObject]";
+
+ var a = new Array();
+ var i = 0;
+
+ a[i++] = new TestObject( "new java.lang.Character(\"0.0\")",
+ new java.lang.Character("a"), "a".charCodeAt(0) );
+
+ a[i++] = new TestObject( "new java.lang.Character(\"0.\")",
+ new java.lang.Character("0"), "0".charCodeAt(0) );
+
+ a[i++] = new TestObject( "new java.lang.Character( 5 )",
+ new java.lang.Character(5), 5 );
+
+ a[i++] = new TestObject( "new java.lang.Character( 5.5 )",
+ new java.lang.Character(5.5), 5 );
+
+ a[i++] = new TestObject( "new java.lang.Character( Number(5) )",
+ new java.lang.Character(Number(5)), 5 );
+
+ a[i++] = new TestObject( "new java.lang.Character( Number(5.5) )",
+ new java.lang.Character(Number(5.5)), 5 );
+
+ for ( var i = 0; i < a.length; i++ ) {
+
+ // check typeof
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "typeof (" + a[i].description +")",
+ a[i].type,
+ typeof a[i].javavalue );
+/*
+ // check the js class
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "("+ a[i].description +").getJSClass()",
+ E_JSCLASS,
+ a[i].jsclass );
+*/
+ // check the number value of the object
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "Number(" + a[i].description +")",
+ a[i].jsvalue,
+ Number( a[i].javavalue.charValue() ) );
+ }
+
+ test();
+
+function TestObject( description, javavalue, jsvalue ) {
+// LC2 does not support the proto property of liveconnect object
+// this.javavalue.__proto__.getJSClass = Object.prototype.toString;
+// this.jsclass = this.javavalue.getJSClass();
+
+ this.description = description;
+ this.javavalue = javavalue;
+ this.jsvalue = jsvalue;
+ this.type = E_TYPE;
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JSToJava/double-001.js b/js/tests/lc2/JSToJava/double-001.js
new file mode 100644
index 00000000000..47eb7ffcad6
--- /dev/null
+++ b/js/tests/lc2/JSToJava/double-001.js
@@ -0,0 +1,142 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Template for LiveConnect Tests
+
+ File Name: number-002.js
+ Description:
+
+ When setting the value of a Java field with a JavaScript number or
+ when passing a JavaScript number to a Java method as an argument,
+ LiveConnect should be able to convert the number to any one of the
+ following types:
+
+ byte
+ short
+ int
+ long
+ float
+ double
+ char
+ java.lang.Double
+
+ Note that the value of the Java field may not be as precise as the
+ JavaScript value's number, if for example, you pass a large number to
+ a short or byte, or a float to integer.
+
+ JavaScript numbers cannot be converted to instances of java.lang.Float
+ or java.lang.Integer.
+
+ This test does not cover the cases in which a Java method returns one
+ of the above primitive Java types.
+
+ Currently split up into numerous tests, since rhino live connect fails
+ to translate numbers into the correct types.
+
+ test for creating java.lang.Double objects.
+
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "double-001";
+ var VERSION = "1_3";
+ var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // typeof all resulting objects is "object";
+ var E_TYPE = "object";
+
+ // JS class of all resulting objects is "JavaObject";
+ var E_JSCLASS = "[object JavaObject]";
+
+ var a = new Array();
+ var i = 0;
+
+ a[i++] = new TestObject( "new java.lang.Double(\"0.0\")",
+ new java.lang.Double("0.0"), 0 );
+
+ a[i++] = new TestObject( "new java.lang.Double(\"0.0\")",
+ new java.lang.Double("0"), 0 );
+
+ a[i++] = new TestObject( "new java.lang.Double( 5 )",
+ new java.lang.Double(5), 5 );
+
+ a[i++] = new TestObject( "new java.lang.Double( 5.5 )",
+ new java.lang.Double(5.5), 5.5 );
+
+ a[i++] = new TestObject( "new java.lang.Double( Number(5) )",
+ new java.lang.Double(Number(5)), 5 );
+
+ a[i++] = new TestObject( "new java.lang.Double( Number(5.5) )",
+ new java.lang.Double(Number(5.5)), 5.5 );
+
+ for ( var i = 0; i < a.length; i++ ) {
+
+ // check typeof
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "typeof (" + a[i].description +")",
+ a[i].type,
+ typeof a[i].javavalue );
+/*
+ // check the js class
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "("+ a[i].description +").getJSClass()",
+ E_JSCLASS,
+ a[i].jsclass );
+*/
+ // check the number value of the object
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "Number(" + a[i].description +")",
+ a[i].jsvalue,
+ Number( a[i].javavalue ) );
+ }
+
+ test();
+
+function TestObject( description, javavalue, jsvalue ) {
+ this.description = description;
+ this.javavalue = javavalue;
+ this.jsvalue = jsvalue;
+ this.type = E_TYPE;
+// LC2 does not support the proto property in Java objects
+// this.javavalue.__proto__.getJSClass = Object.prototype.toString;
+// this.jsclass = this.javavalue.getJSClass();
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JSToJava/double-002.js b/js/tests/lc2/JSToJava/double-002.js
new file mode 100644
index 00000000000..f9ce20785fb
--- /dev/null
+++ b/js/tests/lc2/JSToJava/double-002.js
@@ -0,0 +1,139 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Template for LiveConnect Tests
+
+ File Name: number-001.js
+ Description:
+
+ When setting the value of a Java field with a JavaScript number or
+ when passing a JavaScript number to a Java method as an argument,
+ LiveConnect should be able to convert the number to any one of the
+ following types:
+
+ byte
+ short
+ int
+ long
+ float
+ double
+ char
+ java.lang.Double
+
+ Note that the value of the Java field may not be as precise as the
+ JavaScript value's number, if for example, you pass a large number to
+ a short or byte, or a float to integer.
+
+ JavaScript numbers cannot be converted to instances of java.lang.Float
+ or java.lang.Integer.
+
+ This test does not cover the cases in which a Java method returns one
+ of the above primitive Java types.
+
+ Currently split up into numerous tests, since rhino live connect fails
+ to translate numbers into the correct types.
+
+ Test for passing JavasScript numbers to static java.lang.Integer methods.
+
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "double-001";
+ var VERSION = "1_3";
+ var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // typeof all resulting objects is "object";
+ var E_TYPE = "object";
+
+ // JS class of all resulting objects is "JavaObject";
+ var E_JSCLASS = "[object JavaObject]";
+
+ var a = new Array();
+ var i = 0;
+
+ a[i++] = new TestObject( "java.lang.Double.toString(0)",
+ java.lang.Double.toString(0), "0.0" );
+
+ a[i++] = new TestObject( "java.lang.Double.toString(NaN)",
+ java.lang.Double.toString(NaN), "NaN" );
+
+ a[i++] = new TestObject( "java.lang.Double.toString(5)",
+ java.lang.Double.toString(5), "5.0" );
+
+ a[i++] = new TestObject( "java.lang.Double.toString(9.9)",
+ java.lang.Double.toString(9.9), "9.9" );
+
+ a[i++] = new TestObject( "java.lang.Double.toString(-9.9)",
+ java.lang.Double.toString(-9.9), "-9.9" );
+
+ for ( var i = 0; i < a.length; i++ ) {
+
+ // check typeof
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "typeof (" + a[i].description +")",
+ a[i].type,
+ typeof a[i].javavalue );
+/*
+ // check the js class
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "("+ a[i].description +").getJSClass()",
+ E_JSCLASS,
+ a[i].jsclass );
+*/
+ // check the number value of the object
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "String(" + a[i].description +")",
+ a[i].jsvalue,
+ String( a[i].javavalue ) );
+ }
+
+ test();
+
+function TestObject( description, javavalue, jsvalue ) {
+ this.description = description;
+ this.javavalue = javavalue;
+ this.jsvalue = jsvalue;
+ this.type = E_TYPE;
+// LC2 does not support the proto property in Java objects
+// this.javavalue.__proto__.getJSClass = Object.prototype.toString;
+// this.jsclass = this.javavalue.getJSClass();
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JSToJava/float-001.js b/js/tests/lc2/JSToJava/float-001.js
new file mode 100644
index 00000000000..83d7ff72a2b
--- /dev/null
+++ b/js/tests/lc2/JSToJava/float-001.js
@@ -0,0 +1,144 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Template for LiveConnect Tests
+
+ File Name: number-002.js
+ Description:
+
+ When setting the value of a Java field with a JavaScript number or
+ when passing a JavaScript number to a Java method as an argument,
+ LiveConnect should be able to convert the number to any one of the
+ following types:
+
+ byte
+ short
+ int
+ long
+ float
+ double
+ char
+ java.lang.Double
+
+ Note that the value of the Java field may not be as precise as the
+ JavaScript value's number, if for example, you pass a large number to
+ a short or byte, or a float to integer.
+
+ JavaScript numbers cannot be converted to instances of java.lang.Float
+ or java.lang.Integer.
+
+ This test does not cover the cases in which a Java method returns one
+ of the above primitive Java types.
+
+ Currently split up into numerous tests, since rhino live connect fails
+ to translate numbers into the correct types.
+
+ test for creating java.lang.Float objects.
+
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // typeof all resulting objects is "object";
+ var E_TYPE = "object";
+
+
+ // JS class of all resulting objects is "JavaObject";
+ var E_JSCLASS = "[object JavaObject]";
+
+
+ var a = new Array();
+ var i = 0;
+
+ a[i++] = new TestObject( "new java.lang.Float(\"0.0\")",
+ new java.lang.Float("0.0"), 0 );
+
+ a[i++] = new TestObject( "new java.lang.Float(\"0.\")",
+ new java.lang.Float("0"), 0 );
+
+ a[i++] = new TestObject( "new java.lang.Float( 5 )",
+ new java.lang.Float(5), 5 );
+
+ a[i++] = new TestObject( "new java.lang.Float( 5.5 )",
+ new java.lang.Float(5.5), 5.5 );
+
+ a[i++] = new TestObject( "new java.lang.Float( Number(5) )",
+ new java.lang.Float(Number(5)), 5 );
+
+ a[i++] = new TestObject( "new java.lang.Float( Number(5.5) )",
+ new java.lang.Float(Number(5.5)), 5.5 );
+
+ for ( var i = 0; i < a.length; i++ ) {
+
+ // check typeof
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "typeof (" + a[i].description +")",
+ a[i].type,
+ typeof a[i].javavalue );
+/*
+ // check the js class
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "("+ a[i].description +").getJSClass()",
+ E_JSCLASS,
+ a[i].jsclass );
+*/
+ // check the number value of the object
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "Number(" + a[i].description +")",
+ a[i].jsvalue,
+ Number( a[i].javavalue ) );
+ }
+
+ test();
+
+function TestObject( description, javavalue, jsvalue ) {
+ this.description = description;
+ this.javavalue = javavalue;
+ this.jsvalue = jsvalue;
+ this.type = E_TYPE;
+// LC2 does not support the proto property in Java objects
+// this.javavalue.__proto__.getJSClass = Object.prototype.toString;
+// this.jsclass = this.javavalue.getJSClass();
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JSToJava/float-002.js b/js/tests/lc2/JSToJava/float-002.js
new file mode 100644
index 00000000000..bcd286fa139
--- /dev/null
+++ b/js/tests/lc2/JSToJava/float-002.js
@@ -0,0 +1,139 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Template for LiveConnect Tests
+
+ File Name: number-001.js
+ Description:
+
+ When setting the value of a Java field with a JavaScript number or
+ when passing a JavaScript number to a Java method as an argument,
+ LiveConnect should be able to convert the number to any one of the
+ following types:
+
+ byte
+ short
+ int
+ long
+ float
+ double
+ char
+ java.lang.Double
+
+ Note that the value of the Java field may not be as precise as the
+ JavaScript value's number, if for example, you pass a large number to
+ a short or byte, or a float to integer.
+
+ JavaScript numbers cannot be converted to instances of java.lang.Float
+ or java.lang.Integer.
+
+ This test does not cover the cases in which a Java method returns one
+ of the above primitive Java types.
+
+ Currently split up into numerous tests, since rhino live connect fails
+ to translate numbers into the correct types.
+
+ Test for passing JavasScript numbers to static java.lang.Integer methods.
+
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // typeof all resulting objects is "object";
+ var E_TYPE = "object";
+
+ // JS class of all resulting objects is "JavaObject";
+ var E_JSCLASS = "[object JavaObject]";
+
+ var a = new Array();
+ var i = 0;
+
+ a[i++] = new TestObject( "java.lang.Float.toString(0)",
+ java.lang.Float.toString(0), "0.0" );
+
+ a[i++] = new TestObject( "java.lang.Float.toString(NaN)",
+ java.lang.Float.toString(NaN), "NaN" );
+
+ a[i++] = new TestObject( "java.lang.Float.toString(5)",
+ java.lang.Float.toString(5), "5.0" );
+
+ a[i++] = new TestObject( "java.lang.Float.toString(9.9)",
+ java.lang.Float.toString(9.9), "9.9" );
+
+ a[i++] = new TestObject( "java.lang.Float.toString(-9.9)",
+ java.lang.Float.toString(-9.9), "-9.9" );
+
+ for ( var i = 0; i < a.length; i++ ) {
+
+ // check typeof
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "typeof (" + a[i].description +")",
+ a[i].type,
+ typeof a[i].javavalue );
+/*
+ // check the js class
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "("+ a[i].description +").getJSClass()",
+ E_JSCLASS,
+ a[i].jsclass );
+*/
+ // check the number value of the object
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "String(" + a[i].description +")",
+ a[i].jsvalue,
+ String( a[i].javavalue ) );
+ }
+
+ test();
+
+function TestObject( description, javavalue, jsvalue ) {
+ this.description = description;
+ this.javavalue = javavalue;
+ this.jsvalue = jsvalue;
+ this.type = E_TYPE;
+// LC2 does not support the proto property in Java objects
+// this.javavalue.__proto__.getJSClass = Object.prototype.toString;
+// this.jsclass = this.javavalue.getJSClass();
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JSToJava/integer-001.js b/js/tests/lc2/JSToJava/integer-001.js
new file mode 100644
index 00000000000..bc03488cbe9
--- /dev/null
+++ b/js/tests/lc2/JSToJava/integer-001.js
@@ -0,0 +1,144 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Template for LiveConnect Tests
+
+ File Name: number-001.js
+ Description:
+
+ When setting the value of a Java field with a JavaScript number or
+ when passing a JavaScript number to a Java method as an argument,
+ LiveConnect should be able to convert the number to any one of the
+ following types:
+
+ byte
+ short
+ int
+ long
+ float
+ double
+ char
+ java.lang.Double
+
+ Note that the value of the Java field may not be as precise as the
+ JavaScript value's number, if for example, you pass a large number to
+ a short or byte, or a float to integer.
+
+ JavaScript numbers cannot be converted to instances of java.lang.Float
+ or java.lang.Integer.
+
+ This test does not cover the cases in which a Java method returns one
+ of the above primitive Java types.
+
+ Currently split up into numerous tests, since rhino live connect fails
+ to translate numbers into the correct types.
+
+ test for creating java.lang.Integer objects.
+
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
+
+ var BUGNUMBER="196276";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // typeof all resulting objects is "object";
+ var E_TYPE = "object";
+
+
+ // JS class of all resulting objects is "JavaObject";
+ var E_JSCLASS = "[object JavaObject]";
+
+
+ var a = new Array();
+ var i = 0;
+
+
+ a[i++] = new TestObject( "new java.lang.Integer(\"0.\")",
+ new java.lang.Integer("0"), 0 );
+
+ a[i++] = new TestObject( "new java.lang.Integer( 5 )",
+ new java.lang.Integer(5), 5 );
+
+ a[i++] = new TestObject( "new java.lang.Integer( 5.5 )",
+ new java.lang.Integer(5.5), 5 );
+
+ a[i++] = new TestObject( "new java.lang.Integer( Number(5) )",
+ new java.lang.Integer(Number(5)), 5 );
+
+ a[i++] = new TestObject( "new java.lang.Integer( Number(5.5) )",
+ new java.lang.Integer(Number(5.5)), 5 );
+
+ for ( var i = 0; i < a.length; i++ ) {
+
+ // check typeof
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "typeof (" + a[i].description +")",
+ a[i].type,
+ typeof a[i].javavalue );
+/*
+ // check the js class
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "("+ a[i].description +").getJSClass()",
+ E_JSCLASS,
+ a[i].jsclass );
+*/
+ // check the number value of the object
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "Number(" + a[i].description +")",
+ a[i].jsvalue,
+ Number( a[i].javavalue ) );
+ }
+
+ test();
+
+function TestObject( description, javavalue, jsvalue ) {
+ this.description = description;
+ this.javavalue = javavalue;
+ this.jsvalue = jsvalue;
+ this.type = E_TYPE;
+// LC2 does not support the proto property in Java objects
+// this.javavalue.__proto__.getJSClass = Object.prototype.toString;
+// this.jsclass = this.javavalue.getJSClass();
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JSToJava/integer-002.js b/js/tests/lc2/JSToJava/integer-002.js
new file mode 100644
index 00000000000..485c9c4a038
--- /dev/null
+++ b/js/tests/lc2/JSToJava/integer-002.js
@@ -0,0 +1,138 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Template for LiveConnect Tests
+
+ File Name: number-001.js
+ Description:
+
+ When setting the value of a Java field with a JavaScript number or
+ when passing a JavaScript number to a Java method as an argument,
+ LiveConnect should be able to convert the number to any one of the
+ following types:
+
+ byte
+ short
+ int
+ long
+ float
+ double
+ char
+ java.lang.Double
+
+ Note that the value of the Java field may not be as precise as the
+ JavaScript value's number, if for example, you pass a large number to
+ a short or byte, or a float to integer.
+
+ JavaScript numbers cannot be converted to instances of java.lang.Float
+ or java.lang.Integer.
+
+ This test does not cover the cases in which a Java method returns one
+ of the above primitive Java types.
+
+ Currently split up into numerous tests, since rhino live connect fails
+ to translate numbers into the correct types.
+
+ Test for passing JavasScript numbers to static java.lang.Integer methods.
+
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // typeof all resulting objects is "object";
+ var E_TYPE = "object";
+
+ // JS class of all resulting objects is "JavaObject";
+ var E_JSCLASS = "[object JavaObject]";
+
+ var a = new Array();
+ var i = 0;
+
+ a[i++] = new TestObject( "java.lang.Integer.toString(0)",
+ java.lang.Integer.toString(0), "0" );
+
+// a[i++] = new TestObject( "java.lang.Integer.toString(NaN)",
+// java.lang.Integer.toString(NaN), "NaN" );
+
+ a[i++] = new TestObject( "java.lang.Integer.toString(5)",
+ java.lang.Integer.toString(5), "5" );
+
+ a[i++] = new TestObject( "java.lang.Integer.toString(9.9)",
+ java.lang.Integer.toString(9.9), "9" );
+
+ a[i++] = new TestObject( "java.lang.Integer.toString(-9.9)",
+ java.lang.Integer.toString(-9.9), "-9" );
+
+ for ( var i = 0; i < a.length; i++ ) {
+
+ // check typeof
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "typeof (" + a[i].description +")",
+ a[i].type,
+ typeof a[i].javavalue );
+/*
+ // check the js class
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "("+ a[i].description +").getJSClass()",
+ E_JSCLASS,
+ a[i].jsclass );
+*/
+ // check the number value of the object
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "String(" + a[i].description +")",
+ a[i].jsvalue,
+ String( a[i].javavalue ) );
+ }
+
+ test();
+
+function TestObject( description, javavalue, jsvalue ) {
+ this.description = description;
+ this.javavalue = javavalue;
+ this.jsvalue = jsvalue;
+ this.type = E_TYPE;
+// this.javavalue.__proto__.getJSClass = Object.prototype.toString;
+// this.jsclass = this.javavalue.getJSClass();
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JSToJava/long-001.js b/js/tests/lc2/JSToJava/long-001.js
new file mode 100644
index 00000000000..fcdee59f86f
--- /dev/null
+++ b/js/tests/lc2/JSToJava/long-001.js
@@ -0,0 +1,141 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Template for LiveConnect Tests
+
+ File Name: number-004.js
+ Description:
+
+ When setting the value of a Java field with a JavaScript number or
+ when passing a JavaScript number to a Java method as an argument,
+ LiveConnect should be able to convert the number to any one of the
+ following types:
+
+ byte
+ short
+ int
+ long
+ float
+ double
+ char
+ java.lang.Double
+
+ Note that the value of the Java field may not be as precise as the
+ JavaScript value's number, if for example, you pass a large number to
+ a short or byte, or a float to integer.
+
+ JavaScript numbers cannot be converted to instances of java.lang.Float
+ or java.lang.Integer.
+
+ This test does not cover the cases in which a Java method returns one
+ of the above primitive Java types.
+
+ Currently split up into numerous tests, since rhino live connect fails
+ to translate numbers into the correct types.
+
+ test for creating java.lang.Long objects.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // typeof all resulting objects is "object";
+ var E_TYPE = "object";
+
+ // JS class of all resulting objects is "JavaObject";
+ var E_JSCLASS = "[object JavaObject]";
+
+ var a = new Array();
+ var i = 0;
+/*
+ a[i++] = new TestObject( "new java.lang.Long(\"0.0\")",
+ new java.lang.Long("0.0"), 0 );
+*/
+ a[i++] = new TestObject( "new java.lang.Long(\"0.\")",
+ new java.lang.Long("0"), 0 );
+
+ a[i++] = new TestObject( "new java.lang.Long( 5 )",
+ new java.lang.Long(5), 5 );
+
+ a[i++] = new TestObject( "new java.lang.Long( 5.5 )",
+ new java.lang.Long(5.5), 5 );
+
+ a[i++] = new TestObject( "new java.lang.Long( Number(5) )",
+ new java.lang.Long(Number(5)), 5 );
+
+ a[i++] = new TestObject( "new java.lang.Long( Number(5.5) )",
+ new java.lang.Long(Number(5.5)), 5 );
+
+ for ( var i = 0; i < a.length; i++ ) {
+
+ // check typeof
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "typeof (" + a[i].description +")",
+ a[i].type,
+ typeof a[i].javavalue );
+/*
+ // check the js class
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "("+ a[i].description +").getJSClass()",
+ E_JSCLASS,
+ a[i].jsclass );
+*/
+ // check the number value of the object
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "Number(" + a[i].description +")",
+ a[i].jsvalue,
+ Number( a[i].javavalue ) );
+ }
+
+ test();
+
+function TestObject( description, javavalue, jsvalue ) {
+ this.description = description;
+ this.javavalue = javavalue;
+ this.jsvalue = jsvalue;
+ this.type = E_TYPE;
+// LC2 does not support the __proto__ property in Java objects.
+// this.javavalue.__proto__.getJSClass = Object.prototype.toString;
+// this.jsclass = this.javavalue.getJSClass();
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JSToJava/long-002.js b/js/tests/lc2/JSToJava/long-002.js
new file mode 100644
index 00000000000..b3fdc01d498
--- /dev/null
+++ b/js/tests/lc2/JSToJava/long-002.js
@@ -0,0 +1,139 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Template for LiveConnect Tests
+
+ File Name: number-001.js
+ Description:
+
+ When setting the value of a Java field with a JavaScript number or
+ when passing a JavaScript number to a Java method as an argument,
+ LiveConnect should be able to convert the number to any one of the
+ following types:
+
+ byte
+ short
+ int
+ long
+ float
+ double
+ char
+ java.lang.Double
+
+ Note that the value of the Java field may not be as precise as the
+ JavaScript value's number, if for example, you pass a large number to
+ a short or byte, or a float to integer.
+
+ JavaScript numbers cannot be converted to instances of java.lang.Float
+ or java.lang.Integer.
+
+ This test does not cover the cases in which a Java method returns one
+ of the above primitive Java types.
+
+ Currently split up into numerous tests, since rhino live connect fails
+ to translate numbers into the correct types.
+
+ Test for passing JavasScript numbers to static java.lang.Integer methods.
+
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // typeof all resulting objects is "object";
+ var E_TYPE = "object";
+
+ // JS class of all resulting objects is "JavaObject";
+ var E_JSCLASS = "[object JavaObject]";
+
+ var a = new Array();
+ var i = 0;
+
+ a[i++] = new TestObject( "java.lang.Long.toString(0)",
+ java.lang.Long.toString(0), "0" );
+
+// a[i++] = new TestObject( "java.lang.Long.toString(NaN)",
+// java.lang.Long.toString(NaN), "0" );
+
+ a[i++] = new TestObject( "java.lang.Long.toString(5)",
+ java.lang.Long.toString(5), "5" );
+
+ a[i++] = new TestObject( "java.lang.Long.toString(9.9)",
+ java.lang.Long.toString(9.9), "9" );
+
+ a[i++] = new TestObject( "java.lang.Long.toString(-9.9)",
+ java.lang.Long.toString(-9.9), "-9" );
+
+ for ( var i = 0; i < a.length; i++ ) {
+
+ // check typeof
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "typeof (" + a[i].description +")",
+ a[i].type,
+ typeof a[i].javavalue );
+/*
+ // check the js class
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "("+ a[i].description +").getJSClass()",
+ E_JSCLASS,
+ a[i].jsclass );
+*/
+ // check the number value of the object
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "String(" + a[i].description +")",
+ a[i].jsvalue,
+ String( a[i].javavalue ) );
+ }
+
+ test();
+
+function TestObject( description, javavalue, jsvalue ) {
+ this.description = description;
+ this.javavalue = javavalue;
+ this.jsvalue = jsvalue;
+ this.type = E_TYPE;
+// LC2 does not support the __proto__ property in Java objects.
+// this.javavalue.__proto__.getJSClass = Object.prototype.toString;
+// this.jsclass = this.javavalue.getJSClass();
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JSToJava/long-003-n.js b/js/tests/lc2/JSToJava/long-003-n.js
new file mode 100644
index 00000000000..ea89de7f165
--- /dev/null
+++ b/js/tests/lc2/JSToJava/long-003-n.js
@@ -0,0 +1,100 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Template for LiveConnect Tests
+
+ File Name: number-001.js
+ Description:
+
+ This test fails in lc3, but will succeed if the underlying version
+ of liveconnect only supports LC2.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // typeof all resulting objects is "object";
+ var E_TYPE = "object";
+
+ // JS class of all resulting objects is "JavaObject";
+ var E_JSCLASS = "[object JavaObject]";
+
+ var a = new Array();
+ var i = 0;
+
+ a[i++] = new TestObject( "java.lang.Long.toString(NaN)",
+ java.lang.Long.toString(NaN), "0" );
+
+ for ( var i = 0; i < a.length; i++ ) {
+
+ // check typeof
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "typeof (" + a[i].description +")",
+ a[i].type,
+ typeof a[i].javavalue );
+/*
+ // check the js class
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "("+ a[i].description +").getJSClass()",
+ E_JSCLASS,
+ a[i].jsclass );
+*/
+ // check the number value of the object
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "String(" + a[i].description +")",
+ a[i].jsvalue,
+ String( a[i].javavalue ) );
+ }
+
+ test();
+
+function TestObject( description, javavalue, jsvalue ) {
+ this.description = description;
+ this.javavalue = javavalue;
+ this.jsvalue = jsvalue;
+ this.type = E_TYPE;
+// LC2 does not support the __proto__ property in Java objects.
+// this.javavalue.__proto__.getJSClass = Object.prototype.toString;
+// this.jsclass = this.javavalue.getJSClass();
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JSToJava/short-001.js b/js/tests/lc2/JSToJava/short-001.js
new file mode 100644
index 00000000000..2434117426c
--- /dev/null
+++ b/js/tests/lc2/JSToJava/short-001.js
@@ -0,0 +1,139 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Template for LiveConnect Tests
+
+ File Name: number-004.js
+ Description:
+
+ When setting the value of a Java field with a JavaScript number or
+ when passing a JavaScript number to a Java method as an argument,
+ LiveConnect should be able to convert the number to any one of the
+ following types:
+
+ byte
+ short
+ int
+ long
+ float
+ double
+ char
+ java.lang.Double
+
+ Note that the value of the Java field may not be as precise as the
+ JavaScript value's number, if for example, you pass a large number to
+ a short or byte, or a float to integer.
+
+ JavaScript numbers cannot be converted to instances of java.lang.Float
+ or java.lang.Integer.
+
+ This test does not cover the cases in which a Java method returns one
+ of the above primitive Java types.
+
+ Currently split up into numerous tests, since rhino live connect fails
+ to translate numbers into the correct types.
+
+ test for creating java.lang.Short objects.
+
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // typeof all resulting objects is "object";
+ var E_TYPE = "object";
+
+ // JS class of all resulting objects is "JavaObject";
+ var E_JSCLASS = "[object JavaObject]";
+
+ var a = new Array();
+ var i = 0;
+
+ a[i++] = new TestObject( "new java.lang.Short(\"0\")",
+ new java.lang.Short("0"), 0 );
+
+ a[i++] = new TestObject( "new java.lang.Short( 5 )",
+ new java.lang.Short(5), 5 );
+
+ a[i++] = new TestObject( "new java.lang.Short( 5.5 )",
+ new java.lang.Short(5.5), 5 );
+
+ a[i++] = new TestObject( "new java.lang.Short( Number(5) )",
+ new java.lang.Short(Number(5)), 5 );
+
+ a[i++] = new TestObject( "new java.lang.Short( Number(5.5) )",
+ new java.lang.Short(Number(5.5)), 5 );
+
+ for ( var i = 0; i < a.length; i++ ) {
+
+ // check typeof
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "typeof (" + a[i].description +")",
+ a[i].type,
+ typeof a[i].javavalue );
+/*
+ // check the js class
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "("+ a[i].description +").getJSClass()",
+ E_JSCLASS,
+ a[i].jsclass );
+*/
+ // check the number value of the object
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "Number(" + a[i].description +")",
+ a[i].jsvalue,
+ Number( a[i].javavalue ) );
+ }
+
+ test();
+
+function TestObject( description, javavalue, jsvalue ) {
+ this.description = description;
+ this.javavalue = javavalue;
+ this.jsvalue = jsvalue;
+ this.type = E_TYPE;
+// LC2 does not support the __proto__ property in Java objects.
+// this.javavalue.__proto__.getJSClass = Object.prototype.toString;
+// this.jsclass = this.javavalue.getJSClass();
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JSToJava/short-002.js b/js/tests/lc2/JSToJava/short-002.js
new file mode 100644
index 00000000000..880e5cbca1f
--- /dev/null
+++ b/js/tests/lc2/JSToJava/short-002.js
@@ -0,0 +1,138 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Template for LiveConnect Tests
+
+ File Name: number-001.js
+ Description:
+
+ When setting the value of a Java field with a JavaScript number or
+ when passing a JavaScript number to a Java method as an argument,
+ LiveConnect should be able to convert the number to any one of the
+ following types:
+
+ byte
+ short
+ int
+ long
+ float
+ double
+ char
+ java.lang.Double
+
+ Note that the value of the Java field may not be as precise as the
+ JavaScript value's number, if for example, you pass a large number to
+ a short or byte, or a float to integer.
+
+ JavaScript numbers cannot be converted to instances of java.lang.Float
+ or java.lang.Integer.
+
+ This test does not cover the cases in which a Java method returns one
+ of the above primitive Java types.
+
+ Currently split up into numerous tests, since rhino live connect fails
+ to translate numbers into the correct types.
+
+ Test for passing JavasScript numbers to static java.lang.Integer methods.
+
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // typeof all resulting objects is "object";
+ var E_TYPE = "object";
+
+ // JS class of all resulting objects is "JavaObject";
+ var E_JSCLASS = "[object JavaObject]";
+
+ var a = new Array();
+ var i = 0;
+
+ a[i++] = new TestObject( "java.lang.Short.toString(0)",
+ java.lang.Short.toString(0), "0" );
+
+// a[i++] = new TestObject( "java.lang.Short.toString(NaN)",
+// java.lang.Short.toString(NaN), "0" );
+
+ a[i++] = new TestObject( "java.lang.Short.toString(5)",
+ java.lang.Short.toString(5), "5" );
+
+ a[i++] = new TestObject( "java.lang.Short.toString(9.9)",
+ java.lang.Short.toString(9.9), "9" );
+
+ a[i++] = new TestObject( "java.lang.Short.toString(-9.9)",
+ java.lang.Short.toString(-9.9), "-9" );
+
+ for ( var i = 0; i < a.length; i++ ) {
+
+ // check typeof
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "typeof (" + a[i].description +")",
+ a[i].type,
+ typeof a[i].javavalue );
+/*
+ // check the js class
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "("+ a[i].description +").getJSClass()",
+ E_JSCLASS,
+ a[i].jsclass );
+*/
+ // check the number value of the object
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "String(" + a[i].description +")",
+ a[i].jsvalue,
+ String( a[i].javavalue ) );
+ }
+
+ test();
+
+function TestObject( description, javavalue, jsvalue ) {
+ this.description = description;
+ this.javavalue = javavalue;
+ this.jsvalue = jsvalue;
+ this.type = E_TYPE;
+// this.javavalue.__proto__.getJSClass = Object.prototype.toString;
+// this.jsclass = this.javavalue.getJSClass();
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JSToJava/short-003-n.js b/js/tests/lc2/JSToJava/short-003-n.js
new file mode 100644
index 00000000000..578154d4fa5
--- /dev/null
+++ b/js/tests/lc2/JSToJava/short-003-n.js
@@ -0,0 +1,126 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ Template for LiveConnect Tests
+
+ File Name: number-001.js
+ Description:
+
+ When setting the value of a Java field with a JavaScript number or
+ when passing a JavaScript number to a Java method as an argument,
+ LiveConnect should be able to convert the number to any one of the
+ following types:
+
+ byte
+ short
+ int
+ long
+ float
+ double
+ char
+ java.lang.Double
+
+ Note that the value of the Java field may not be as precise as the
+ JavaScript value's number, if for example, you pass a large number to
+ a short or byte, or a float to integer.
+
+ JavaScript numbers cannot be converted to instances of java.lang.Float
+ or java.lang.Integer.
+
+ This test does not cover the cases in which a Java method returns one
+ of the above primitive Java types.
+
+ Currently split up into numerous tests, since rhino live connect fails
+ to translate numbers into the correct types.
+
+ Test for passing JavasScript numbers to static java.lang.Integer methods.
+
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // typeof all resulting objects is "object";
+ var E_TYPE = "object";
+
+ // JS class of all resulting objects is "JavaObject";
+ var E_JSCLASS = "[object JavaObject]";
+
+ var a = new Array();
+ var i = 0;
+
+ a[i++] = new TestObject( "java.lang.Short.toString(NaN)",
+ java.lang.Short.toString(NaN), "0" );
+
+ for ( var i = 0; i < a.length; i++ ) {
+
+ // check typeof
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "typeof (" + a[i].description +")",
+ a[i].type,
+ typeof a[i].javavalue );
+/*
+ // check the js class
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "("+ a[i].description +").getJSClass()",
+ E_JSCLASS,
+ a[i].jsclass );
+*/
+ // check the number value of the object
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "String(" + a[i].description +")",
+ a[i].jsvalue,
+ String( a[i].javavalue ) );
+ }
+
+ test();
+
+function TestObject( description, javavalue, jsvalue ) {
+ this.description = description;
+ this.javavalue = javavalue;
+ this.jsvalue = jsvalue;
+ this.type = E_TYPE;
+// this.javavalue.__proto__.getJSClass = Object.prototype.toString;
+// this.jsclass = this.javavalue.getJSClass();
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JavaToJS/String-001.js b/js/tests/lc2/JavaToJS/String-001.js
new file mode 100644
index 00000000000..aea5bf1cf20
--- /dev/null
+++ b/js/tests/lc2/JavaToJS/String-001.js
@@ -0,0 +1,74 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: String-001.js
+ Description:
+
+ When accessing a Java field whose value is a java.lang.String,
+ JavaScript should read the value as the JavaScript JavaObject,
+ an object whose class is JavaObject.
+
+ To test this:
+
+ 1. Call a java method that returns a java.lang.String
+ 2. Check the value of the returned object, which should be the value
+ of the string
+ 3. Check the type of the returned object, which should be "object"
+ 4. Check the class of the object, using Object.prototype.toString,
+ which should be "[object JavaObject]"
+ 5. Check the class of the JavaObject, using getClass, and compare
+ it to java.lang.Class.forName("java.lang.String");
+
+ NOT DONE. need a test class with a string field.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+
+
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "Java Number Primitive to JavaScript Object";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+// display test information
+
+ test();
+
+function CheckType( et, at ) {
+}
+function CheckValue( ev, av ) {
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JavaToJS/boolean-001.js b/js/tests/lc2/JavaToJS/boolean-001.js
new file mode 100644
index 00000000000..0f0a9b02ee9
--- /dev/null
+++ b/js/tests/lc2/JavaToJS/boolean-001.js
@@ -0,0 +1,114 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: boolean-001.js
+ Description:
+
+ If a Java method returns a Java boolean primitive, JavaScript should
+ read the value as a JavaScript boolean primitive.
+
+ To test this:
+
+ 1. Call a java method that returns a Java boolean primitive.
+ 2. Check the type of the returned type, which should be "boolean"
+ 3. Check the value of the returned type, which should be true or false.
+
+ It is an error if the returned value is read as a JavaScript Boolean
+ object.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "Java Boolean Primitive to JavaScript Object";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // In all test cases, the expected type is "boolean"
+
+ var E_TYPE = "boolean";
+
+ // Create arrays of actual results (java_array) and expected results
+ // (test_array).
+
+ var java_array = new Array();
+ var test_array = new Array();
+
+ var i = 0;
+
+ // Call a java method that returns true
+ java_array[i] = new JavaValue( (new java.lang.Boolean(true)).booleanValue() );
+ test_array[i] = new TestValue( "(new java.lang.Boolean(true)).booleanValue()",
+ true )
+ i++;
+
+ // Call a java method that returns false
+ java_array[i] = new JavaValue( (new java.lang.Boolean(false)).booleanValue() );
+ test_array[i] = new TestValue( "(new java.lang.Boolean(false)).booleanValue()",
+ false )
+ i++;
+
+ for ( i = 0; i < java_array.length; i++ ) {
+ CompareValues( java_array[i], test_array[i] );
+
+ }
+
+ test();
+
+function CompareValues( javaval, testval ) {
+ // Check value
+ testcases[testcases.length] = new TestCase( SECTION,
+ testval.description,
+ testval.value,
+ javaval.value );
+ // Check type.
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +")",
+ testval.type,
+ javaval.type );
+}
+function JavaValue( value ) {
+ this.value = value;
+ this.type = typeof value;
+ return this;
+}
+function TestValue( description, value ) {
+ this.description = description;
+ this.value = value;
+ this.type = E_TYPE;
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JavaToJS/boolean-003.js b/js/tests/lc2/JavaToJS/boolean-003.js
new file mode 100644
index 00000000000..4d1e393e27b
--- /dev/null
+++ b/js/tests/lc2/JavaToJS/boolean-003.js
@@ -0,0 +1,134 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: boolean-005.js
+ Description:
+
+ A java.lang.Boolean object field should be read as a JavaScript JavaObject.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "Java Boolean Object to JavaScript Object";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // In all test cases, the expected type is "object"
+
+ var E_TYPE = "object";
+
+ // The JavaScrpt [[Class]] of a JavaObject should be JavaObject"
+
+ var E_JSCLASS = "[object JavaObject]";
+
+ // The Java class of this object is java.lang.Boolean.
+
+ var E_JAVACLASS = java.lang.Class.forName( "java.lang.Boolean" );
+
+ // Create arrays of actual results (java_array) and expected results
+ // (test_array).
+
+ var java_array = new Array();
+ var test_array = new Array();
+
+ var i = 0;
+
+ // Test for java.lang.Boolean.FALSE, which is a Boolean object.
+ java_array[i] = new JavaValue( java.lang.Boolean.FALSE );
+ test_array[i] = new TestValue( "java.lang.Boolean.FALSE",
+ false );
+
+ i++;
+
+ // Test for java.lang.Boolean.TRUE, which is a Boolean object.
+ java_array[i] = new JavaValue( java.lang.Boolean.TRUE );
+ test_array[i] = new TestValue( "java.lang.Boolean.TRUE",
+ true );
+
+ i++;
+
+ for ( i = 0; i < java_array.length; i++ ) {
+ CompareValues( java_array[i], test_array[i] );
+
+ }
+
+ test();
+
+function CompareValues( javaval, testval ) {
+ // Check booleanValue()
+ testcases[testcases.length] = new TestCase( SECTION,
+ "("+testval.description+").booleanValue()",
+ testval.value,
+ javaval.value );
+ // Check typeof, which should be E_TYPE
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +")",
+ testval.type,
+ javaval.type );
+/*
+ // Check JavaScript class, which should be E_JSCLASS
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +").getJSClass()",
+ testval.jsclass,
+ javaval.jsclass );
+*/
+ // Check Java class, which should equal() E_JAVACLASS
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +").getClass().equals( " + E_JAVACLASS +" )",
+ true,
+ javaval.javaclass.equals( testval.javaclass ) );
+}
+function JavaValue( value ) {
+ // java.lang.Object.getClass() returns the Java Object's class.
+ this.javaclass = value.getClass();
+
+ // Object.prototype.toString will show its JavaScript wrapper object.
+// value.__proto__.getJSClass = Object.prototype.toString;
+// this.jsclass = value.getJSClass();
+
+ this.value = value.booleanValue();
+ this.type = typeof value;
+ return this;
+}
+function TestValue( description, value ) {
+ this.description = description;
+ this.value = value;
+ this.type = E_TYPE;
+ this.javaclass = E_JAVACLASS;
+ this.jsclass = E_JSCLASS;
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JavaToJS/boolean-004.js b/js/tests/lc2/JavaToJS/boolean-004.js
new file mode 100644
index 00000000000..e70dbabd63b
--- /dev/null
+++ b/js/tests/lc2/JavaToJS/boolean-004.js
@@ -0,0 +1,144 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: boolean-004.js
+ Description:
+
+ A java.lang.Boolean object should be read as a JavaScript JavaObject.
+ To test this:
+
+ 1. The object should have a method called booleanValue(), which should
+ return the object's value.
+ 2. The typeof the object should be "object"
+ 3. The object should have a method called getClass(), which should
+ return the class java.lang.Boolean.
+ 4. Add a method to the object's prototype, called getJSClass() that
+ is Object.prototype.toString. Calling getJSClass() should return the
+ object's internal [[Class]] property, which should be JavaObject.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "Java Boolean Object to JavaScript Object";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // In all test cases, the expected type is "object"
+
+ var E_TYPE = "object";
+
+ // ToString of a JavaObject should return "[object JavaObject]"
+
+ var E_JSCLASS = "[object JavaObject]";
+
+ // The class of this object is java.lang.Boolean.
+
+ var E_JAVACLASS = java.lang.Class.forName( "java.lang.Boolean" );
+
+ // Create arrays of actual results (java_array) and expected results
+ // (test_array).
+
+ var java_array = new Array();
+ var test_array = new Array();
+
+ var i = 0;
+
+ // Instantiate a new java.lang.Boolean object whose value is Boolean.TRUE
+ java_array[i] = new JavaValue( new java.lang.Boolean( true ) );
+ test_array[i] = new TestValue( "new java.lang.Boolean( true )",
+ true );
+
+ i++;
+
+ // Instantiate a new java.lang.Boolean object whose value is Boolean.FALSE
+ java_array[i] = new JavaValue( new java.lang.Boolean( true ) );
+ test_array[i] = new TestValue( "new java.lang.Boolean( true )",
+ true );
+
+ i++;
+
+ for ( i = 0; i < java_array.length; i++ ) {
+ CompareValues( java_array[i], test_array[i] );
+
+ }
+
+ test();
+
+function CompareValues( javaval, testval ) {
+ // Check value
+ testcases[testcases.length] = new TestCase( SECTION,
+ "("+testval.description+").booleanValue()",
+ testval.value,
+ javaval.value );
+ // Check type, which should be E_TYPE
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +")",
+ testval.type,
+ javaval.type );
+/*
+ // Check JavaScript class, which should be E_JSCLASS
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +").getJSClass()",
+ testval.jsclass,
+ javaval.jsclass );
+*/
+ // Check Java class, which should equal() E_JAVACLASS
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +").getClass().equals( " + E_JAVACLASS +" )",
+ true,
+ javaval.javaclass.equals( testval.javaclass ) );
+}
+function JavaValue( value ) {
+ // java.lang.Object.getClass() returns the Java Object's class.
+ this.javaclass = value.getClass();
+
+ // Object.prototype.toString will show its JavaScript wrapper object.
+// value.__proto__.getJSClass = Object.prototype.toString;
+// this.jsclass = value.getJSClass();
+
+ this.value = value.booleanValue();
+ this.type = typeof value;
+ return this;
+}
+function TestValue( description, value ) {
+ this.description = description;
+ this.value = value;
+ this.type = E_TYPE;
+ this.javaclass = E_JAVACLASS;
+ this.jsclass = E_JSCLASS;
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JavaToJS/boolean-005.js b/js/tests/lc2/JavaToJS/boolean-005.js
new file mode 100644
index 00000000000..149f8fbb5b8
--- /dev/null
+++ b/js/tests/lc2/JavaToJS/boolean-005.js
@@ -0,0 +1,146 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: boolean-005.js
+ Description:
+
+ A java.lang.Boolean object should be read as a JavaScript JavaObject.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "Java Boolean Object to JavaScript Object";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // In all test cases, the expected type is "object"
+
+ var E_TYPE = "object";
+
+ // The JavaScrpt [[Class]] of a JavaObject should be JavaObject"
+
+ var E_JSCLASS = "[object JavaObject]";
+
+ // The Java class of this object is java.lang.Boolean.
+
+ var E_JAVACLASS = java.lang.Class.forName( "java.lang.Boolean" );
+
+ // Create arrays of actual results (java_array) and expected results
+ // (test_array).
+
+ var java_array = new Array();
+ var test_array = new Array();
+
+ var i = 0;
+
+ // Test for java.lang.Boolean.FALSE, which is a Boolean object.
+ java_array[i] = new JavaValue( java.lang.Boolean.FALSE );
+ test_array[i] = new TestValue( "java.lang.Boolean.FALSE",
+ false );
+
+ i++;
+
+ // Test for java.lang.Boolean.TRUE, which is a Boolean object.
+ java_array[i] = new JavaValue( java.lang.Boolean.TRUE );
+ test_array[i] = new TestValue( "java.lang.Boolean.TRUE",
+ true );
+
+ i++;
+
+ for ( i = 0; i < java_array.length; i++ ) {
+ CompareValues( java_array[i], test_array[i] );
+
+ }
+
+ test();
+
+function CompareValues( javaval, testval ) {
+ // Check booleanValue()
+ testcases[testcases.length] = new TestCase( SECTION,
+ "("+testval.description+").booleanValue()",
+ testval.value,
+ javaval.value );
+ // Check typeof, which should be E_TYPE
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +")",
+ testval.type,
+ javaval.type );
+/*
+ // Check JavaScript class, which should be E_JSCLASS
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +").getJSClass()",
+ testval.jsclass,
+ javaval.jsclass );
+*/
+ // Check Java class, which should equal() E_JAVACLASS
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +").getClass().equals( " + E_JAVACLASS +" )",
+ true,
+ javaval.javaclass.equals( testval.javaclass ) );
+
+ // Check string representation
+ testcases[testcases.length] = new TestCase( SECTION,
+ "("+ testval.description+") + ''",
+ testval.string,
+ javaval.string );
+}
+function JavaValue( value ) {
+ // java.lang.Object.getClass() returns the Java Object's class.
+ this.javaclass = value.getClass();
+
+
+// __proto__ of Java objects is not supported in LC2.
+// Object.prototype.toString will show its JavaScript wrapper object.
+// value.__proto__.getJSClass = Object.prototype.toString;
+// this.jsclass = value.getJSClass();
+
+ this.string = value + "";
+ print( this.string );
+ this.value = value.booleanValue();
+ this.type = typeof value;
+
+ return this;
+}
+function TestValue( description, value ) {
+ this.description = description;
+ this.string = String( value );
+ this.value = value;
+ this.type = E_TYPE;
+ this.javaclass = E_JAVACLASS;
+ this.jsclass = E_JSCLASS;
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JavaToJS/char-001.js b/js/tests/lc2/JavaToJS/char-001.js
new file mode 100644
index 00000000000..e7906457916
--- /dev/null
+++ b/js/tests/lc2/JavaToJS/char-001.js
@@ -0,0 +1,111 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: char-001.js
+ Description:
+
+ Java methods that return a char value should be read as a
+ JavaScript number.
+
+ To test this:
+
+ 1. Call a method that returns a char.
+ 2. Set the value of a JavaScript variable to the char value.
+ 3. Check the value of the returned type, which should be "number"
+ 4. Check the type of the returned type, which should be the Unicode
+ encoding of that character.
+
+ It is an error if the JavaScript variable is an object, or JavaObject
+ whose class is java.lang.Character.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "Java char return value to JavaScript Object";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+// In all cases, the expected type is "number"
+ var E_TYPE = "number";
+
+ // Create arrays of actual results (java_array) and expected results
+ // (test_array).
+
+ var java_array = new Array();
+ var test_array = new Array();
+
+ var i = 0;
+
+ // Get a char using String.charAt()
+
+ java_array[i] = new JavaValue( (new java.lang.String( "JavaScript" )).charAt(0) );
+ test_array[i] = new TestValue( "(new java.lang.String( 'JavaScript' )).charAt(0)",
+ 74 );
+
+ i++;
+
+ for ( i = 0; i < java_array.length; i++ ) {
+ CompareValues( java_array[i], test_array[i] );
+
+ }
+
+ test();
+
+function CompareValues( javaval, testval ) {
+ // Check value
+ testcases[testcases.length] = new TestCase( SECTION,
+ testval.description,
+ testval.value,
+ javaval.value );
+ // Check type, which should be E_TYPE
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +")",
+ testval.type,
+ javaval.type );
+
+}
+function JavaValue( value ) {
+ this.value = value;
+ this.type = typeof value;
+ return this;
+}
+function TestValue( description, value ) {
+ this.description = description;
+ this.value = value;
+ this.type = E_TYPE;
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JavaToJS/char-002.js b/js/tests/lc2/JavaToJS/char-002.js
new file mode 100644
index 00000000000..a6b4b2fc986
--- /dev/null
+++ b/js/tests/lc2/JavaToJS/char-002.js
@@ -0,0 +1,123 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: char-002.js
+ Description:
+
+ Java fields whose value is char should be read as a JavaScript number.
+
+ To test this:
+
+ 1. Instantiate a Java object that has fields with char values,
+ or reference a classes static field whose value is a char.
+ 2. Reference the field, and set the value of a JavaScript variable
+ to that field's value.
+ 3. Check the value of the returned type, which should be "number"
+ 4. Check the type of the returned type, which should be a number
+
+ It is an error if the JavaScript variable is an object, or JavaObject
+ whose class is java.lang.Character.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "Java char return value to JavaScript Object";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+// In all cases, the expected type is "number"
+ var E_TYPE = "number";
+
+ // Create arrays of actual results (java_array) and expected results
+ // (test_array).
+
+ var java_array = new Array();
+ var test_array = new Array();
+
+ var i = 0;
+
+ // Get File.separator char
+
+ var os = java.lang.System.getProperty( "os.name" );
+ var v;
+
+ if ( os.startsWith( "Windows" ) ) {
+ v = 92;
+ } else {
+ if ( os.startsWith( "Mac" ) ) {
+ v = 58;
+ } else {
+ v = 47;
+ }
+ }
+
+ java_array[i] = new JavaValue( java.io.File.separatorChar );
+ test_array[i] = new TestValue( "java.io.File.separatorChar", v );
+
+ i++;
+
+ for ( i = 0; i < java_array.length; i++ ) {
+ CompareValues( java_array[i], test_array[i] );
+
+ }
+
+ test();
+
+function CompareValues( javaval, testval ) {
+ // Check value
+ testcases[testcases.length] = new TestCase( SECTION,
+ testval.description,
+ testval.value,
+ javaval.value );
+ // Check type, which should be E_TYPE
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +")",
+ testval.type,
+ javaval.type );
+
+}
+function JavaValue( value ) {
+ this.value = value;
+ this.type = typeof value;
+ return this;
+}
+function TestValue( description, value ) {
+ this.description = description;
+ this.value = value;
+ this.type = E_TYPE;
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JavaToJS/enum-001.js b/js/tests/lc2/JavaToJS/enum-001.js
new file mode 100644
index 00000000000..09306c1b3c9
--- /dev/null
+++ b/js/tests/lc2/JavaToJS/enum-001.js
@@ -0,0 +1,74 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: enum-001.js
+ Section: LiveConnect
+ Description:
+
+ Tests enumeration of a java object.
+
+ Regression test for bug:
+
+ http://scopus.mcom.com/bugsplat/show_bug.cgi?id=107638
+
+ Author: christine@netscape.com
+ Date: 12 november 1997
+*/
+ var SECTION = "enum-001";
+ var VERSION = "JS1_3";
+ var TITLE = "The variable statment";
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = new Array();
+
+ var v = new java.util.Vector();
+ v.addElement("PASSED!");
+ v.addElement("PASSED!");
+ v.addElement("PASSED!");
+
+ for (e = v.elements(), result = new Array(), i = 0 ; e.hasMoreElements();
+ i++ )
+ {
+ result[i] = String( e.nextElement() );
+ }
+
+ for ( i = 0; i < result.length; i++ ) {
+ testcases[testcases.length] = new TestCase( SECTION,
+ "test enumeration of a java object: element at " + i,
+ "PASSED!",
+ result[i] );
+ }
+
+ test();
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JavaToJS/enum-002.js b/js/tests/lc2/JavaToJS/enum-002.js
new file mode 100644
index 00000000000..637b2441f9b
--- /dev/null
+++ b/js/tests/lc2/JavaToJS/enum-002.js
@@ -0,0 +1,73 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: enum-002.js
+ Section: LiveConnect
+ Description:
+
+ Tests enumeration of a java object. This also does some
+ conversions.
+
+ Regression test for bug:
+
+ http://scopus.mcom.com/bugsplat/show_bug.cgi?id=107638
+
+ Author: christine@netscape.com
+ Date: 12 november 1997
+*/
+ var SECTION = "enum-002";
+ var VERSION = "JS1_3";
+ var TITLE = "The variable statment";
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = new Array();
+
+ var v = new java.util.Vector();
+ v.addElement("TRUE");
+
+ for (e = v.elements(), result = new Array(), i = 0 ; e.hasMoreElements();
+ i++ )
+ {
+ result[i] = (new java.lang.Boolean(e.nextElement())).booleanValue();
+ }
+
+ for ( i = 0; i < result.length; i++ ) {
+ testcases[testcases.length] = new TestCase( SECTION,
+ "test enumeration of a java object: element at " + i,
+ "true",
+ String( result[i] ) );
+ }
+
+ test();
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JavaToJS/null-001.js b/js/tests/lc2/JavaToJS/null-001.js
new file mode 100644
index 00000000000..61daac1b08e
--- /dev/null
+++ b/js/tests/lc2/JavaToJS/null-001.js
@@ -0,0 +1,79 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: null-001.js
+ Description:
+
+ When accessing a Java field whose value is null, JavaScript should read
+ the value as the JavaScript null object.
+
+ To test this:
+
+ 1. Call a java method that returns the Java null value
+ 2. Check the value of the returned object, which should be null
+ 3. Check the type of the returned object, which should be "object"
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "Java null to JavaScript Object";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+// display test information
+
+ var choice = new java.awt.Choice();
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "var choice = new java.awt.Choice(); choice.getSelectedObjects()",
+ null,
+ choice.getSelectedObjects() );
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "typeof choice.getSelectedObjects()",
+ "object",
+ typeof choice.getSelectedObjects() );
+
+
+
+ test();
+
+function CheckType( et, at ) {
+}
+function CheckValue( ev, av ) {
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JavaToJS/number-001.js b/js/tests/lc2/JavaToJS/number-001.js
new file mode 100644
index 00000000000..ec792397506
--- /dev/null
+++ b/js/tests/lc2/JavaToJS/number-001.js
@@ -0,0 +1,165 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+
+ File Name: number-001.js
+ Description:
+
+ If a Java method returns one of the primitive Java types below,
+ JavaScript should read the value as JavaScript number primitive.
+ * byte
+ * short
+ * int
+ * long
+ * float
+ * double
+ * char
+
+ To test this:
+
+ 1. Call a java method that returns one of the primitive java types above.
+ 2. Check the value of the returned type
+ 3. Check the type of the returned type, which should be "number"
+
+ It is an error if the type of the JavaScript variable is "object" or if
+ its class is JavaObject or Number.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "Java Number Primitive to JavaScript Object";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // In all test cases, the expected type is "number"
+
+ var E_TYPE = "number";
+
+ // Create arrays of actual results (java_array) and
+ // expected results (test_array).
+
+ var java_array = new Array();
+ var test_array = new Array();
+
+ var i = 0;
+
+ // Call a java function that returns a value whose type is int.
+ java_array[i] = new JavaValue( java.lang.Integer.parseInt('255') );
+ test_array[i] = new TestValue( "java.lang.Integer.parseInt('255')",
+ 255,
+ E_TYPE );
+
+ i++;
+
+ java_array[i] = new JavaValue( (new java.lang.Double( '123456789' )).intValue() );
+ test_array[i] = new TestValue( "(new java.lang.Double( '123456789' )).intValue()",
+ 123456789,
+ E_TYPE );
+
+ i++;
+
+ // Call a java function that returns a value whose type is double
+ java_array[i] = new JavaValue( (new java.lang.Integer( '123456789' )).doubleValue() );
+ test_array[i] = new TestValue( "(new java.lang.Integer( '123456789' )).doubleValue()",
+ 123456789,
+ E_TYPE );
+
+ // Call a java function that returns a value whose type is long
+ java_array[i] = new JavaValue( (new java.lang.Long('1234567891234567' )).longValue() );
+ test_array[i] = new TestValue( "(new java.lang.Long( '1234567891234567' )).longValue()",
+ 1234567891234567,
+ E_TYPE );
+
+ // Call a java function that returns a value whose type is float
+
+ java_array[i] = new JavaValue( (new java.lang.Float( '1.23456789' )).floatValue() );
+ test_array[i] = new TestValue( "(new java.lang.Float( '1.23456789' )).floatValue()",
+ 1.23456789,
+ E_TYPE );
+
+ i++;
+
+ // Call a java function that returns a value whose type is char
+ java_array[i] = new JavaValue( (new java.lang.String("hello")).charAt(0) );
+ test_array[i] = new TestValue( "(new java.lang.String('hello')).charAt(0)",
+ "h".charCodeAt(0),
+ E_TYPE );
+ i++;
+
+ // Call a java function that returns a value whose type is short
+ java_array[i] = new JavaValue( (new java.lang.Byte(127)).shortValue() );
+ test_array[i] = new TestValue( "(new java.lang.Byte(127)).shortValue()",
+ 127,
+ E_TYPE );
+ i++;
+
+ // Call a java function that returns a value whose type is byte
+ java_array[i] = new JavaValue( (new java.lang.Byte(127)).byteValue() );
+ test_array[i] = new TestValue( "(new java.lang.Byte(127)).byteValue()",
+ 127,
+ E_TYPE );
+
+
+ for ( i = 0; i < java_array.length; i++ ) {
+ CompareValues( java_array[i], test_array[i] );
+ }
+
+ test();
+function CompareValues( javaval, testval ) {
+ // Check value
+ testcases[testcases.length] = new TestCase( SECTION,
+ testval.description,
+ testval.value,
+ javaval.value );
+ // Check type.
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +")",
+ testval.type,
+ javaval.type );
+}
+function JavaValue( value ) {
+ this.value = value.valueOf();
+ this.type = typeof value;
+ return this;
+}
+function TestValue( description, value, type, classname ) {
+ this.description = description;
+ this.value = value;
+ this.type = type;
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/JavaToJS/number-002.js b/js/tests/lc2/JavaToJS/number-002.js
new file mode 100644
index 00000000000..7bbe5ec8074
--- /dev/null
+++ b/js/tests/lc2/JavaToJS/number-002.js
@@ -0,0 +1,167 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: number-001.js
+ Description:
+
+ Accessing a Java field whose value is one of the primitive Java types
+ below, JavaScript should read this as a JavaScript Number object.
+ byte
+ short
+ int
+ long
+ float
+ double
+ char
+
+ To test this:
+ 1. Instantiate a new Java object that has a field whose type one of
+ the above primitive Java types, OR get the value of a class's static
+ field.
+ 2. Check the value of the returned object
+ 3. Check the type of the returned object, which should be "object"
+ 4. Check the class of the returned object using Object.prototype.toString,
+ which should return "[object Number]"
+
+ It is an error if the type of the JavaScript variable is "number" or if
+ its class is JavaObject.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect";
+ var VERSION = "1_3";
+ var TITLE = "Java Number Primitive to JavaScript Object";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // In all test cases, the expected type is "object, and the expected
+ // class is "Number"
+
+ var E_TYPE = "number";
+
+ // Create arrays of actual results (java_array) and expected results
+ // (test_array).
+
+ var java_array = new Array();
+ var test_array = new Array();
+
+ var i = 0;
+
+ // Get a static java field whose type is byte.
+
+ java_array[i] = new JavaValue( java.lang.Byte.MIN_VALUE );
+ test_array[i] = new TestValue( "java.lang.Byte.MIN_VALUE",
+ -128 )
+ i++;
+
+ // Get a static java field whose type is short.
+ java_array[i] = new JavaValue( java.lang.Short.MIN_VALUE );
+ test_array[i] = new TestValue( "java.lang.Short.MIN_VALUE",
+ -32768 )
+ i++;
+
+ // Get a static java field whose type is int.
+
+ java_array[i] = new JavaValue( java.lang.Integer.MIN_VALUE );
+ test_array[i] = new TestValue( "java.lang.Integer.MIN_VALUE",
+ -2147483648 )
+ i++;
+
+
+ // Instantiate a class, and get a field in that class whose type is int.
+
+ var java_rect = new java.awt.Rectangle( 1,2,3,4 );
+
+ java_array[i] = new JavaValue( java_rect.width );
+ test_array[i] = new TestValue( "java_object = new java.awt.Rectangle( 1,2,3,4 ); java_object.width",
+ 3 );
+ i++;
+
+ // Get a static java field whose type is long.
+ java_array[i] = new JavaValue( java.lang.Long.MIN_VALUE );
+ test_array[i] = new TestValue( "java.lang.Long.MIN_VALUE",
+ -9223372036854776000 );
+ i++;
+
+ // Get a static java field whose type is float.
+ java_array[i] = new JavaValue( java.lang.Float.MAX_VALUE );
+ test_array[i] = new TestValue( "java.lang.Float.MAX_VALUE",
+ 3.4028234663852886e+38 )
+ i++;
+
+ // Get a static java field whose type is double.
+ java_array[i] = new JavaValue( java.lang.Double.MAX_VALUE );
+ test_array[i] = new TestValue( "java.lang.Double.MAX_VALUE",
+ 1.7976931348623157e+308 )
+ i++;
+
+ // Get a static java field whose type is char.
+ java_array[i] = new JavaValue( java.lang.Character.MAX_VALUE );
+ test_array[i] = new TestValue( "java.lang.Character.MAX_VALUE",
+ 65535 );
+ i++;
+
+ for ( i = 0; i < java_array.length; i++ ) {
+ CompareValues( java_array[i], test_array[i] );
+
+ }
+
+ test();
+function CompareValues( javaval, testval ) {
+ // Check value
+ testcases[testcases.length] = new TestCase( SECTION,
+ testval.description,
+ testval.value,
+ javaval.value );
+ // Check type.
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +")",
+ testval.type,
+ javaval.type );
+}
+function JavaValue( value ) {
+ this.value = value.valueOf();
+ this.type = typeof value;
+ return this;
+}
+function TestValue( description, value, type ) {
+ this.description = description;
+ this.value = value;
+ this.type = E_TYPE;
+// this.classname = classname;
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Methods/method-001.js b/js/tests/lc2/Methods/method-001.js
new file mode 100644
index 00000000000..c91418b9ce0
--- /dev/null
+++ b/js/tests/lc2/Methods/method-001.js
@@ -0,0 +1,132 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: method-001.js
+ Description:
+
+ Call a static method of an object and verify return value.
+ This is covered more thoroughly in the type conversion test cases.
+ This only covers cases in which JavaObjects are returned.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect Objects";
+ var VERSION = "1_3";
+ var TITLE = "Calling Static Methods";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // All JavaObjects are of the type "object"
+
+ var E_TYPE = "object";
+
+ // All JavaObjects [[Class]] property is JavaObject
+ var E_JSCLASS = "[object JavaObject]";
+
+ // Create arrays of actual results (java_array) and
+ // expected results (test_array).
+
+ var java_array = new Array();
+ var test_array = new Array();
+
+ var i = 0;
+
+ java_array[i] = new JavaValue( java.lang.String.valueOf(true) );
+ test_array[i] = new TestValue( "java.lang.String.valueOf(true)",
+ "object", "java.lang.String", "true" );
+
+ i++;
+
+ java_array[i] = new JavaValue( java.awt.Color.getHSBColor(0.0, 0.0, 0.0) );
+ test_array[i] = new TestValue( "java.awt.Color.getHSBColor(0.0, 0.0, 0.0)",
+ "object", "java.awt.Color", "java.awt.Color[r=0,g=0,b=0]" );
+
+ i++;
+
+
+ for ( i = 0; i < java_array.length; i++ ) {
+ CompareValues( java_array[i], test_array[i] );
+ }
+
+ test();
+
+function CompareValues( javaval, testval ) {
+ // Check type, which should be E_TYPE
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +" )",
+ testval.type,
+ javaval.type );
+/*
+ // Check JavaScript class, which should be E_JSCLASS
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +" ).getJSClass()",
+ E_JSCLASS,
+ javaval.jsclass );
+*/
+ // Check the JavaClass, which should be the same as the result as Class.forName(description).
+ testcases[testcases.length] = new TestCase( SECTION,
+ "("+testval.description +").getClass().equals( " +
+ "java.lang.Class.forName( '" + testval.classname +
+ "' ) )",
+ true,
+ (javaval.javaclass).equals( testval.javaclass ) );
+ // check the string value
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "("+testval.description+") +''",
+ testval.stringval,
+ javaval.value +"" );
+}
+function JavaValue( value ) {
+ this.type = typeof value;
+ this.value = value;
+// LC2 does not support the __proto__ property in Java objects
+// Object.prototype.toString will show its JavaScript wrapper object.
+// value.__proto__.getJSClass = Object.prototype.toString;
+// this.jsclass = value.getJSClass();
+ this.javaclass = value.getClass();
+
+ return this;
+}
+function TestValue( description, type, classname, stringval ) {
+ this.description = description;
+ this.type = type;
+ this.classname = classname;
+ this.javaclass = java.lang.Class.forName( classname );
+ this.stringval = stringval;
+
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Methods/method-002.js b/js/tests/lc2/Methods/method-002.js
new file mode 100644
index 00000000000..4c9c68f9a83
--- /dev/null
+++ b/js/tests/lc2/Methods/method-002.js
@@ -0,0 +1,157 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: method-002.js
+ Description:
+
+ Call a method of a JavaObject instance and verify that return value.
+ This is covered more thouroughly in the type conversion test cases.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect Objects";
+ var VERSION = "1_3";
+ var TITLE = "Invoking Java Methods";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // All JavaObjects are of the type "object"
+
+ var E_TYPE = "object";
+
+ // All JavaObjects [[Class]] property is JavaObject
+ var E_JSCLASS = "[object JavaObject]";
+
+ // Create arrays of actual results (java_array) and
+ // expected results (test_array).
+
+ var java_array = new Array();
+ var test_array = new Array();
+
+ var i = 0;
+
+ // method returns an object
+
+ var rect = new java.awt.Rectangle(1,2,3,4);
+ var size = rect.getSize();
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "var size = (new java.awt.Rectangle(1,2,3,4)).getSize(); "+
+ "size.getClass().equals(java.lang.Class.forName(\""+
+ "java.awt.Dimension\"))",
+ true,
+ size.getClass().equals(java.lang.Class.forName("java.awt.Dimension")));
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "size.width",
+ 3,
+ size.width );
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "size.height",
+ 4,
+ size.height );
+
+ // method returns void
+ var r = rect.setSize(5,6);
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "var r = rect.setSize(5,6); r",
+ void 0,
+ r );
+
+ // method returns a string
+
+ var string = new java.lang.String( " hello " );
+ s = string.trim()
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "var string = new java.lang.String(\" hello \"); "+
+ "var s = string.trim(); s.getClass().equals("+
+ "java.lang.Class.forName(\"java.lang.String\")",
+ true,
+ s.getClass().equals(java.lang.Class.forName("java.lang.String")) );
+
+ // method returns an int
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "s.length()",
+ 5,
+ s.length() );
+
+ test();
+
+function CompareValues( javaval, testval ) {
+ // Check type, which should be E_TYPE
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +" )",
+ testval.type,
+ javaval.type );
+
+ // Check JavaScript class, which should be E_JSCLASS
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +" ).getJSClass()",
+ testval.jsclass,
+ javaval.jsclass );
+ // Check the JavaClass, which should be the same as the result as Class.forName(description).
+ testcases[testcases.length] = new TestCase( SECTION,
+ testval.description +".getClass().equals( " +
+ "java.lang.Class.forName( '" + testval.classname +
+ "' ) )",
+ true,
+ javaval.javaclass.equals( testval.javaclass ) );
+}
+function JavaValue( value ) {
+ this.type = typeof value;
+ // Object.prototype.toString will show its JavaScript wrapper object.
+ value.__proto__.getJSClass = Object.prototype.toString;
+ this.jsclass = value.getJSClass();
+ this.javaclass = value.getClass();
+ return this;
+}
+function TestValue( description, classname ) {
+ this.description = description;
+ this.classname = classname;
+ this.type = E_TYPE;
+ this.jsclass = E_JSCLASS;
+ this.javaclass = java.lang.Class.forName( classname );
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Methods/method-003.js b/js/tests/lc2/Methods/method-003.js
new file mode 100644
index 00000000000..e6bd970edde
--- /dev/null
+++ b/js/tests/lc2/Methods/method-003.js
@@ -0,0 +1,101 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: method-003.js
+ Description:
+
+ JavaMethod objects are of the type "function" since they implement the
+ [[Call]] method.
+
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect Objects";
+ var VERSION = "1_3";
+ var TITLE = "Type and Class of Java Methods";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // All JavaMethods are of the type "function"
+ var E_TYPE = "function";
+
+ // All JavaMethods [[Class]] property is Function
+ var E_JSCLASS = "[object Function]";
+
+ // Create arrays of actual results (java_array) and
+ // expected results (test_array).
+
+ var java_array = new Array();
+ var test_array = new Array();
+
+ var i = 0;
+
+ java_array[i] = new JavaValue( java.lang.System.out.println );
+ test_array[i] = new TestValue( "java.lang.System.out.println" );
+ i++;
+
+ for ( i = 0; i < java_array.length; i++ ) {
+ CompareValues( java_array[i], test_array[i] );
+ }
+
+ test();
+
+function CompareValues( javaval, testval ) {
+ // Check type, which should be E_TYPE
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +" )",
+ testval.type,
+ javaval.type );
+
+ // Check JavaScript class, which should be E_JSCLASS
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +" ).getJSClass()",
+ testval.jsclass,
+ javaval.jsclass );
+}
+function JavaValue( value ) {
+ this.type = typeof value;
+ // Object.prototype.toString will show its JavaScript wrapper object.
+ value.getJSClass = Object.prototype.toString;
+ this.jsclass = value.getJSClass();
+ return this;
+}
+function TestValue( description ) {
+ this.description = description;
+ this.type = E_TYPE;
+ this.jsclass = E_JSCLASS;
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Methods/method-004-n.js b/js/tests/lc2/Methods/method-004-n.js
new file mode 100644
index 00000000000..9e8ec6a308b
--- /dev/null
+++ b/js/tests/lc2/Methods/method-004-n.js
@@ -0,0 +1,60 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: method-004-n.js
+ Description:
+
+ Passing arguments of the wrong type, or the wrong number of arguments,
+ should cause a runtime error.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect Objects";
+ var VERSION = "1_3";
+ var TITLE = "Passing bad arguments to a method";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var string = new java.lang.String("");
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "var string = new java.lang.String(\"\"); string.charAt(\"foo\")",
+ "error",
+ string.charAt("foo") );
+
+ test();
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Methods/method-005.js b/js/tests/lc2/Methods/method-005.js
new file mode 100644
index 00000000000..b3f6dbfc99a
--- /dev/null
+++ b/js/tests/lc2/Methods/method-005.js
@@ -0,0 +1,87 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: method-005.js
+ Description:
+
+ Assigning a Java method to a JavaScript object should not change the
+ context associated with the Java method -- its this object should
+ be the Java object, not the JavaScript object.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect Objects";
+ var VERSION = "1_3";
+ var TITLE = "Assigning a Static Java Method to a JavaScript object";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var java_string = new java.lang.String("LiveConnect");
+ var js_string = "JavaScript";
+
+ js_string.startsWith = java_string.startsWith;
+/*
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "var java_string = new java.lang.String(\"LiveConnect\");" +
+ "var js_string = \"JavaScript\"" +
+ "js_string.startsWith = java_string.startsWith"+
+ "js_string.startsWith(\"J\")",
+ false,
+ js_string.startsWith("J") );
+*/
+ var mo = new MyObject();
+
+ var c = mo.classForName( "java.lang.String" );
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "var mo = new MyObject(); "+
+ "var c = mo.classForName(\"java.lang.String\");" +
+ "c.equals(java.lang.Class.forName(\"java.lang.String\))",
+ true,
+ c.equals(java.lang.Class.forName("java.lang.String")) );
+
+
+
+ test();
+
+function MyObject() {
+ this.println = java.lang.System.out.println;
+ this.classForName = java.lang.Class.forName;
+ return this;
+}
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Methods/method-006-n.js b/js/tests/lc2/Methods/method-006-n.js
new file mode 100644
index 00000000000..7749d1928f8
--- /dev/null
+++ b/js/tests/lc2/Methods/method-006-n.js
@@ -0,0 +1,75 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: method-006-n.js
+ Description:
+
+ Assigning a Java method to a JavaScript object should not change the
+ context associated with the Java method -- its this object should
+ be the Java object, not the JavaScript object.
+
+ That is from Flanagan. In practice, this fails all implementations.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect Objects";
+ var VERSION = "1_3";
+ var TITLE = "Assigning a Non-Static Java Method to a JavaScript Object";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var java_string = new java.lang.String("LiveConnect");
+ var js_string = "JavaScript";
+
+ js_string.startsWith = java_string.startsWith;
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "var java_string = new java.lang.String(\"LiveConnect\");" +
+ "var js_string = \"JavaScript\"" +
+ "js_string.startsWith = java_string.startsWith"+
+ "js_string.startsWith(\"J\")",
+ false,
+ js_string.startsWith("J") );
+
+ test();
+
+function MyObject() {
+ this.println = java.lang.System.out.println;
+ this.classForName = java.lang.Class.forName;
+ return this;
+}
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Methods/println-001.js b/js/tests/lc2/Methods/println-001.js
new file mode 100644
index 00000000000..6f97dc72af6
--- /dev/null
+++ b/js/tests/lc2/Methods/println-001.js
@@ -0,0 +1,62 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: println-001.js
+ Section: LiveConnect
+ Description:
+
+ Regression test for
+ http://scopus.mcom.com/bugsplat/show_bug.cgi?id=114820
+
+ Verify that java.lang.System.out.println does not cause an error.
+ Not sure how to get to the error any other way.
+
+ Author: christine@netscape.com
+ Date: 12 november 1997
+*/
+ var SECTION = "println-001.js";
+ var VERSION = "JS1_3";
+ var TITLE = "java.lang.System.out.println";
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = new Array();
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "java.lang.System.out.println( \"output from test live/Methods/println-001.js\")",
+ void 0,
+ java.lang.System.out.println( "output from test live/Methods/println-001.js" ) );
+
+ test();
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Objects/object-001.js b/js/tests/lc2/Objects/object-001.js
new file mode 100644
index 00000000000..a1bbd9edb72
--- /dev/null
+++ b/js/tests/lc2/Objects/object-001.js
@@ -0,0 +1,160 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: object-001.js
+ Description:
+
+ Given a JavaObject, calling the getClass() method of java.lang.Object
+ should return the java.lang.Class of that object.
+
+ To test this:
+
+ 1. Create a JavaObject by instantiating a new object OR call
+ a java method that returns a JavaObject.
+
+ 2. Call getClass() on that object. Compare it to the result of
+ java.lang.Class.forName( "" ).
+
+ 3. Also compare the result of getClass() to the literal classname
+
+ Note: this test does not use the LiveConnect getClass function, which
+ currently is not available.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect Objects";
+ var VERSION = "1_3";
+ var TITLE = "Getting the Class of JavaObjects";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // All JavaObjects are of the type "object"
+
+ var E_TYPE = "object";
+
+ // All JavaObjects [[Class]] property is JavaObject
+ var E_JSCLASS = "[object JavaObject]";
+
+ // Create arrays of actual results (java_array) and
+ // expected results (test_array).
+
+ var java_array = new Array();
+ var test_array = new Array();
+
+ var i = 0;
+
+ java_array[i] = new JavaValue( new java.awt.Rectangle(1,2,3,4) );
+ test_array[i] = new TestValue( "new java.awt.Rectangle(1,2,3,4)", "java.awt.Rectangle" );
+ i++;
+
+ java_array[i] = new JavaValue( new java.io.PrintStream( java.lang.System.out ) );
+ test_array[i] = new TestValue( "new java.io.PrintStream(java.lang.System.out)", "java.io.PrintStream" );
+ i++;
+
+ java_array[i] = new JavaValue( new java.lang.String("hello") );
+ test_array[i] = new TestValue( "new java.lang.String('hello')", "java.lang.String" );
+ i++;
+
+ java_array[i] = new JavaValue( new java.net.URL("http://home.netscape.com/") );
+ test_array[i] = new TestValue( "new java.net.URL('http://home.netscape.com')", "java.net.URL" );
+ i++;
+
+/*
+ java_array[i] = new JavaValue( java.rmi.RMISecurityManager );
+ test_array[i] = new TestValue( "java.rmi.RMISecurityManager" );
+ i++;
+ java_array[i] = new JavaValue( java.text.DateFormat );
+ test_array[i] = new TestValue( "java.text.DateFormat" );
+ i++;
+*/
+ java_array[i] = new JavaValue( new java.util.Vector() );
+ test_array[i] = new TestValue( "new java.util.Vector()", "java.util.Vector" );
+ i++;
+
+/*
+ java_array[i] = new JavaValue( new Packages.com.netscape.javascript.Context() );
+ test_array[i] = new TestValue( "new Packages.com.netscape.javascript.Context()", "com.netscape.javascript.Context" );
+ i++;
+
+ java_array[i] = new JavaValue( Packages.com.netscape.javascript.examples.Shell );
+ test_array[i] = new TestValue( "Packages.com.netscape.javascript.examples.Shell" );
+ i++;
+*/
+
+ for ( i = 0; i < java_array.length; i++ ) {
+ CompareValues( java_array[i], test_array[i] );
+ }
+
+ test();
+
+function CompareValues( javaval, testval ) {
+ // Check type, which should be E_TYPE
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +" )",
+ testval.type,
+ javaval.type );
+/*
+ // Check JavaScript class, which should be E_JSCLASS
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +" ).getJSClass()",
+ testval.jsclass,
+ javaval.jsclass );
+*/
+ // Check the JavaClass, which should be the same as the result as Class.forName(description).
+ testcases[testcases.length] = new TestCase( SECTION,
+ testval.description +".getClass().equals( " +
+ "java.lang.Class.forName( '" + testval.classname +
+ "' ) )",
+ true,
+ javaval.javaclass.equals( testval.javaclass ) );
+}
+function JavaValue( value ) {
+ this.type = typeof value;
+// LC2 does not support the __proto__ property in Java objects
+ // Object.prototype.toString will show its JavaScript wrapper object.
+// value.__proto__.getJSClass = Object.prototype.toString;
+// this.jsclass = value.getJSClass();
+ this.javaclass = value.getClass();
+ return this;
+}
+function TestValue( description, classname ) {
+ this.description = description;
+ this.classname = classname;
+ this.type = E_TYPE;
+ this.jsclass = E_JSCLASS;
+ this.javaclass = java.lang.Class.forName( classname );
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Objects/object-002.js b/js/tests/lc2/Objects/object-002.js
new file mode 100644
index 00000000000..61efac88786
--- /dev/null
+++ b/js/tests/lc2/Objects/object-002.js
@@ -0,0 +1,159 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: object-002.js
+ Description:
+
+ Given a JavaObject, calling the getClass() method of java.lang.Object
+ should return the java.lang.Class of that object.
+
+ This tests the LiveConnect function getClass( ), which
+ should be a defined function that returns the JavaClass object for
+ a JavaObject instance.
+
+ The absense of the getClass function is
+ http://scopus/bugsplat/show_bug.cgi?id=106560
+
+ To test this:
+
+ 1. Create a JavaObject by instantiating a new object OR call
+ a java method that returns a JavaObject.
+
+ 2. Call the getClass() function with the object as its argument.
+
+ 3. Compare the result of 2 to the Class.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect Objects";
+ var VERSION = "1_3";
+ var TITLE = "Getting the Class of JavaObjects";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // All JavaObjects are of the type "object"
+
+ var E_TYPE = "object";
+
+ // All JavaObjects [[Class]] property is JavaObject
+ var E_JSCLASS = "[object JavaObject]";
+
+ // Create arrays of actual results (java_array) and
+ // expected results (test_array).
+
+ var java_array = new Array();
+ var test_array = new Array();
+
+ var i = 0;
+
+ java_array[i] = new JavaValue( new java.awt.Rectangle(1,2,3,4) );
+ test_array[i] = new TestValue( "new java.awt.Rectangle(1,2,3,4)", "java.awt.Rectangle" );
+ i++;
+
+ java_array[i] = new JavaValue( new java.io.PrintStream( java.lang.System.out ) );
+ test_array[i] = new TestValue( "new java.io.PrintStream(java.lang.System.out)", "java.io.PrintStream" );
+ i++;
+
+ java_array[i] = new JavaValue( new java.lang.String("hello") );
+ test_array[i] = new TestValue( "new java.lang.String('hello')", "java.lang.String" );
+ i++;
+
+ java_array[i] = new JavaValue( new java.net.URL("http://home.netscape.com/") );
+ test_array[i] = new TestValue( "new java.net.URL('http://home.netscape.com')", "java.net.URL" );
+ i++;
+
+/*
+ java_array[i] = new JavaValue( java.rmi.RMISecurityManager );
+ test_array[i] = new TestValue( "java.rmi.RMISecurityManager" );
+ i++;
+ java_array[i] = new JavaValue( java.text.DateFormat );
+ test_array[i] = new TestValue( "java.text.DateFormat" );
+ i++;
+*/
+ java_array[i] = new JavaValue( new java.util.Vector() );
+ test_array[i] = new TestValue( "new java.util.Vector()", "java.util.Vector" );
+ i++;
+
+/*
+ java_array[i] = new JavaValue( new Packages.com.netscape.javascript.Context() );
+ test_array[i] = new TestValue( "new Packages.com.netscape.javascript.Context()", "com.netscape.javascript.Context" );
+ i++;
+
+*/
+ for ( i = 0; i < java_array.length; i++ ) {
+ CompareValues( java_array[i], test_array[i] );
+ }
+
+ test();
+
+function CompareValues( javaval, testval ) {
+ // Check type, which should be E_TYPE
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +" )",
+ testval.type,
+ javaval.type );
+/*
+ // Check JavaScript class, which should be E_JSCLASS
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +" ).getJSClass()",
+ testval.jsclass,
+ javaval.jsclass );
+*/
+ // Check the JavaClass, which should be the same as the result as Class.forName(description).
+ testcases[testcases.length] = new TestCase( SECTION,
+ testval.description +".getClass().equals( " +
+ "java.lang.Class.forName( '" + testval.classname +
+ "' ) )",
+ true,
+ javaval.javaclass.equals( testval.javaclass ) );
+}
+function JavaValue( value ) {
+ this.type = typeof value;
+// LC2 does not support the __proto__ property in Java objects
+ // Object.prototype.toString will show its JavaScript wrapper object.
+// value.__proto__.getJSClass = Object.prototype.toString;
+// this.jsclass = value.getJSClass();
+ this.javaclass = value.getClass();
+ return this;
+}
+function TestValue( description, classname ) {
+ this.description = description;
+ this.classname = classname;
+ this.type = E_TYPE;
+ this.jsclass = E_JSCLASS;
+ this.javaclass = java.lang.Class.forName( classname );
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Objects/object-003.js b/js/tests/lc2/Objects/object-003.js
new file mode 100644
index 00000000000..4bcd81ca80a
--- /dev/null
+++ b/js/tests/lc2/Objects/object-003.js
@@ -0,0 +1,72 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: object-003.js
+ Description:
+
+ Getting and Setting Java Object properties by index value.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect Objects";
+ var VERSION = "1_3";
+ var TITLE = "Getting and setting JavaObject properties by index value";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var vector = new java.util.Vector();
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "var vector = new java.util.Vector(); vector.addElement(\"hi\")",
+ void 0,
+ vector.addElement("hi") );
+
+ test();
+
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
+function EnumerateJavaObject( javaobject ) {
+ var properties = new Array();
+ for ( var p in javaobject ) {
+ properties[properties.length] = new Property( p, javaobject[p] );
+ }
+ return properties;
+}
+function Property( name, value ) {
+ this.name = name;
+ this.value = value;
+}
+
diff --git a/js/tests/lc2/Objects/object-004.js b/js/tests/lc2/Objects/object-004.js
new file mode 100644
index 00000000000..ed9aaa3725c
--- /dev/null
+++ b/js/tests/lc2/Objects/object-004.js
@@ -0,0 +1,77 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: object-004.js
+ Description:
+
+ Getting and Setting Java Object properties by index value.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect Objects";
+ var VERSION = "1_3";
+ var TITLE = "Getting and setting JavaObject properties by index value";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var vector = new java.util.Vector();
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "var vector = new java.util.Vector(); vector.addElement(\"hi\")",
+ void 0,
+ vector.addElement("hi") );
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "vector.elementAt(0) +''",
+ "hi",
+ vector.elementAt(0)+"" );
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "vector.setElementAt( \"hello\", 0)",
+ void 0,
+ vector.setElementAt( "hello", 0) );
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "vector.elementAt(0) +''",
+ "hello",
+ vector.elementAt(0)+"" );
+
+ test();
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Objects/object-005.js b/js/tests/lc2/Objects/object-005.js
new file mode 100644
index 00000000000..a50a17a866b
--- /dev/null
+++ b/js/tests/lc2/Objects/object-005.js
@@ -0,0 +1,120 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: object-005.js
+ Description:
+
+ Call ToNumber, ToString, and use the addition operator to
+ access the DefaultValue with hints Number, String, and no
+ hint (respectively).
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect Objects";
+ var VERSION = "1_3";
+ var TITLE = "Getting the Class of JavaObjects";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var a = new Array();
+ var i = 0;
+
+ // here's an object that should be converted to a number
+ a[i++] = new TestObject( "new java.lang.Integer(999)",
+ new java.lang.Integer(999), "Number", 999, "number" );
+
+ a[i++] = new TestObject(
+ "new java.lang.Float(999.0)",
+ new java.lang.Float(999.0),
+ "Number",
+ 999,
+ "number" );
+
+ a[i++] = new TestObject(
+ "new java.lang.String(\"hi\")",
+ new java.lang.String("hi"),
+ "String",
+ "hi",
+ "string" );
+
+ a[i++] = new TestObject(
+ "new java.lang.Integer(2134)",
+ new java.lang.Integer(2134),
+ "0 + ",
+ "21340",
+ "string" );
+
+ a[i++] = new TestObject(
+ "new java.lang.Integer(666)",
+ new java.lang.Integer(666),
+ "Boolean",
+ true,
+ "boolean" );
+
+ for ( i = 0; i < a.length; i++ ) {
+ CompareValues( a[i] );
+ }
+
+ test();
+
+function CompareValues( t ) {
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ t.converter +"("+ t.description +")",
+ t.expect,
+ t.actual );
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "typeof (" + t.converter +"( "+ t.description +" ) )",
+ t.type,
+ typeof t.actual );
+}
+function TestObject( description, javaobject, converter, expect, type ) {
+ this.description = description;
+ this.javavalue = javaobject
+ this.converter = converter;
+ this.expect = expect;
+ this.type = type;
+
+ switch ( converter ) {
+ case( "Number" ) : this.actual = Number( javaobject ); break;
+ case( "String" ) : this.actual = String( javaobject ); break;
+ case( "Boolean") : this.actual = Boolean(javaobject ); break;
+ default: this.actual = javaobject + 0;
+ }
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Objects/object-006.js b/js/tests/lc2/Objects/object-006.js
new file mode 100644
index 00000000000..661c2577e88
--- /dev/null
+++ b/js/tests/lc2/Objects/object-006.js
@@ -0,0 +1,67 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: object-006.js
+ Description:
+
+ Attempt to construct a java.lang.Character. currently this fails because of
+ http://scopus/bugsplat/show_bug.cgi?id=106464
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+
+ var SECTION = "LiveConnect Objects";
+ var VERSION = "1_3";
+ var TITLE = "Construct a java.lang.Character";
+
+ var testcases = new Array();
+
+ var error = err;
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ testcases[testcases.length] = new TestCase (
+ SECTION,
+ "var string = new java.lang.String(\"hi\"); "+
+ "var c = new java.lang.Character(string.charAt(0)); String(c.toString())",
+ "h",
+ "" )
+
+ var string = new java.lang.String("hi");
+ var c = new java.lang.Character( string.charAt(0) );
+
+ testcases[0].actual = String(c.toString());
+
+ test();
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Packages/package-001.js b/js/tests/lc2/Packages/package-001.js
new file mode 100644
index 00000000000..3de68fae65f
--- /dev/null
+++ b/js/tests/lc2/Packages/package-001.js
@@ -0,0 +1,148 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: package-001.js
+ Description:
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect Packages";
+ var VERSION = "1_3";
+ var TITLE = "LiveConnect Packages";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // All packages are of the type "object"
+ var E_TYPE = "object";
+
+ // The JavaScript [[Class]] property for all Packages is "[JavaPackage ]"
+ var E_JSCLASS = "[JavaPackage ";
+
+ // Create arrays of actual results (java_array) and
+ // expected results (test_array).
+
+ var java_array = new Array();
+ var test_array = new Array();
+
+ var i = 0;
+
+ java_array[i] = new JavaValue( java );
+ test_array[i] = new TestValue( "java" );
+ i++;
+
+ java_array[i] = new JavaValue( java.awt );
+ test_array[i] = new TestValue( "java.awt" );
+ i++;
+
+ java_array[i] = new JavaValue( java.beans );
+ test_array[i] = new TestValue( "java.beans" );
+ i++;
+
+ java_array[i] = new JavaValue( java.io );
+ test_array[i] = new TestValue( "java.io" );
+ i++;
+
+ java_array[i] = new JavaValue( java.lang );
+ test_array[i] = new TestValue( "java.lang" );
+ i++;
+
+ java_array[i] = new JavaValue( java.math );
+ test_array[i] = new TestValue( "java.math" );
+ i++;
+
+ java_array[i] = new JavaValue( java.net );
+ test_array[i] = new TestValue( "java.net" );
+ i++;
+
+ java_array[i] = new JavaValue( java.rmi );
+ test_array[i] = new TestValue( "java.rmi" );
+ i++;
+
+ java_array[i] = new JavaValue( java.text );
+ test_array[i] = new TestValue( "java.text" );
+ i++;
+
+ java_array[i] = new JavaValue( java.util );
+ test_array[i] = new TestValue( "java.util" );
+ i++;
+
+ java_array[i] = new JavaValue( Packages.javax );
+ test_array[i] = new TestValue( "Packages.javax" );
+ i++;
+
+ java_array[i] = new JavaValue( Packages.javax.javascript );
+ test_array[i] = new TestValue( "Packages.javax.javascript" );
+ i++;
+
+ java_array[i] = new JavaValue( Packages.javax.javascript.examples );
+ test_array[i] = new TestValue( "Packages.javax.javascript.examples" );
+ i++;
+
+ for ( i = 0; i < java_array.length; i++ ) {
+ CompareValues( java_array[i], test_array[i] );
+
+ }
+
+ test();
+function CompareValues( javaval, testval ) {
+ // Check typeof, which should be E_TYPE
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +")",
+ testval.type,
+ javaval.type );
+
+ // Check JavaScript class, which should be E_JSCLASS + the package name
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +").getJSClass()",
+ testval.jsclass,
+ javaval.jsclass );
+}
+function JavaValue( value ) {
+ this.value = value;
+ this.type = typeof value;
+ this.jsclass = value +""
+ return this;
+}
+function TestValue( description ) {
+ this.packagename = (description.substring(0, "Packages.".length) ==
+ "Packages.") ? description.substring("Packages.".length, description.length ) :
+ description;
+
+ this.description = description;
+ this.type = E_TYPE;
+ this.jsclass = E_JSCLASS + this.packagename +"]";
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Packages/package-002.js b/js/tests/lc2/Packages/package-002.js
new file mode 100644
index 00000000000..d2162ef7826
--- /dev/null
+++ b/js/tests/lc2/Packages/package-002.js
@@ -0,0 +1,108 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: package-001.js
+ Description:
+
+ Use package names that are not in the classpath.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect Packages";
+ var VERSION = "1_3";
+ var TITLE = "LiveConnect Packages";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // All packages are of the type "object"
+ var E_TYPE = "object";
+
+ // The JavaScript [[Class]] property for all Packages is "[JavaPackage ]"
+ var E_JSCLASS = "[JavaPackage ";
+
+ // Create arrays of actual results (java_array) and
+ // expected results (test_array).
+
+ var java_array = new Array();
+ var test_array = new Array();
+
+ var i = 0;
+
+ java_array[i] = new JavaValue( java.bad.packagename );
+ test_array[i] = new TestValue( "java.bad.packagename" );
+ i++;
+
+
+ java_array[i] = new JavaValue( Packages.javax.badpackage );
+ test_array[i] = new TestValue( "Packages.javax.badpackage" );
+ i++;
+
+
+ for ( i = 0; i < java_array.length; i++ ) {
+ CompareValues( java_array[i], test_array[i] );
+
+ }
+
+ test();
+function CompareValues( javaval, testval ) {
+ // Check typeof, which should be E_TYPE
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +")",
+ testval.type,
+ javaval.type );
+
+ // Check JavaScript class, which should be E_JSCLASS + the package name
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +").getJSClass()",
+ testval.jsclass,
+ javaval.jsclass );
+}
+function JavaValue( value ) {
+ this.value = value;
+ this.type = typeof value;
+ this.jsclass = value +""
+ return this;
+}
+function TestValue( description ) {
+ this.packagename = (description.substring(0, "Packages.".length) ==
+ "Packages.") ? description.substring("Packages.".length, description.length ) :
+ description;
+
+ this.description = description;
+ this.type = E_TYPE;
+ this.jsclass = E_JSCLASS + this.packagename +"]";
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Packages/package-003.js b/js/tests/lc2/Packages/package-003.js
new file mode 100644
index 00000000000..d6cab4fac9c
--- /dev/null
+++ b/js/tests/lc2/Packages/package-003.js
@@ -0,0 +1,143 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: package-003.js
+ Description:
+
+ Set the package name to a JavaScript variable, and attempt to access
+ classes relative to the package name.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect Packages";
+ var VERSION = "1_3";
+ var TITLE = "LiveConnect Packages";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ // All packages are of the type "object"
+ var E_TYPE = "object";
+
+ // The JavaScript [[Class]] property for all Packages is "[JavaPackage ]"
+ var E_JSCLASS = "[JavaPackage ";
+
+ // Create arrays of actual results (java_array) and
+ // expected results (test_array).
+
+ var java_array = new Array();
+ var test_array = new Array();
+
+ var i = 0;
+
+ var js = Packages.javax.javascript;
+
+ java_array[i] = new JavaValue( js );
+ test_array[i] = new TestValue( "javax.javascript" );
+ i++;
+
+ var util = java.util;
+
+ java_array[i] = new JavaValue( util );
+ test_array[i] = new TestValue( "java.util" );
+ i++;
+
+ for ( i = 0; i < java_array.length; i++ ) {
+ CompareValues( java_array[i], test_array[i] );
+
+ }
+
+ var v = new util.Vector();
+
+ test();
+
+function CompareValues( javaval, testval ) {
+ // Check typeof, which should be E_TYPE
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +")",
+ testval.type,
+ javaval.type );
+
+ // Check JavaScript class, which should be E_JSCLASS + the package name
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +").getJSClass()",
+ testval.jsclass,
+ javaval.jsclass );
+
+ // Number( package ) is NaN
+ testcases[testcases.length] = new TestCase( SECTION,
+ "Number (" + testval.description +")",
+ NaN,
+ Number( javaval.value ) );
+
+ // String( package ) is string value
+ testcases[testcases.length] = new TestCase( SECTION,
+ "String (" + testval.description +")",
+ testval.jsclass,
+ String(javaval.value) );
+/*
+ // ( package ).toString() is string value
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +").toString()",
+ testval.jsclass,
+ (javaval.value).toString() );
+*/
+ // Boolean( package ) is true
+ testcases[testcases.length] = new TestCase( SECTION,
+ "Boolean (" + testval.description +")",
+ true,
+ Boolean( javaval.value ) );
+ // add 0 is name + "0"
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +") +0",
+ testval.jsclass +"0",
+ javaval.value + 0);
+}
+function JavaValue( value ) {
+ this.value = value;
+ this.type = typeof value;
+ this.jsclass = value +""
+ return this;
+}
+function TestValue( description ) {
+ this.packagename = (description.substring(0, "Packages.".length) ==
+ "Packages.") ? description.substring("Packages.".length, description.length ) :
+ description;
+
+ this.description = description;
+ this.type = E_TYPE;
+ this.jsclass = E_JSCLASS + this.packagename +"]";
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Packages/package-004.js b/js/tests/lc2/Packages/package-004.js
new file mode 100644
index 00000000000..0eba3ee958d
--- /dev/null
+++ b/js/tests/lc2/Packages/package-004.js
@@ -0,0 +1,127 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: package-003.js
+ Description:
+
+ Set the package name to a JavaScript variable, and attempt to access
+ classes relative to the package name.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect Packages";
+ var VERSION = "1_3";
+ var TITLE = "LiveConnect Packages";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var util = java.util;
+ var v = new util.Vector();
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "var v = new util.Vector(); v.size()",
+ 0,
+ v.size() );
+
+ var h = util.Hashcode;
+ var hString = String(h);
+ util.Hashcode = null;
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "util.Hashcode = null; String( util.Hashcode )",
+ hString,
+ String( util.Hashcode ) );
+
+ test();
+
+function CompareValues( javaval, testval ) {
+ // Check typeof, which should be E_TYPE
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +")",
+ testval.type,
+ javaval.type );
+
+ // Check JavaScript class, which should be E_JSCLASS + the package name
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +").getJSClass()",
+ testval.jsclass,
+ javaval.getJSClass() );
+
+ // Number( package ) is NaN
+ testcases[testcases.length] = new TestCase( SECTION,
+ "Number (" + testval.description +")",
+ NaN,
+ Number( javaval ) );
+
+ // String( package ) is string value
+ testcases[testcases.length] = new TestCase( SECTION,
+ "String (" + testval.description +")",
+ testval.jsclass,
+ String(javaval) );
+ // ( package ).toString() is string value
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +").toString()",
+ testval.jsclass,
+ (javaval).toString() );
+
+ // Boolean( package ) is true
+ testcases[testcases.length] = new TestCase( SECTION,
+ "Boolean (" + testval.description +")",
+ true,
+ Boolean( javaval ) );
+ // add 0 is name + "0"
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +") +0",
+ testval.jsclass +"0",
+ javaval + 0);
+}
+function JavaValue( value ) {
+ this.value = value;
+ this.type = typeof value;
+ this.getJSClass = Object.prototype.toString;
+ this.jsclass = value +""
+ return this;
+}
+function TestValue( description ) {
+ this.packagename = (description.substring(0, "Packages.".length) ==
+ "Packages.") ? description.substring("Packages.".length, description.length ) :
+ description;
+
+ this.description = description;
+ this.type = E_TYPE;
+ this.jsclass = E_JSCLASS + this.packagename +"]";
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Packages/package-005.js b/js/tests/lc2/Packages/package-005.js
new file mode 100644
index 00000000000..bfdd7f95585
--- /dev/null
+++ b/js/tests/lc2/Packages/package-005.js
@@ -0,0 +1,124 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: package-005.js
+ Description:
+
+ Access a package property that does not exist.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var error = err;
+ var SECTION = "LiveConnect Packages";
+ var VERSION = "1_3";
+ var TITLE = "LiveConnect Packages";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var util = java.util;
+ var v = new util.Vector();
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "java.util[\"0\"]",
+ void 0,
+ java.util["0"] );
+
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "java.util[1]",
+ void 0,
+ java.util[1] );
+
+ test();
+
+function CompareValues( javaval, testval ) {
+ // Check typeof, which should be E_TYPE
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +")",
+ testval.type,
+ javaval.type );
+
+ // Check JavaScript class, which should be E_JSCLASS + the package name
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +").getJSClass()",
+ testval.jsclass,
+ javaval.getJSClass() );
+
+ // Number( package ) is NaN
+ testcases[testcases.length] = new TestCase( SECTION,
+ "Number (" + testval.description +")",
+ NaN,
+ Number( javaval ) );
+
+ // String( package ) is string value
+ testcases[testcases.length] = new TestCase( SECTION,
+ "String (" + testval.description +")",
+ testval.jsclass,
+ String(javaval) );
+ // ( package ).toString() is string value
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +").toString()",
+ testval.jsclass,
+ (javaval).toString() );
+
+ // Boolean( package ) is true
+ testcases[testcases.length] = new TestCase( SECTION,
+ "Boolean (" + testval.description +")",
+ true,
+ Boolean( javaval ) );
+ // add 0 is name + "0"
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +") +0",
+ testval.jsclass +"0",
+ javaval + 0);
+}
+function JavaValue( value ) {
+ this.value = value;
+ this.type = typeof value;
+ this.getJSClass = Object.prototype.toString;
+ this.jsclass = value +""
+ return this;
+}
+function TestValue( description ) {
+ this.packagename = (description.substring(0, "Packages.".length) ==
+ "Packages.") ? description.substring("Packages.".length, description.length ) :
+ description;
+
+ this.description = description;
+ this.type = E_TYPE;
+ this.jsclass = E_JSCLASS + this.packagename +"]";
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Packages/package-006.js b/js/tests/lc2/Packages/package-006.js
new file mode 100644
index 00000000000..9f619aeba61
--- /dev/null
+++ b/js/tests/lc2/Packages/package-006.js
@@ -0,0 +1,60 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: package-006.js
+ Description:
+
+ Access a package property that does not exist.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var error = err;
+ var SECTION = "LiveConnect Packages";
+ var VERSION = "1_3";
+ var TITLE = "LiveConnect Packages";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var util = java.util;
+ var v = new util.Vector();
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "java.util[1]",
+ void 0,
+ java.util[1] );
+
+ test();
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Packages/package-007-n.js b/js/tests/lc2/Packages/package-007-n.js
new file mode 100644
index 00000000000..5e118671731
--- /dev/null
+++ b/js/tests/lc2/Packages/package-007-n.js
@@ -0,0 +1,118 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: package-003.js
+ Description:
+
+ Set the package name to a JavaScript variable, and attempt to access
+ classes relative to the package name.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect Packages";
+ var VERSION = "1_3";
+ var TITLE = "LiveConnect Packages";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ java.util[0] ="hi";
+ java.util["x"] = "bye";
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "java.util[0] = \"hi\"; typeof java.util[0]",
+ "undefined",
+ typeof java.util[0] );
+
+ test();
+
+function CompareValues( javaval, testval ) {
+ // Check typeof, which should be E_TYPE
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +")",
+ testval.type,
+ javaval.type );
+
+ // Check JavaScript class, which should be E_JSCLASS + the package name
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +").getJSClass()",
+ testval.jsclass,
+ javaval.getJSClass() );
+
+ // Number( package ) is NaN
+ testcases[testcases.length] = new TestCase( SECTION,
+ "Number (" + testval.description +")",
+ NaN,
+ Number( javaval ) );
+
+ // String( package ) is string value
+ testcases[testcases.length] = new TestCase( SECTION,
+ "String (" + testval.description +")",
+ testval.jsclass,
+ String(javaval) );
+ // ( package ).toString() is string value
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +").toString()",
+ testval.jsclass,
+ (javaval).toString() );
+
+ // Boolean( package ) is true
+ testcases[testcases.length] = new TestCase( SECTION,
+ "Boolean (" + testval.description +")",
+ true,
+ Boolean( javaval ) );
+ // add 0 is name + "0"
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +") +0",
+ testval.jsclass +"0",
+ javaval + 0);
+}
+function JavaValue( value ) {
+ this.value = value;
+ this.type = typeof value;
+ this.getJSClass = Object.prototype.toString;
+ this.jsclass = value +""
+ return this;
+}
+function TestValue( description ) {
+ this.packagename = (description.substring(0, "Packages.".length) ==
+ "Packages.") ? description.substring("Packages.".length, description.length ) :
+ description;
+
+ this.description = description;
+ this.type = E_TYPE;
+ this.jsclass = E_JSCLASS + this.packagename +"]";
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Packages/package-008-n.js b/js/tests/lc2/Packages/package-008-n.js
new file mode 100644
index 00000000000..970f52ea42c
--- /dev/null
+++ b/js/tests/lc2/Packages/package-008-n.js
@@ -0,0 +1,117 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: package-003.js
+ Description:
+
+ Set the package name to a JavaScript variable, and attempt to access
+ classes relative to the package name.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect Packages";
+ var VERSION = "1_3";
+ var TITLE = "LiveConnect Packages";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ java.util[0] ="hi";
+ java.util["x"] = "bye";
+
+ testcases[testcases.length] = new TestCase( SECTION,
+ "String(java.util[\"x\"])",
+ "[JavaPackage java.util.x]",
+ String(java.util["x"]) );
+ test();
+
+function CompareValues( javaval, testval ) {
+ // Check typeof, which should be E_TYPE
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof (" + testval.description +")",
+ testval.type,
+ javaval.type );
+
+ // Check JavaScript class, which should be E_JSCLASS + the package name
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +").getJSClass()",
+ testval.jsclass,
+ javaval.getJSClass() );
+
+ // Number( package ) is NaN
+ testcases[testcases.length] = new TestCase( SECTION,
+ "Number (" + testval.description +")",
+ NaN,
+ Number( javaval ) );
+
+ // String( package ) is string value
+ testcases[testcases.length] = new TestCase( SECTION,
+ "String (" + testval.description +")",
+ testval.jsclass,
+ String(javaval) );
+ // ( package ).toString() is string value
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +").toString()",
+ testval.jsclass,
+ (javaval).toString() );
+
+ // Boolean( package ) is true
+ testcases[testcases.length] = new TestCase( SECTION,
+ "Boolean (" + testval.description +")",
+ true,
+ Boolean( javaval ) );
+ // add 0 is name + "0"
+ testcases[testcases.length] = new TestCase( SECTION,
+ "(" + testval.description +") +0",
+ testval.jsclass +"0",
+ javaval + 0);
+}
+function JavaValue( value ) {
+ this.value = value;
+ this.type = typeof value;
+ this.getJSClass = Object.prototype.toString;
+ this.jsclass = value +""
+ return this;
+}
+function TestValue( description ) {
+ this.packagename = (description.substring(0, "Packages.".length) ==
+ "Packages.") ? description.substring("Packages.".length, description.length ) :
+ description;
+
+ this.description = description;
+ this.type = E_TYPE;
+ this.jsclass = E_JSCLASS + this.packagename +"]";
+ return this;
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/Protected/variable-001-n.js b/js/tests/lc2/Protected/variable-001-n.js
new file mode 100644
index 00000000000..661c7862b9f
--- /dev/null
+++ b/js/tests/lc2/Protected/variable-001-n.js
@@ -0,0 +1,78 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: variable-001-n.js
+ Description:
+
+ Attempt to access a protected variable should fail.
+
+ In LiveConnect v 1, it failed silently, and accessing a protected
+ member returned undefined.
+
+ In LiveConnect v 2, it fails with the same error that occurs when
+ referring to a method or field that does not exist.
+
+ @author christine@netscape.com
+ @version 1.00
+*/
+ var SECTION = "LiveConnect Objects";
+ var VERSION = "1_3";
+ var TITLE = "Accessing protected variables";
+
+ var testcases = new Array();
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var vector = new java.util.Vector();
+ vector.addElement("hi");
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "var vector = new java.util.Vector(); vector.addElement(\"hi\"); String(vector.elementAt(0))",
+ "hi",
+ String(vector.elementAt(0)) );
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "Number(vector.size())",
+ 1,
+ Number(vector.size()) );
+
+ testcases[testcases.length] = new TestCase(
+ SECTION,
+ "vector.elementCount",
+ void 0,
+ vector.elementCount );
+
+ test();
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/browser.js b/js/tests/lc2/browser.js
new file mode 100644
index 00000000000..8804b3cf218
--- /dev/null
+++ b/js/tests/lc2/browser.js
@@ -0,0 +1,142 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+var completed = false;
+var testcases;
+
+
+SECTION = "";
+VERSION = "";
+BUGNUMBER = "";
+DEBUG = false;
+TZ_DIFF = -8;
+
+var GLOBAL = "[object Window]";
+
+var HTML_OUTPUT = false;
+
+function TestCase( n, d, e, a ) {
+ this.name = n;
+ this.description = d;
+ this.expect = e;
+ this.actual = a;
+ this.reason = "";
+ this.bugnumber = BUGNUMBER;
+
+ this.passed = getTestCaseResult( this.expect, this.actual );
+
+}
+function startTest() {
+// document.open();
+}
+function getTestCaseResult( expect, actual ) {
+ // because ( NaN == NaN ) always returns false, need to do
+ // a special compare to see if we got the right result.
+
+ if ( actual != actual ) {
+ if ( typeof actual == "object" ) {
+ actual = "NaN object";
+ } else {
+ actual = "NaN number";
+ }
+ }
+
+ if ( expect != expect ) {
+ if ( typeof expect == "object" ) {
+ expect = "NaN object";
+ } else {
+ expect = "NaN number";
+ }
+ }
+
+ var passed = ( expect == actual ) ? true : false;
+
+ // if both objects are numbers, give a little leeway for rounding.
+ if ( !passed
+ && typeof(actual) == "number"
+ && typeof(expect) == "number"
+ ) {
+ if ( Math.abs(actual-expect) < 0.0000001 ) {
+ passed = true;
+ }
+ }
+
+ // verify type is the same
+ if ( typeof(expect) != typeof(actual) ) {
+ passed = false;
+ }
+
+ return passed;
+}
+
+function writeTestCaseResult( expect, actual, string ) {
+ var passed = getTestCaseResult( expect, actual );
+ writeFormattedResult( expect, actual, string, passed );
+ return passed;
+}
+function writeFormattedResult( expect, actual, string, passed ) {
+ var s = "" + string ;
+
+ for ( k = 0;
+ k < (60 - string.length >= 0 ? 60 - string.length : 5) ;
+ k++ ) {
+ s += " " ;
+ }
+
+ s += " PASSED!"
+ : "'#990000' > FAILED: expected " +
+ expect ) + "";
+
+ writeLineToLog( s + "" );
+
+ return passed;
+}
+function writeLineToLog( string ) {
+ document.write( string + "
\n" );
+}
+function writeHeaderToLog( string ) {
+ document.write( "" + string + "
\n" );
+}
+function stopTest() {
+// document.write("
");
+// document.close();
+ completed = true;
+}
+
+function ToInteger( t ) {
+ t = Number( t );
+
+ if ( isNaN( t ) ){
+ return ( Number.NaN );
+ }
+ if ( t == 0 || t == -0 ||
+ t == Number.POSITIVE_INFINITY || t == Number.NEGATIVE_INFINITY ) {
+ return 0;
+ }
+
+ var sign = ( t < 0 ) ? -1 : 1;
+
+ return ( sign * Math.floor( Math.abs( t ) ) );
+}
+function Enumerate ( o ) {
+ var p;
+ for ( p in o ) {
+ print( p +": " + o[p] );
+ }
+}
diff --git a/js/tests/lc2/jsref.js b/js/tests/lc2/jsref.js
new file mode 100644
index 00000000000..9acd3217dda
--- /dev/null
+++ b/js/tests/lc2/jsref.js
@@ -0,0 +1,171 @@
+var completed = false;
+var testcases;
+
+SECTION = "";
+VERSION = "";
+
+BUGNUMBER="";
+EXCLUDE = "";
+
+var TT = "";
+var TT_ = "";
+var BR = "";
+var NBSP = " ";
+var CR = "\n";
+var FONT = "";
+var FONT_ = "";
+var FONT_RED = "";
+var FONT_GREEN = "";
+var B = "";
+var B_ = ""
+var H2 = "";
+var H2_ = "";
+var HR = "";
+
+// version("130");
+
+var PASSED = " PASSED!"
+var FAILED = " FAILED! expected: ";
+
+function TestCase( n, d, e, a ) {
+ this.name = n;
+ this.description = d;
+ this.expect = e;
+ this.actual = a;
+ this.passed = true;
+ this.reason = "";
+ this.bugnumber = BUGNUMBER;
+
+ this.passed = getTestCaseResult( this.expect, this.actual );
+}
+function startTest() {
+ // JavaScript 1.3 is supposed to be compliant ecma version 1.0
+ if ( VERSION == "ECMA_1" ) {
+ version ( "130" );
+ }
+ if ( VERSION == "JS_1.3" ) {
+ version ( "130" );
+ }
+ if ( VERSION == "JS_1.2" ) {
+ version ( "120" );
+ }
+ if ( VERSION == "JS_1.1" ) {
+ version ( "110" );
+ }
+ // for ecma version 2.0, we will leave the javascript version to
+ // the default ( for now ).
+}
+function getTestCaseResult( expect, actual ) {
+ // because ( NaN == NaN ) always returns false, need to do
+ // a special compare to see if we got the right result.
+ if ( actual != actual ) {
+ if ( typeof actual == "object" ) {
+ actual = "NaN object";
+ } else {
+ actual = "NaN number";
+ }
+ }
+ if ( expect != expect ) {
+ if ( typeof expect == "object" ) {
+ expect = "NaN object";
+ } else {
+ expect = "NaN number";
+ }
+ }
+
+ var passed = ( expect == actual ) ? true : false;
+
+ // if both objects are numbers
+ // need to replace w/ IEEE standard for rounding
+ if ( !passed
+ && typeof(actual) == "number"
+ && typeof(expect) == "number"
+ ) {
+ if ( Math.abs(actual-expect) < 0.0000001 ) {
+ passed = true;
+ }
+ }
+
+ // verify type is the same
+ if ( typeof(expect) != typeof(actual) ) {
+ passed = false;
+ }
+
+ return passed;
+}
+function writeTestCaseResult( expect, actual, string ) {
+ var passed = getTestCaseResult( expect, actual );
+ writeFormattedResult( expect, actual, string, passed );
+ return passed;
+}
+function writeFormattedResult( expect, actual, string, passed ) {
+ var s = TT + string ;
+
+ for ( k = 0;
+ k < (60 - string.length >= 0 ? 60 - string.length : 5) ;
+ k++ ) {
+// s += NBSP;
+ }
+
+ s += B ;
+ s += ( passed ) ? FONT_GREEN + NBSP + PASSED : FONT_RED + NBSP + FAILED + expect + TT_ ;
+
+ writeLineToLog( s + FONT_ + B_ + TT_ );
+
+ return passed;
+}
+
+function writeLineToLog( string ) {
+ print( string + BR + CR );
+}
+function writeHeaderToLog( string ) {
+ print( H2 + string + H2_ );
+}
+function stopTest()
+{
+ var sizeTag = "<#TEST CASES SIZE>";
+ var doneTag = "<#TEST CASES DONE>";
+ var beginTag = "<#TEST CASE ";
+ var endTag = ">";
+
+ print(sizeTag);
+ print(testcases.length);
+ for (tc = 0; tc < testcases.length; tc++)
+ {
+ print(beginTag + 'PASSED' + endTag);
+ print(testcases[tc].passed);
+ print(beginTag + 'NAME' + endTag);
+ print(testcases[tc].name);
+ print(beginTag + 'EXPECTED' + endTag);
+ print(testcases[tc].expect);
+ print(beginTag + 'ACTUAL' + endTag);
+ print(testcases[tc].actual);
+ print(beginTag + 'DESCRIPTION' + endTag);
+ print(testcases[tc].description);
+ print(beginTag + 'REASON' + endTag);
+ print(( testcases[tc].passed ) ? "" : "wrong value ");
+ print(beginTag + 'BUGNUMBER' + endTag);
+ print( BUGNUMBER );
+ }
+ print(doneTag);
+
+ print( HR );
+ gc();
+}
+function getFailedCases() {
+ for ( var i = 0; i < testcases.length; i++ ) {
+ if ( ! testcases[i].passed ) {
+ print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect );
+ }
+ }
+}
+function err( msg, page, line ) {
+ testcases[tc].actual = "error";
+ testcases[tc].reason = msg;
+ writeTestCaseResult( testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+ testcases[tc].actual +
+ ": " + testcases[tc].reason );
+ stopTest();
+ return true;
+}
diff --git a/js/tests/lc2/misc/constructor.js b/js/tests/lc2/misc/constructor.js
new file mode 100644
index 00000000000..4c67f274d7d
--- /dev/null
+++ b/js/tests/lc2/misc/constructor.js
@@ -0,0 +1,97 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ * Tests constructing some Java classes from JS.
+ * Tests constructor matching algorithm.
+ *
+ * this needs to be converted to the new test structure
+ *
+ * @author cbegle and mikeang
+ */
+
+ var SECTION = "wrapUnwrap.js";
+ var VERSION = "JS1_3";
+ var TITLE = "LiveConnect";
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = new Array();
+
+ var char_object = java.lang.Character.forDigit(22, 36);
+ test_typeof( "string", char_object+"a" );
+
+ var boolean_object = new java.lang.Boolean( true );
+ test_class( "java.lang.Boolean", boolean_object );
+
+ var boolean_object = new java.lang.Boolean( false );
+ test_class( "java.lang.Boolean", boolean_object );
+
+ var integer_object = new java.lang.Integer( 12345 );
+ test_class( "java.lang.Integer", integer_object );
+
+ var string_object = new java.lang.String( "string object value" );
+ test_class( "java.lang.String", string_object );
+
+ // This doesn't work - bug #105857
+ var float_object = new java.lang.Float( .009 * .009 );
+ test_class( "java.lang.Float", float_object );
+
+ var double_object = new java.lang.Double( java.lang.Math.PI );
+ test_class( "java.lang.Double", double_object );
+
+ var long_object = new java.lang.Long( 92233720368547760 );
+ test_class( "java.lang.Long", long_object );
+
+ var rect_object = new java.awt.Rectangle( 0, 0, 100, 100 );
+ test_class ( "java.awt.Rectangle", rect_object );
+
+ test();
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
+
+function test_typeof( eType, someObject ) {
+ testcases[testcases.length] = new TestCase( SECTION,
+ "typeof( " +someObject+")",
+ eType,
+ typeof someObject );
+}
+
+/**
+ * Implements Java instanceof keyword.
+ */
+function test_class( eClass, javaObject ) {
+ testcases[testcases.length] = new TestCase( SECTION,
+ javaObject +".getClass().equals( java.lang.Class.forName( " +
+ eClass +")",
+ true,
+ (javaObject.getClass()).equals( java.lang.Class.forName(eClass)) );
+}
\ No newline at end of file
diff --git a/js/tests/lc2/misc/wrapUnwrap.js b/js/tests/lc2/misc/wrapUnwrap.js
new file mode 100644
index 00000000000..f56c7ae1235
--- /dev/null
+++ b/js/tests/lc2/misc/wrapUnwrap.js
@@ -0,0 +1,98 @@
+/* The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ */
+/**
+ File Name: wrapUnwrap.js
+ Section: LiveConnect
+ Description:
+
+ Tests wrapping and unwrapping objects.
+ @author mikeang
+
+*/
+ var SECTION = "wrapUnwrap.js";
+ var VERSION = "JS1_3";
+ var TITLE = "LiveConnect";
+
+ startTest();
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = new Array();
+
+
+ var hashtable = new java.util.Hashtable();
+ var sameHashtable = hashtable;
+
+jsEquals(hashtable,sameHashtable);
+javaEquals(hashtable,sameHashtable);
+
+function returnString(theString) {
+ return theString;
+}
+var someString = new java.lang.String("foo");
+var sameString = returnString(someString);
+jsEquals(someString,sameString);
+javaEquals(someString,sameString);
+
+var assignToProperty = new Object();
+assignToProperty.assignedString = someString;
+jsEquals(someString,assignToProperty.assignedString);
+javaEquals(someString,assignToProperty.assignedString);
+
+function laConstructor(a,b,c) {
+ this.one = a;
+ this.two = b;
+ this.three = c;
+}
+var stack1 = new java.util.Stack();
+var stack2 = new java.util.Stack();
+var num = 28;
+var constructed = new laConstructor(stack1, stack2, num);
+javaEquals(stack1, constructed.one);
+javaEquals(stack2, constructed.two);
+jsEquals(num, constructed.three);
+
+ test();
+
+function jsEquals(expectedResult, actualResult, message) {
+ testcases[testcases.length] = new TestCase( SECTION,
+ expectedResult +" == "+actualResult,
+ expectedResult,
+ actualResult );
+}
+
+function javaEquals(expectedResult, actualResult, message) {
+ testcases[testcases.length] = new TestCase( SECTION,
+ expectedResult +" == "+actualResult,
+ expectedResult,
+ actualResult );
+}
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
diff --git a/js/tests/lc2/shell.js b/js/tests/lc2/shell.js
new file mode 100644
index 00000000000..006f3496a62
--- /dev/null
+++ b/js/tests/lc2/shell.js
@@ -0,0 +1,145 @@
+var completed = false;
+var testcases;
+
+SECTION = "";
+VERSION = "";
+BUGNUMBER="";
+
+var TT = "";
+var TT_ = "";
+var BR = "";
+var NBSP = " ";
+var CR = "\n";
+var FONT = "";
+var FONT_ = "";
+var FONT_RED = "";
+var FONT_GREEN = "";
+var B = "";
+var B_ = ""
+var H2 = "";
+var H2_ = "";
+var HR = "";
+
+// version("130");
+
+var PASSED = " PASSED!"
+var FAILED = " FAILED! expected: ";
+
+function TestCase( n, d, e, a ) {
+ this.name = n;
+ this.description = d;
+ this.expect = e;
+ this.actual = a;
+ this.passed = true;
+ this.reason = "";
+ this.bugnumber = BUGNUMBER;
+
+ this.passed = getTestCaseResult( this.expect, this.actual );
+}
+function startTest() {
+ // JavaScript 1.3 is supposed to be compliant ecma version 1.0
+ if ( VERSION == "ECMA_1" ) {
+ version ( "130" );
+ }
+ if ( VERSION == "JS_1.3" ) {
+ version ( "130" );
+ }
+ if ( VERSION == "JS_1.2" ) {
+ version ( "120" );
+ }
+ if ( VERSION == "JS_1.1" ) {
+ version ( "110" );
+ }
+ // for ecma version 2.0, we will leave the javascript version to
+ // the default ( for now ).
+}
+function getTestCaseResult( expect, actual ) {
+ // because ( NaN == NaN ) always returns false, need to do
+ // a special compare to see if we got the right result.
+ if ( actual != actual ) {
+ if ( typeof actual == "object" ) {
+ actual = "NaN object";
+ } else {
+ actual = "NaN number";
+ }
+ }
+ if ( expect != expect ) {
+ if ( typeof expect == "object" ) {
+ expect = "NaN object";
+ } else {
+ expect = "NaN number";
+ }
+ }
+
+ var passed = ( expect == actual ) ? true : false;
+
+ // if both objects are numbers
+ // need to replace w/ IEEE standard for rounding
+ if ( !passed
+ && typeof(actual) == "number"
+ && typeof(expect) == "number"
+ ) {
+ if ( Math.abs(actual-expect) < 0.0000001 ) {
+ passed = true;
+ }
+ }
+
+ // verify type is the same
+ if ( typeof(expect) != typeof(actual) ) {
+ passed = false;
+ }
+
+ return passed;
+}
+function writeTestCaseResult( expect, actual, string ) {
+ var passed = getTestCaseResult( expect, actual );
+ writeFormattedResult( expect, actual, string, passed );
+ return passed;
+}
+function writeFormattedResult( expect, actual, string, passed ) {
+ var s = TT + string ;
+
+ for ( k = 0;
+ k < (60 - string.length >= 0 ? 60 - string.length : 5) ;
+ k++ ) {
+// s += NBSP;
+ }
+
+ s += B ;
+ s += ( passed ) ? FONT_GREEN + NBSP + PASSED : FONT_RED + NBSP + FAILED + expect + TT_ ;
+
+ writeLineToLog( s + FONT_ + B_ + TT_ );
+
+ return passed;
+}
+
+function writeLineToLog( string ) {
+ print( string + BR + CR );
+}
+function writeHeaderToLog( string ) {
+ print( H2 + string + H2_ );
+}
+function stopTest() {
+ print( HR );
+ var gc;
+ if ( gc != undefined ) {
+ gc();
+ }
+}
+function getFailedCases() {
+ for ( var i = 0; i < testcases.length; i++ ) {
+ if ( ! testcases[i].passed ) {
+ print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect );
+ }
+ }
+}
+function err( msg, page, line ) {
+ testcases[tc].actual = "error";
+ testcases[tc].reason = msg;
+ writeTestCaseResult( testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+ testcases[tc].actual +
+ ": " + testcases[tc].reason );
+ stopTest();
+ return true;
+}