diff --git a/mozilla/js/tests/ecma_2/FunctionObjects/call-1.js b/mozilla/js/tests/ecma_2/FunctionObjects/call-1.js new file mode 100644 index 00000000000..9ea9074752f --- /dev/null +++ b/mozilla/js/tests/ecma_2/FunctionObjects/call-1.js @@ -0,0 +1,40 @@ +/** + File Name: call-1.js + Section: Function.prototype.call + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "call-1"; + var VERSION = "ECMA_2"; + var TITLE = "Function.prototype.call"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + + testcases[tc++] = new TestCase( SECTION, + "ToString.call( this, this )", + GLOBAL, + ToString.call( this, this ) ); + + testcases[tc++] = new TestCase( SECTION, + "ToString.call( Boolean, Boolean.prototype )", + "false", + ToString.call( Boolean, Boolean.prototype ) ); + + testcases[tc++] = new TestCase( SECTION, + "ToString.call( Boolean, Boolean.prototype.valueOf() )", + "false", + ToString.call( Boolean, Boolean.prototype.valueOf() ) ); + + test(); + +function ToString( obj ) { + return obj +""; +} \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ArrayMethods/byte-001.js b/mozilla/js/tests/lc3/ArrayMethods/byte-001.js new file mode 100644 index 00000000000..0fd3eb4aaf1 --- /dev/null +++ b/mozilla/js/tests/lc3/ArrayMethods/byte-001.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. + * + */ +/** + * java array objects "inherit" JS string methods. verify that byte arrays + * can inherit JavaScript Array object methods + * + * + */ + var SECTION = "java array object inheritance JavaScript Array methods"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 " + SECTION; + + startTest(); + + var a = new Array(); + + a[a.length] = new TestObject( + "var b"+a.length+" = new java.lang.String(\"hello\").getBytes(); b"+a.length+".join() +''", + "b"+a.length, + "join", + true, + "104,101,108,108,111" ); + + a[a.length] = new TestObject( + "var b"+a.length+" = new java.lang.String(\"JavaScript\").getBytes(); b"+a.length+".reverse().join() +''", + "b"+a.length, + "reverse", + true, + getCharValues("tpircSavaJ") ); + + a[a.length] = new TestObject( + "var b"+a.length+" = new java.lang.String(\"JavaScript\").getBytes(); b"+a.length+".sort().join() +''", + "b"+a.length, + "sort", + true, + getCharValues("J,S,a,a,c,i,p,r,t,v") ); + + a[a.length] = new TestObject( + "var b"+a.length+" = new java.lang.String(\"JavaScript\").getBytes(); b"+a.length+".sort().join() +''", + "b"+a.length, + "sort", + true, + getCharValues("J,S,a,a,c,i,p,r,t,v") ); + + test(); + + // given a string, return a string consisting of the char value of each + // character in the string, separated by commas + + function getCharValues(string) { + for ( var c = 0, cString = ""; c < string.length; c++ ) { + cString += string.charCodeAt(c) + ((c+1 < string.length) ? "," : ""); + } + return cString; + } + + // figure out what methods exist + // if there is no java method with the same name as a js method, should + // be able to invoke the js method without casting to a js string. also + // the method should equal the same method of String.prototype. + // if there is a java method with the same name as a js method, invoking + // the method should call the java method + + function TestObject( description, ob, method, override, expect ) { + this.description = description; + this.object = ob; + this.method = method; + this.override = override + this.expect; + + this.result = eval(description); + + this.isJSMethod = eval( ob +"."+ method +" == Array.prototype." + method ); + + // verify result of method + + testcases[tc++] = new TestCase( + description, + expect, + this.result ); + + // verify that method is the method of Array.prototype + + testcases[tc++] = new TestCase( + ob +"." + method +" == Array.prototype." + method, + override, + this.isJSMethod ); + + // verify that it's not cast to JS Array type + + testcases[tc++] = new TestCase( + ob + ".getClass().getName() +''", + "[B", + eval( ob+".getClass().getName() +''") ); + + } diff --git a/mozilla/js/tests/lc3/ArrayMethods/byte-002.js b/mozilla/js/tests/lc3/ArrayMethods/byte-002.js new file mode 100644 index 00000000000..6ca3aa95371 --- /dev/null +++ b/mozilla/js/tests/lc3/ArrayMethods/byte-002.js @@ -0,0 +1,38 @@ +/* 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. + * + */ +/** + * java array objects "inherit" JS string methods. verify that byte arrays + * can inherit JavaScript Array object methods + * + * + */ + var SECTION = "java array object inheritance JavaScript Array methods"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 " + SECTION; + + startTest(); + + var b = new java.lang.String("abcdefghijklmnopqrstuvwxyz").getBytes(); + + testcases[tc++] = new TestCase( + "var b = new java.lang.String(\"abcdefghijklmnopqrstuvwxyz\").getBytes(); b.valueOf()", + b, + b.valueOf() ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ArrayMethods/object-001.js b/mozilla/js/tests/lc3/ArrayMethods/object-001.js new file mode 100644 index 00000000000..119f4e58af3 --- /dev/null +++ b/mozilla/js/tests/lc3/ArrayMethods/object-001.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. + * + */ +/** + * java array objects "inherit" JS string methods. verify that byte arrays + * can inherit JavaScript Array object methods join, reverse, sort and valueOf + * + */ + var SECTION = "java array object inheritance JavaScript Array methods"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 " + SECTION; + + startTest(); + + dt = new Packages.com.netscape.javascript.qa.liveconnect.DataTypeClass(); + + obArray = dt.PUB_ARRAY_OBJECT; + + // check string value + + testcases[tc++] = new TestCase( + "dt = new Packages.com.netscape.javascript.qa.liveconnect.DataTypeClass(); "+ + "obArray = dt.PUB_ARRAY_OBJECT" + + "obArray.join() +''", + join(obArray), + obArray.join() ); + + // check type of object returned by method + + testcases[tc++] = new TestCase( + "typeof obArray.reverse().join()", + reverse(obArray), + obArray.reverse().join() ); + + testcases[tc++] = new TestCase( + "obArray.reverse().getClass().getName() +''", + "[Ljava.lang.Object;", + obArray.reverse().getClass().getName() +''); + + test(); + + function join( a ) { + for ( var i = 0, s = ""; i < a.length; i++ ) { + s += a[i].toString() + ( i + 1 < a.length ? "," : "" ); + } + return s; + } + function reverse( a ) { + for ( var i = a.length -1, s = ""; i >= 0; i-- ) { + s += a[i].toString() + ( i> 0 ? "," : "" ); + } + return s; + } \ No newline at end of file diff --git a/mozilla/js/tests/lc3/CallStatic/boolean-001.js b/mozilla/js/tests/lc3/CallStatic/boolean-001.js new file mode 100644 index 00000000000..ac358efa2f1 --- /dev/null +++ b/mozilla/js/tests/lc3/CallStatic/boolean-001.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. + * + */ +/** + * The Java language allows static methods to be invoked using either the + * class name or a reference to an instance of the class, but previous + * versions of liveocnnect only allowed the former. + * + * author: christine@netscape.com + * + * date: 12/9/1998 + * + */ + var SECTION = "Call static methods from an instance"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 " + + SECTION; + startTest(); + + var DT = Packages.com.netscape.javascript.qa.liveconnect.DataTypeClass; + var dt = new DT(); + + var a = new Array; + var i = 0; + + a[i++] = new TestObject( + "dt.staticSetBoolean( true )", + "dt.PUB_STATIC_BOOLEAN", + "dt.staticGetBoolean()", + "typeof dt.staticGetBoolean()", + true, + "boolean" ); + + a[i++] = new TestObject( + "dt.staticSetBoolean( false )", + "dt.PUB_STATIC_BOOLEAN", + "dt.staticGetBoolean()", + "typeof dt.staticGetBoolean()", + false, + "boolean" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/CallStatic/number-001.js b/mozilla/js/tests/lc3/CallStatic/number-001.js new file mode 100644 index 00000000000..324691395c9 --- /dev/null +++ b/mozilla/js/tests/lc3/CallStatic/number-001.js @@ -0,0 +1,136 @@ +/* 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. + * + */ +/** + * The Java language allows static methods to be invoked using either the + * class name or a reference to an instance of the class, but previous + * versions of liveocnnect only allowed the former. + * + * Verify that we can call static methods and get the value of static fields + * from an instance reference. + * + * author: christine@netscape.com + * + * date: 12/9/1998 + * + */ + var SECTION = "Call static methods from an instance"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 " + + SECTION; + startTest(); + + var DT = Packages.com.netscape.javascript.qa.liveconnect.DataTypeClass; + var dt = new DT(); + + var a = new Array; + var i = 0; + + a[i++] = new TestObject( + "dt.staticSetByte( 99 )", + "dt.PUB_STATIC_BYTE", + "dt.staticGetByte()", + "typeof dt.staticGetByte()", + 99, + "number" ); + + a[i++] = new TestObject( + "dt.staticSetChar( 45678 )", + "dt.PUB_STATIC_CHAR", + "dt.staticGetChar()", + "typeof dt.staticGetChar()", + 45678, + "number" ); + + a[i++] = new TestObject( + "dt.staticSetShort( 32109 )", + "dt.PUB_STATIC_SHORT", + "dt.staticGetShort()", + "typeof dt.staticGetShort()", + 32109, + "number" ); + + a[i++] = new TestObject( + "dt.staticSetInteger( 2109876543 )", + "dt.PUB_STATIC_INT", + "dt.staticGetInteger()", + "typeof dt.staticGetInteger()", + 2109876543, + "number" ); + + a[i++] = new TestObject( + "dt.staticSetLong( 9012345678901234567 )", + "dt.PUB_STATIC_LONG", + "dt.staticGetLong()", + "typeof dt.staticGetLong()", + 9012345678901234567, + "number" ); + + + a[i++] = new TestObject( + "dt.staticSetDouble( java.lang.Double.MIN_VALUE )", + "dt.PUB_STATIC_DOUBLE", + "dt.staticGetDouble()", + "typeof dt.staticGetDouble()", + java.lang.Double.MIN_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.staticSetFloat( java.lang.Float.MIN_VALUE )", + "dt.PUB_STATIC_FLOAT", + "dt.staticGetFloat()", + "typeof dt.staticGetFloat()", + java.lang.Float.MIN_VALUE, + "number" ); + + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/CallStatic/object-001.js b/mozilla/js/tests/lc3/CallStatic/object-001.js new file mode 100644 index 00000000000..29fb3b24d2a --- /dev/null +++ b/mozilla/js/tests/lc3/CallStatic/object-001.js @@ -0,0 +1,136 @@ +/* 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. + * + */ +/** + * The Java language allows static methods to be invoked using either the + * class name or a reference to an instance of the class, but previous + * versions of liveocnnect only allowed the former. + * + * Verify that we can call static methods and get the value of static fields + * from an instance reference. + * + * author: christine@netscape.com + * + * date: 12/9/1998 + * + */ + var SECTION = "Call static methods from an instance"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 " + + SECTION; + startTest(); + + var DT = Packages.com.netscape.javascript.qa.liveconnect.DataTypeClass; + var dt = new DT(); + + var a = new Array; + var i = 0; + + a[i++] = new TestObject( + "dt.staticSetDoubleObject( 99 )", + "dt.PUB_STATIC_DOUBLE_OBJECT.doubleValue()", + "dt.staticGetDoubleObject().doubleValue()", + "dt.staticGetDoubleObject().getClass().getName() +''", + 99, + "java.lang.Double" ); + + a[i++] = new TestObject( + "dt.staticSetShortObject( new java.lang.Short(32109) )", + "dt.PUB_STATIC_SHORT_OBJECT.doubleValue()", + "dt.staticGetShortObject().doubleValue()", + "dt.staticGetShortObject().getClass().getName() +''", + 32109, + "java.lang.Short" ); + + a[i++] = new TestObject( + "dt.staticSetIntegerObject( new java.lang.Integer(2109876543) )", + "dt.PUB_STATIC_INTEGER_OBJECT.doubleValue()", + "dt.staticGetIntegerObject().doubleValue()", + "dt.staticGetIntegerObject().getClass().getName() +''", + 2109876543, + "java.lang.Integer" ); + + + a[i++] = new TestObject( + "dt.staticSetLongObject( new java.lang.Long(9012345678901234567) )", + "dt.PUB_STATIC_LONG_OBJECT.doubleValue()", + "dt.staticGetLongObject().doubleValue()", + "dt.staticGetLongObject().getClass().getName() +''", + 9012345678901234567, + "java.lang.Long" ); + + + a[i++] = new TestObject( + "dt.staticSetDoubleObject(new java.lang.Double( java.lang.Double.MIN_VALUE) )", + "dt.PUB_STATIC_DOUBLE_OBJECT.doubleValue()", + "dt.staticGetDoubleObject().doubleValue()", + "dt.staticGetDoubleObject().getClass().getName()+''", + java.lang.Double.MIN_VALUE, + "java.lang.Double" ); + + a[i++] = new TestObject( + "dt.staticSetFloatObject( new java.lang.Float(java.lang.Float.MIN_VALUE) )", + "dt.PUB_STATIC_FLOAT_OBJECT.doubleValue()", + "dt.staticGetFloatObject().doubleValue()", + "dt.staticGetFloatObject().getClass().getName() +''", + java.lang.Float.MIN_VALUE, + "java.lang.Float" ); + + a[i++] = new TestObject( + "dt.staticSetCharacter( new java.lang.Character(45678) )", + "dt.PUB_STATIC_CHAR_OBJECT.charValue()", + "dt.staticGetCharacter().charValue()", + "dt.staticGetCharacter().getClass().getName()+''", + 45678, + "java.lang.Character" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/Constructors/construct-001.js b/mozilla/js/tests/lc3/Constructors/construct-001.js new file mode 100644 index 00000000000..7f1f81ea726 --- /dev/null +++ b/mozilla/js/tests/lc3/Constructors/construct-001.js @@ -0,0 +1,203 @@ +/* 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. + * + */ +/** + * Verify that specific constructors can be invoked. + * + * + */ + + var SECTION = "Explicit Constructor Invokation"; + var VERSION = "JS1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Conversion"; + + startTest(); + + var DT = Packages.com.netscape.javascript.qa.liveconnect.DataTypeClass; + + testcases[tc++] = new TestCase( + "dt = new DT()" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT().CONSTRUCTOR_ARG_NONE, + new DT().PUB_STRING_CONSTRUCTOR_ARG ); + + testcases[tc++] = new TestCase( + "dt = new DT(5)" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT(5).CONSTRUCTOR_ARG_DOUBLE, + new DT(5).PUB_STRING_CONSTRUCTOR_ARG ); + + testcases[tc++] = new TestCase( + "dt = new DT(\"true\")" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT(true).CONSTRUCTOR_ARG_BOOLEAN, + new DT(true).PUB_STRING_CONSTRUCTOR_ARG ); + + // force type conversion + + + // convert boolean + + testcases[tc++] = new TestCase( + "dt = new DT[\"(boolean)\"](true)" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT("5").CONSTRUCTOR_ARG_BOOLEAN, + new DT["(boolean)"](true).PUB_STRING_CONSTRUCTOR_ARG ); + + testcases[tc++] = new TestCase( + "dt = new DT[\"(java.lang.Boolean)\"](true)" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT().CONSTRUCTOR_ARG_BOOLEAN_OBJECT, + new DT["(java.lang.Boolean)"](true).PUB_STRING_CONSTRUCTOR_ARG ); + + testcases[tc++] = new TestCase( + "dt = new DT[\"(java.lang.Object)\"](true)" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT("5").CONSTRUCTOR_ARG_OBJECT, + new DT["(java.lang.Object)"](true).PUB_STRING_CONSTRUCTOR_ARG ); + + testcases[tc++] = new TestCase( + "dt = new DT[\"(java.lang.String)\"](true)" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT().CONSTRUCTOR_ARG_STRING, + new DT["(java.lang.String)"](true).PUB_STRING_CONSTRUCTOR_ARG ); + + + // convert number + + testcases[tc++] = new TestCase( + "dt = new DT[\"(double)\"](5)" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT(5).CONSTRUCTOR_ARG_DOUBLE, + new DT["(double)"]("5").PUB_STRING_CONSTRUCTOR_ARG ); + + testcases[tc++] = new TestCase( + "dt = new DT[\"(java.lang.Double)\"](5)" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT(5).CONSTRUCTOR_ARG_DOUBLE_OBJECT, + new DT["(java.lang.Double)"](5).PUB_STRING_CONSTRUCTOR_ARG ); + + testcases[tc++] = new TestCase( + "dt = new DT[\"(char)\"](5)" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT().CONSTRUCTOR_ARG_CHAR, + new DT["(char)"](5).PUB_STRING_CONSTRUCTOR_ARG ); + + testcases[tc++] = new TestCase( + "dt = new DT[\"(java.lang.Object)\"](5)" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT().CONSTRUCTOR_ARG_OBJECT, + new DT["(java.lang.Object)"](5).PUB_STRING_CONSTRUCTOR_ARG ); + + testcases[tc++] = new TestCase( + "dt = new DT[\"(java.lang.String)\"](5)" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT().CONSTRUCTOR_ARG_STRING, + new DT["(java.lang.String)"](5).PUB_STRING_CONSTRUCTOR_ARG ); + + // convert string + + testcases[tc++] = new TestCase( + "dt = new DT(\"5\")" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT("5").CONSTRUCTOR_ARG_STRING, + new DT("5").PUB_STRING_CONSTRUCTOR_ARG ); + + testcases[tc++] = new TestCase( + "dt = new DT[\"(java.lang.String)\"](\"5\")" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT("5").CONSTRUCTOR_ARG_STRING, + new DT["(java.lang.String)"]("5").PUB_STRING_CONSTRUCTOR_ARG ); + + testcases[tc++] = new TestCase( + "dt = new DT[\"(char)\"](\"J\")" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT().CONSTRUCTOR_ARG_CHAR, + new DT["(char)"]("J").PUB_STRING_CONSTRUCTOR_ARG ); + + testcases[tc++] = new TestCase( + "dt = new DT[\"(double)\"](\"5\")" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT("5").CONSTRUCTOR_ARG_DOUBLE, + new DT["(double)"]("5").PUB_STRING_CONSTRUCTOR_ARG ); + + testcases[tc++] = new TestCase( + "dt = new DT[\"(java.lang.Object)\"](\"hello\")" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT("hello").CONSTRUCTOR_ARG_OBJECT, + new DT["(java.lang.Object)"]("hello").PUB_STRING_CONSTRUCTOR_ARG ); + + // convert java object + + testcases[tc++] = new TestCase( + "dt = new DT[\"(java.lang.Object)\"](new java.lang.String(\"hello\")" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT().CONSTRUCTOR_ARG_OBJECT, + new DT["(java.lang.Object)"](new java.lang.String("hello")).PUB_STRING_CONSTRUCTOR_ARG ); + + testcases[tc++] = new TestCase( + "dt = new DT[\"(java.lang.Object)\"](new java.lang.String(\"hello\")" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT().CONSTRUCTOR_ARG_OBJECT, + new DT["(java.lang.Object)"](new java.lang.String("hello")).PUB_STRING_CONSTRUCTOR_ARG ); + + testcases[tc++] = new TestCase( + "dt = new DT[\"(double)\"](new java.lang.Double(5);" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT().CONSTRUCTOR_ARG_DOUBLE, + new DT["(double)"](new java.lang.Double(5)).PUB_STRING_CONSTRUCTOR_ARG ); + + testcases[tc++] = new TestCase( + "dt = new DT[\"(char)\"](new java.lang.Double(5);" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT().CONSTRUCTOR_ARG_CHAR, + new DT["(char)"](new java.lang.Double(5)).PUB_STRING_CONSTRUCTOR_ARG ); + + testcases[tc++] = new TestCase( + "dt = new DT[\"(java.lang.String)\"](new java.lang.Double(5);" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT().CONSTRUCTOR_ARG_STRING, + new DT["(java.lang.String)"](new java.lang.Double(5)).PUB_STRING_CONSTRUCTOR_ARG ); + + testcases[tc++] = new TestCase( + "dt = new DT[\"(java.lang.Double)\"](new java.lang.Double(5);" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT().CONSTRUCTOR_ARG_DOUBLE_OBJECT, + new DT["(java.lang.Double)"](new java.lang.Double(5)).PUB_STRING_CONSTRUCTOR_ARG ); + + testcases[tc++] = new TestCase( + "dt = new DT(new java.lang.Double(5);" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT().CONSTRUCTOR_ARG_DOUBLE_OBJECT, + new DT(new java.lang.Double(5)).PUB_STRING_CONSTRUCTOR_ARG ); + + // java array + + testcases[tc++] = new TestCase( + "dt = new DT[\"(java.lang.String)\"](new java.lang.String(\"hello\").getBytes())" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT("hello").CONSTRUCTOR_ARG_STRING, + new DT["(java.lang.String)"](new java.lang.String("hello").getBytes()).PUB_STRING_CONSTRUCTOR_ARG ); + + testcases[tc++] = new TestCase( + "dt = new DT[\"(byte[])\"](new java.lang.String(\"hello\").getBytes())" + + "dt.PUB_CONSTRUCTOR_ARG", + new DT("hello").CONSTRUCTOR_ARG_BYTE_ARRAY, + new DT["(byte[])"](new java.lang.String("hello").getBytes()).PUB_STRING_CONSTRUCTOR_ARG ); + + test(); diff --git a/mozilla/js/tests/lc3/ConvertBoolean/boolean-001.js b/mozilla/js/tests/lc3/ConvertBoolean/boolean-001.js new file mode 100644 index 00000000000..737c732f38f --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertBoolean/boolean-001.js @@ -0,0 +1,45 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * Passing a JavaScript boolean to a Java method should prefer to call + * a Java method of the same name that expects a Java boolean. + * + */ + var SECTION = "Preferred argument conversion: boolean"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.bool.Boolean_001; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( true )", + TEST_CLASS.expect(), + TEST_CLASS.ambiguous(true) ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( false )", + TEST_CLASS.expect(), + TEST_CLASS.ambiguous( false ) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertBoolean/boolean-002.js b/mozilla/js/tests/lc3/ConvertBoolean/boolean-002.js new file mode 100644 index 00000000000..dbece8adf4e --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertBoolean/boolean-002.js @@ -0,0 +1,43 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * + */ + var SECTION = "Preferred argument conversion: boolean"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.bool.Boolean_002; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( true )", + TEST_CLASS.expect(), + TEST_CLASS.ambiguous(true) ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( false )", + TEST_CLASS.expect(), + TEST_CLASS.ambiguous( false ) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertBoolean/boolean-003.js b/mozilla/js/tests/lc3/ConvertBoolean/boolean-003.js new file mode 100644 index 00000000000..62774e75129 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertBoolean/boolean-003.js @@ -0,0 +1,43 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * + */ + var SECTION = "Preferred argument conversion: boolean"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.bool.Boolean_003; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( true )", + TEST_CLASS.expect(), + TEST_CLASS.ambiguous(true) ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( false )", + TEST_CLASS.expect(), + TEST_CLASS.ambiguous( false ) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertBoolean/boolean-004.js b/mozilla/js/tests/lc3/ConvertBoolean/boolean-004.js new file mode 100644 index 00000000000..b6f794fdd01 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertBoolean/boolean-004.js @@ -0,0 +1,43 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * + */ + var SECTION = "Preferred argument conversion: boolean"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.bool.Boolean_004; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( true )", + TEST_CLASS.expect(), + TEST_CLASS.ambiguous(true) ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( false )", + TEST_CLASS.expect(), + TEST_CLASS.ambiguous( false ) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertBoolean/boolean-005-n.js b/mozilla/js/tests/lc3/ConvertBoolean/boolean-005-n.js new file mode 100644 index 00000000000..517bfbb7457 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertBoolean/boolean-005-n.js @@ -0,0 +1,38 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * + */ + var SECTION = "Preferred argument conversion: boolean"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.bool.Boolean_005; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( true )", + "error", + TEST_CLASS.ambiguous(true) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertBoolean/boolean-006-n.js b/mozilla/js/tests/lc3/ConvertBoolean/boolean-006-n.js new file mode 100644 index 00000000000..f7abaf99b6a --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertBoolean/boolean-006-n.js @@ -0,0 +1,38 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * + */ + var SECTION = "Preferred argument conversion: boolean"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.bool.Boolean_005; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( false )", + "error", + TEST_CLASS.ambiguous(false) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertBoolean/boolean-007-n.js b/mozilla/js/tests/lc3/ConvertBoolean/boolean-007-n.js new file mode 100644 index 00000000000..d0a85190ea7 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertBoolean/boolean-007-n.js @@ -0,0 +1,40 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * It is an error to pass a JavaScript boolean to a method that expects + * a primitive Java numeric type. + * + */ + var SECTION = "Preferred argument conversion: boolean"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.bool.Boolean_004; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(long)\"](true)", + "error", + TEST_CLASS["ambiguous(long)"](true) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertBoolean/boolean-008-n.js b/mozilla/js/tests/lc3/ConvertBoolean/boolean-008-n.js new file mode 100644 index 00000000000..81d3a7ff639 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertBoolean/boolean-008-n.js @@ -0,0 +1,40 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * It is an error to pass a JavaScript boolean to a method that expects + * a primitive Java numeric type. + * + */ + var SECTION = "Preferred argument conversion: boolean"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.bool.Boolean_004; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(short)\"](true)", + "error", + TEST_CLASS["ambiguous(short)"](true) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertBoolean/boolean-009-n.js b/mozilla/js/tests/lc3/ConvertBoolean/boolean-009-n.js new file mode 100644 index 00000000000..586b0260ecb --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertBoolean/boolean-009-n.js @@ -0,0 +1,40 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * It is an error to pass a JavaScript boolean to a method that expects + * a primitive Java numeric type. + * + */ + var SECTION = "Preferred argument conversion: boolean"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.bool.Boolean_004; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(char)\"](true)", + "error", + TEST_CLASS["ambiguous(char)"](true) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertBoolean/boolean-010-n.js b/mozilla/js/tests/lc3/ConvertBoolean/boolean-010-n.js new file mode 100644 index 00000000000..a82f0dd9197 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertBoolean/boolean-010-n.js @@ -0,0 +1,40 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * It is an error to pass a JavaScript boolean to a method that expects + * a primitive Java numeric type. + * + */ + var SECTION = "Preferred argument conversion: boolean"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.bool.Boolean_004; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(int)\"](true)", + "error", + TEST_CLASS["ambiguous(int)"](true) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertBoolean/boolean-011-n.js b/mozilla/js/tests/lc3/ConvertBoolean/boolean-011-n.js new file mode 100644 index 00000000000..e42c7d82df1 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertBoolean/boolean-011-n.js @@ -0,0 +1,40 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * It is an error to pass a JavaScript boolean to a method that expects + * a primitive Java numeric type. + * + */ + var SECTION = "Preferred argument conversion: boolean"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.bool.Boolean_004; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(byte)\"](true)", + "error", + TEST_CLASS["ambiguous(byte)"](true) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertBoolean/boolean-012-n.js b/mozilla/js/tests/lc3/ConvertBoolean/boolean-012-n.js new file mode 100644 index 00000000000..6c4ebbffc85 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertBoolean/boolean-012-n.js @@ -0,0 +1,40 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * It is an error to pass a JavaScript boolean to a method that expects + * a primitive Java numeric type. + * + */ + var SECTION = "Preferred argument conversion: boolean"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.bool.Boolean_004; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(double)\"](true)", + "error", + TEST_CLASS["ambiguous(double)"](true) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertBoolean/boolean-013-n.js b/mozilla/js/tests/lc3/ConvertBoolean/boolean-013-n.js new file mode 100644 index 00000000000..017da9b03ce --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertBoolean/boolean-013-n.js @@ -0,0 +1,40 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * It is an error to pass a JavaScript boolean to a method that expects + * a primitive Java numeric type. + * + */ + var SECTION = "Preferred argument conversion: boolean"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.bool.Boolean_004; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(float)\"](true)", + "error", + TEST_CLASS["ambiguous(float)"](true) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertBoolean/boolean-014.js b/mozilla/js/tests/lc3/ConvertBoolean/boolean-014.js new file mode 100644 index 00000000000..4c2480983ad --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertBoolean/boolean-014.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. + * + */ +/** + * Preferred Argument Conversion. + * + * Use the syntax for explicit method invokation to override the default + * preferred argument conversion. + * + */ + var SECTION = "Preferred argument conversion: boolean"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.bool.Boolean_001; + + // invoke method that accepts java.lang.Boolean + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(java.lang.Boolean)\"](true)", + TEST_CLASS.BOOLEAN_OBJECT, + TEST_CLASS["ambiguous(java.lang.Boolean)"](true) ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(java.lang.Boolean)\"](false)", + TEST_CLASS.BOOLEAN_OBJECT, + TEST_CLASS["ambiguous(java.lang.Boolean)"](false) ); + + // invoke method that expects java.lang.Object + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(java.lang.Object)\"](true)", + TEST_CLASS.OBJECT, + TEST_CLASS["ambiguous(java.lang.Object)"](true) ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(java.lang.Boolean)\"](false)", + TEST_CLASS.OBJECT, + TEST_CLASS["ambiguous(java.lang.Object)"](false) ); + + // invoke method that expects a String + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(java.lang.String)\"](true)", + TEST_CLASS.STRING, + TEST_CLASS["ambiguous(java.lang.String)"](true) ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(java.lang.Boolean)\"](false)", + TEST_CLASS.STRING, + TEST_CLASS["ambiguous(java.lang.String)"](false) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertJSObject/ToBoolean-001.js b/mozilla/js/tests/lc3/ConvertJSObject/ToBoolean-001.js new file mode 100644 index 00000000000..9b9f1c9d6be --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertJSObject/ToBoolean-001.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. + * + */ +/** + * Preferred Argument Conversion. + * + * Passing a JavaScript boolean to a Java method should prefer to call + * a Java method of the same name that expects a Java boolean. + * + */ + var SECTION = "Preferred argument conversion: boolean"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new Packages.com.netscape.javascript.qa.lc3.jsobject.JSObject_004; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new String() ) +''", + "DOUBLE", + TEST_CLASS.ambiguous(new String()) +'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Boolean() ) +''", + "DOUBLE", + TEST_CLASS.ambiguous( new Boolean() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Number() ) +''", + "DOUBLE", + TEST_CLASS.ambiguous( new Number() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Date() ) +''", + "DOUBLE", + TEST_CLASS.ambiguous( new Date() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Function() ) +''", + "DOUBLE", + TEST_CLASS.ambiguous( new Function() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Array() ) +''", + "DOUBLE", + TEST_CLASS.ambiguous( new Array() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( this ) +''", + "DOUBLE", + TEST_CLASS.ambiguous( this )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new RegExp() ) +''", + "DOUBLE", + TEST_CLASS.ambiguous( new RegExp() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( Math ) +''", + "DOUBLE", + TEST_CLASS.ambiguous( Math )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Object() ) +''", + "DOUBLE", + TEST_CLASS.ambiguous( new Object() )+'' ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertJSObject/ToByte-001.js b/mozilla/js/tests/lc3/ConvertJSObject/ToByte-001.js new file mode 100644 index 00000000000..c2d23178cfe --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertJSObject/ToByte-001.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. + * + */ +/** + * Preferred Argument Conversion. + * + * Passing a JavaScript boolean to a Java method should prefer to call + * a Java method of the same name that expects a Java boolean. + * + */ + var SECTION = "Preferred argument conversion: JavaScript Object to short"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new Packages.com.netscape.javascript.qa.lc3.jsobject.JSObject_010; + + function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + } + + function MyFunction() { + return; + } + MyFunction.valueOf = new Function( "return -128" ); + + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new String() ) +''", + "BYTE", + TEST_CLASS.ambiguous(new String()) +'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Boolean() ) +''", + "BYTE", + TEST_CLASS.ambiguous( new Boolean() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Number() ) +''", + "BYTE", + TEST_CLASS.ambiguous( new Number() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Date(99) ) +''", + "BYTE", + TEST_CLASS.ambiguous( new Date(99) )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Array() ) +''", + "BYTE", + TEST_CLASS.ambiguous( new Array() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new MyObject(127) ) +''", + "BYTE", + TEST_CLASS.ambiguous( new MyObject(127) )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( MyFunction ) +''", + "BYTE", + TEST_CLASS.ambiguous( MyFunction )+'' ); + + test(); + + diff --git a/mozilla/js/tests/lc3/ConvertJSObject/ToByte-002.js b/mozilla/js/tests/lc3/ConvertJSObject/ToByte-002.js new file mode 100644 index 00000000000..25657e9e387 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertJSObject/ToByte-002.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. + * + */ +/** + * Preferred Argument Conversion. + * + * Passing a JavaScript boolean to a Java method should prefer to call + * a Java method of the same name that expects a Java boolean. + * + */ + var SECTION = "Preferred argument conversion: JavaScript Object to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new Packages.com.netscape.javascript.qa.lc3.jsobject.JSObject_010; + + function MyFunction() { + return "hello"; + } + MyFunction.valueOf = new Function( "return 99" ); + + function MyOtherFunction() { + return "goodbye"; + } + MyOtherFunction.valueOf = null; + MyOtherFunction.toString = new Function( "return 99" ); + + function MyObject(value) { + this.value = value; + this.valueOf = new Function("return this.value"); + } + + function MyOtherObject(stringValue) { + this.stringValue = String( stringValue ); + this.toString = new Function( "return this.stringValue" ); + this.valueOf = null; + } + + function AnotherObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return 666" ); + } + + // should pass MyFunction.valueOf() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( MyFunction ) +''", + "BYTE", + TEST_CLASS.ambiguous( MyFunction )+'' ); + + // should pass MyOtherFunction.toString() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( MyOtherFunction ) +''", + "BYTE", + TEST_CLASS.ambiguous( MyOtherFunction )+'' ); + + // should pass MyObject.valueOf() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new MyObject(123) ) +''", + "BYTE", + TEST_CLASS.ambiguous( new MyObject(123) )+'' ); + + // should pass MyOtherObject.toString() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new MyOtherObject(\"123\") ) +''", + "BYTE", + TEST_CLASS.ambiguous( new MyOtherObject("123") )+'' ); + + // should pass AnotherObject.valueOf() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new AnotherObject(\"123\") ) +''", + "BYTE", + TEST_CLASS.ambiguous( new AnotherObject("123") )+'' ); + + test(); + diff --git a/mozilla/js/tests/lc3/ConvertJSObject/ToChar-001.js b/mozilla/js/tests/lc3/ConvertJSObject/ToChar-001.js new file mode 100644 index 00000000000..06526824dd8 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertJSObject/ToChar-001.js @@ -0,0 +1,61 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * Passing a JavaScript boolean to a Java method should prefer to call + * a Java method of the same name that expects a Java boolean. + * + */ + var SECTION = "Preferred argument conversion: JavaScript Object to short"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new Packages.com.netscape.javascript.qa.lc3.jsobject.JSObject_009; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new String() ) +''", + "CHAR", + TEST_CLASS.ambiguous(new String()) +'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Boolean() ) +''", + "CHAR", + TEST_CLASS.ambiguous( new Boolean() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Number() ) +''", + "CHAR", + TEST_CLASS.ambiguous( new Number() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Date(999) ) +''", + "CHAR", + TEST_CLASS.ambiguous( new Date(999) )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Array() ) +''", + "CHAR", + TEST_CLASS.ambiguous( new Array() )+'' ); + + test(); + + diff --git a/mozilla/js/tests/lc3/ConvertJSObject/ToChar-002.js b/mozilla/js/tests/lc3/ConvertJSObject/ToChar-002.js new file mode 100644 index 00000000000..51fd82461e3 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertJSObject/ToChar-002.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. + * + */ +/** + * Preferred Argument Conversion. + * + * Passing a JavaScript boolean to a Java method should prefer to call + * a Java method of the same name that expects a Java boolean. + * + */ + var SECTION = "Preferred argument conversion: JavaScript Object to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new Packages.com.netscape.javascript.qa.lc3.jsobject.JSObject_009; + + function MyFunction() { + return "hello"; + } + MyFunction.valueOf = new Function( "return 999" ); + + function MyOtherFunction() { + return "goodbye"; + } + MyOtherFunction.valueOf = null; + MyOtherFunction.toString = new Function( "return 999" ); + + function MyObject(value) { + this.value = value; + this.valueOf = new Function("return this.value"); + } + + function MyOtherObject(stringValue) { + this.stringValue = String( stringValue ); + this.toString = new Function( "return this.stringValue" ); + this.valueOf = null; + } + + function AnotherObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return 666" ); + } + + // should pass MyFunction.valueOf() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( MyFunction ) +''", + "CHAR", + TEST_CLASS.ambiguous( MyFunction )+'' ); + + // should pass MyOtherFunction.toString() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( MyOtherFunction ) +''", + "CHAR", + TEST_CLASS.ambiguous( MyOtherFunction )+'' ); + + // should pass MyObject.valueOf() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new MyObject(12345) ) +''", + "CHAR", + TEST_CLASS.ambiguous( new MyObject(12345) )+'' ); + + // should pass MyOtherObject.toString() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new MyOtherObject(\"12345\") ) +''", + "CHAR", + TEST_CLASS.ambiguous( new MyOtherObject("12345") )+'' ); + + // should pass AnotherObject.valueOf() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new AnotherObject(\"12345\") ) +''", + "CHAR", + TEST_CLASS.ambiguous( new AnotherObject("12345") )+'' ); + + test(); + diff --git a/mozilla/js/tests/lc3/ConvertJSObject/ToDouble-001.js b/mozilla/js/tests/lc3/ConvertJSObject/ToDouble-001.js new file mode 100644 index 00000000000..7f875c0b4f1 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertJSObject/ToDouble-001.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. + * + */ +/** + * Preferred Argument Conversion. + * + * Passing a JavaScript boolean to a Java method should prefer to call + * a Java method of the same name that expects a Java boolean. + * + */ + var SECTION = "Preferred argument conversion: JavaScript object to double"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new Packages.com.netscape.javascript.qa.lc3.jsobject.JSObject_004; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new String() ) +''", + "DOUBLE", + TEST_CLASS.ambiguous(new String()) +'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Boolean() ) +''", + "DOUBLE", + TEST_CLASS.ambiguous( new Boolean() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Number() ) +''", + "DOUBLE", + TEST_CLASS.ambiguous( new Number() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Date() ) +''", + "DOUBLE", + TEST_CLASS.ambiguous( new Date() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Function() ) +''", + "DOUBLE", + TEST_CLASS.ambiguous( new Function() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Array() ) +''", + "DOUBLE", + TEST_CLASS.ambiguous( new Array() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( this ) +''", + "DOUBLE", + TEST_CLASS.ambiguous( this )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new RegExp() ) +''", + "DOUBLE", + TEST_CLASS.ambiguous( new RegExp() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( Math ) +''", + "DOUBLE", + TEST_CLASS.ambiguous( Math )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Object() ) +''", + "DOUBLE", + TEST_CLASS.ambiguous( new Object() )+'' ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertJSObject/ToFloat-001.js b/mozilla/js/tests/lc3/ConvertJSObject/ToFloat-001.js new file mode 100644 index 00000000000..0119108d56d --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertJSObject/ToFloat-001.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. + * + */ +/** + * Preferred Argument Conversion. + * + * Passing a JavaScript boolean to a Java method should prefer to call + * a Java method of the same name that expects a Java boolean. + * + */ + var SECTION = "Preferred argument conversion: boolean"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new Packages.com.netscape.javascript.qa.lc3.jsobject.JSObject_005; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new String() ) +''", + "FLOAT", + TEST_CLASS.ambiguous(new String()) +'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Boolean() ) +''", + "FLOAT", + TEST_CLASS.ambiguous( new Boolean() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Number() ) +''", + "FLOAT", + TEST_CLASS.ambiguous( new Number() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Date() ) +''", + "FLOAT", + TEST_CLASS.ambiguous( new Date() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Function() ) +''", + "FLOAT", + TEST_CLASS.ambiguous( new Function() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Array() ) +''", + "FLOAT", + TEST_CLASS.ambiguous( new Array() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( this ) +''", + "FLOAT", + TEST_CLASS.ambiguous( this )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new RegExp() ) +''", + "FLOAT", + TEST_CLASS.ambiguous( new RegExp() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( Math ) +''", + "FLOAT", + TEST_CLASS.ambiguous( Math )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Object() ) +''", + "FLOAT", + TEST_CLASS.ambiguous( new Object() )+'' ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertJSObject/ToInt-001.js b/mozilla/js/tests/lc3/ConvertJSObject/ToInt-001.js new file mode 100644 index 00000000000..ddb9d90c31b --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertJSObject/ToInt-001.js @@ -0,0 +1,61 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * Passing a JavaScript boolean to a Java method should prefer to call + * a Java method of the same name that expects a Java boolean. + * + */ + var SECTION = "Preferred argument conversion: JavaScript Object to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new Packages.com.netscape.javascript.qa.lc3.jsobject.JSObject_007; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new String() ) +''", + "INT", + TEST_CLASS.ambiguous(new String()) +'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Boolean() ) +''", + "INT", + TEST_CLASS.ambiguous( new Boolean() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Number() ) +''", + "INT", + TEST_CLASS.ambiguous( new Number() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Date(0) ) +''", + "INT", + TEST_CLASS.ambiguous( new Date(0) )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Array() ) +''", + "INT", + TEST_CLASS.ambiguous( new Array() )+'' ); + + test(); + + diff --git a/mozilla/js/tests/lc3/ConvertJSObject/ToInt-002.js b/mozilla/js/tests/lc3/ConvertJSObject/ToInt-002.js new file mode 100644 index 00000000000..408c7cedc5f --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertJSObject/ToInt-002.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. + * + */ +/** + * Preferred Argument Conversion. + * + * Passing a JavaScript boolean to a Java method should prefer to call + * a Java method of the same name that expects a Java boolean. + * + */ + var SECTION = "Preferred argument conversion: JavaScript Object to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new Packages.com.netscape.javascript.qa.lc3.jsobject.JSObject_007; + + function MyFunction() { + return "hello"; + } + MyFunction.valueOf = new Function( "return 999" ); + + function MyOtherFunction() { + return "goodbye"; + } + MyOtherFunction.valueOf = null; + MyOtherFunction.toString = new Function( "return 999" ); + + function MyObject(value) { + this.value = value; + this.valueOf = new Function("return this.value"); + } + + function MyOtherObject(stringValue) { + this.stringValue = String( stringValue ); + this.toString = new Function( "return this.stringValue" ); + this.valueOf = null; + } + + function AnotherObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return 666" ); + } + + // should pass MyFunction.valueOf() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( MyFunction ) +''", + "INT", + TEST_CLASS.ambiguous( MyFunction )+'' ); + + // should pass MyOtherFunction.toString() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( MyOtherFunction ) +''", + "INT", + TEST_CLASS.ambiguous( MyOtherFunction )+'' ); + + // should pass MyObject.valueOf() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new MyObject(12345) ) +''", + "INT", + TEST_CLASS.ambiguous( new MyObject(12345) )+'' ); + + // should pass MyOtherObject.toString() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new MyOtherObject(\"12345\") ) +''", + "INT", + TEST_CLASS.ambiguous( new MyOtherObject("12345") )+'' ); + + // should pass AnotherObject.valueOf() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new AnotherObject(\"12345\") ) +''", + "INT", + TEST_CLASS.ambiguous( new AnotherObject("12345") )+'' ); + + test(); + diff --git a/mozilla/js/tests/lc3/ConvertJSObject/ToJSObject-001.js b/mozilla/js/tests/lc3/ConvertJSObject/ToJSObject-001.js new file mode 100644 index 00000000000..40ed45f7988 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertJSObject/ToJSObject-001.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. + * + */ +/** + * Preferred Argument Conversion. + * + * Passing a JavaScript boolean to a Java method should prefer to call + * a Java method of the same name that expects a Java boolean. + * + */ + var SECTION = "Preferred argument conversion: boolean"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.jsobject.JSObject_001; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new String() ) +''", + "JSOBJECT", + TEST_CLASS.ambiguous(new String()) +'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Boolean() ) +''", + "JSOBJECT", + TEST_CLASS.ambiguous( new Boolean() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Number() ) +''", + "JSOBJECT", + TEST_CLASS.ambiguous( new Number() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Date() ) +''", + "JSOBJECT", + TEST_CLASS.ambiguous( new Date() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Function() ) +''", + "JSOBJECT", + TEST_CLASS.ambiguous( new Function() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Array() ) +''", + "JSOBJECT", + TEST_CLASS.ambiguous( new Array() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( this ) +''", + "JSOBJECT", + TEST_CLASS.ambiguous( this )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new RegExp() ) +''", + "JSOBJECT", + TEST_CLASS.ambiguous( new RegExp() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( Math ) +''", + "JSOBJECT", + TEST_CLASS.ambiguous( Math )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Object() ) +''", + "JSOBJECT", + TEST_CLASS.ambiguous( new Object() )+'' ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertJSObject/ToLong-001.js b/mozilla/js/tests/lc3/ConvertJSObject/ToLong-001.js new file mode 100644 index 00000000000..5dcd0c60440 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertJSObject/ToLong-001.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. + * + */ +/** + * Preferred Argument Conversion. + * + * Passing a JavaScript boolean to a Java method should prefer to call + * a Java method of the same name that expects a Java boolean. + * + */ + var SECTION = "Preferred argument conversion: JavaScript Object to Long"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new Packages.com.netscape.javascript.qa.lc3.jsobject.JSObject_006; + + function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + } + + function MyFunction() { + return; + } + MyFunction.valueOf = new Function( "return 6060842" ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new String() ) +''", + "LONG", + TEST_CLASS.ambiguous(new String()) +'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Boolean() ) +''", + "LONG", + TEST_CLASS.ambiguous( new Boolean() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Number() ) +''", + "LONG", + TEST_CLASS.ambiguous( new Number() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Date(0) ) +''", + "LONG", + TEST_CLASS.ambiguous( new Date(0) )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Array() ) +''", + "LONG", + TEST_CLASS.ambiguous( new Array() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new MyObject(999) ) +''", + "LONG", + TEST_CLASS.ambiguous( new MyObject(999) )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( MyFunction ) +''", + "LONG", + TEST_CLASS.ambiguous( MyFunction )+'' ); + + test(); + + diff --git a/mozilla/js/tests/lc3/ConvertJSObject/ToLong-002.js b/mozilla/js/tests/lc3/ConvertJSObject/ToLong-002.js new file mode 100644 index 00000000000..fa66c2aa9e6 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertJSObject/ToLong-002.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. + * + */ +/** + * Preferred Argument Conversion. + * + * Passing a JavaScript boolean to a Java method should prefer to call + * a Java method of the same name that expects a Java boolean. + * + */ + var SECTION = "Preferred argument conversion: JavaScript Object to Long"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new Packages.com.netscape.javascript.qa.lc3.jsobject.JSObject_006; + + function MyFunction() { + return "hello"; + } + MyFunction.valueOf = new Function( "return 999" ); + + function MyOtherFunction() { + return "goodbye"; + } + MyOtherFunction.valueOf = null; + MyOtherFunction.toString = new Function( "return 999" ); + + function MyObject(value) { + this.value = value; + this.valueOf = new Function("return this.value"); + } + + function MyOtherObject(stringValue) { + this.stringValue = String( stringValue ); + this.toString = new Function( "return this.stringValue" ); + this.valueOf = null; + } + + function AnotherObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return 666" ); + } + + // should pass MyFunction.valueOf() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( MyFunction ) +''", + "LONG", + TEST_CLASS.ambiguous( MyFunction )+'' ); + + // should pass MyOtherFunction.toString() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( MyOtherFunction ) +''", + "LONG", + TEST_CLASS.ambiguous( MyOtherFunction )+'' ); + + // should pass MyObject.valueOf() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new MyObject(12345) ) +''", + "LONG", + TEST_CLASS.ambiguous( new MyObject(12345) )+'' ); + + // should pass MyOtherObject.toString() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new MyOtherObject(\"12345\") ) +''", + "LONG", + TEST_CLASS.ambiguous( new MyOtherObject("12345") )+'' ); + + // should pass AnotherObject.valueOf() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new AnotherObject(\"12345\") ) +''", + "LONG", + TEST_CLASS.ambiguous( new AnotherObject("12345") )+'' ); + + test(); + diff --git a/mozilla/js/tests/lc3/ConvertJSObject/ToObject-001.js b/mozilla/js/tests/lc3/ConvertJSObject/ToObject-001.js new file mode 100644 index 00000000000..f8262115afd --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertJSObject/ToObject-001.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. + * + */ +/** + * Preferred Argument Conversion. + * + * Passing a JavaScript boolean to a Java method should prefer to call + * a Java method of the same name that expects a Java boolean. + * + */ + var SECTION = "Preferred argument conversion: boolean"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new Packages.com.netscape.javascript.qa.lc3.jsobject.JSObject_002; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new String() ) +''", + "OBJECT", + TEST_CLASS.ambiguous(new String()) +'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Boolean() ) +''", + "OBJECT", + TEST_CLASS.ambiguous( new Boolean() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Number() ) +''", + "OBJECT", + TEST_CLASS.ambiguous( new Number() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Date() ) +''", + "OBJECT", + TEST_CLASS.ambiguous( new Date() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Function() ) +''", + "OBJECT", + TEST_CLASS.ambiguous( new Function() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Array() ) +''", + "OBJECT", + TEST_CLASS.ambiguous( new Array() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( this ) +''", + "OBJECT", + TEST_CLASS.ambiguous( this )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new RegExp() ) +''", + "OBJECT", + TEST_CLASS.ambiguous( new RegExp() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( Math ) +''", + "OBJECT", + TEST_CLASS.ambiguous( Math )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Object() ) +''", + "OBJECT", + TEST_CLASS.ambiguous( new Object() )+'' ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertJSObject/ToShort-001.js b/mozilla/js/tests/lc3/ConvertJSObject/ToShort-001.js new file mode 100644 index 00000000000..0c79050c7b7 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertJSObject/ToShort-001.js @@ -0,0 +1,61 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * Passing a JavaScript boolean to a Java method should prefer to call + * a Java method of the same name that expects a Java boolean. + * + */ + var SECTION = "Preferred argument conversion: JavaScript Object to short"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new Packages.com.netscape.javascript.qa.lc3.jsobject.JSObject_008; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new String() ) +''", + "SHORT", + TEST_CLASS.ambiguous(new String()) +'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Boolean() ) +''", + "SHORT", + TEST_CLASS.ambiguous( new Boolean() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Number() ) +''", + "SHORT", + TEST_CLASS.ambiguous( new Number() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Date(999) ) +''", + "SHORT", + TEST_CLASS.ambiguous( new Date(999) )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Array() ) +''", + "SHORT", + TEST_CLASS.ambiguous( new Array() )+'' ); + + test(); + + diff --git a/mozilla/js/tests/lc3/ConvertJSObject/ToShort-002.js b/mozilla/js/tests/lc3/ConvertJSObject/ToShort-002.js new file mode 100644 index 00000000000..432cbb994c1 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertJSObject/ToShort-002.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. + * + */ +/** + * Preferred Argument Conversion. + * + * Passing a JavaScript boolean to a Java method should prefer to call + * a Java method of the same name that expects a Java boolean. + * + */ + var SECTION = "Preferred argument conversion: JavaScript Object to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new Packages.com.netscape.javascript.qa.lc3.jsobject.JSObject_008; + + function MyFunction() { + return "hello"; + } + MyFunction.valueOf = new Function( "return 999" ); + + function MyOtherFunction() { + return "goodbye"; + } + MyOtherFunction.valueOf = null; + MyOtherFunction.toString = new Function( "return 999" ); + + function MyObject(value) { + this.value = value; + this.valueOf = new Function("return this.value"); + } + + function MyOtherObject(stringValue) { + this.stringValue = String( stringValue ); + this.toString = new Function( "return this.stringValue" ); + this.valueOf = null; + } + + function AnotherObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return 666" ); + } + + // should pass MyFunction.valueOf() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( MyFunction ) +''", + "SHORT", + TEST_CLASS.ambiguous( MyFunction )+'' ); + + // should pass MyOtherFunction.toString() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( MyOtherFunction ) +''", + "SHORT", + TEST_CLASS.ambiguous( MyOtherFunction )+'' ); + + // should pass MyObject.valueOf() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new MyObject(12345) ) +''", + "SHORT", + TEST_CLASS.ambiguous( new MyObject(12345) )+'' ); + + // should pass MyOtherObject.toString() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new MyOtherObject(\"12345\") ) +''", + "SHORT", + TEST_CLASS.ambiguous( new MyOtherObject("12345") )+'' ); + + // should pass AnotherObject.valueOf() to ambiguous + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new AnotherObject(\"12345\") ) +''", + "SHORT", + TEST_CLASS.ambiguous( new AnotherObject("12345") )+'' ); + + test(); + diff --git a/mozilla/js/tests/lc3/ConvertJSObject/ToString-001.js b/mozilla/js/tests/lc3/ConvertJSObject/ToString-001.js new file mode 100644 index 00000000000..cf320338ba4 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertJSObject/ToString-001.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. + * + */ +/** + * Preferred Argument Conversion. + * + * Passing a JavaScript boolean to a Java method should prefer to call + * a Java method of the same name that expects a Java boolean. + * + */ + var SECTION = "Preferred argument conversion: boolean"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new Packages.com.netscape.javascript.qa.lc3.jsobject.JSObject_003; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new String() ) +''", + "STRING", + TEST_CLASS.ambiguous(new String()) +'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Boolean() ) +''", + "STRING", + TEST_CLASS.ambiguous( new Boolean() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Number() ) +''", + "STRING", + TEST_CLASS.ambiguous( new Number() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Date() ) +''", + "STRING", + TEST_CLASS.ambiguous( new Date() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Function() ) +''", + "STRING", + TEST_CLASS.ambiguous( new Function() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Array() ) +''", + "STRING", + TEST_CLASS.ambiguous( new Array() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( this ) +''", + "STRING", + TEST_CLASS.ambiguous( this )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new RegExp() ) +''", + "STRING", + TEST_CLASS.ambiguous( new RegExp() )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( Math ) +''", + "STRING", + TEST_CLASS.ambiguous( Math )+'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( new Object() ) +''", + "STRING", + TEST_CLASS.ambiguous( new Object() )+'' ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertNull/null-001.js b/mozilla/js/tests/lc3/ConvertNull/null-001.js new file mode 100644 index 00000000000..aba5fb3a39a --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertNull/null-001.js @@ -0,0 +1,45 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * There is no preference among Java types for converting from the jJavaScript + * undefined value. + * + */ + var SECTION = "Preferred argument conversion: null"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.jsnull.Null_001; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(java.lang.Object)\"](null) +''", + "OBJECT", + TEST_CLASS["ambiguous(java.lang.Object)"](null) +'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(java.lang.String)\"](null) +''", + "STRING", + TEST_CLASS["ambiguous(java.lang.String)"](null) +'' ); + + test(); diff --git a/mozilla/js/tests/lc3/ConvertNull/null-002.js b/mozilla/js/tests/lc3/ConvertNull/null-002.js new file mode 100644 index 00000000000..b5ba13759e8 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertNull/null-002.js @@ -0,0 +1,56 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * There is no preference among Java types for converting from the jJavaScript + * undefined value. + * + */ + var SECTION = "Preferred argument conversion: null"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + // pass null to a static method that expects an Object with explicit + // method syntax. + + testcases[testcases.length] = new TestCase( + "java.lang.String[\"valueOf(java.lang.Object)\"](null) +''", + "null", + java.lang.String["valueOf(java.lang.Object)"](null) + "" ); + + // Pass null to a static method that expects a string without explicit + // method syntax. In this case, there is only one matching method. + + testcases[testcases.length] = new TestCase( + "java.lang.Boolean.valueOf(null) +''", + "false", + java.lang.Boolean.valueOf(null) +"" ); + + // Pass null to a static method that expects a string using explicit + // method syntax. + + testcases[testcases.length] = new TestCase( + "java.lang.Boolean[\"valueOf(java.lang.String)\"](null)", + "false", + java.lang.Boolean["valueOf(java.lang.String)"](null) +"" ); + + test(); diff --git a/mozilla/js/tests/lc3/ConvertNull/null-003-n.js b/mozilla/js/tests/lc3/ConvertNull/null-003-n.js new file mode 100644 index 00000000000..40e9cc83cbf --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertNull/null-003-n.js @@ -0,0 +1,43 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * There is no preference among Java types for converting from the jJavaScript + * undefined value. + * + */ + var SECTION = "Preferred argument conversion: null"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.jsnull.Null_001; + + // Call an ambiguous method without using the explicit method + // syntax should be an error. + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous(null)", + "error", + TEST_CLASS.ambiguous(null) ); + + test(); diff --git a/mozilla/js/tests/lc3/ConvertNull/null-004-n.js b/mozilla/js/tests/lc3/ConvertNull/null-004-n.js new file mode 100644 index 00000000000..e9609d423e6 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertNull/null-004-n.js @@ -0,0 +1,43 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * There is no preference among Java types for converting from the jJavaScript + * undefined value. + * + */ + var SECTION = "Preferred argument conversion: null"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.jsnull.Null_001; + + // Call an ambiguous static method without using the explicit method + // syntax should be an error. + + testcases[testcases.length] = new TestCase( + "Packages.com.netscape.javascript.qa.lc3.jsnull.Null_001.staticAmbiguous(null)", + "error", + Packages.com.netscape.javascript.qa.lc3.jsnull.Null_001.staticAmbiguous(null) ); + + test(); diff --git a/mozilla/js/tests/lc3/ConvertNull/null-005.js b/mozilla/js/tests/lc3/ConvertNull/null-005.js new file mode 100644 index 00000000000..9409620df2f --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertNull/null-005.js @@ -0,0 +1,54 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * There is no preference among Java types for converting from the jJavaScript + * undefined value. + * + */ + var SECTION = "Preferred argument conversion: null"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.jsnull.Null_001; + + // Call an ambiguous static method using the explicit method + // syntax should succeed. + + testcases[testcases.length] = new TestCase( + "Packages.com.netscape.javascript.qa.lc3.jsnull.Null_001[\"staticAmbiguous(java.lang.Object)\"](null)", + "STATIC_OBJECT", + Packages.com.netscape.javascript.qa.lc3.jsnull.Null_001["staticAmbiguous(java.lang.Object)"](null) +""); + + testcases[testcases.length] = new TestCase( + "Packages.com.netscape.javascript.qa.lc3.jsnull.Null_001[\"staticAmbiguous(java.lang.Boolean)\"](null)", + "STATIC_BOOLEAN_OBJECT", + Packages.com.netscape.javascript.qa.lc3.jsnull.Null_001["staticAmbiguous(java.lang.Boolean)"](null) +""); + + testcases[testcases.length] = new TestCase( + "Packages.com.netscape.javascript.qa.lc3.jsnull.Null_001[\"staticAmbiguous(java.lang.String)\"](null)", + "STATIC_STRING", + Packages.com.netscape.javascript.qa.lc3.jsnull.Null_001["staticAmbiguous(java.lang.String)"](null) +""); + + + test(); diff --git a/mozilla/js/tests/lc3/ConvertNull/null-006-n.js b/mozilla/js/tests/lc3/ConvertNull/null-006-n.js new file mode 100644 index 00000000000..f0e83dfef40 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertNull/null-006-n.js @@ -0,0 +1,43 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * There is no preference among Java types for converting from the jJavaScript + * undefined value. + * + */ + var SECTION = "Preferred argument conversion: null"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.jsnull.Null_001; + + // Call an ambiguous static method using the explicit method + // syntax, where the method in question does not exist. + + testcases[testcases.length] = new TestCase( + "Packages.com.netscape.javascript.qa.lc3.jsnull.Null_001[\"staticAmbiguous(java.lang.Class)\"](null)", + "error", + Packages.com.netscape.javascript.qa.lc3.jsnull.Null_001["staticAmbiguous(java.lang.Class)"](null) +""); + + test(); diff --git a/mozilla/js/tests/lc3/ConvertNumber/number-001.js b/mozilla/js/tests/lc3/ConvertNumber/number-001.js new file mode 100644 index 00000000000..b6be3a75f11 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertNumber/number-001.js @@ -0,0 +1,39 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * Pass a JavaScript number to ambiguous method. + * + */ + var SECTION = "Preferred argument conversion: undefined"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.number.Number_001; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous(1)", + TEST_CLASS.expect(), + TEST_CLASS.ambiguous(1) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertNumber/number-002.js b/mozilla/js/tests/lc3/ConvertNumber/number-002.js new file mode 100644 index 00000000000..8788c71c0dc --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertNumber/number-002.js @@ -0,0 +1,39 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * Pass a JavaScript number to ambiguous method. + * + */ + var SECTION = "Preferred argument conversion: undefined"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.number.Number_002; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous(1)", + TEST_CLASS.expect(), + TEST_CLASS.ambiguous(1) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertNumber/number-003.js b/mozilla/js/tests/lc3/ConvertNumber/number-003.js new file mode 100644 index 00000000000..55181eae64a --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertNumber/number-003.js @@ -0,0 +1,39 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * Pass a JavaScript number to ambiguous method. + * + */ + var SECTION = "Preferred argument conversion: undefined"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.number.Number_003; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous(1)", + TEST_CLASS.expect(), + TEST_CLASS.ambiguous(1) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertNumber/number-004.js b/mozilla/js/tests/lc3/ConvertNumber/number-004.js new file mode 100644 index 00000000000..78ce025f6d7 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertNumber/number-004.js @@ -0,0 +1,39 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * Pass a JavaScript number to ambiguous method. + * + */ + var SECTION = "Preferred argument conversion: undefined"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.number.Number_004; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous(1)", + TEST_CLASS.expect(), + TEST_CLASS.ambiguous(1) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertNumber/number-005.js b/mozilla/js/tests/lc3/ConvertNumber/number-005.js new file mode 100644 index 00000000000..504e644b465 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertNumber/number-005.js @@ -0,0 +1,39 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * Pass a JavaScript number to ambiguous method. + * + */ + var SECTION = "Preferred argument conversion: undefined"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.number.Number_005; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous(1)", + TEST_CLASS.expect(), + TEST_CLASS.ambiguous(1) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertNumber/number-006.js b/mozilla/js/tests/lc3/ConvertNumber/number-006.js new file mode 100644 index 00000000000..5e0fcbbeef0 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertNumber/number-006.js @@ -0,0 +1,39 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * Pass a JavaScript number to ambiguous method. + * + */ + var SECTION = "Preferred argument conversion: undefined"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.number.Number_006; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous(1)", + TEST_CLASS.expect(), + TEST_CLASS.ambiguous(1) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertNumber/number-007.js b/mozilla/js/tests/lc3/ConvertNumber/number-007.js new file mode 100644 index 00000000000..1c11484f0d9 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertNumber/number-007.js @@ -0,0 +1,39 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * Pass a JavaScript number to ambiguous method. + * + */ + var SECTION = "Preferred argument conversion: undefined"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.number.Number_007; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous(1)", + TEST_CLASS.expect(), + TEST_CLASS.ambiguous(1) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertNumber/number-008.js b/mozilla/js/tests/lc3/ConvertNumber/number-008.js new file mode 100644 index 00000000000..5fb8b821792 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertNumber/number-008.js @@ -0,0 +1,39 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * Pass a JavaScript number to ambiguous method. + * + */ + var SECTION = "Preferred argument conversion: undefined"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.number.Number_008; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous(1)", + TEST_CLASS.expect(), + TEST_CLASS.ambiguous(1) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertNumber/number-009.js b/mozilla/js/tests/lc3/ConvertNumber/number-009.js new file mode 100644 index 00000000000..bb6186e8505 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertNumber/number-009.js @@ -0,0 +1,39 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * Pass a JavaScript number to ambiguous method. + * + */ + var SECTION = "Preferred argument conversion: undefined"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.number.Number_009; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous(1)", + TEST_CLASS.expect(), + TEST_CLASS.ambiguous(1) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertNumber/number-010.js b/mozilla/js/tests/lc3/ConvertNumber/number-010.js new file mode 100644 index 00000000000..8de914f0256 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertNumber/number-010.js @@ -0,0 +1,39 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * Pass a JavaScript number to ambiguous method. + * + */ + var SECTION = "Preferred argument conversion: undefined"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.number.Number_010; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous(1)", + TEST_CLASS.expect(), + TEST_CLASS.ambiguous(1) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertNumber/number-011.js b/mozilla/js/tests/lc3/ConvertNumber/number-011.js new file mode 100644 index 00000000000..1569ecac7ef --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertNumber/number-011.js @@ -0,0 +1,86 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * Use the explicit method invocation syntax to override the preferred + * argument conversion. + * + */ + var SECTION = "Preferred argument conversion: undefined"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.number.Number_001; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(java.lang.Object)\"](1)", + "OBJECT", + TEST_CLASS["ambiguous(java.lang.Object)"](1) +''); + + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(java.lang.String)\"](1)", + "STRING", + TEST_CLASS["ambiguous(java.lang.String)"](1) +''); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(byte)\"](1)", + "BYTE", + TEST_CLASS["ambiguous(byte)"](1) +''); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(char)\"](1)", + "CHAR", + TEST_CLASS["ambiguous(char)"](1) +''); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(short)\"](1)", + "SHORT", + TEST_CLASS["ambiguous(short)"](1) +''); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(int)\"](1)", + "INT", + TEST_CLASS["ambiguous(int)"](1) +''); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(long)\"](1)", + "LONG", + TEST_CLASS["ambiguous(long)"](1) +''); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(float)\"](1)", + "FLOAT", + TEST_CLASS["ambiguous(float)"](1) +''); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(java.lang.Double)\"](1)", + "DOUBLE_OBJECT", + TEST_CLASS["ambiguous(java.lang.Double)"](1) +''); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(double)\"](1)", + "DOUBLE", + TEST_CLASS["ambiguous(double)"](1) +''); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertString/string-001.js b/mozilla/js/tests/lc3/ConvertString/string-001.js new file mode 100644 index 00000000000..2404db2035b --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertString/string-001.js @@ -0,0 +1,41 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * Pass a JavaScript number to ambiguous method. + * + */ + var SECTION = "Preferred argument conversion: string"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.string.String_001; + + var string = "JavaScript Test String"; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous(string)", + TEST_CLASS.expect(), + TEST_CLASS.ambiguous(string) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertString/string-002.js b/mozilla/js/tests/lc3/ConvertString/string-002.js new file mode 100644 index 00000000000..5d9b622d14e --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertString/string-002.js @@ -0,0 +1,41 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * Pass a JavaScript number to ambiguous method. + * + */ + var SECTION = "Preferred argument conversion: string"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.string.String_002; + + var string = "JavaScript Test String"; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous(string)", + TEST_CLASS.expect(), + TEST_CLASS.ambiguous(string) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertString/string-003.js b/mozilla/js/tests/lc3/ConvertString/string-003.js new file mode 100644 index 00000000000..a7ae75990b0 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertString/string-003.js @@ -0,0 +1,41 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * Pass a JavaScript number to ambiguous method. + * + */ + var SECTION = "Preferred argument conversion: string"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.string.String_003; + + var string = "J"; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous(string)", + TEST_CLASS.expect(), + TEST_CLASS.ambiguous(string) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertString/string-004-n.js b/mozilla/js/tests/lc3/ConvertString/string-004-n.js new file mode 100644 index 00000000000..5734dabeab4 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertString/string-004-n.js @@ -0,0 +1,41 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * Pass a JavaScript number to ambiguous method. + * + */ + var SECTION = "Preferred argument conversion: string"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.string.String_003; + + var string = "JavaScript Test String"; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous(string)", + TEST_CLASS.expect(), + TEST_CLASS.ambiguous(string) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertString/string-005-n.js b/mozilla/js/tests/lc3/ConvertString/string-005-n.js new file mode 100644 index 00000000000..3f7c46a613c --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertString/string-005-n.js @@ -0,0 +1,41 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * Pass a JavaScript number to ambiguous method. + * + */ + var SECTION = "Preferred argument conversion: string"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.string.String_004; + + var string = "255"; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous(string)", + "error", + TEST_CLASS.ambiguous(string) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertString/string-006.js b/mozilla/js/tests/lc3/ConvertString/string-006.js new file mode 100644 index 00000000000..141da36877a --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertString/string-006.js @@ -0,0 +1,83 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * Pass a JavaScript number to ambiguous method. Use the explicit method + * invokation syntax to override the preferred argument conversion. + * + */ + var SECTION = "Preferred argument conversion: string"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.string.String_001; + + var string = "255"; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(java.lang.String)\"](string))", + "STRING", + TEST_CLASS["ambiguous(java.lang.String)"](string) +''); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(java.lang.Object)\"](string))", + "OBJECT", + TEST_CLASS["ambiguous(java.lang.Object)"](string) +''); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(char)\"](string))", + "CHAR", + TEST_CLASS["ambiguous(char)"](string) +''); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(double)\"](string))", + "DOUBLE", + TEST_CLASS["ambiguous(double)"](string) +''); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(float)\"](string))", + "FLOAT", + TEST_CLASS["ambiguous(float)"](string) +''); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(long)\"](string))", + "LONG", + TEST_CLASS["ambiguous(long)"](string) +''); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(int)\"](string))", + "INT", + TEST_CLASS["ambiguous(int)"](string) +''); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(short)\"](string))", + "SHORT", + TEST_CLASS["ambiguous(short)"](string) +''); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(byte)\"](\"127\"))", + "BYTE", + TEST_CLASS["ambiguous(byte)"]("127") +''); + + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertString/string-007-n.js b/mozilla/js/tests/lc3/ConvertString/string-007-n.js new file mode 100644 index 00000000000..c3626b6910a --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertString/string-007-n.js @@ -0,0 +1,42 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * Pass a JavaScript number to ambiguous method. Use the explicit method + * invokation syntax to override the preferred argument conversion. + * + */ + var SECTION = "Preferred argument conversion: string"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.string.String_001; + + var string = "255"; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(boolean)\"](string))", + "error", + TEST_CLASS["ambiguous(boolean)"](string) +''); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertUndefined/undefined-001-n.js b/mozilla/js/tests/lc3/ConvertUndefined/undefined-001-n.js new file mode 100644 index 00000000000..641869b0633 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertUndefined/undefined-001-n.js @@ -0,0 +1,40 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * There is no preference among Java types for converting from the jJavaScript + * undefined value. + * + */ + var SECTION = "Preferred argument conversion: undefined"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.undefined.Undefined_001; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS.ambiguous( void 0 )", + "error", + TEST_CLASS.ambiguous(void 0) ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertUndefined/undefined-002.js b/mozilla/js/tests/lc3/ConvertUndefined/undefined-002.js new file mode 100644 index 00000000000..00053012235 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertUndefined/undefined-002.js @@ -0,0 +1,46 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * There is no preference among Java types for converting from the jJavaScript + * undefined value. + * + */ + var SECTION = "Preferred argument conversion: undefined"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.undefined.Undefined_001; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(java.lang.Object)\"](void 0) +''", + "OBJECT", + TEST_CLASS["ambiguous(java.lang.Object)"](void 0) +'' ); + + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(java.lang.String)\"](void 0) +''", + "STRING", + TEST_CLASS["ambiguous(java.lang.String)"](void 0) +'' ); + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/ConvertUndefined/undefined-003.js b/mozilla/js/tests/lc3/ConvertUndefined/undefined-003.js new file mode 100644 index 00000000000..50503c31870 --- /dev/null +++ b/mozilla/js/tests/lc3/ConvertUndefined/undefined-003.js @@ -0,0 +1,45 @@ +/* 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. + * + */ +/** + * Preferred Argument Conversion. + * + * There is no preference among Java types for converting from the jJavaScript + * undefined value. + * + */ + var SECTION = "Preferred argument conversion: undefined"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var TEST_CLASS = new + Packages.com.netscape.javascript.qa.lc3.undefined.Undefined_001; + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(java.lang.Object)\"](void 0) +''", + "OBJECT", + TEST_CLASS["ambiguous(java.lang.Object)"](void 0) +'' ); + + testcases[testcases.length] = new TestCase( + "TEST_CLASS[\"ambiguous(java.lang.String)\"](void 0) +''", + "STRING", + TEST_CLASS["ambiguous(java.lang.String)"](void 0) +'' ); + + test(); diff --git a/mozilla/js/tests/lc3/Exceptions/throw_js_types.js b/mozilla/js/tests/lc3/Exceptions/throw_js_types.js new file mode 100644 index 00000000000..80c72f81da8 --- /dev/null +++ b/mozilla/js/tests/lc3/Exceptions/throw_js_types.js @@ -0,0 +1,253 @@ +/* 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: throw_js_type.js + Title: Throw JS types as exceptions through Java + Description: Attempt to throw all of the basic JS primitive types + ie. String + Number + Boolean + Object + as exceptions through Java. If wrapping/unwrapping + occurs as expected, the original type will be + preserved. + + Author: Chris Cooper + Email: coop@netscape.com + Date: 12/04/1998 +*/ + +var SECTION = "LC3"; +var TITLE = "Throw JS types as exceptions through Java"; +startTest(); +var testcases = new Array(); +var exception = "No exception thrown"; +var result = "Failed"; +var data_type = "no type"; + +/************************** + * JS String + *************************/ +try { + exception = Packages.com.netscape.javascript.qa.liveconnect.JSObjectEval.eval(this, "throw 'foo';"); +} catch ( e ) { + exception = e.toString(); + data_type = typeof e; + if (exception == "foo") + result = "Passed!"; +} + +testcases[tc++] = new TestCase("Throwing JS string through Java "+ + "\n=> threw ("+data_type+") "+exception+" ", + "Passed!", + result ); + +/************************** + * JS Number (int) + *************************/ +exception = "No exception thrown"; +result = "Failed"; +data_type = "no type"; + +try { + exception = Packages.com.netscape.javascript.qa.liveconnect.JSObjectEval.eval(this, "throw 42;"); +} catch ( e ) { + exception = e.toString(); + data_type = typeof e; + if (exception == "42") + result = "Passed!"; +} + +testcases[tc++] = new TestCase("Throwing JS number (int) through Java "+ + "\n=> threw ("+data_type+") "+exception+" ", + "Passed!", + result ); + +/************************** + * JS Number (float) + *************************/ +exception = "No exception thrown"; +result = "Failed"; +data_type = "no type"; + +try { + exception = Packages.com.netscape.javascript.qa.liveconnect.JSObjectEval.eval(this, "throw 4.2;"); +} catch ( e ) { + exception = e.toString(); + data_type = typeof e; + if (exception == "4.2") + result = "Passed!"; +} + +testcases[tc++] = new TestCase("Throwing JS number (float) through Java "+ + "\n=> threw ("+data_type+") "+exception+" ", + "Passed!", + result ); + +/************************** + * JS Boolean + *************************/ +exception = "No exception thrown"; +result = "Failed"; +data_type = "no type"; + +try { + exception = Packages.com.netscape.javascript.qa.liveconnect.JSObjectEval.eval(this, "throw false;"); +} catch ( e ) { + exception = e.toString(); + data_type = typeof e; + if (exception == "false") + result = "Passed!"; +} + +testcases[tc++] = new TestCase("Throwing JS boolean through Java "+ + "\n=> threw ("+data_type+") "+exception+" ", + "Passed!", + result ); + +/************************** + * JS Object + *************************/ +exception = "No exception thrown"; +result = "Failed"; +data_type = "no type"; + +try { + exception = Packages.com.netscape.javascript.qa.liveconnect.JSObjectEval.eval(this, "throw {a:5};"); +} catch ( e ) { + exception = e.toString(); + data_type = typeof e; + result = "Passed!"; +} + +testcases[tc++] = new TestCase("Throwing JS Object through Java "+ + "\n=> threw ("+data_type+") "+exception+" ", + "Passed!", + result ); + +/************************** + * JS Object (Date) + *************************/ +exception = "No exception thrown"; +result = "Failed"; +data_type = "no type"; + +try { + exception = Packages.com.netscape.javascript.qa.liveconnect.JSObjectEval.eval(this, "throw new Date();"); +} catch ( e ) { + exception = e.toString(); + data_type = typeof e; + result = "Passed!"; +} + +testcases[tc++] = new TestCase("Throwing JS Object (Date)through Java "+ + "\n=> threw ("+data_type+") "+exception+" ", + "Passed!", + result ); + +/************************** + * JS Object (String) + *************************/ +exception = "No exception thrown"; +result = "Failed"; +data_type = "no type"; + +try { + exception = Packages.com.netscape.javascript.qa.liveconnect.JSObjectEval.eval(this, "throw new String();"); +} catch ( e ) { + exception = e.toString(); + data_type = typeof e; + result = "Passed!"; +} + +testcases[tc++] = new TestCase("Throwing JS Object (String) through Java "+ + "\n=> threw ("+data_type+") "+exception+" ", + "Passed!", + result ); + +/************************** + * Undefined + *************************/ +exception = "No exception thrown"; +result = "Failed"; +data_type = "no type"; + +try { + exception = Packages.com.netscape.javascript.qa.liveconnect.JSObjectEval.eval(this, "throw undefined"); +} catch ( e ) { + exception = "Exception"; + data_type = typeof e; + result = "Passed!"; +} + +testcases[tc++] = new TestCase("Throwing undefined through Java "+ + "\n=> threw ("+data_type+") "+exception+" ", + "Passed!", + result ); + +/************************** + * null + *************************/ +exception = "No exception thrown"; +result = "Failed"; +data_type = "no type"; + +try { + exception = Packages.com.netscape.javascript.qa.liveconnect.JSObjectEval.eval(this, "throw null;"); +} catch ( e ) { + exception = "Exception"; + data_type = typeof e; + result = "Passed!"; +} + +testcases[tc++] = new TestCase("Throwing null through Java "+ + "\n=> threw ("+data_type+") "+exception+" ", + "Passed!", + result ); + +test(); + + +function test() { + // Iterate through testcases, and print results to the display. You + // probably want to leave this block alone. You don't really need to + // do this, but it helps if you want the test case results to be + // written to the display. + + 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 "; + } + + // Leave the following line alone. All tests must call stop tests just + // before they return the testcases object. This lets Navigator know that + // the test has completed. + + stopTest(); + + // Leave the following alone. All tests must return an array of + // TestCase objects. + + return ( testcases ); +} diff --git a/mozilla/js/tests/lc3/JSBoolean/boolean-001.js b/mozilla/js/tests/lc3/JSBoolean/boolean-001.js new file mode 100644 index 00000000000..1c02672a0b0 --- /dev/null +++ b/mozilla/js/tests/lc3/JSBoolean/boolean-001.js @@ -0,0 +1,166 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript boolean values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "boolean conversion"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + var BUGNUMBER = "335907"; + + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a boolean to a java method that expects a boolean should map + // directly to the Java true / false equivalent + + a[i++] = new TestObject( + "dt.setBoolean( true )", + "dt.PUB_BOOLEAN", + "dt.getBoolean()", + "typeof dt.getBoolean()", + true, + "boolean" ); + + a[i++] = new TestObject( + "dt.setBoolean( false )", + "dt.PUB_BOOLEAN", + "dt.getBoolean()", + "typeof dt.getBoolean()", + false, + "boolean" ); + + // passing a boolean to a java method that expects a Boolean object + // should convert to a new instance of java.lang.Boolean + + a[i++] = new TestObject( + "dt.setBooleanObject( true )", + "dt.PUB_BOOLEAN_OBJECT +''", + "dt.getBooleanObject() +''", + "dt.getBooleanObject().getClass()", + "true", + java.lang.Class.forName( "java.lang.Boolean") ); + + a[i++] = new TestObject( + "dt.setBooleanObject( false )", + "dt.PUB_BOOLEAN_OBJECT +''", + "dt.getBooleanObject() +''", + "dt.getBooleanObject().getClass()", + "false", + java.lang.Class.forName( "java.lang.Boolean") ); + + + // passing a boolean to a java method that expects a java.lang.Object + // should convert to a new instance of java.lang.Boolean + + a[i++] = new TestObject( + "dt.setObject( true )", + "dt.PUB_OBJECT +''", + "dt.getObject() +''", + "dt.getObject().getClass()", + "true", + java.lang.Class.forName( "java.lang.Boolean") ); + + a[i++] = new TestObject( + "dt.setObject( false )", + "dt.PUB_OBJECT +''", + "dt.getObject() +''", + "dt.getObject().getClass()", + "false", + java.lang.Class.forName( "java.lang.Boolean") ); + + // passing a boolean to a java method that expects a java.lang.String + // should convert true to a java.lang.String whose value is "true" and + // false to a java.lang.String whose value is "false" + + a[i++] = new TestObject( + "dt.setStringObject( true )", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "dt.getStringObject().getClass()", + "true", + java.lang.Class.forName( "java.lang.String") ); + + a[i++] = new TestObject( + "dt.setStringObject( false )", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "dt.getStringObject().getClass()", + "false", + java.lang.Class.forName( "java.lang.String") ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSBoolean/boolean-002-n.js b/mozilla/js/tests/lc3/JSBoolean/boolean-002-n.js new file mode 100644 index 00000000000..0fadddb1136 --- /dev/null +++ b/mozilla/js/tests/lc3/JSBoolean/boolean-002-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript boolean values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "boolean conversion"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a boolean to a java method that expects a boolean should map + // directly to the Java true / false equivalent + + + // passing a boolean to a java method that expects a double + // should be an error + + a[i++] = new TestObject( + "dt.setDouble( true )", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + "error", + "error" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSBoolean/boolean-003-n.js b/mozilla/js/tests/lc3/JSBoolean/boolean-003-n.js new file mode 100644 index 00000000000..a116c402ada --- /dev/null +++ b/mozilla/js/tests/lc3/JSBoolean/boolean-003-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript boolean values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "boolean conversion"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a boolean to a java method that expects a float + // should be an error + + a[i++] = new TestObject( + "dt.setFloat( true )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + "error", + "error" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSBoolean/boolean-004-n.js b/mozilla/js/tests/lc3/JSBoolean/boolean-004-n.js new file mode 100644 index 00000000000..e70fd478749 --- /dev/null +++ b/mozilla/js/tests/lc3/JSBoolean/boolean-004-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript boolean values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "boolean conversion"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a boolean to a java method that expects a long + // should be an error + + a[i++] = new TestObject( + "dt.setLong( true )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + "error", + "error" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSBoolean/boolean-005-n.js b/mozilla/js/tests/lc3/JSBoolean/boolean-005-n.js new file mode 100644 index 00000000000..cbd3c7f9b34 --- /dev/null +++ b/mozilla/js/tests/lc3/JSBoolean/boolean-005-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript boolean values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "boolean conversion"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a boolean to a java method that expects an int + // should be an error + + a[i++] = new TestObject( + "dt.setInteger( true )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInt()", + "error", + "error" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSBoolean/boolean-006-n.js b/mozilla/js/tests/lc3/JSBoolean/boolean-006-n.js new file mode 100644 index 00000000000..f2265d2f356 --- /dev/null +++ b/mozilla/js/tests/lc3/JSBoolean/boolean-006-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript boolean values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "boolean conversion"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a boolean to a java method that expects an short + // should be an error + + a[i++] = new TestObject( + "dt.setShort( true )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + "error", + "error" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSBoolean/boolean-007-n.js b/mozilla/js/tests/lc3/JSBoolean/boolean-007-n.js new file mode 100644 index 00000000000..173bfb62509 --- /dev/null +++ b/mozilla/js/tests/lc3/JSBoolean/boolean-007-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript boolean values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "boolean conversion"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a boolean to a java method that expects an char + // should be an error + + a[i++] = new TestObject( + "dt.setChar( true )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + "error", + "error" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSBoolean/boolean-008-n.js b/mozilla/js/tests/lc3/JSBoolean/boolean-008-n.js new file mode 100644 index 00000000000..2f3023b1c4d --- /dev/null +++ b/mozilla/js/tests/lc3/JSBoolean/boolean-008-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript boolean values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "boolean conversion"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a boolean to a java method that expects an byte + // should be an error + + a[i++] = new TestObject( + "dt.setByte( true )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + "error", + "error" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNull/ToBoolean-001-n.js b/mozilla/js/tests/lc3/JSNull/ToBoolean-001-n.js new file mode 100644 index 00000000000..02567d14e44 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNull/ToBoolean-001-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "null"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JavaScript null to a method that expect a class or interface + // converts null to a java null. passing null to methods that expect + // number types convert null to 0. passing null to methods that expect + // a boolean results in an error. + + a[i++] = new TestObject( + "dt.setBoolean( null )", + "dt.PUB_BOOLEAN", + "dt.getBoolean()", + "typeof dt.getBoolean()", + "error", + "error" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNull/ToFloat-001-n.js b/mozilla/js/tests/lc3/JSNull/ToFloat-001-n.js new file mode 100644 index 00000000000..9a4020b5fa9 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNull/ToFloat-001-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "null"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JavaScript null to a method that expect a class or interface + // converts null to a java null. passing null to methods that expect + // number types convert null to 0. passing null to methods that expect + // a boolean convert null to false. + + + a[i++] = new TestObject( + "dt.setFloat( null )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + "error", + "error" ); +/* + a[i++] = new TestObject( + "dt.setLong( null )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setInteger( null )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setShort( null )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setByte( null )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setChar( null )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 0, + "number" ); +*/ + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNull/ToLong-001-n.js b/mozilla/js/tests/lc3/JSNull/ToLong-001-n.js new file mode 100644 index 00000000000..72ef338adf8 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNull/ToLong-001-n.js @@ -0,0 +1,131 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "null"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JavaScript null to a method that expect a class or interface + // converts null to a java null. passing null to methods that expect + // number types convert null to 0. passing null to methods that expect + // a boolean convert null to false. + + + a[i++] = new TestObject( + "dt.setLong( null )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + "error", + "error" ); +/* + a[i++] = new TestObject( + "dt.setInteger( null )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setShort( null )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setByte( null )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setChar( null )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 0, + "number" ); +*/ + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNull/ToNumber-001-n.js b/mozilla/js/tests/lc3/JSNull/ToNumber-001-n.js new file mode 100644 index 00000000000..16f2f859a8b --- /dev/null +++ b/mozilla/js/tests/lc3/JSNull/ToNumber-001-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "null"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JavaScript null to a method that expect a class or interface + // converts null to a java null. passing null to methods that expect + // number types convert null to 0. passing null to methods that expect + // a boolean convert null to false. + + a[i++] = new TestObject( + "dt.setDouble( null )", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + "error", + "error" ); +/* + a[i++] = new TestObject( + "dt.setFloat( null )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setLong( null )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setInteger( null )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setShort( null )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setByte( null )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setChar( null )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 0, + "number" ); +*/ + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNull/ToObject-001.js b/mozilla/js/tests/lc3/JSNull/ToObject-001.js new file mode 100644 index 00000000000..90639dae81a --- /dev/null +++ b/mozilla/js/tests/lc3/JSNull/ToObject-001.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "null"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JavaScript null to a method that expect a class or interface + // converts null to a java null. passing null to methods that expect + // number types convert null to 0. passing null to methods that expect + // a boolean convert null to false. + + a[i++] = new TestObject( + "dt.setBooleanObject( null )", + "dt.PUB_BOOLEAN_OBJECT", + "dt.getBooleanObject()", + "typeof dt.getBooleanObject()", + null, + "object" ); + + a[i++] = new TestObject( + "dt.setDoubleObject( null )", + "dt.PUB_BOOLEAN_OBJECT", + "dt.getDoubleObject()", + "typeof dt.getDoubleObject()", + null, + "object" ); + + a[i++] = new TestObject( + "dt.setStringObject( null )", + "dt.PUB_STRING", + "dt.getStringObject()", + "typeof dt.getStringObject()", + null, + "object" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); +/* + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); +*/ + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); +// this.javaMethodName = javaMethod; +// this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToByte-001.js b/mozilla/js/tests/lc3/JSNumber/ToByte-001.js new file mode 100644 index 00000000000..9a336d5122b --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToByte-001.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to byte"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a int: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setByte( 0 )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + 0, + "number" ); + + // 0 can only have a negative sign for floats and doubles + + a[i++] = new TestObject( + "dt.setByte( -0 )", + "Infinity / dt.PUB_BYTE", + "Infinity / dt.getByte()", + "typeof dt.getByte()", + Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setByte( java.lang.Byte.MAX_VALUE )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + java.lang.Byte.MAX_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setByte( java.lang.Byte.MIN_VALUE )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + java.lang.Byte.MIN_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setByte( -java.lang.Byte.MAX_VALUE )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + -java.lang.Byte.MAX_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setByte(1e-2000)", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setByte(-1e-2000)", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + 0, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToByte-002-n.js b/mozilla/js/tests/lc3/JSNumber/ToByte-002-n.js new file mode 100644 index 00000000000..5862c2bc859 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToByte-002-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Jav`a methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a int: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setByte(java.lang.Byte.MAX_VALUE +1)", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToByte-003-n.js b/mozilla/js/tests/lc3/JSNumber/ToByte-003-n.js new file mode 100644 index 00000000000..8ca9c2ca811 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToByte-003-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to byte"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a byte: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setByte(java.lang.Byte.MIN_VALUE - 1)", + "dt.PUB_BYTE", + "dt.getShort()", + "typeof dt.getShort()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToByte-004.js b/mozilla/js/tests/lc3/JSNumber/ToByte-004.js new file mode 100644 index 00000000000..3ddc3364c76 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToByte-004.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to byte"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + var BUGNUMBER="335589"; + + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a byte: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setByte(java.lang.Byte.MIN_VALUE + 0.6)", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + java.lang.Byte.MIN_VALUE +1, + "number" ); + + a[i++] = new TestObject( + "dt.setByte(java.lang.Byte.MIN_VALUE + 0.5)", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + java.lang.Byte.MIN_VALUE +1, + "number" ); + + a[i++] = new TestObject( + "dt.setByte(java.lang.Byte.MIN_VALUE + 0.4)", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + java.lang.Byte.MIN_VALUE +1, + "number" ); + + a[i++] = new TestObject( + "dt.setByte(java.lang.Byte.MIN_VALUE - 0.5)", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + java.lang.Byte.MIN_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setByte(java.lang.Byte.MIN_VALUE - 0.4)", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + java.lang.Byte.MIN_VALUE, + "number" ); + a[i++] = new TestObject( + "dt.setByte(java.lang.Byte.MIN_VALUE - 0.6)", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + java.lang.Byte.MIN_VALUE, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToByte-005-n.js b/mozilla/js/tests/lc3/JSNumber/ToByte-005-n.js new file mode 100644 index 00000000000..fb47d7285c2 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToByte-005-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to byte"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a byte: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan is a runtime error. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setByte( NaN )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + "error", + "error" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToChar-001.js b/mozilla/js/tests/lc3/JSNumber/ToChar-001.js new file mode 100644 index 00000000000..06a8d459e78 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToChar-001.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to char"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a int: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setChar( 0 )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 0, + "number" ); + + // 0 can only have a negative sign for floats and doubles + + a[i++] = new TestObject( + "dt.setChar( -0 )", + "Infinity / dt.PUB_CHAR", + "Infinity / dt.getChar()", + "typeof dt.getChar()", + Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setChar( java.lang.Character.MAX_VALUE )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + java.lang.Character.MAX_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setChar( java.lang.Character.MIN_VALUE )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + java.lang.Character.MIN_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setChar( 0 )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setChar(1e-2000)", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setChar(-1e-2000)", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 0, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToChar-002-n.js b/mozilla/js/tests/lc3/JSNumber/ToChar-002-n.js new file mode 100644 index 00000000000..728a953331e --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToChar-002-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Jav`a methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to char"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a char: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setChar(java.lang.Character.MAX_VALUE +1)", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToChar-003-n.js b/mozilla/js/tests/lc3/JSNumber/ToChar-003-n.js new file mode 100644 index 00000000000..6510f77346e --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToChar-003-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to char"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a char: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setChar(java.lang.Character.MIN_VALUE - 1)", + "dt.PUB_CHAR", + "dt.getShort()", + "typeof dt.getShort()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToChar-004.js b/mozilla/js/tests/lc3/JSNumber/ToChar-004.js new file mode 100644 index 00000000000..37ef6f756ab --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToChar-004.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to char"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a char: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setChar(java.lang.Character.MAX_VALUE - 0.5)", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + java.lang.Character.MAX_VALUE - 1, + "number" ); + + a[i++] = new TestObject( + "dt.setChar(java.lang.Character.MAX_VALUE - 0.5)", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + java.lang.Character.MAX_VALUE - 1, + "number" ); + + a[i++] = new TestObject( + "dt.setChar(java.lang.Character.MAX_VALUE - 0.4)", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + java.lang.Character.MAX_VALUE - 1, + "number" ); + + a[i++] = new TestObject( + "dt.setChar(java.lang.Character.MIN_VALUE + 0.6)", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + java.lang.Character.MIN_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setChar(java.lang.Character.MIN_VALUE + 0.4)", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + java.lang.Character.MIN_VALUE, + "number" ); + a[i++] = new TestObject( + "dt.setChar(java.lang.Character.MIN_VALUE + 0.6)", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + java.lang.Character.MIN_VALUE, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToChar-005-n.js b/mozilla/js/tests/lc3/JSNumber/ToChar-005-n.js new file mode 100644 index 00000000000..7ba5613921e --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToChar-005-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to char"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a char: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setChar( NaN )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + "error", + "error" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToChar-006-n.js b/mozilla/js/tests/lc3/JSNumber/ToChar-006-n.js new file mode 100644 index 00000000000..a84ed801a65 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToChar-006-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to char"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a char: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setChar( -1 )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + "error", + "error" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToDouble-001.js b/mozilla/js/tests/lc3/JSNumber/ToDouble-001.js new file mode 100644 index 00000000000..a76bfb8fbac --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToDouble-001.js @@ -0,0 +1,320 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a number to a java method that expects a double should + // transfer the exact value to java with no rounding or loss of magnitude + // or sign. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setDouble( 0 )", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble( -0 )", + "Infinity / dt.PUB_DOUBLE", + "Infinity / dt.getDouble()", + "typeof dt.getDouble()", + -Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble( Infinity )", + "dt.PUB_DOUBLE ", + "dt.getDouble() ", + "typeof dt.getDouble()", + Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble( -Infinity )", + "dt.PUB_DOUBLE", + "dt.getDouble() ", + "typeof dt.getDouble()", + -Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble( NaN )", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + NaN, + "number" ); + + // test cases from waldemar + + a[i++] = new TestObject( + "dt.setDouble(077777777777777777)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 2251799813685247, + "number" ); + + + a[i++] = new TestObject( + "dt.setDouble(077777777777777776)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 2251799813685246, + "number" ); + + + a[i++] = new TestObject( + "dt.setDouble(0x1fffffffffffff)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 9007199254740991, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble(0x20000000000000)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 9007199254740992, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble(0x20123456789abc)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 9027215253084860, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble(0x20123456789abd)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 9027215253084860, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble(0x20123456789abe)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 9027215253084862, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble(0x20123456789abf)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 9027215253084864, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble(0x1000000000000080)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 1152921504606847000, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble(0x1000000000000081)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 1152921504606847200, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble(0x1000000000000100)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 1152921504606847200, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble(0x100000000000017f)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 1152921504606847200, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble(0x1000000000000180)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 1152921504606847500, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble(0x1000000000000181)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 1152921504606847500, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble(1.7976931348623157E+308)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 1.7976931348623157e+308, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble(1.7976931348623158e+308)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 1.7976931348623157e+308, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble(1.7976931348623159e+308)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble(-1.7976931348623157E+308)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + -1.7976931348623157e+308, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble(-1.7976931348623158e+308)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + -1.7976931348623157e+308, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble(-1.7976931348623159e+308)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + -Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble(1e-2000)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble(1e2000)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 1e2000, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble(-1e2000)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + -1e2000, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToDouble-002.js b/mozilla/js/tests/lc3/JSNumber/ToDouble-002.js new file mode 100644 index 00000000000..4d07ad32295 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToDouble-002.js @@ -0,0 +1,320 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a number to a java method that expects a Double object should + // transfer the exact value to java with no rounding or loss of magnitude + // or sign. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setDoubleObject( 0 )", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + 0, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject( -0 )", + "Infinity / dt.PUB_DOUBLE_OBJECT", + "Infinity / dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + -Infinity, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject( Infinity )", + "dt.PUB_DOUBLE_OBJECT.doubleValue() ", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + Infinity, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject( -Infinity )", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + -Infinity, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject( NaN )", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + NaN, + java.lang.Class.forName("java.lang.Double") ); + + // test cases from waldemar + + a[i++] = new TestObject( + "dt.setDoubleObject(077777777777777777)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + 2251799813685247, + java.lang.Class.forName("java.lang.Double") ); + + + a[i++] = new TestObject( + "dt.setDoubleObject(077777777777777776)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + 2251799813685246, + java.lang.Class.forName("java.lang.Double") ); + + + a[i++] = new TestObject( + "dt.setDoubleObject(0x1fffffffffffff)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + 9007199254740991, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject(0x20000000000000)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + 9007199254740992, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject(0x20123456789abc)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + 9027215253084860, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject(0x20123456789abd)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + 9027215253084860, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject(0x20123456789abe)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + 9027215253084862, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject(0x20123456789abf)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + 9027215253084864, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject(0x1000000000000080)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + 1152921504606847000, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject(0x1000000000000081)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + 1152921504606847200, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject(0x1000000000000100)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + 1152921504606847200, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject(0x100000000000017f)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + 1152921504606847200, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject(0x1000000000000180)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + 1152921504606847500, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject(0x1000000000000181)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + 1152921504606847500, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject(1.7976931348623157E+308)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + 1.7976931348623157e+308, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject(1.7976931348623158e+308)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + 1.7976931348623157e+308, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject(1.7976931348623159e+308)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + Infinity, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject(-1.7976931348623157E+308)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + -1.7976931348623157e+308, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject(-1.7976931348623158e+308)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + -1.7976931348623157e+308, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject(-1.7976931348623159e+308)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + -Infinity, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject(1e-2000)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + 0, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject(1e2000)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + 1e2000, + java.lang.Class.forName("java.lang.Double") ); + + a[i++] = new TestObject( + "dt.setDoubleObject(-1e2000)", + "dt.PUB_DOUBLE_OBJECT.doubleValue()", + "dt.getDoubleObject().doubleValue()", + "dt.getDoubleObject().getClass()", + -1e2000, + java.lang.Class.forName("java.lang.Double") ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToDouble-003.js b/mozilla/js/tests/lc3/JSNumber/ToDouble-003.js new file mode 100644 index 00000000000..bf7691f03d8 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToDouble-003.js @@ -0,0 +1,237 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to float"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a number value to a method that expects a float should round JS + // number to float precision. unrepresentably large values are converted + // to +/- Infinity. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setFloat( 0 )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setFloat( -0 )", + "Infinity / dt.PUB_FLOAT", + "Infinity / dt.getFloat()", + "typeof dt.getFloat()", + -Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setFloat( Infinity )", + "dt.PUB_FLOAT ", + "dt.getFloat() ", + "typeof dt.getFloat()", + Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setFloat( -Infinity )", + "dt.PUB_FLOAT", + "dt.getFloat() ", + "typeof dt.getFloat()", + -Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setFloat( NaN )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + NaN, + "number" ); + + a[i++] = new TestObject( + "dt.setFloat( java.lang.Float.MAX_VALUE )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + java.lang.Float.MAX_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setFloat( java.lang.Float.MIN_VALUE )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + java.lang.Float.MIN_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setFloat( -java.lang.Float.MAX_VALUE )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + -java.lang.Float.MAX_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setFloat( -java.lang.Float.MIN_VALUE )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + -java.lang.Float.MIN_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setFloat(1.7976931348623157E+308)", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setFloat(1.7976931348623158e+308)", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setFloat(1.7976931348623159e+308)", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setFloat(-1.7976931348623157E+308)", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + -Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setFloat(-1.7976931348623158e+308)", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + -Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setFloat(-1.7976931348623159e+308)", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + -Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setFloat(1e-2000)", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setFloat(1e2000)", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setFloat(-1e2000)", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + -Infinity, + "number" ); + + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToInt-001.js b/mozilla/js/tests/lc3/JSNumber/ToInt-001.js new file mode 100644 index 00000000000..86498b76cfd --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToInt-001.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + var BUGNUMBER="335589"; + + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a int: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setInteger( 0 )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 0, + "number" ); + + // only doubles and floats know about -0 + + a[i++] = new TestObject( + "dt.setInteger( -0 )", + "Infinity / dt.PUB_INT", + "Infinity / dt.getInteger()", + "typeof dt.getInteger()", + Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setInteger( java.lang.Integer.MAX_VALUE )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + java.lang.Integer.MAX_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setInteger( java.lang.Integer.MIN_VALUE )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + java.lang.Integer.MIN_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setInteger( -java.lang.Integer.MAX_VALUE )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + -java.lang.Integer.MAX_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setInteger(1e-2000)", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setInteger(-1e-2000)", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 0, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToInt-002-n.js b/mozilla/js/tests/lc3/JSNumber/ToInt-002-n.js new file mode 100644 index 00000000000..4ba9deb2a20 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToInt-002-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a int: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setInteger(java.lang.Integer.MAX_VALUE +1)", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToInt-003-n.js b/mozilla/js/tests/lc3/JSNumber/ToInt-003-n.js new file mode 100644 index 00000000000..13b720586a8 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToInt-003-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a int: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setInteger(java.lang.Integer.MIN_VALUE - 1)", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToInt-004.js b/mozilla/js/tests/lc3/JSNumber/ToInt-004.js new file mode 100644 index 00000000000..de2ecabdb5a --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToInt-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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + var BUGNUMBER="335589"; + + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a int: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setInteger(java.lang.Integer.MIN_VALUE - 0.5)", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + java.lang.Integer.MIN_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setInteger(java.lang.Integer.MIN_VALUE - 0.4)", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + java.lang.Integer.MIN_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setInteger(java.lang.Integer.MIN_VALUE + 0.6)", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + java.lang.Integer.MIN_VALUE+1, + "number" ); + + a[i++] = new TestObject( + "dt.setInteger(java.lang.Integer.MIN_VALUE + 0.5)", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + java.lang.Integer.MIN_VALUE +1, + "number" ); + + a[i++] = new TestObject( + "dt.setInteger(java.lang.Integer.MIN_VALUE + 0.4)", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + java.lang.Integer.MIN_VALUE +1, + "number" ); + + a[i++] = new TestObject( + "dt.setInteger(java.lang.Integer.MIN_VALUE - 0.999)", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + java.lang.Integer.MIN_VALUE, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToInt-005-n.js b/mozilla/js/tests/lc3/JSNumber/ToInt-005-n.js new file mode 100644 index 00000000000..f845be24f15 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToInt-005-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a int: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setInteger( NaN )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + "error", + "error" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToLong-001.js b/mozilla/js/tests/lc3/JSNumber/ToLong-001.js new file mode 100644 index 00000000000..2c8912b67c2 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToLong-001.js @@ -0,0 +1,199 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to long"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a long: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setLong( 0 )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setLong( -0 )", + "Infinity / dt.PUB_LONG", + "Infinity / dt.getLong()", + "typeof dt.getLong()", + Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setLong(1234567890123)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + 1234567890123, + "number" ); + + a[i++] = new TestObject( + "dt.setLong(-1234567890123)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + -1234567890123, + "number" ); + + a[i++] = new TestObject( + "dt.setLong(0x7ffffffffffffff)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + 0x7ffffffffffffff, + "number" ); + + a[i++] = new TestObject( + "dt.setLong(0x7ffffffffffffff)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + 0x7ffffffffffffff, + "number" ); + + a[i++] = new TestObject( + "dt.setLong(0xfffffffffffffff)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + 0xfffffffffffffff, + "number" ); + + a[i++] = new TestObject( + "dt.setLong(0x6fffffffffffffff)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + 0x6fffffffffffffff, + "number" ); + + a[i++] = new TestObject( + "dt.setLong(-0x6fffffffffffffff)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + -0x6fffffffffffffff, + "number" ); + +/* + a[i++] = new TestObject( + "dt.setLong( java.lang.Long.MAX_VALUE )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + java.lang.Long.MAX_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setLong( java.lang.Long.MIN_VALUE )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + java.lang.Long.MIN_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setLong( -java.lang.Long.MAX_VALUE )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + -java.lang.Long.MAX_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setLong( -java.lang.Long.MIN_VALUE )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + -java.lang.Long.MIN_VALUE, + "number" ); +*/ + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToLong-002-n.js b/mozilla/js/tests/lc3/JSNumber/ToLong-002-n.js new file mode 100644 index 00000000000..29805c0315d --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToLong-002-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to long"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a long: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: Infinity, -Infinity should cause a runtime error + + a[i++] = new TestObject( + "dt.setLong( Infinity )", + "dt.PUB_LONG ", + "dt.getLong() ", + "typeof dt.getLong()", + "error", + "number" ); +/* + a[i++] = new TestObject( + "dt.setLong( -Infinity )", + "dt.PUB_LONG", + "dt.getLong() ", + "typeof dt.getLong()", + -Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setLong(1.7976931348623157E+308)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setLong(1.7976931348623158e+308)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setLong(1.7976931348623159e+308)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setLong(-1.7976931348623157E+308)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + -Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setLong(-1.7976931348623158e+308)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + -Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setLong(-1.7976931348623159e+308)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + -Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setLong(1e-2000)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setLong(1e2000)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setLong(-1e2000)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + -Infinity, + "number" ); +*/ + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToLong-003-n.js b/mozilla/js/tests/lc3/JSNumber/ToLong-003-n.js new file mode 100644 index 00000000000..0b1c30190e9 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToLong-003-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to long"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a long: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: Infinity, -Infinity should cause a runtime error + + a[i++] = new TestObject( + "dt.setLong( -Infinity )", + "dt.PUB_LONG", + "dt.getLong() ", + "typeof dt.getLong()", + -Infinity, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToLong-004-n.js b/mozilla/js/tests/lc3/JSNumber/ToLong-004-n.js new file mode 100644 index 00000000000..6de3721c830 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToLong-004-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to long"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a long: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: Infinity, -Infinity should cause a runtime error + + a[i++] = new TestObject( + "dt.setLong(1.7976931348623157E+308)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + Infinity, + "number" ); + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToLong-005-n.js b/mozilla/js/tests/lc3/JSNumber/ToLong-005-n.js new file mode 100644 index 00000000000..a854f3471dc --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToLong-005-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to long"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a long: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: Infinity, -Infinity should cause a runtime error + + a[i++] = new TestObject( + "dt.setLong(1.7976931348623158e+308)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + Infinity, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToLong-006-n.js b/mozilla/js/tests/lc3/JSNumber/ToLong-006-n.js new file mode 100644 index 00000000000..9f98ed17703 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToLong-006-n.js @@ -0,0 +1,103 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to long"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a long: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: Infinity, -Infinity should cause a runtime error + + + a[i++] = new TestObject( + "dt.setLong(1.7976931348623159e+308)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + Infinity, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToLong-007-n.js b/mozilla/js/tests/lc3/JSNumber/ToLong-007-n.js new file mode 100644 index 00000000000..c88399a458a --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToLong-007-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to long"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a long: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: Infinity, -Infinity should cause a runtime error + + a[i++] = new TestObject( + "dt.setLong(-1.7976931348623157E+308)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + -Infinity, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToLong-008-n.js b/mozilla/js/tests/lc3/JSNumber/ToLong-008-n.js new file mode 100644 index 00000000000..b9ed3da3ef7 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToLong-008-n.js @@ -0,0 +1,103 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to long"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a long: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: Infinity, -Infinity should cause a runtime error + + a[i++] = new TestObject( + "dt.setLong(-1.7976931348623158e+308)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + -Infinity, + "number" ); + + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToLong-009-n.js b/mozilla/js/tests/lc3/JSNumber/ToLong-009-n.js new file mode 100644 index 00000000000..d9f7f4aaeb3 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToLong-009-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to long"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a long: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: Infinity, -Infinity should cause a runtime error + + a[i++] = new TestObject( + "dt.setLong(-1.7976931348623159e+308)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + -Infinity, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToLong-010-n.js b/mozilla/js/tests/lc3/JSNumber/ToLong-010-n.js new file mode 100644 index 00000000000..094c71b4a64 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToLong-010-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to long"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a long: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: Infinity, -Infinity should cause a runtime error + + a[i++] = new TestObject( + "dt.setLong(1e2000)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + Infinity, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToLong-011-n.js b/mozilla/js/tests/lc3/JSNumber/ToLong-011-n.js new file mode 100644 index 00000000000..fff3158f03a --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToLong-011-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to long"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a long: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: Infinity, -Infinity should cause a runtime error + + a[i++] = new TestObject( + "dt.setLong(-1e2000)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + Infinity, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToShort-001.js b/mozilla/js/tests/lc3/JSNumber/ToShort-001.js new file mode 100644 index 00000000000..7354a3f09ab --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToShort-001.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a int: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setShort( 0 )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + 0, + "number" ); + + // only doubles and floats know about -0 + + a[i++] = new TestObject( + "dt.setShort( -0 )", + "Infinity / dt.PUB_SHORT", + "Infinity / dt.getShort()", + "typeof dt.getShort()", + Infinity, + "number" ); + + a[i++] = new TestObject( + "dt.setShort( java.lang.Short.MAX_VALUE )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + java.lang.Short.MAX_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setShort( java.lang.Short.MIN_VALUE )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + java.lang.Short.MIN_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setShort( -java.lang.Short.MAX_VALUE )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + -java.lang.Short.MAX_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setShort(1e-2000)", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + 0, + "number" ); + + a[i++] = new TestObject( + "dt.setShort(-1e-2000)", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + 0, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToShort-002-n.js b/mozilla/js/tests/lc3/JSNumber/ToShort-002-n.js new file mode 100644 index 00000000000..74c1e367ed4 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToShort-002-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Jav`a methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a int: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setShort(java.lang.Short.MAX_VALUE +1)", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToShort-003-n.js b/mozilla/js/tests/lc3/JSNumber/ToShort-003-n.js new file mode 100644 index 00000000000..1a40765155c --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToShort-003-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to short"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a short: + // round JS number to SHORTegral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target SHORTegral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setShort( java.lang.Short.MIN_VALUE -1 )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + "error", + "error" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToShort-004.js b/mozilla/js/tests/lc3/JSNumber/ToShort-004.js new file mode 100644 index 00000000000..ccf14d9d4dc --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToShort-004.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a int: + // round JS number to integral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target integral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setShort(java.lang.Short.MIN_VALUE - 0.5)", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + java.lang.Short.MIN_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setShort(java.lang.Short.MIN_VALUE - 0.4)", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + java.lang.Short.MIN_VALUE, + "number" ); + + a[i++] = new TestObject( + "dt.setShort(java.lang.Short.MIN_VALUE + 0.6)", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + java.lang.Short.MIN_VALUE + 1, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSNumber/ToShort-005-n.js b/mozilla/js/tests/lc3/JSNumber/ToShort-005-n.js new file mode 100644 index 00000000000..9b9dc02f477 --- /dev/null +++ b/mozilla/js/tests/lc3/JSNumber/ToShort-005-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "number conversion to short"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing a JS number to a method that expects a short: + // round JS number to SHORTegral value using round-to-negative-infinity mode + // numbers with a magnitude too large to be represented in the target SHORTegral + // type result in a runtime error. + // Nan converts to 0. + + // Special cases: 0, -0, Infinity, -Infinity, and NaN + + a[i++] = new TestObject( + "dt.setShort( NaN )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + "error", + "error" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSObject/ToByte-001.js b/mozilla/js/tests/lc3/JSObject/ToByte-001.js new file mode 100644 index 00000000000..d53c0970aa3 --- /dev/null +++ b/mozilla/js/tests/lc3/JSObject/ToByte-001.js @@ -0,0 +1,298 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaScript Object to java.lang.String"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 3.3.6.4 Other JavaScript Objects + // Passing a JavaScript object to a java method that that expects a byte + // should: + // 1. Apply the ToPrimitive operator (ECMA 9.3) to the JavaScript object + // with hint Number + // 2. Convert Result(1) to Java numeric type using the rules in 3.3.3. +/* + a[i++] = new TestObject( + "dt.setByte(void 0)", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + NaN, + "number"); + + a[i++] = new TestObject( + "dt.setByte(null)", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + 0, + "number"); +*/ + var bool = new Boolean(true); + + a[i++] = new TestObject( + "dt.setByte( bool )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + 1, + "number"); + + bool = new Boolean(false); + + a[i++] = new TestObject( + "dt.setByte( bool )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + 0, + "number"); + + var number = new Number(0); + + a[i++] = new TestObject( + "dt.setByte( number )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + 0, + "number"); +/* + nan = new Number(NaN); + + a[i++] = new TestObject( + "dt.setByte( nan )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + NaN, + "number"); + + infinity = new Number(Infinity); + + a[i++] = new TestObject( + "dt.setByte( infinity )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + Infinity, + "number"); + + var neg_infinity = new Number(-Infinity); + + a[i++] = new TestObject( + "dt.setByte( new Number(neg_infinity))", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + -Infinity, + "number"); + + var string = new String("JavaScript String Value"); + + a[i++] = new TestObject( + "dt.setByte(string)", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + NaN, + "number"); +*/ + var string = new String("127"); + + a[i++] = new TestObject( + "dt.setByte(string)", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + 127, + "number"); + + var string = new String("-128"); + + a[i++] = new TestObject( + "dt.setByte(string)", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + -128, + "number"); + + var myobject = new MyObject( "5.5" ); + + a[i++] = new TestObject( + "dt.setByte( myobject )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + 5, + "number"); + + myobject = new MyOtherObject( "-9.5"); + + a[i++] = new TestObject( + "dt.setByte( myobject )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + -9, + "number"); + + myobject = new AnotherObject( "111"); + + a[i++] = new TestObject( + "dt.setByte( myobject )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + 111, + "number"); +/* + var object = new Object(); + + a[i++] = new TestObject( + "dt.setByte( object )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + NaN, + "number"); + + var array = new Array(1,2,3) + + a[i++] = new TestObject( + "dt.setByte(array)", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + NaN, + "number"); + + a[i++] = new TestObject( + "dt.setByte( MyObject )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + NaN, + "number"); + + a[i++] = new TestObject( + "dt.setByte( this )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + NaN, + "number"); + + a[i++] = new TestObject( + "dt.setByte( Math )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + NaN, + "number"); + + a[i++] = new TestObject( + "dt.setByte( Function )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + NaN, + "number"); +*/ + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function MyObject( stringValue ) { + this.stringValue = String(stringValue); + this.toString = new Function( "return this.stringValue" ); +} + +function MyOtherObject( value ) { + this.toString = null; + this.value = value; + this.valueOf = new Function( "return this.value" ); +} + +function AnotherObject( value ) { + this.toString = new Function( "return new Number(666)" ); + this.value = value; + this.valueOf = new Function( "return this.value" ); +} + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSObject/ToChar-001.js b/mozilla/js/tests/lc3/JSObject/ToChar-001.js new file mode 100644 index 00000000000..81a6197d549 --- /dev/null +++ b/mozilla/js/tests/lc3/JSObject/ToChar-001.js @@ -0,0 +1,190 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaScript Object to java.lang.String"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 3.3.6.4 Other JavaScript Objects + // Passing a JavaScript object to a java method that that expects a char + // should: + // 1. Apply the ToPrimitive operator (ECMA 9.3) to the JavaScript object + // with hint Number + // 2. Convert Result(1) to Java numeric type using the rules in 3.3.3. + + var bool = new Boolean(true); + + a[i++] = new TestObject( + "dt.setChar( bool )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 1, + "number"); + + bool = new Boolean(false); + + a[i++] = new TestObject( + "dt.setChar( bool )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 0, + "number"); + + var number = new Number(0); + + a[i++] = new TestObject( + "dt.setChar( number )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 0, + "number"); + + var string = new String("65535"); + + a[i++] = new TestObject( + "dt.setChar(string)", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 65535, + "number"); + + var string = new String("1"); + + a[i++] = new TestObject( + "dt.setChar(string)", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 1, + "number"); + + var myobject = new MyObject( "5.5" ); + + a[i++] = new TestObject( + "dt.setChar( myobject )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 5, + "number"); + + myobject = new MyOtherObject( "107.5"); + + a[i++] = new TestObject( + "dt.setChar( myobject )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 107, + "number"); + + myobject = new AnotherObject( "6666"); + + a[i++] = new TestObject( + "dt.setChar( myobject )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 6666, + "number"); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function MyObject( stringValue ) { + this.stringValue = String(stringValue); + this.toString = new Function( "return this.stringValue" ); +} + +function MyOtherObject( value ) { + this.toString = null; + this.value = value; + this.valueOf = new Function( "return this.value" ); +} + +function AnotherObject( value ) { + this.toString = new Function( "return new Number(666)" ); + this.value = value; + this.valueOf = new Function( "return this.value" ); +} + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSObject/ToDouble-001.js b/mozilla/js/tests/lc3/JSObject/ToDouble-001.js new file mode 100644 index 00000000000..2bc90aa0566 --- /dev/null +++ b/mozilla/js/tests/lc3/JSObject/ToDouble-001.js @@ -0,0 +1,283 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaScript Object to java.lang.String"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 3.3.6.4 Other JavaScript Objects + // Passing a JavaScript object to a java method that that expects a double + // should: + // 1. Apply the ToPrimitive operator (ECMA 9.3) to the JavaScript object + // with hint Number + // 2. Convert Result(1) to Java numeric type using the rules in 3.3.3. + + var bool = new Boolean(true); + + a[i++] = new TestObject( + "dt.setDouble( bool )", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 1, + "number"); + + bool = new Boolean(false); + + a[i++] = new TestObject( + "dt.setDouble( bool )", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 0, + "number"); + + var number = new Number(0); + + a[i++] = new TestObject( + "dt.setDouble( number )", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 0, + "number"); + + nan = new Number(NaN); + + a[i++] = new TestObject( + "dt.setDouble( nan )", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + NaN, + "number"); + + infinity = new Number(Infinity); + + a[i++] = new TestObject( + "dt.setDouble( infinity )", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + Infinity, + "number"); + + var neg_infinity = new Number(-Infinity); + + a[i++] = new TestObject( + "dt.setDouble( new Number(neg_infinity))", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + -Infinity, + "number"); + + var string = new String("JavaScript String Value"); + + a[i++] = new TestObject( + "dt.setDouble(string)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + NaN, + "number"); + + var string = new String("1234567890"); + + a[i++] = new TestObject( + "dt.setDouble(string)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 1234567890, + "number"); + + + var string = new String("1234567890.123456789"); + + a[i++] = new TestObject( + "dt.setDouble(string)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 1234567890.123456789, + "number"); + + var myobject = new MyObject( "9876543210" ); + + a[i++] = new TestObject( + "dt.setDouble( myobject )", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 9876543210, + "number"); + + myobject = new MyOtherObject( "5551212"); + + a[i++] = new TestObject( + "dt.setDouble( myobject )", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 5551212, + "number"); + + myobject = new AnotherObject( "6060842"); + + a[i++] = new TestObject( + "dt.setDouble( myobject )", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + 6060842, + "number"); + + var object = new Object(); + + a[i++] = new TestObject( + "dt.setDouble( object )", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + NaN, + "number"); + + var array = new Array(1,2,3) + + a[i++] = new TestObject( + "dt.setDouble(array)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + NaN, + "number"); + + a[i++] = new TestObject( + "dt.setDouble( MyObject )", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + NaN, + "number"); + + a[i++] = new TestObject( + "dt.setDouble( this )", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + NaN, + "number"); + + a[i++] = new TestObject( + "dt.setDouble( Math )", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + NaN, + "number"); + + a[i++] = new TestObject( + "dt.setDouble( Function )", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + NaN, + "number"); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function MyObject( stringValue ) { + this.stringValue = String(stringValue); + this.toString = new Function( "return this.stringValue" ); +} + +function MyOtherObject( value ) { + this.toString = null; + this.value = value; + this.valueOf = new Function( "return this.value" ); +} + +function AnotherObject( value ) { + this.toString = new Function( "return new Number(666)" ); + this.value = value; + this.valueOf = new Function( "return this.value" ); +} + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSObject/ToDouble-002-n.js b/mozilla/js/tests/lc3/JSObject/ToDouble-002-n.js new file mode 100644 index 00000000000..bfc3bad5561 --- /dev/null +++ b/mozilla/js/tests/lc3/JSObject/ToDouble-002-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaScript Object to java.lang.String"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + a[i++] = new TestObject( + "dt.setDouble(void 0)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + "error", + "error"); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function MyObject( stringValue ) { + this.stringValue = String(stringValue); + this.toString = new Function( "return this.stringValue" ); +} + +function MyOtherObject( value ) { + this.toString = null; + this.value = value; + this.valueOf = new Function( "return this.value" ); +} + +function AnotherObject( value ) { + this.toString = new Function( "return new Number(666)" ); + this.value = value; + this.valueOf = new Function( "return this.value" ); +} + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSObject/ToDouble-003-n.js b/mozilla/js/tests/lc3/JSObject/ToDouble-003-n.js new file mode 100644 index 00000000000..d7c1e92e78e --- /dev/null +++ b/mozilla/js/tests/lc3/JSObject/ToDouble-003-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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaScript Object to java.lang.String"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 3.3.6.4 Other JavaScript Objects + // Passing a JavaScript object to a java method that that expects a double + // should: + // 1. Apply the ToPrimitive operator (ECMA 9.3) to the JavaScript object + // with hint Number + // 2. Convert Result(1) to Java numeric type using the rules in 3.3.3. + + a[i++] = new TestObject( + "dt.setDouble(null)", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + "error", + "error"); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function MyObject( stringValue ) { + this.stringValue = String(stringValue); + this.toString = new Function( "return this.stringValue" ); +} + +function MyOtherObject( value ) { + this.toString = null; + this.value = value; + this.valueOf = new Function( "return this.value" ); +} + +function AnotherObject( value ) { + this.toString = new Function( "return new Number(666)" ); + this.value = value; + this.valueOf = new Function( "return this.value" ); +} + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSObject/ToFloat-001.js b/mozilla/js/tests/lc3/JSObject/ToFloat-001.js new file mode 100644 index 00000000000..4e5211ff87a --- /dev/null +++ b/mozilla/js/tests/lc3/JSObject/ToFloat-001.js @@ -0,0 +1,284 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaScript Object to java.lang.String"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + var BUGNUMBER = "335899"; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 3.3.6.4 Other JavaScript Objects + // Passing a JavaScript object to a java method that that expects a float + // should: + // 1. Apply the ToPrimitive operator (ECMA 9.3) to the JavaScript object + // with hint Number + // 2. Convert Result(1) to Java numeric type using the rules in 3.3.3. + + var bool = new Boolean(true); + + a[i++] = new TestObject( + "dt.setFloat( bool )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + 1, + "number"); + + bool = new Boolean(false); + + a[i++] = new TestObject( + "dt.setFloat( bool )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + 0, + "number"); + + var number = new Number(0); + + a[i++] = new TestObject( + "dt.setFloat( number )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + 0, + "number"); + + nan = new Number(NaN); + + a[i++] = new TestObject( + "dt.setFloat( nan )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + NaN, + "number"); + + infinity = new Number(Infinity); + + a[i++] = new TestObject( + "dt.setFloat( infinity )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + Infinity, + "number"); + + var neg_infinity = new Number(-Infinity); + + a[i++] = new TestObject( + "dt.setFloat( new Number(neg_infinity))", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + -Infinity, + "number"); + + var string = new String("JavaScript String Value"); + + a[i++] = new TestObject( + "dt.setFloat(string)", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + NaN, + "number"); + + var string = new String("1234567"); + + a[i++] = new TestObject( + "dt.setFloat(string)", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + 1234567, + "number"); + + + var string = new String("123456"); + + a[i++] = new TestObject( + "dt.setFloat(string)", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + 123456, + "number"); + + var myobject = new MyObject( "5555555" ); + + a[i++] = new TestObject( + "dt.setFloat( myobject )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + 5555555, + "number"); + + myobject = new MyOtherObject( "5551212"); + + a[i++] = new TestObject( + "dt.setFloat( myobject )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + 5551212, + "number"); + + myobject = new AnotherObject( "6060842"); + + a[i++] = new TestObject( + "dt.setFloat( myobject )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + 6060842, + "number"); + + var object = new Object(); + + a[i++] = new TestObject( + "dt.setFloat( object )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + NaN, + "number"); + + var array = new Array(1,2,3) + + a[i++] = new TestObject( + "dt.setFloat(array)", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + NaN, + "number"); + + a[i++] = new TestObject( + "dt.setFloat( MyObject )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + NaN, + "number"); + + a[i++] = new TestObject( + "dt.setFloat( this )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + NaN, + "number"); + + a[i++] = new TestObject( + "dt.setFloat( Math )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + NaN, + "number"); + + a[i++] = new TestObject( + "dt.setFloat( Function )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + NaN, + "number"); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function MyObject( stringValue ) { + this.stringValue = String(stringValue); + this.toString = new Function( "return this.stringValue" ); +} + +function MyOtherObject( value ) { + this.toString = null; + this.value = value; + this.valueOf = new Function( "return this.value" ); +} + +function AnotherObject( value ) { + this.toString = new Function( "return new Number(666)" ); + this.value = value; + this.valueOf = new Function( "return this.value" ); +} + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSObject/ToFloat-002-n.js b/mozilla/js/tests/lc3/JSObject/ToFloat-002-n.js new file mode 100644 index 00000000000..4bc67e57c12 --- /dev/null +++ b/mozilla/js/tests/lc3/JSObject/ToFloat-002-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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaScript Object to java.lang.String"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 3.3.6.4 Other JavaScript Objects + // Passing a JavaScript object to a java method that that expects a float + // should: + // 1. Apply the ToPrimitive operator (ECMA 9.3) to the JavaScript object + // with hint Number + // 2. Convert Result(1) to Java numeric type using the rules in 3.3.3. + + a[i++] = new TestObject( + "dt.setFloat(null)", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + "error", + "error"); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function MyObject( stringValue ) { + this.stringValue = String(stringValue); + this.toString = new Function( "return this.stringValue" ); +} + +function MyOtherObject( value ) { + this.toString = null; + this.value = value; + this.valueOf = new Function( "return this.value" ); +} + +function AnotherObject( value ) { + this.toString = new Function( "return new Number(666)" ); + this.value = value; + this.valueOf = new Function( "return this.value" ); +} + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSObject/ToFloat-003-n.js b/mozilla/js/tests/lc3/JSObject/ToFloat-003-n.js new file mode 100644 index 00000000000..923716a43f7 --- /dev/null +++ b/mozilla/js/tests/lc3/JSObject/ToFloat-003-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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaScript Object to java.lang.String"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 3.3.6.4 Other JavaScript Objects + // Passing a JavaScript object to a java method that that expects a float + // should: + // 1. Apply the ToPrimitive operator (ECMA 9.3) to the JavaScript object + // with hint Number + // 2. Convert Result(1) to Java numeric type using the rules in 3.3.3. + a[i++] = new TestObject( + "dt.setFloat(void 0)", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + "error", + "error"); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function MyObject( stringValue ) { + this.stringValue = String(stringValue); + this.toString = new Function( "return this.stringValue" ); +} + +function MyOtherObject( value ) { + this.toString = null; + this.value = value; + this.valueOf = new Function( "return this.value" ); +} + +function AnotherObject( value ) { + this.toString = new Function( "return new Number(666)" ); + this.value = value; + this.valueOf = new Function( "return this.value" ); +} + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSObject/ToInt-001.js b/mozilla/js/tests/lc3/JSObject/ToInt-001.js new file mode 100644 index 00000000000..65e622b08bd --- /dev/null +++ b/mozilla/js/tests/lc3/JSObject/ToInt-001.js @@ -0,0 +1,190 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaScript Object to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 3.3.6.4 Other JavaScript Objects + // Passing a JavaScript object to a java method that that expects a int + // should: + // 1. Apply the ToPrimitive operator (ECMA 9.3) to the JavaScript object + // with hint Number + // 2. Convert Result(1) to Java numeric type using the rules in 3.3.3. + + var bool = new Boolean(true); + + a[i++] = new TestObject( + "dt.setInteger( bool )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 1, + "number"); + + bool = new Boolean(false); + + a[i++] = new TestObject( + "dt.setInteger( bool )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 0, + "number"); + + var number = new Number(0); + + a[i++] = new TestObject( + "dt.setInteger( number )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 0, + "number"); + + var string = new String("2147483647"); + + a[i++] = new TestObject( + "dt.setInteger(string)", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 2147483647, + "number"); + + var string = new String("-2147483648"); + + a[i++] = new TestObject( + "dt.setInteger(string)", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + -2147483648, + "number"); + + var myobject = new MyObject( "5.5" ); + + a[i++] = new TestObject( + "dt.setInteger( myobject )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 5, + "number"); + + myobject = new MyOtherObject( "-107.5"); + + a[i++] = new TestObject( + "dt.setInteger( myobject )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + -107, + "number"); + + myobject = new AnotherObject( "6666"); + + a[i++] = new TestObject( + "dt.setInteger( myobject )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 6666, + "number"); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function MyObject( stringValue ) { + this.stringValue = String(stringValue); + this.toString = new Function( "return this.stringValue" ); +} + +function MyOtherObject( value ) { + this.toString = null; + this.value = value; + this.valueOf = new Function( "return this.value" ); +} + +function AnotherObject( value ) { + this.toString = new Function( "return new Number(666)" ); + this.value = value; + this.valueOf = new Function( "return this.value" ); +} + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSObject/ToInt-002.js b/mozilla/js/tests/lc3/JSObject/ToInt-002.js new file mode 100644 index 00000000000..57c2dfd0ad3 --- /dev/null +++ b/mozilla/js/tests/lc3/JSObject/ToInt-002.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * src/ns/js/tests/src on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaScript Object to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + function MyFunction() { + return "hello"; + } + MyFunction.valueOf = new Function( "return 999" ); + + function MyOtherFunction() { + return "goodbye"; + } + MyOtherFunction.valueOf = null; + MyOtherFunction.toString = new Function( "return 999" ); + + // 3.3.6.4 Other JavaScript Objects + // Passing a JavaScript object to a java method that that expects a int + // should: + // 1. Apply the ToPrimitive operator (ECMA 9.3) to the JavaScript object + // with hint Number + // 2. Convert Result(1) to Java numeric type using the rules in 3.3.3. + + a[i++] = new TestObject( + "dt.setInteger( MyFunction )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 999, + "number"); + + a[i++] = new TestObject( + "dt.setInteger( MyOtherFunction )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 999, + "number"); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSObject/ToJSObject-001.js b/mozilla/js/tests/lc3/JSObject/ToJSObject-001.js new file mode 100644 index 00000000000..78462dab7d6 --- /dev/null +++ b/mozilla/js/tests/lc3/JSObject/ToJSObject-001.js @@ -0,0 +1,234 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaScript Object to java.lang.String"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var jsoc = new Packages.com.netscape.javascript.qa.liveconnect.JSObjectConversion(); + + var a = new Array(); + var i = 0; + + // 3.3.6.4 Other JavaScript Objects + // Passing a JavaScript object to a java method that that expects a JSObject + // should wrap the JS object in a new instance of netscape.javascript.JSObject. + // HOwever, since we are running the test from JavaScript, getting the value + // back should return the unwrapped object. + + var string = new String("JavaScript String Value"); + + a[i++] = new TestObject( + "jsoc.setJSObject(string)", + "jsoc.PUB_JSOBJECT", + "jsoc.getJSObject()", + "jsoc.getJSObject().constructor", + string, + String); + + var myobject = new MyObject( string ); + + a[i++] = new TestObject( + "jsoc.setJSObject( myobject )", + "jsoc.PUB_JSOBJECT", + "jsoc.getJSObject()", + "jsoc.getJSObject().constructor", + myobject, + MyObject); + + var bool = new Boolean(true); + + a[i++] = new TestObject( + "jsoc.setJSObject( bool )", + "jsoc.PUB_JSOBJECT", + "jsoc.getJSObject()", + "jsoc.getJSObject().constructor", + bool, + Boolean); + + bool = new Boolean(false); + + a[i++] = new TestObject( + "jsoc.setJSObject( bool )", + "jsoc.PUB_JSOBJECT", + "jsoc.getJSObject()", + "jsoc.getJSObject().constructor", + bool, + Boolean); + + var object = new Object(); + + a[i++] = new TestObject( + "jsoc.setJSObject( object)", + "jsoc.PUB_JSOBJECT", + "jsoc.getJSObject()", + "jsoc.getJSObject().constructor", + object, + Object); + + var number = new Number(0); + + a[i++] = new TestObject( + "jsoc.setJSObject( number )", + "jsoc.PUB_JSOBJECT", + "jsoc.getJSObject()", + "jsoc.getJSObject().constructor", + number, + Number); + + nan = new Number(NaN); + + a[i++] = new TestObject( + "jsoc.setJSObject( nan )", + "jsoc.PUB_JSOBJECT", + "jsoc.getJSObject()", + "jsoc.getJSObject().constructor", + nan, + Number); + + infinity = new Number(Infinity); + + a[i++] = new TestObject( + "jsoc.setJSObject( infinity )", + "jsoc.PUB_JSOBJECT", + "jsoc.getJSObject()", + "jsoc.getJSObject().constructor", + infinity, + Number); + + var neg_infinity = new Number(-Infinity); + + a[i++] = new TestObject( + "jsoc.setJSObject( neg_infinity)", + "jsoc.PUB_JSOBJECT", + "jsoc.getJSObject()", + "jsoc.getJSObject().constructor", + neg_infinity, + Number); + + var array = new Array(1,2,3) + + a[i++] = new TestObject( + "jsoc.setJSObject(array)", + "jsoc.PUB_JSOBJECT", + "jsoc.getJSObject()", + "jsoc.getJSObject().constructor", + array, + Array); + + + a[i++] = new TestObject( + "jsoc.setJSObject( MyObject )", + "jsoc.PUB_JSOBJECT", + "jsoc.getJSObject()", + "jsoc.getJSObject().constructor", + MyObject, + Function); + + var THIS = this; + + a[i++] = new TestObject( + "jsoc.setJSObject( THIS )", + "jsoc.PUB_JSOBJECT", + "jsoc.getJSObject()", + "jsoc.getJSObject().constructor", + this, + Object); + + a[i++] = new TestObject( + "jsoc.setJSObject( Math )", + "jsoc.PUB_JSOBJECT", + "jsoc.getJSObject()", + "jsoc.getJSObject().constructor", + Math, + Object); + + a[i++] = new TestObject( + "jsoc.setJSObject( Function )", + "jsoc.PUB_JSOBJECT", + "jsoc.getJSObject()", + "jsoc.getJSObject().constructor", + Function, + Function); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function MyObject( stringValue ) { + this.stringValue = String(stringValue); + this.toString = new Function( "return this.stringValue" ); +} + + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + print("hi"); + eval (description); + print("bye") + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSObject/ToLong-001.js b/mozilla/js/tests/lc3/JSObject/ToLong-001.js new file mode 100644 index 00000000000..1c3b2397119 --- /dev/null +++ b/mozilla/js/tests/lc3/JSObject/ToLong-001.js @@ -0,0 +1,194 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaScript Object to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 3.3.6.4 Other JavaScript Objects + // Passing a JavaScript object to a java method that that expects a int + // should: + // 1. Apply the ToPrimitive operator (ECMA 9.3) to the JavaScript object + // with hint Number + // 2. Convert Result(1) to Java numeric type using the rules in 3.3.3. + + var bool = new Boolean(true); + + a[i++] = new TestObject( + "dt.setLong( bool )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + 1, + "number"); + + bool = new Boolean(false); + + a[i++] = new TestObject( + "dt.setLong( bool )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + 0, + "number"); + + var number = new Number(0); + + a[i++] = new TestObject( + "dt.setLong( number )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + 0, + "number"); + + + var long_max = java.lang.Short.MAX_VALUE; + var long_min = java.lang.Short.MIN_VALUE; + + var string = new String(long_max); + + a[i++] = new TestObject( + "dt.setLong(string)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + long_max, + "number"); + + var string = new String(long_min); + + a[i++] = new TestObject( + "dt.setLong(string)", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + long_min, + "number"); + + var myobject = new MyObject( "5.5" ); + + a[i++] = new TestObject( + "dt.setLong( myobject )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + 5, + "number"); + + myobject = new MyOtherObject( "-107.5"); + + a[i++] = new TestObject( + "dt.setLong( myobject )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + -107, + "number"); + + myobject = new AnotherObject( "6666"); + + a[i++] = new TestObject( + "dt.setLong( myobject )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + 6666, + "number"); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function MyObject( stringValue ) { + this.stringValue = String(stringValue); + this.toString = new Function( "return this.stringValue" ); +} + +function MyOtherObject( value ) { + this.toString = null; + this.value = value; + this.valueOf = new Function( "return this.value" ); +} + +function AnotherObject( value ) { + this.toString = new Function( "return new Number(666)" ); + this.value = value; + this.valueOf = new Function( "return this.value" ); +} + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSObject/ToObject-001.js b/mozilla/js/tests/lc3/JSObject/ToObject-001.js new file mode 100644 index 00000000000..ef7c4ddd444 --- /dev/null +++ b/mozilla/js/tests/lc3/JSObject/ToObject-001.js @@ -0,0 +1,235 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaScript Object to java.lang.String"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + var BUGNUMBER="335882"; + + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 3.3.6.4 Other JavaScript Objects + // Passing a JavaScript object to a java method that that expects a JSObject + // should wrap the JS object in a new instance of netscape.javascript.JSObject. + // HOwever, since we are running the test from JavaScript, getting the value + // back should return the unwrapped object. + + var string = new String("JavaScript String Value"); + + a[i++] = new TestObject( + "dt.setObject(string)", + "dt.PUB_OBJECT +''", + "dt.getObject() +''", + "dt.getObject().constructor", + string +"", + String); + + var myobject = new MyObject( string ); + + a[i++] = new TestObject( + "dt.setObject( myobject )", + "dt.PUB_OBJECT", + "dt.getObject()", + "dt.getObject().constructor", + myobject, + MyObject); + + var bool = new Boolean(true); + + a[i++] = new TestObject( + "dt.setObject( bool )", + "dt.PUB_OBJECT", + "dt.getObject()", + "dt.getObject().constructor", + bool, + Boolean); + + bool = new Boolean(false); + + a[i++] = new TestObject( + "dt.setObject( bool )", + "dt.PUB_OBJECT", + "dt.getObject()", + "dt.getObject().constructor", + bool, + Boolean); + + var object = new Object(); + + a[i++] = new TestObject( + "dt.setObject( object)", + "dt.PUB_OBJECT", + "dt.getObject()", + "dt.getObject().constructor", + object, + Object); + + var number = new Number(0); + + a[i++] = new TestObject( + "dt.setObject( number )", + "dt.PUB_OBJECT", + "dt.getObject()", + "dt.getObject().constructor", + number, + Number); + + nan = new Number(NaN); + + a[i++] = new TestObject( + "dt.setObject( nan )", + "dt.PUB_OBJECT", + "dt.getObject()", + "dt.getObject().constructor", + nan, + Number); + + infinity = new Number(Infinity); + + a[i++] = new TestObject( + "dt.setObject( infinity )", + "dt.PUB_OBJECT", + "dt.getObject()", + "dt.getObject().constructor", + infinity, + Number); + + var neg_infinity = new Number(-Infinity); + + a[i++] = new TestObject( + "dt.setObject( neg_infinity )", + "dt.PUB_OBJECT", + "dt.getObject()", + "dt.getObject().constructor", + neg_infinity, + Number); + + var array = new Array(1,2,3) + + a[i++] = new TestObject( + "dt.setObject(array)", + "dt.PUB_OBJECT", + "dt.getObject()", + "dt.getObject().constructor", + array, + Array); + + + a[i++] = new TestObject( + "dt.setObject( MyObject )", + "dt.PUB_OBJECT", + "dt.getObject()", + "dt.getObject().constructor", + MyObject, + Function); + + var THIS = this; + + a[i++] = new TestObject( + "dt.setObject( THIS )", + "dt.PUB_OBJECT", + "dt.getObject()", + "dt.getObject().constructor", + this, + Object); + + a[i++] = new TestObject( + "dt.setObject( Math )", + "dt.PUB_OBJECT", + "dt.getObject()", + "dt.getObject().constructor", + Math, + Object); + + a[i++] = new TestObject( + "dt.setObject( Function )", + "dt.PUB_OBJECT", + "dt.getObject()", + "dt.getObject().constructor", + Function, + Function); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function MyObject( stringValue ) { + this.stringValue = String(stringValue); + this.toString = new Function( "return this.stringValue" ); +} + + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSObject/ToShort-001.js b/mozilla/js/tests/lc3/JSObject/ToShort-001.js new file mode 100644 index 00000000000..a973c5599bd --- /dev/null +++ b/mozilla/js/tests/lc3/JSObject/ToShort-001.js @@ -0,0 +1,190 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaScript Object to java.lang.String"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 3.3.6.4 Other JavaScript Objects + // Passing a JavaScript object to a java method that that expects a short + // should: + // 1. Apply the ToPrimitive operator (ECMA 9.3) to the JavaScript object + // with hint Number + // 2. Convert Result(1) to Java numeric type using the rules in 3.3.3. + + var bool = new Boolean(true); + + a[i++] = new TestObject( + "dt.setShort( bool )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + 1, + "number"); + + bool = new Boolean(false); + + a[i++] = new TestObject( + "dt.setShort( bool )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + 0, + "number"); + + var number = new Number(0); + + a[i++] = new TestObject( + "dt.setShort( number )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + 0, + "number"); + + var string = new String("32767"); + + a[i++] = new TestObject( + "dt.setShort(string)", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + 32767, + "number"); + + var string = new String("-32768"); + + a[i++] = new TestObject( + "dt.setShort(string)", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + -32768, + "number"); + + var myobject = new MyObject( "5.5" ); + + a[i++] = new TestObject( + "dt.setShort( myobject )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + 5, + "number"); + + myobject = new MyOtherObject( "-107.5"); + + a[i++] = new TestObject( + "dt.setShort( myobject )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + -107, + "number"); + + myobject = new AnotherObject( "6666"); + + a[i++] = new TestObject( + "dt.setShort( myobject )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + 6666, + "number"); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function MyObject( stringValue ) { + this.stringValue = String(stringValue); + this.toString = new Function( "return this.stringValue" ); +} + +function MyOtherObject( value ) { + this.toString = null; + this.value = value; + this.valueOf = new Function( "return this.value" ); +} + +function AnotherObject( value ) { + this.toString = new Function( "return new Number(666)" ); + this.value = value; + this.valueOf = new Function( "return this.value" ); +} + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSObject/ToString-001.js b/mozilla/js/tests/lc3/JSObject/ToString-001.js new file mode 100644 index 00000000000..226e0addf68 --- /dev/null +++ b/mozilla/js/tests/lc3/JSObject/ToString-001.js @@ -0,0 +1,218 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaScript Object to java.lang.String"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + function MyObject( stringValue ) { + this.stringValue = String(stringValue); + this.toString = new Function( "return this.stringValue" ); + } + + function MyFunction() { + return "hello"; + } + MyFunction.toString = new Function( "return \"MyFunction\";" ); + + // 3.3.6.4 Other JavaScript Objects + // Passing a JavaScript Object to a Java method that expects a + // java.lang.String calls the JS object's toString method, and + // returns the result as a java.lang.String. + + + var stringValue = "JavaScript String Value"; + + a[i++] = new TestObject( + "dt.setStringObject( new String(\""+stringValue+"\"))", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "dt.getStringObject().getClass()", + stringValue, + java.lang.Class.forName("java.lang.String")); + + a[i++] = new TestObject( + "dt.setStringObject( new MyObject(\""+stringValue+"\"))", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "dt.getStringObject().getClass()", + stringValue, + java.lang.Class.forName("java.lang.String")); + + a[i++] = new TestObject( + "dt.setStringObject( new Boolean(true))", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "dt.getStringObject().getClass()", + "true", + java.lang.Class.forName("java.lang.String")); + + a[i++] = new TestObject( + "dt.setStringObject( new Boolean(false))", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "dt.getStringObject().getClass()", + "false", + java.lang.Class.forName("java.lang.String")); + + a[i++] = new TestObject( + "dt.setStringObject( new Object())", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "dt.getStringObject().getClass()", + "[object Object]", + java.lang.Class.forName("java.lang.String")); + + a[i++] = new TestObject( + "dt.setStringObject( new Number(0))", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "dt.getStringObject().getClass()", + "0", + java.lang.Class.forName("java.lang.String")); + + a[i++] = new TestObject( + "dt.setStringObject( new Number(NaN))", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "dt.getStringObject().getClass()", + "NaN", + java.lang.Class.forName("java.lang.String")); + + a[i++] = new TestObject( + "dt.setStringObject( new Number(Infinity))", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "dt.getStringObject().getClass()", + "Infinity", + java.lang.Class.forName("java.lang.String")); + + a[i++] = new TestObject( + "dt.setStringObject( new Number(-Infinity))", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "dt.getStringObject().getClass()", + "-Infinity", + java.lang.Class.forName("java.lang.String")); + + a[i++] = new TestObject( + "dt.setStringObject( new Array(1,2,3))", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "dt.getStringObject().getClass()", + "1,2,3", + java.lang.Class.forName("java.lang.String")); + + a[i++] = new TestObject( + "dt.setStringObject( MyObject )", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "dt.getStringObject().getClass()", + MyObject.toString(), + java.lang.Class.forName("java.lang.String")); + + var THIS = this; + + a[i++] = new TestObject( + "dt.setStringObject( THIS )", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "dt.getStringObject().getClass()", + GLOBAL, + java.lang.Class.forName("java.lang.String")); + + a[i++] = new TestObject( + "dt.setStringObject( Math )", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "dt.getStringObject().getClass()", + "[object Math]", + java.lang.Class.forName("java.lang.String")); + + a[i++] = new TestObject( + "dt.setStringObject( MyFunction )", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "dt.getStringObject().getClass()", + "MyFunction", + java.lang.Class.forName("java.lang.String")); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSUndefined/undefined-001.js b/mozilla/js/tests/lc3/JSUndefined/undefined-001.js new file mode 100644 index 00000000000..2d8108abe12 --- /dev/null +++ b/mozilla/js/tests/lc3/JSUndefined/undefined-001.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes the JavaScript "undefined" value to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "undefined conversion"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing undefined to a java method that expects an object should convert + // undefined to the java.lang.String whose value is "undefined" + + a[i++] = new TestObject( + "dt.setObject( undefined )", + "dt.PUB_OBJECT +''", + "dt.getObject() + ''", + "dt.getObject().getClass()", + "undefined", + java.lang.Class.forName( "java.lang.String" ) ); + + // passing undefined to a java method that expects a string should convert + // undefined to the java.lang.String whose value is "undefined" + + a[i++] = new TestObject( + "dt.setStringObject( undefined )", + "dt.PUB_STRING +''", + "dt.getStringObject() + ''", + "dt.getStringObject().getClass()", + "undefined", + java.lang.Class.forName( "java.lang.String" ) ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JSUndefined/undefined-002-n.js b/mozilla/js/tests/lc3/JSUndefined/undefined-002-n.js new file mode 100644 index 00000000000..22e13962b47 --- /dev/null +++ b/mozilla/js/tests/lc3/JSUndefined/undefined-002-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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes the JavaScript "undefined" value to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "undefined conversion"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing undefined to a java method that expects a long should result + // in a runtime error. + + testcases[testcases.length] = new TestCase( + "dt.setLong( undefined )", + "error", + dt.setLong(undefined) ); + +test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/JSUndefined/undefined-003-n.js b/mozilla/js/tests/lc3/JSUndefined/undefined-003-n.js new file mode 100644 index 00000000000..b3dd64f8885 --- /dev/null +++ b/mozilla/js/tests/lc3/JSUndefined/undefined-003-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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes the JavaScript "undefined" value to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "undefined conversion"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing undefined to a java method that expects an int should result + // in a runtime error. + + testcases[testcases.length] = new TestCase( + "dt.setInteger( undefined )", + "error", + dt.setInteger(undefined) ); + +test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/JSUndefined/undefined-004-n.js b/mozilla/js/tests/lc3/JSUndefined/undefined-004-n.js new file mode 100644 index 00000000000..af852c9ba5d --- /dev/null +++ b/mozilla/js/tests/lc3/JSUndefined/undefined-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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes the JavaScript "undefined" value to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "undefined conversion"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing undefined to a java method that expects a short should result + // in a runtime error. + + testcases[testcases.length] = new TestCase( + "dt.setShort( undefined )", + "error", + dt.setShort(undefined) ); + +test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/JSUndefined/undefined-005-n.js b/mozilla/js/tests/lc3/JSUndefined/undefined-005-n.js new file mode 100644 index 00000000000..d935d031077 --- /dev/null +++ b/mozilla/js/tests/lc3/JSUndefined/undefined-005-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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes the JavaScript "undefined" value to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "undefined conversion"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing undefined to a java method that expects a char should result + // in a runtime error. + + testcases[testcases.length] = new TestCase( + "dt.setChar( undefined )", + "error", + dt.setChar(undefined) ); + +test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/JSUndefined/undefined-006-n.js b/mozilla/js/tests/lc3/JSUndefined/undefined-006-n.js new file mode 100644 index 00000000000..cb747024f4d --- /dev/null +++ b/mozilla/js/tests/lc3/JSUndefined/undefined-006-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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes the JavaScript "undefined" value to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "undefined conversion"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing undefined to a java method that expects a byte should result + // in a runtime error. + + testcases[testcases.length] = new TestCase( + "dt.setByte( undefined )", + "error", + dt.setByte(undefined) ); + +test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/JSUndefined/undefined-007-n.js b/mozilla/js/tests/lc3/JSUndefined/undefined-007-n.js new file mode 100644 index 00000000000..14228653c0c --- /dev/null +++ b/mozilla/js/tests/lc3/JSUndefined/undefined-007-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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes the JavaScript "undefined" value to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "undefined conversion"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing undefined to a java method that expects a byte should result + // in a runtime error. + + testcases[testcases.length] = new TestCase( + "dt.setByte( void 0 )", + "error", + dt.setByte( void 0 ) ); + +test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/JSUndefined/undefined-008-n.js b/mozilla/js/tests/lc3/JSUndefined/undefined-008-n.js new file mode 100644 index 00000000000..eb321e8ddf1 --- /dev/null +++ b/mozilla/js/tests/lc3/JSUndefined/undefined-008-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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes the JavaScript "undefined" value to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "undefined conversion"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing undefined to a java method that expects a double should result + // in a runtime error. + + testcases[testcases.length] = new TestCase( + "dt.setDouble( void 0 )", + "error", + dt.setDouble( void 0) ); + +test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/JSUndefined/undefined-009-n.js b/mozilla/js/tests/lc3/JSUndefined/undefined-009-n.js new file mode 100644 index 00000000000..d9eff308ba2 --- /dev/null +++ b/mozilla/js/tests/lc3/JSUndefined/undefined-009-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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes the JavaScript "undefined" value to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "undefined conversion"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // passing undefined to a java method that expects a float should result + // in a runtime error. + + testcases[testcases.length] = new TestCase( + "dt.setFloat( void 0 )", + "error", + dt.setFloat( void 0) ); + +test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/JSUndefined/undefined-010-n.js b/mozilla/js/tests/lc3/JSUndefined/undefined-010-n.js new file mode 100644 index 00000000000..e927d0993c7 --- /dev/null +++ b/mozilla/js/tests/lc3/JSUndefined/undefined-010-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes the JavaScript "undefined" value to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "undefined conversion"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + + // passing undefined to a java method that expects a boolean be an error + + a[i++] = new TestObject( + "dt.setBoolean( undefined )", + "dt.PUB_BOOLEAN", + "dt.getBoolean()", + "typeof dt.getBoolean()", + "error", + "error" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval( javaType ); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaArray/ToArray-001.js b/mozilla/js/tests/lc3/JavaArray/ToArray-001.js new file mode 100644 index 00000000000..fc7df0b613d --- /dev/null +++ b/mozilla/js/tests/lc3/JavaArray/ToArray-001.js @@ -0,0 +1,250 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaArray to String"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // Passing a JavaArray to a method that expects a java.lang.String should + // call the unwrapped array's toString method and return the result as a + // new java.lang.String. + + // pass a byte array to a method that expects a string + + a[i++] = new TestObject ( + "dt.setStringObject(java.lang.String(new java.lang.String(\"hello\").getBytes()))", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "typeof dt.getStringObject()", + "hello", + "object" ); + + // pass a char array to a method that expects a string + + a[i++] = new TestObject ( + "dt.setStringObject(java.lang.String(new java.lang.String(\"goodbye\").toCharArray()))", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "typeof dt.getStringObject()", + "goodbye", + "object" ); + + a[i++] = new TestObject ( + "dt.setStringObject(java.lang.String(new java.lang.String(\"goodbye\").toCharArray()))", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "typeof dt.getStringObject()", + "goodbye", + "object" ); + + // Vector.copyInto expects an object array + + a[i++] = new TestObject( + "var vector = new java.util.Vector(); "+ + "vector.addElement( \"a\" ); vector.addElement( \"b\" ); "+ + "vector.copyInto( DT.PUB_STATIC_ARRAY_OBJECT )", + "DT.PUB_STATIC_ARRAY_OBJECT[0] +''", + "DT.staticGetObjectArray()[0] +''", + "typeof DT.staticGetObjectArray()[0]", + "a", + "object" ); + + a[i++] = new TestObject( + "var vector = new java.util.Vector(); "+ + "vector.addElement( \"a\" ); vector.addElement( 3 ); "+ + "vector.copyInto( DT.PUB_STATIC_ARRAY_OBJECT )", + "DT.PUB_STATIC_ARRAY_OBJECT[1] +''", + "DT.staticGetObjectArray()[1] +''", + "DT.staticGetObjectArray()[1].getClass().getName() +''", + "3.0", + "java.lang.Double" ); + + // byte array + + var random = Math.random() +""; + + for ( counter = 0; counter < random.length; counter ++ ) { + a[i++] = new TestObject ( + "dt.setByteArray(java.lang.String(\""+random+"\").getBytes());", + "dt.PUB_STATIC_ARRAY_BYTE["+counter+"]", + "dt.getByteArray()["+counter+"]", + "typeof dt.getByteArray()["+counter+"]", + random[counter].charCodeAt(0), + "number" ); + } + + // char array + + random = Math.random() +""; + + for ( counter = 0; counter < random.length; counter ++ ) { + a[i++] = new TestObject ( + "dt.setCharArray(java.lang.String(\""+random+"\").toCharArray());", + "dt.PUB_STATIC_ARRAY_CHAR["+counter+"]", + "dt.getCharArray()["+counter+"]", + "typeof dt.getCharArray()["+counter+"]", + random[counter].charCodeAt(0), + "number" ); + } + + // int array + + random = ( Math.round(Math.random() * Math.pow(10,dt.PUB_ARRAY_INT.length))) +""; + for ( counter = 0; counter < random.length; counter++ ) { + dt.PUB_ARRAY_INT[counter] = random[counter]; + } + for ( counter = 0; counter < random.length; counter ++ ) { + a[i++] = new TestObject ( + "dt.setIntArray(dt.PUB_ARRAY_INT)", + "DT.PUB_STATIC_ARRAY_INT["+counter+"]", + "dt.getIntArray()["+counter+"]", + "typeof dt.getIntArray()["+counter+"]", + Number(random[counter]), + "number" ); + } + + // short array + + random = ( Math.round(Math.random() * Math.pow(10,dt.PUB_ARRAY_SHORT.length))) +""; + for ( counter = 0; counter < random.length; counter++ ) { + dt.PUB_ARRAY_SHORT[counter] = random[counter]; + } + for ( counter = 0; counter < random.length; counter ++ ) { + a[i++] = new TestObject ( + "dt.setShortArray(dt.PUB_ARRAY_SHORT)", + "DT.PUB_STATIC_ARRAY_SHORT["+counter+"]", + "dt.getShortArray()["+counter+"]", + "typeof dt.getShortArray()["+counter+"]", + Number(random[counter]), + "number" ); + } + + // long array + + random = ( Math.round(Math.random() * Math.pow(10,dt.PUB_ARRAY_LONG.length))) +""; + for ( counter = 0; counter < random.length; counter++ ) { + dt.PUB_ARRAY_LONG[counter] = random[counter]; + } + for ( counter = 0; counter < random.length; counter ++ ) { + a[i++] = new TestObject ( + "dt.setLongArray(dt.PUB_ARRAY_LONG)", + "DT.PUB_STATIC_ARRAY_LONG["+counter+"]", + "dt.getLongArray()["+counter+"]", + "typeof dt.getLongArray()["+counter+"]", + Number(random[counter]), + "number" ); + } + + + // double array + + random = ( Math.round(Math.random() * Math.pow(10,dt.PUB_ARRAY_DOUBLE.length))) +""; + for ( counter = 0; counter < random.length; counter++ ) { + dt.PUB_ARRAY_DOUBLE[counter] = random[counter]; + } + for ( counter = 0; counter < random.length; counter ++ ) { + a[i++] = new TestObject ( + "dt.setDoubleArray(dt.PUB_ARRAY_DOUBLE)", + "DT.PUB_STATIC_ARRAY_DOUBLE["+counter+"]", + "dt.getDoubleArray()["+counter+"]", + "typeof dt.getDoubleArray()["+counter+"]", + Number(random[counter]), + "number" ); + } + + // float array + + random = ( Math.round(Math.random() * Math.pow(10,dt.PUB_ARRAY_FLOAT.length))) +""; + for ( counter = 0; counter < random.length; counter++ ) { + dt.PUB_ARRAY_FLOAT[counter] = random[counter]; + } + for ( counter = 0; counter < random.length; counter ++ ) { + a[i++] = new TestObject ( + "dt.setFloatArray(dt.PUB_ARRAY_FLOAT)", + "DT.PUB_STATIC_ARRAY_FLOAT["+counter+"]", + "dt.getFloatArray()["+counter+"]", + "typeof dt.getFloatArray()["+counter+"]", + Number(random[counter]), + "number" ); + } + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval(javaType); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaArray/ToArray-002-n.js b/mozilla/js/tests/lc3/JavaArray/ToArray-002-n.js new file mode 100644 index 00000000000..17f91c1507d --- /dev/null +++ b/mozilla/js/tests/lc3/JavaArray/ToArray-002-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ + +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaArray to Object[]"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // if the array is not an instance of the correct type, create a runtime + // error. + + // Vector.copyInto expects an object array + + a[i++] = new TestObject( + "var vector = new java.util.Vector(); "+ + "vector.addElement( \"a\" ); vector.addElement( \"b\" ); "+ + "vector.copyInto( DT.PUB_STATIC_ARRAY_CHAR )", + "DT.PUB_STATIC_ARRAY_OBJECT[0] +''", + "DT.staticGetObjectArray()[0] +''", + "typeof DT.staticGetObjectArray()[0]", + "error", + "error" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = eval(javaType); + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaArray/ToBoolean-001-n.js b/mozilla/js/tests/lc3/JavaArray/ToBoolean-001-n.js new file mode 100644 index 00000000000..d498e5ca431 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaArray/ToBoolean-001-n.js @@ -0,0 +1,163 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaArray to boolean"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // Passing a JavaArray to a method that expects a boolean should + // always convert the array to true + + var emptyByteArray = new java.lang.String("").getBytes(); + + a[i++] = new TestObject ( + "dt.setBoolean( emptyByteArray )", + "dt.PUB_BOOLEAN ", + "dt.getBoolean() ", + "typeof dt.getBoolean() ", + true, + "boolean" ); + + a[i++] = new TestObject ( + "dt.setBoolean( DT.staticGetByteArray() )", + "dt.PUB_BOOLEAN ", + "dt.getBoolean() ", + "typeof dt.getBoolean() ", + true, + "boolean" ); +/* + a[i++] = new TestObject ( + "dt.setBoolean( DT.staticGetByteArray() )", + "dt.PUB_BOOLEAN ", + "dt.getBoolean() ", + "typeof dt.getBoolean() ", + true, + "boolean" ); + + a[i++] = new TestObject ( + "dt.setBoolean( DT.staticGetCharArray() )", + "dt.PUB_BOOLEAN ", + "dt.getBoolean() ", + "typeof dt.getBoolean() ", + true, + "boolean" ); + + a[i++] = new TestObject ( + "dt.setBoolean( DT.staticGetShortArray() )", + "dt.PUB_BOOLEAN ", + "dt.getBoolean() ", + "typeof dt.getBoolean() ", + true, + "boolean" ); + + a[i++] = new TestObject ( + "dt.setBoolean( DT.staticGetLongArray() )", + "dt.PUB_BOOLEAN ", + "dt.getBoolean() ", + "typeof dt.getBoolean() ", + true, + "boolean" ); + + a[i++] = new TestObject ( + "dt.setBoolean( DT.staticGetIntArray() )", + "dt.PUB_BOOLEAN ", + "dt.getBoolean() ", + "typeof dt.getBoolean() ", + true, + "boolean" ); + + a[i++] = new TestObject ( + "dt.setBoolean( DT.staticGetFloatArray() )", + "dt.PUB_BOOLEAN ", + "dt.getBoolean() ", + "typeof dt.getBoolean() ", + true, + "boolean" ); + + a[i++] = new TestObject ( + "dt.setBoolean( DT.staticGetObjectArray() )", + "dt.PUB_BOOLEAN ", + "dt.getBoolean() ", + "typeof dt.getBoolean() ", + true, + "boolean" ); +*/ + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaArray/ToString-001.js b/mozilla/js/tests/lc3/JavaArray/ToString-001.js new file mode 100644 index 00000000000..b68189bed8e --- /dev/null +++ b/mozilla/js/tests/lc3/JavaArray/ToString-001.js @@ -0,0 +1,158 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaArray to String"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // Passing a JavaArray to a method that expects a java.lang.String should + // call the unwrapped array's toString method and return the result as a + // new java.lang.String. + + // this should return the byte array string representation, which includes + // the object's hash code + + a[i++] = new TestObject ( + "dt.setStringObject( DT.staticGetByteArray() )", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "typeof dt.getStringObject() +''", + DT.PUB_STATIC_ARRAY_BYTE +"", + "string" ); + + + a[i++] = new TestObject ( + "dt.setStringObject( DT.staticGetCharArray() )", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "typeof dt.getStringObject() +''", + DT.PUB_STATIC_ARRAY_CHAR +"", + "string" ); + + a[i++] = new TestObject ( + "dt.setStringObject( DT.staticGetShortArray() )", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "typeof dt.getStringObject() +''", + DT.PUB_STATIC_ARRAY_SHORT +"", + "string" ); + + a[i++] = new TestObject ( + "dt.setStringObject( DT.staticGetLongArray() )", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "typeof dt.getStringObject() +''", + DT.PUB_STATIC_ARRAY_LONG +"", + "string" ); + + a[i++] = new TestObject ( + "dt.setStringObject( DT.staticGetIntArray() )", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "typeof dt.getStringObject() +''", + DT.PUB_STATIC_ARRAY_INT +"", + "string" ); + + a[i++] = new TestObject ( + "dt.setStringObject( DT.staticGetFloatArray() )", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "typeof dt.getStringObject() +''", + DT.PUB_STATIC_ARRAY_FLOAT +"", + "string" ); + + a[i++] = new TestObject ( + "dt.setStringObject( DT.staticGetObjectArray() )", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "typeof dt.getStringObject() +''", + DT.PUB_STATIC_ARRAY_OBJECT +"", + "string" ); + + a[i++] = new TestObject ( + "dt.setStringObject(java.lang.String(new java.lang.String(\"hello\").getBytes()))", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "typeof dt.getStringObject() +''", + "hello", + "string" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaClass/ToClass-001.js b/mozilla/js/tests/lc3/JavaClass/ToClass-001.js new file mode 100644 index 00000000000..3d148a62199 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaClass/ToClass-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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaClass to java.lang.Class"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // Extract the corresponding Java class object + + a[i++] = new TestObject ( + "var newClass = java.lang.Class.forName(\"java.lang.Byte\"); "+ + "dt.setClass( newClass )", + "dt.PUB_CLASS", + "dt.instanceGetClass()", + "dt.instanceGetClass()", + java.lang.Class.forName("java.lang.Byte"), + "object" ); + + // pass a java class to a method that expects a java.lang.Object + + a[i++] = new TestObject ( + "var newClass = java.lang.Class.forName(\"java.lang.Byte\"); "+ + "var javaVector = new java.util.Vector() ;"+ + "javaVector.addElement( newClass ); " + + "javaVector.elementAt(0)", + "dt.PUB_CLASS", + "dt.instanceGetClass()", + "dt.instanceGetClass()", + java.lang.Class.forName("java.lang.Byte"), + "object" ); + + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaClass/ToJSObject-001.js b/mozilla/js/tests/lc3/JavaClass/ToJSObject-001.js new file mode 100644 index 00000000000..960cc31a0d0 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaClass/ToJSObject-001.js @@ -0,0 +1,103 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaClass to java.lang.Class"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + + var BUGNUMBER ="335885"; + + startTest(); + + var jsoc = new + Packages.com.netscape.javascript.qa.liveconnect.JSObjectConversion(); + + var a = new Array(); + var i = 0; + + // Pass a JavaClass to a method that expects a JSObject should wrap + // the object in a new instance of JSObject. + + a[i++] = new TestObject ( + "var newClass = java.lang.Integer; "+ + "jsoc.setJSObject( newClass )", + "jsoc.PUB_JSOBJECT", + "jsoc.getJSObject()", + "jsoc.getJSObject()", + java.lang.Integer, + "function" ); + + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaClass/ToObject-001.js b/mozilla/js/tests/lc3/JavaClass/ToObject-001.js new file mode 100644 index 00000000000..a7e21826129 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaClass/ToObject-001.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaClass to java.lang.Class"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // Pass a JavaClass to a method that expects an Object should wrap + // the object in a new instance of JSObject. + + a[i++] = new TestObject ( + "var newClass = java.lang.Class.forName(\"java.lang.Integer\"); "+ + "dt.setObject( newClass )", + "dt.PUB_OBJECT", + "dt.getObject()", + "dt.getObject()", + java.lang.Class.forName("java.lang.Integer"), + "object" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaClass/ToString-001.js b/mozilla/js/tests/lc3/JavaClass/ToString-001.js new file mode 100644 index 00000000000..4a44ee0a0f5 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaClass/ToString-001.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaClass to java.lang.Class"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // Pass a JavaClass to a method that expects a java.lang.String call + // the java class's toString method and return the result as an instance + // of java.lang.String + + a[i++] = new TestObject ( + "var newClass = java.lang.Class.forName(\"java.lang.Integer\"); "+ + "dt.setStringObject( newClass )", + "dt.PUB_STRING+''", + "dt.getStringObject()+''", + "dt.getStringObject().getClass()", + java.lang.Class.forName("java.lang.Integer") +"", + "string" ); + + a[i++] = new TestObject ( + "var newClass = java.lang.Class.forName(\"java.lang.Class\"); "+ + "dt.setStringObject( newClass )", + "dt.PUB_STRING+''", + "dt.getStringObject()+''", + "dt.getStringObject().getClass()", + java.lang.Class.forName("java.lang.Class") +"", + "string" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToBoolean-001-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToBoolean-001-n.js new file mode 100644 index 00000000000..2f724a677f8 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToBoolean-001-n.js @@ -0,0 +1,107 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to boolean"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // If JavaScript 1.3 or later: + // return true + + a[i++] = new TestObject ( + "dt.PUB_BOOLEAN_REPRESENTATION = false ;"+ + "dt.setBoolean( dt )", + "dt.PUB_BOOLEAN", + "dt.getBoolean()", + "typeof dt.getBoolean)", + "error", + "error" ); +/* + a[i++] = new TestObject ( + "dt.PUB_BOOLEAN_REPRESENTATION = true ;"+ + "dt.setBoolean( dt )", + "dt.PUB_BOOLEAN", + "dt.getBoolean()", + "typeof dt.getBoolean)", + true, + "boolean" ); +*/ + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToBoolean-002-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToBoolean-002-n.js new file mode 100644 index 00000000000..d44ebcf3713 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToBoolean-002-n.js @@ -0,0 +1,107 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to boolean"; + var VERSION = "1_2"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // If JavaScript 1.3 or later: + // return true + + a[i++] = new TestObject ( + "dt.PUB_BOOLEAN_REPRESENTATION = false ;"+ + "dt.setBoolean( dt )", + "dt.PUB_BOOLEAN", + "dt.getBoolean()", + "typeof dt.getBoolean)", + "error", + "error" ); +/* + a[i++] = new TestObject ( + "dt.PUB_BOOLEAN_REPRESENTATION = true ;"+ + "dt.setBoolean( dt )", + "dt.PUB_BOOLEAN", + "dt.getBoolean()", + "typeof dt.getBoolean)", + true, + "boolean" ); +*/ + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-001.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-001.js new file mode 100644 index 00000000000..952f72b7ea7 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-001.js @@ -0,0 +1,206 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to boolean"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + var BUGNUMBER = "335589"; + + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 0.5 ;"+ + "dt.setByte( dt )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -0.5;"+ + "dt.setByte( dt )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 0.5;"+ + "dt.setByte( dt )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -0.4;"+ + "dt.setByte( dt )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 0.6;"+ + "dt.setByte( dt )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -0.6;"+ + "dt.setByte( dt )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = "+Math.PI+";"+ + "dt.setByte( dt )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + 3, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -" +Math.PI+";"+ + "dt.setByte( dt )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + -3, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 127;"+ + "dt.setByte( dt )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + 127, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -128;"+ + "dt.setByte( dt )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + -128, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -128.5;"+ + "dt.setByte( dt )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + -128, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 127.5;"+ + "dt.setByte( dt )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + 127, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-002-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-002-n.js new file mode 100644 index 00000000000..97abc7433c5 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-002-n.js @@ -0,0 +1,106 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to byte"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + var newValue = Math.random(); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = NaN;"+ + "dt.setByte( dt )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-003-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-003-n.js new file mode 100644 index 00000000000..3fe3d81aa49 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-003-n.js @@ -0,0 +1,106 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to byte"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + var newValue = Math.random(); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 128;"+ + "dt.setByte( dt )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-004-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-004-n.js new file mode 100644 index 00000000000..b7578522270 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-004-n.js @@ -0,0 +1,106 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to byte"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + var newValue = Math.random(); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -129;"+ + "dt.setByte( dt )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-005-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-005-n.js new file mode 100644 index 00000000000..8a3808b358b --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-005-n.js @@ -0,0 +1,106 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to byte"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + var newValue = Math.random(); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 127.6;"+ + "dt.setByte( dt )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-006-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-006-n.js new file mode 100644 index 00000000000..4125d1fec54 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-006-n.js @@ -0,0 +1,106 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to byte"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + var newValue = Math.random(); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -128.6;"+ + "dt.setByte( dt )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-007-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-007-n.js new file mode 100644 index 00000000000..c8b86fcf8e2 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-007-n.js @@ -0,0 +1,106 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to byte"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + var newValue = Math.random(); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = Infinity;"+ + "dt.setByte( dt )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-008-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-008-n.js new file mode 100644 index 00000000000..4c05aef6564 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToByte-008-n.js @@ -0,0 +1,106 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to byte"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + var newValue = Math.random(); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -Infinity;"+ + "dt.setByte( dt )", + "dt.PUB_BYTE", + "dt.getByte()", + "typeof dt.getByte()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToChar-001.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToChar-001.js new file mode 100644 index 00000000000..18421135ffa --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToChar-001.js @@ -0,0 +1,178 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to char"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + var BUGNUMBER = "335589"; + + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 0.5 ;"+ + "dt.setChar( dt )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -0.5;"+ + "dt.setChar( dt )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 0.5;"+ + "dt.setChar( dt )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -0.4;"+ + "dt.setChar( dt )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 0.6;"+ + "dt.setChar( dt )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -0.6;"+ + "dt.setChar( dt )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = "+Math.PI+";"+ + "dt.setChar( dt )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 3, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 65535;"+ + "dt.setChar( dt )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 65535, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 65535.5;"+ + "dt.setChar( dt )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + 65535, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToChar-002-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToChar-002-n.js new file mode 100644 index 00000000000..3ca6ce8a5b7 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToChar-002-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to char"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -0.6;"+ + "dt.setChar( dt )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToChar-003-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToChar-003-n.js new file mode 100644 index 00000000000..c1d2aaa2193 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToChar-003-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to char"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = NaN;"+ + "dt.setChar( dt )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToChar-004-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToChar-004-n.js new file mode 100644 index 00000000000..5b7d26ebcef --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToChar-004-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to char"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 65535.6;"+ + "dt.setChar( dt )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToChar-005-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToChar-005-n.js new file mode 100644 index 00000000000..df65cb2fe13 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToChar-005-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to char"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = Infinity;"+ + "dt.setChar( dt )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToChar-006-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToChar-006-n.js new file mode 100644 index 00000000000..f36ca2fd18e --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToChar-006-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to char"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -Infinity;"+ + "dt.setChar( dt )", + "dt.PUB_CHAR", + "dt.getChar()", + "typeof dt.getChar()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToDouble-001.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToDouble-001.js new file mode 100644 index 00000000000..c6450c72e0f --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToDouble-001.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to double"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. Convert Result(2) to Java numeric type. with no loss of magnitude or + // sign. + + var newValue = Math.random(); + + a[i++] = new TestObject( + "dt.setDouble( " +newValue +" )", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + newValue, + "number" ); + + a[i++] = new TestObject( + "dt.setDouble( dt )", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + dt.PUB_DOUBLE_REPRESENTATION, + "number" ); + + a[i++] = new TestObject( + "dt.doubleValue()", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + dt.PUB_DOUBLE_REPRESENTATION, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = java.lang.Double.MIN_VALUE", + "dt.PUB_DOUBLE_REPRESENTATION", + "new java.lang.Double( dt ).doubleValue()", + "typeof new java.lang.Double(dt).doubleValue()", + 5e-324, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToFloat-001.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToFloat-001.js new file mode 100644 index 00000000000..e3494a4c625 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToFloat-001.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to float"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + var BUGNUMBER = "335899"; + + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. Convert Result(2) to Java numeric type. Round to float precision. + // Unrepresentably large numbers are converted to +/-Infinity. + + var newValue = Math.random(); + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = " +newValue, + "dt.PUB_DOUBLE_REPRESENTATION", + "new java.lang.Float( dt ).doubleValue()", + "typeof new java.lang.Float(dt).doubleValue()", + newValue, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = java.lang.Double.MIN_VALUE", + "dt.PUB_DOUBLE_REPRESENTATION", + "new java.lang.Float( dt ).doubleValue()", + "typeof new java.lang.Float(dt).doubleValue()", + java.lang.Double.MIN_VALUE, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = java.lang.Double.MAX_VALUE;" + + "dt.setFloat( dt )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + Infinity, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -java.lang.Double.MAX_VALUE;" + + "dt.setFloat( dt )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + -Infinity, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = java.lang.Float.MAX_VALUE * 2;" + + "dt.setFloat( dt )", + "dt.PUB_FLOAT", + "dt.getFloat()", + "typeof dt.getFloat()", + Infinity, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToInt-001.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToInt-001.js new file mode 100644 index 00000000000..cc0750717e8 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToInt-001.js @@ -0,0 +1,205 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + var BUGNUMBER="335589"; + + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 0.5 ;"+ + "dt.setInteger( dt )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -0.5;"+ + "dt.setInteger( dt )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 0.5;"+ + "dt.setInteger( dt )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -0.4;"+ + "dt.setInteger( dt )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 0.6;"+ + "dt.setInteger( dt )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -0.6;"+ + "dt.setInteger( dt )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = "+Math.PI+";"+ + "dt.setInteger( dt )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 3, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -" +Math.PI+";"+ + "dt.setInteger( dt )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + -3, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 2147483647;"+ + "dt.setInteger( dt )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 2147483647, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -2147483648;"+ + "dt.setInteger( dt )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + -2147483648, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -2147483648.5;"+ + "dt.setInteger( dt )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + -2147483648, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 2147483647.5;"+ + "dt.setInteger( dt )", + "dt.PUB_INT", + "dt.getInteger()", + "typeof dt.getInteger()", + 2147483647, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToInt-002-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToInt-002-n.js new file mode 100644 index 00000000000..f8b8b4da972 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToInt-002-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = NaN ;"+ + "dt.setInteger( dt )", + "dt.PUB_INTEGER", + "dt.getInteger()", + "typeof dt.getInteger()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToInt-003-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToInt-003-n.js new file mode 100644 index 00000000000..6de6e022864 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToInt-003-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = Infinity ;"+ + "dt.setInteger( dt )", + "dt.PUB_INTEGER", + "dt.getInteger()", + "typeof dt.getInteger()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToInt-004-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToInt-004-n.js new file mode 100644 index 00000000000..6516da0998f --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToInt-004-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -Infinity ;"+ + "dt.setInteger( dt )", + "dt.PUB_INTEGER", + "dt.getInteger()", + "typeof dt.getInteger()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToInt-005-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToInt-005-n.js new file mode 100644 index 00000000000..432fa209672 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToInt-005-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 2147483647.6 ;"+ + "dt.setInteger( dt )", + "dt.PUB_INTEGER", + "dt.getInteger()", + "typeof dt.getInteger()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToInt-006-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToInt-006-n.js new file mode 100644 index 00000000000..847b6b7cef6 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToInt-006-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to int"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -2147483648.6 ;"+ + "dt.setInteger( dt )", + "dt.PUB_INTEGER", + "dt.getInteger()", + "typeof dt.getInteger()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToLong-001.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToLong-001.js new file mode 100644 index 00000000000..7321d6a361d --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToLong-001.js @@ -0,0 +1,170 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to long"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + var BUGNUMBER = "335589"; + + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 0.5 ;"+ + "dt.setLong( dt )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -0.5;"+ + "dt.setLong( dt )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 0.5;"+ + "dt.setLong( dt )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -0.4;"+ + "dt.setLong( dt )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 0.6;"+ + "dt.setLong( dt )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -0.6;"+ + "dt.setLong( dt )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = "+Math.PI+";"+ + "dt.setLong( dt )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + 3, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -" +Math.PI+";"+ + "dt.setLong( dt )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + -3, + "number" ); + + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToLong-002-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToLong-002-n.js new file mode 100644 index 00000000000..4252bb14c31 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToLong-002-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to long"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = NaN ;"+ + "dt.setLong( dt )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToLong-003-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToLong-003-n.js new file mode 100644 index 00000000000..155d5fd143d --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToLong-003-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to long"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = Infinity ;"+ + "dt.setLong( dt )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToLong-004-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToLong-004-n.js new file mode 100644 index 00000000000..946b40ecb05 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToLong-004-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to long"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -Infinity ;"+ + "dt.setLong( dt )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToLong-005-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToLong-005-n.js new file mode 100644 index 00000000000..d80df207726 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToLong-005-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to long"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -9223372036854776000.6;"+ + "dt.setLong( dt )", + "dt.PUB_LONG", + "dt.getLong()", + "typeof dt.getLong()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToShort-001.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToShort-001.js new file mode 100644 index 00000000000..162f0b3c3a5 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToShort-001.js @@ -0,0 +1,205 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to short"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + var BUGNUMBER = "335589"; + + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 0.5 ;"+ + "dt.setShort( dt )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -0.5;"+ + "dt.setShort( dt )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 0.5;"+ + "dt.setShort( dt )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -0.4;"+ + "dt.setShort( dt )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 0.6;"+ + "dt.setShort( dt )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -0.6;"+ + "dt.setShort( dt )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + 0, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = "+Math.PI+";"+ + "dt.setShort( dt )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + 3, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -" +Math.PI+";"+ + "dt.setShort( dt )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + -3, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 32767;"+ + "dt.setShort( dt )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + 32767, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -32768;"+ + "dt.setShort( dt )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + -32768, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -32768.5;"+ + "dt.setShort( dt )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + -32768, + "number" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 32767.5;"+ + "dt.setShort( dt )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + 32767, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToShort-002-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToShort-002-n.js new file mode 100644 index 00000000000..b0a4d574c93 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToShort-002-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to short"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = NaN;"+ + "dt.setShort( dt )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToShort-003-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToShort-003-n.js new file mode 100644 index 00000000000..9de8332078e --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToShort-003-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to short"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = Infinity;"+ + "dt.setShort( dt )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToShort-004-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToShort-004-n.js new file mode 100644 index 00000000000..df16df8185b --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToShort-004-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to short"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -Infinity;"+ + "dt.setShort( dt )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToShort-005-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToShort-005-n.js new file mode 100644 index 00000000000..76dd4ac0b10 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToShort-005-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to short"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = 32767.6;"+ + "dt.setShort( dt )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToShort-006-n.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToShort-006-n.js new file mode 100644 index 00000000000..f7c959b9709 --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToShort-006-n.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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to short"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // 1. If the object does not have a doubleValue() method, a runtime error + // occurs. + // 2. Call the object's doubleValue() method + // 3. If result(2) is NaN, a runtime error occurs + // 3. Convert Result(2) to Java numeric type. Round JS number to integral + // value using round-to-negative-infinity mode. + // Numbers with a magnitude too large to be represented in the target + // integral type should result in a runtime error. + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE_REPRESENTATION = -32768.6;"+ + "dt.setShort( dt )", + "dt.PUB_SHORT", + "dt.getShort()", + "typeof dt.getShort()", + "error", + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/JavaObject/JavaObjectToString-001.js b/mozilla/js/tests/lc3/JavaObject/JavaObjectToString-001.js new file mode 100644 index 00000000000..32deda00e0e --- /dev/null +++ b/mozilla/js/tests/lc3/JavaObject/JavaObjectToString-001.js @@ -0,0 +1,109 @@ +/* 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. + * + */ +/* -*- Mode: java; tab-width: 8 -*- + * Copyright © 1997, 1998 Netscape Communications Corporation, + * All Rights Reserved. + */ +/** + * JavaScript to Java type conversion. + * + * This test passes JavaScript number values to several Java methods + * that expect arguments of various types, and verifies that the value is + * converted to the correct value and type. + * + * This tests instance methods, and not static methods. + * + * Running these tests successfully requires you to have + * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath. + * + * Specification: Method Overloading Proposal for Liveconnect 3.0 + * + * @author: christine@netscape.com + * + */ + var SECTION = "JavaObject to string"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + var dt = new DT(); + + var a = new Array(); + var i = 0; + + // Call the unwrapped object's toString() method, and return the result as + // a new java.lang.String. + + var newValue = Math.random(); + var newString = String( newValue ); + + a[i++] = new TestObject ( + "dt.PUB_STRING_REPRESENTATION = \""+newString+"\";" + + "dt.setStringObject( dt )", + "dt.PUB_STRING +''", + "dt.getStringObject() +''", + "typeof dt.getStringObject()", + newString, + "string" ); + + a[i++] = new TestObject ( + "dt.PUB_DOUBLE = java.lang.Double.valueOf(\"" + newString +"\")", + "dt.PUB_DOUBLE", + "dt.getDouble()", + "typeof dt.getDouble()", + newValue, + "number" ); + + for ( i = 0; i < a.length; i++ ) { + testcases[testcases.length] = new TestCase( + a[i].description +"; "+ a[i].javaFieldName, + a[i].jsValue, + a[i].javaFieldValue ); + + testcases[testcases.length] = new TestCase( + a[i].description +"; " + a[i].javaMethodName, + a[i].jsValue, + a[i].javaMethodValue ); + + testcases[testcases.length] = new TestCase( + a[i].javaTypeName, + a[i].jsType, + a[i].javaTypeValue ); + + } + + test(); + +function TestObject( description, javaField, javaMethod, javaType, + jsValue, jsType ) +{ + eval (description ); + + this.description = description; + this.javaFieldName = javaField; + this.javaFieldValue = eval( javaField ); + this.javaMethodName = javaMethod; + this.javaMethodValue = eval( javaMethod ); + this.javaTypeName = javaType, + this.javaTypeValue = typeof this.javaFieldValue; + + this.jsValue = jsValue; + this.jsType = jsType; +} diff --git a/mozilla/js/tests/lc3/StringMethods/string-001.js b/mozilla/js/tests/lc3/StringMethods/string-001.js new file mode 100644 index 00000000000..191c47495a3 --- /dev/null +++ b/mozilla/js/tests/lc3/StringMethods/string-001.js @@ -0,0 +1,224 @@ +/* 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. + * + */ +/** + * java.lang.String objects "inherit" JS string methods + * + * + */ + var SECTION = "java.lang.Strings using JavaScript String methods"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 " + SECTION; + + startTest(); + + var jm = getMethods( "java.lang.String" ); + var methods = new Array(); + + for ( var i = 0; i < jm.length; i++ ) { + cm = jm[i].toString(); + methods[methods.length] = [ getMethodName(cm), getArguments(cm) ]; + } + + var a = new Array(); + + // These are methods of String.prototype that differ from existing + // methods of java.lang.String in argument number or type, and but + // according to scott should still be overriden by java.lang.String + // methods. valueOf + + a[a.length] = new TestObject( + "var s"+a.length+" = new java.lang.String(\"hello\"); s"+a.length+".valueOf("+a.length+") +''", + "s"+a.length, + "valueOf", + 1, + false, + "0.0" ); + + // These are methods of String.prototype that should be overriden + // by methods of java.lang.String: + // toString charAt indexOf lastIndexOf substring substring(int, int) + // toLowerCase toUpperCase + + a[a.length] = new TestObject( + "var s" +a.length+" = new java.lang.String(\"boo\"); s"+a.length+".toString() +''", + "s"+a.length, + "toString", + 0, + false, + "boo" ); + + a[a.length] = new TestObject( + "var s" +a.length+" = new java.lang.String(\"JavaScript LiveConnect\"); s"+a.length+".charAt(0)", + "s"+a.length, + "charAt", + 1, + false, + "J".charCodeAt(0) ); + + a[a.length] = new TestObject( + "var s" +a.length+" = new java.lang.String(\"JavaScript LiveConnect\"); s"+a.length+".indexOf(\"L\")", + "s"+a.length, + "indexOf", + 1, + false, + 11 ); + + + a[a.length] = new TestObject( + "var s" +a.length+" = new java.lang.String(\"JavaScript LiveConnect\"); s"+a.length+".lastIndexOf(\"t\")", + "s"+a.length, + "lastIndexOf", + 1, + false, + 21 ); + + a[a.length] = new TestObject( + "var s" +a.length+" = new java.lang.String(\"JavaScript LiveConnect\"); s"+a.length+".substring(\"11\") +''", + "s"+a.length, + "substring", + 1, + false, + "LiveConnect" ); + + a[a.length] = new TestObject( + "var s" +a.length+" = new java.lang.String(\"JavaScript LiveConnect\"); s"+a.length+".substring(\"15\") +''", + "s"+a.length, + "substring", + 1, + false, + "Connect" ); + + a[a.length] = new TestObject( + "var s" +a.length+" = new java.lang.String(\"JavaScript LiveConnect\"); s"+a.length+".substring(4,10) +''", + "s"+a.length, + "substring", + 2, + false, + "Script" ); + + a[a.length] = new TestObject( + "var s" +a.length+" = new java.lang.String(\"JavaScript LiveConnect\"); s"+a.length+".toLowerCase() +''", + "s"+a.length, + "substring", + 0, + false, + "javascript liveconnect" ); + + a[a.length] = new TestObject( + "var s" +a.length+" = new java.lang.String(\"JavaScript LiveConnect\"); s"+a.length+".toUpperCase() +''", + "s"+a.length, + "substring", + 0, + false, + "JAVASCRIPT LIVECONNECT" ); + + // These are methods of String.prototype but are not methods of + // java.lang.String, so they should not be overriden. The method + // of the instance should be the same as the method of String.prototype + // fromCharCode charCodeAt constructor split + + a[a.length] = new TestObject( + "var s" +a.length+" = new java.lang.String(\"0 1 2 3 4 5 6 7 8 9\"); s"+a.length+".split(\" \") +''", + "s"+a.length, + "split", + 0, + true, + "0,1,2,3,4,5,6,7,8,9" ); + + a[a.length] = new TestObject( + "var s" +a.length+" = new java.lang.String(\"0 1 2 3 4 5 6 7 8 9\"); s"+a.length+".constructor", + "s"+a.length, + "constructor", + 0, + true, + String.prototype.constructor); + + + test(); + + // figure out what methods exist + // if there is no java method with the same name as a js method, should + // be able to invoke the js method without casting to a js string. also + // the method should equal the same method of String.prototype. + // if there is a java method with the same name as a js method, invoking + // the method should call the java method + + function TestObject( description, ob, method, argLength, override, expect ) { + this.description = description; + this.object = ob; + this.method = method; + this.override = override + this.argLength = argLength; + this.expect; + + this.result = eval(description); + + this.isJSMethod = eval( ob +"."+ method +" == String.prototype." + method ); + + testcases[tc++] = new TestCase( + description, + expect, + this.result ); + + if ( hasMethod( method, argLength ) ) { + testcases[tc++] = new TestCase( + ob +"." + method +" == String.prototype." + method, + override, + this.isJSMethod ); + + } else { + // If the java class has no method with that name and number of + // arguments, the value of the method should be the value of + // String.prototype.methodName + + testcases[tc++] = new TestCase( + ob +"." + method +" == String.prototype." + method, + override, + this.isJSMethod ); + } + } + + function getMethods( javaString ) { + return java.lang.Class.forName( javaString ).getMethods(); + } + function isStatic( m ) { + if ( m.lastIndexOf("static") > 0 ) { + // static method, return true + return true; + } + return false; + } + function getArguments( m ) { + var argIndex = m.lastIndexOf("(", m.length()); + var argString = m.substr(argIndex+1, m.length() - argIndex -2); + return argString.split( "," ); + } + function getMethodName( m ) { + var argIndex = m.lastIndexOf( "(", m.length()); + var nameIndex = m.lastIndexOf( ".", argIndex); + return m.substr( nameIndex +1, argIndex - nameIndex -1 ); + } + function hasMethod( m, noArgs ) { + for ( var i = 0; i < methods.length; i++ ) { + if ( (m == methods[i][0]) && (noArgs == methods[i][1].length)) { + return true; + } + } + return false; + } diff --git a/mozilla/js/tests/lc3/forin/array-001.js b/mozilla/js/tests/lc3/forin/array-001.js new file mode 100644 index 00000000000..911d4254984 --- /dev/null +++ b/mozilla/js/tests/lc3/forin/array-001.js @@ -0,0 +1,113 @@ +/* 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. + * + */ +/** + * Verify that for-in loops can be used with java objects. + * + * Java array members should be enumerated in for... in loops. + * + * + */ + var SECTION = "array-001"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0: for ... in java objects"; + SECTION; + startTest(); + + // we just need to know the names of all the expected enumerated + // properties. we will get the values to the original objects. + + // for arrays, we just need to know the length, since java arrays + // don't have any extra properties + + + var dt = new Packages.com.netscape.javascript.qa.liveconnect.DataTypeClass; + + var a = new Array(); + + a[a.length] = new TestObject( + new java.lang.String("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789").getBytes(), + "new java.lang.String(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\").getBytes()", + 36 ); + + a[a.length] = new TestObject( + dt.PUB_ARRAY_SHORT, + "dt.PUB_ARRAY_SHORT", + dt.PUB_ARRAY_SHORT.length ); + + a[a.length] = new TestObject( + dt.PUB_ARRAY_LONG, + "dt.PUB_ARRAY_LONG", + dt.PUB_ARRAY_LONG.length ); + + a[a.length] = new TestObject( + dt.PUB_ARRAY_DOUBLE, + "dt.PUB_ARRAY_DOUBLE", + dt.PUB_ARRAY_DOUBLE.length ); + + a[a.length] = new TestObject( + dt.PUB_ARRAY_BYTE, + "dt.PUB_ARRAY_BYTE", + dt.PUB_ARRAY_BYTE.length ); + + a[a.length] = new TestObject( + dt.PUB_ARRAY_CHAR, + "dt.PUB_ARRAY_CHAR", + dt.PUB_ARRAY_CHAR.length ); + + a[a.length] = new TestObject( + dt.PUB_ARRAY_OBJECT, + "dt.PUB_ARRAY_OBJECT", + dt.PUB_ARRAY_OBJECT.length ); + + for ( var i = 0; i < a.length; i++ ) { + // check the number of properties of the enumerated object + testcases[tc++] = new TestCase( + a[i].description +"; length", + a[i].items, + a[i].enumedArray.pCount ); + + for ( var arrayItem = 0; arrayItem < a[i].items; arrayItem++ ) { + testcases[tc++] = new TestCase( + "["+arrayItem+"]", + a[i].javaArray[arrayItem], + a[i].enumedArray[arrayItem] ); + } + } + + test(); + + function TestObject( arr, descr, len ) { + this.javaArray = arr; + this.description = descr; + this.items = len; + this.enumedArray = new enumObject(arr); + } + + function enumObject( o ) { + this.pCount = 0; + for ( var p in o ) { + this.pCount++; + if ( typeof p == "number" ) { + eval( "this["+p+"] = o["+p+"]" ); + } else { + eval( "this." + p + " = o["+ p+"]" ); + } + } + } + diff --git a/mozilla/js/tests/lc3/forin/object-001.js b/mozilla/js/tests/lc3/forin/object-001.js new file mode 100644 index 00000000000..f3411c55ad8 --- /dev/null +++ b/mozilla/js/tests/lc3/forin/object-001.js @@ -0,0 +1,183 @@ +/* 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. + * + */ +/** + * Verify that for-in loops can be used with java objects. + * + * Java array members of object instances should be enumerated in + * for... in loops. + * + */ + var SECTION = "for...in"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0"; + SECTION; + startTest(); + + // we just need to know the names of all the expected enumerated + // properties. we will get the values to the original objects. + + var dt = new Packages.com.netscape.javascript.qa.liveconnect.DataTypeClass; + + var a = new Array(); + + a[a.length] = new TestObject( + dt.PUB_STRING, + "var dt = new Packages.com.netscape.javascript.qa.liveconnect.DataTypeClass; dt.getString()", + 0, + "java.lang.String"); + + a[a.length] = new TestObject( + dt.getLongObject(), + "dt.getLongObject()", + 0, + "java.lang.Long"); + + a[a.length] = new TestObject( + new java.awt.Rectangle(5,6,7,8), + "new java.awt.Rectangle(5,6,7,8)", + 0, + "java.awt.Rectangle"); + + for ( var i = 0; i < a.length; i++ ) { + // check the value of each indexed array item + + for ( var arrayItem = 0; arrayItem < a[i].items; arrayItem++ ) { + testcases[tc++] = new TestCase( + "["+arrayItem+"]", + a[i].javaObject[arrayItem], + a[i].enumedObject[arrayItem] ); + } + + // verify that all non-static properties are enumerated + + + var fieldArray = getFields( a[i].javaClass ); + + for ( var fieldIndex = 0; fieldIndex < fieldArray.length; fieldIndex++ ) { + var f = fieldArray[fieldIndex] +""; + + if ( ! isStatic( f ) ) { + var currentField = getFieldName( f ); + + testcases[tc++] = new TestCase( + a[i].javaClass+"." + currentField + " enumerated ", + true, + a[i].enumedObject[currentField]+"" == a[i].javaObject[currentField] +""); + } + } + + // verify that all non-static methods are enumerated + + var methodArray = getMethods(a[i].javaClass); + + for ( var methodIndex = 0; methodIndex < methodArray.length; methodIndex++ ) { + var m = methodArray[methodIndex] +""; + + if ( ! isStatic(m) && inClass( a[i].javaClass, m)) { + var currentMethod = getMethodName(m); + + testcases[tc++] = new TestCase( + a[i].javaClass+"."+currentMethod + " enumerated ", + true, + a[i].enumedObject[currentMethod] +"" == a[i].javaObject[currentMethod] +""); + + } + + } + } + + + test(); + + function TestObject( ob, descr, len, jc) { + this.javaObject= ob; + this.description = descr; + this.items = len; + this.javaClass = jc; + this.enumedObject = new enumObject(ob); + } + + function enumObject( o ) { + this.pCount = 0; + for ( var p in o ) { + this.pCount++; + if ( typeof p == "number" ) { + eval( "this["+p+"] = o["+p+"]" ); + } else { + eval( "this." + p + " = o."+ p ); + } + } + } + + // only return if the method is a method of the class, not an inherited + // method + + function inClass( javaClass, m ) { + var argIndex = m.lastIndexOf( "(", m.length ); + var methodIndex = m.lastIndexOf( ".", argIndex ); + var classIndex = m.lastIndexOf( " ", methodIndex ); + var className = m.substr(classIndex +1, methodIndex - classIndex -1 ); + + if ( className == javaClass ) { + return true; + } + return false; + } + function isStatic( m ) { + if ( m.lastIndexOf ( "static" ) > 0 ) { + return true; + } + return false; + } + function getMethods( javaString ) { + return java.lang.Class.forName( javaString ).getMethods(); + } + function getArguments( m ) { + var argIndex = m.lastIndexOf("(", m.length()); + var argString = m.substr(argIndex+1, m.length() - argIndex -2); + return argString.split( "," ); + } + function getMethodName( m ) { + var argIndex = m.lastIndexOf( "(", m.length); + var nameIndex = m.lastIndexOf( ".", argIndex); + return m.substr( nameIndex +1, argIndex - nameIndex -1 ); + } + function getFields( javaClassName ) { + return java.lang.Class.forName( javaClassName ).getFields(); + } + function getFieldName( f ) { + return f.substr( f.lastIndexOf(".", f.length)+1, f.length ); + } + function getFieldNames( javaClassName ) { + var javaFieldArray = getFields( javaClassName ); + + for ( var i = 0, jsFieldArray = new Array(); i < javaFieldArray.length; i++ ) { + var f = javaFieldArray[i] +""; + jsFieldArray[i] = f.substr( f.lastIndexOf(".", f.length)+1, f.length ); + } + return jsFieldArray; + } + function hasMethod( m, noArgs ) { + for ( var i = 0; i < methods.length; i++ ) { + if ( (m == methods[i][0]) && (noArgs == methods[i][1].length)) { + return true; + } + } + return false; + } diff --git a/mozilla/js/tests/lc3/instanceof/instanceof-001.js b/mozilla/js/tests/lc3/instanceof/instanceof-001.js new file mode 100644 index 00000000000..f1d84a717b6 --- /dev/null +++ b/mozilla/js/tests/lc3/instanceof/instanceof-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. + * + */ +/** + * Verify that we can use the instanceof operator on java objects. + * + * + */ + var SECTION = "instanceof"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + + testcases[tc++] = new TestCase( + "\"hi\" instance of java.lang.String", + false, + "hi" instanceof java.lang.String ); + + testcases[tc++] = new TestCase( + "new java.lang.String(\"hi\") instanceof java.lang.String", + true, + new java.lang.String("hi") instanceof java.lang.String ); + + testcases[tc++] = new TestCase( + "new java.lang.String(\"hi\") instanceof java.lang.Object", + true, + new java.lang.String("hi") instanceof java.lang.Object ); + + testcases[tc++] = new TestCase( + "java.lang.String instanceof java.lang.Class", + false, + java.lang.String instanceof java.lang.Class ); + + testcases[tc++] = new TestCase( + "java.lang.Class.forName(\"java.lang.String\") instanceof java.lang.Class", + true, + java.lang.Class.forName("java.lang.String") instanceof java.lang.Class ); + + testcases[tc++] = new TestCase( + "new java.lang.Double(5.0) instanceof java.lang.Double", + true, + new java.lang.Double(5.0) instanceof java.lang.Double ); + + testcases[tc++] = new TestCase( + "new java.lang.Double(5.0) instanceof java.lang.Number", + true, + new java.lang.Double(5.0) instanceof java.lang.Number ); + + testcases[tc++] = new TestCase( + "new java.lang.String(\"hi\").getBytes() instanceof java.lang.Double", + true, + new java.lang.Double(5.0) instanceof java.lang.Double ); + + + + + test(); \ No newline at end of file diff --git a/mozilla/js/tests/lc3/jsref.js b/mozilla/js/tests/lc3/jsref.js new file mode 100644 index 00000000000..55a70d7ab2e --- /dev/null +++ b/mozilla/js/tests/lc3/jsref.js @@ -0,0 +1,214 @@ +/* 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 = ""; +TITLE = ""; + +BUGNUMBER=""; +var EXCLUDE = ""; + +var GLOBAL = "[object global]"; +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 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 TestCase( d, e, a ) { + this.name = SECTION; + 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() { + testcases = new Array(); + tc = 0; + + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "JS1_4" ) { + version( 140 ); + } + if ( VERSION == "ECMA_1" ) { + version ( "130" ); + } + if ( VERSION == "JS1_3" ) { + version ( "130" ); + } + if ( VERSION == "JS1_2" ) { + version ( "120" ); + } + if ( VERSION == "JS1_1" ) { + version ( "110" ); + } + + writeHeaderToLog( SECTION + " "+ TITLE); + + // verify that DataTypeClass is on the CLASSPATH + + DT = Packages.com.netscape.javascript.qa.liveconnect.DataTypeClass; + + if ( typeof DT != "function" ) { + throw "Test Exception: "+ + "com.netscape.javascript.qa.liveconnect.DataTypeClass "+ + "is not on the CLASSPATH"; + } +} + +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 ); + } + } +} diff --git a/mozilla/js/tests/lc3/shell.js b/mozilla/js/tests/lc3/shell.js new file mode 100644 index 00000000000..4d57a3fa6b6 --- /dev/null +++ b/mozilla/js/tests/lc3/shell.js @@ -0,0 +1,187 @@ +/* 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; +var DT; + +TITLE = ""; +SECTION = ""; +VERSION = ""; +BUGNUMBER=""; + +var GLOBAL= "[object global]"; +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 = ""; + +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 ); +} + +function TestCase( d, e, a ) { + this.name = SECTION; + 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() { + testcases = new Array(); + tc = 0; + + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "JS1_4" ) { + version( 140 ); + } + if ( VERSION == "ECMA_1" ) { + version ( "130" ); + } + if ( VERSION == "JS1_3" ) { + version ( "130" ); + } + if ( VERSION == "JS1_2" ) { + version ( "120" ); + } + if ( VERSION == "JS1_1" ) { + version ( "110" ); + } + + writeHeaderToLog( SECTION + " "+ TITLE); + + // verify that DataTypeClass is on the CLASSPATH + + DT = Packages.com.netscape.javascript.qa.liveconnect.DataTypeClass; + + if ( typeof DT != "function" ) { + throw "Test Exception: "+ + "com.netscape.javascript.qa.liveconnect.DataTypeClass "+ + "is not on the CLASSPATH"; + } +} + +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 gc; + + if ( gc != undefined ) { + gc(); + } + print( HR ); +} +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 ); + } + } +} diff --git a/mozilla/js/tests/lc3/template.js b/mozilla/js/tests/lc3/template.js new file mode 100644 index 00000000000..9c73b7afbe8 --- /dev/null +++ b/mozilla/js/tests/lc3/template.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. + * + */ +/** + * Template for LiveConnect 3.0 tests. + * + * + */ + var SECTION = "undefined conversion"; + var VERSION = "1_4"; + var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " + + SECTION; + startTest(); + + // 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 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; + return this; +}