Check in modifications to allow lc2 tests to be run in the browser, no bug

This commit is contained in:
bob%bclary.com 2005-08-31 04:47:33 +00:00
Родитель 7f3100012a
Коммит 8ce6f71386
77 изменённых файлов: 3298 добавлений и 3958 удалений

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -54,83 +55,81 @@
5. Check the class of the JavaArray, using getClass, and compare
it to java.lang.Class.forName("java.lang.Array");
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Array to JavaScript JavaArray object";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Array to JavaScript JavaArray object";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// In all test cases, the expected type is "object, and the expected
// class is "Number"
// In all test cases, the expected type is "object, and the expected
// class is "Number"
var E_TYPE = "object";
var E_CLASS = "[object JavaArray]";
var test_array = new Array();
var E_TYPE = "object";
var E_CLASS = "[object JavaArray]";
var test_array = new Array();
// Create arrays of actual results (java_array) and expected results
// (test_array).
// Create arrays of actual results (java_array) and expected results
// (test_array).
var java_array = new Array();
var java_array = new Array();
var i = 0;
var i = 0;
// byte[]
// byte[]
var byte_array = ( new java.lang.String("hello") ).getBytes();
var byte_array = ( new java.lang.String("hello") ).getBytes();
java_array[i] = new JavaValue( byte_array );
test_array[i] = new TestValue( "( new java.lang.String('hello') ).getBytes()",
["h".charCodeAt(0),
"e".charCodeAt(0),
"l".charCodeAt(0),
"l".charCodeAt(0),
"o".charCodeAt(0) ],
"[B"
);
i++;
java_array[i] = new JavaValue( byte_array );
test_array[i] = new TestValue( "( new java.lang.String('hello') ).getBytes()",
["h".charCodeAt(0),
"e".charCodeAt(0),
"l".charCodeAt(0),
"l".charCodeAt(0),
"o".charCodeAt(0) ],
"[B"
);
i++;
// char[]
var char_array = ( new java.lang.String("rhino") ).toCharArray();
// char[]
var char_array = ( new java.lang.String("rhino") ).toCharArray();
java_array[i] = new JavaValue( char_array );
test_array[i] = new TestValue( "( new java.lang.String('rhino') ).toCharArray()",
[ "r".charCodeAt(0),
"h".charCodeAt(0),
"i".charCodeAt(0),
"n".charCodeAt(0),
"o".charCodeAt(0)],
"[C");
i++;
java_array[i] = new JavaValue( char_array );
test_array[i] = new TestValue( "( new java.lang.String('rhino') ).toCharArray()",
[ "r".charCodeAt(0),
"h".charCodeAt(0),
"i".charCodeAt(0),
"n".charCodeAt(0),
"o".charCodeAt(0)],
"[C");
i++;
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
test();
test();
function CompareValues( javaval, testval ) {
// Check value
for ( var i = 0; i < testval.value.length; i++ ) {
testcases[testcases.length] = new TestCase( SECTION,
"("+ testval.description +")["+i+"]",
testval.value[i],
javaval.value[i] );
new TestCase( SECTION,
"("+ testval.description +")["+i+"]",
testval.value[i],
javaval.value[i] );
}
// Check type
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
// Check class
@ -146,8 +145,8 @@ function JavaValue( value ) {
this.classname = this.value.getClass();
jlo_class = java.lang.Class.forName("java.lang.Object")
jlo_getClass_method = jlo_class.getMethod("getClass", null)
this.lcclass = jlo_getClass_method.invoke(value, null );
jlo_getClass_method = jlo_class.getMethod("getClass", null)
this.lcclass = jlo_getClass_method.invoke(value, null );
return this;
}
@ -159,16 +158,3 @@ function TestValue( description, value, lcclass ) {
this.classname = E_CLASS;
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -38,69 +39,67 @@
File Name: array-002.js
Description:
JavaArrays should have a length property that specifies the number of
elements in the array.
JavaArrays should have a length property that specifies the number of
elements in the array.
JavaArray elements can be referenced with the [] array index operator.
JavaArray elements can be referenced with the [] array index operator.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Array to JavaScript JavaArray object";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Array to JavaScript JavaArray object";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// In all test cases, the expected type is "object, and the expected
// class is "JavaArray"
// In all test cases, the expected type is "object, and the expected
// class is "JavaArray"
var E_TYPE = "object";
var E_CLASS = "[object JavaArray]";
var E_TYPE = "object";
var E_CLASS = "[object JavaArray]";
// Create arrays of actual results (java_array) and expected results
// (test_array).
// Create arrays of actual results (java_array) and expected results
// (test_array).
var java_array = new Array();
var test_array = new Array();
var java_array = new Array();
var test_array = new Array();
var i = 0;
var i = 0;
// byte[]
// byte[]
var byte_array = ( new java.lang.String("ABCDEFGHIJKLMNOPQRSTUVWXYZ") ).getBytes();
var byte_array = ( new java.lang.String("ABCDEFGHIJKLMNOPQRSTUVWXYZ") ).getBytes();
java_array[i] = new JavaValue( byte_array );
test_array[i] = new TestValue( "( new java.lang.String('ABCDEFGHIJKLMNOPQRSTUVWXYZ') ).getBytes()",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ".length
);
i++;
java_array[i] = new JavaValue( byte_array );
test_array[i] = new TestValue( "( new java.lang.String('ABCDEFGHIJKLMNOPQRSTUVWXYZ') ).getBytes()",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ".length
);
i++;
// char[]
var char_array = ( new java.lang.String("rhino") ).toCharArray();
// char[]
var char_array = ( new java.lang.String("rhino") ).toCharArray();
java_array[i] = new JavaValue( char_array );
test_array[i] = new TestValue( "( new java.lang.String('rhino') ).toCharArray()",
"rhino".length );
i++;
java_array[i] = new JavaValue( char_array );
test_array[i] = new TestValue( "( new java.lang.String('rhino') ).toCharArray()",
"rhino".length );
i++;
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
test();
test();
function CompareValues( javaval, testval ) {
// Check length
testcases[testcases.length] = new TestCase( SECTION,
"("+ testval.description +").length",
testval.value,
javaval.length );
new TestCase( SECTION,
"("+ testval.description +").length",
testval.value,
javaval.length );
}
function JavaValue( value ) {
this.value = value;
@ -113,21 +112,8 @@ function JavaValue( value ) {
function TestValue( description, value ) {
this.description = description;
this.length = value
this.value = value;
this.value = value;
this.type = E_TYPE;
this.classname = E_CLASS;
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -38,67 +39,65 @@
File Name: array-003.js
Description:
JavaArray elements should be enumerable using a for/in loop.
JavaArray elements should be enumerable using a for/in loop.
@version 1.00
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Array to JavaScript JavaArray object";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Array to JavaScript JavaArray object";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// In all test cases, the expected type is "object, and the expected
// class is "Number"
// In all test cases, the expected type is "object, and the expected
// class is "Number"
var E_TYPE = "object";
var E_CLASS = "[object JavaArray]";
var E_TYPE = "object";
var E_CLASS = "[object JavaArray]";
// Create arrays of actual results (java_array) and expected results
// (test_array).
// Create arrays of actual results (java_array) and expected results
// (test_array).
var java_array = new Array();
var test_array = new Array();
var java_array = new Array();
var test_array = new Array();
var i = 0;
var i = 0;
// byte[]
// byte[]
var byte_array = ( new java.lang.String("hello") ).getBytes();
var byte_array = ( new java.lang.String("hello") ).getBytes();
java_array[i] = new JavaValue( byte_array );
test_array[i] = new TestValue( "( new java.lang.String('hello') ).getBytes()",
["h".charCodeAt(0),
"e".charCodeAt(0),
"l".charCodeAt(0),
"l".charCodeAt(0),
"o".charCodeAt(0) ],
"[B"
);
i++;
java_array[i] = new JavaValue( byte_array );
test_array[i] = new TestValue( "( new java.lang.String('hello') ).getBytes()",
["h".charCodeAt(0),
"e".charCodeAt(0),
"l".charCodeAt(0),
"l".charCodeAt(0),
"o".charCodeAt(0) ],
"[B"
);
i++;
// char[]
var char_array = ( new java.lang.String("rhino") ).toCharArray();
// char[]
var char_array = ( new java.lang.String("rhino") ).toCharArray();
java_array[i] = new JavaValue( char_array );
test_array[i] = new TestValue( "( new java.lang.String('rhino') ).toCharArray()",
[ "r".charCodeAt(0),
"h".charCodeAt(0),
"i".charCodeAt(0),
"n".charCodeAt(0),
"o".charCodeAt(0) ],
"[C" );
i++;
java_array[i] = new JavaValue( char_array );
test_array[i] = new TestValue( "( new java.lang.String('rhino') ).toCharArray()",
[ "r".charCodeAt(0),
"h".charCodeAt(0),
"i".charCodeAt(0),
"n".charCodeAt(0),
"o".charCodeAt(0) ],
"[C" );
i++;
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
test();
test();
function CompareValues( javaval, testval ) {
// Check value
@ -107,10 +106,10 @@ function CompareValues( javaval, testval ) {
var e = 0;
for ( p in javaval.value ) {
testcases[testcases.length] = new TestCase( SECTION,
"("+ testval.description +")["+p+"]",
testval.value[p],
javaval.value[p] );
new TestCase( SECTION,
"("+ testval.description +")["+p+"]",
testval.value[p],
javaval.value[p] );
e++;
}
@ -119,18 +118,18 @@ function CompareValues( javaval, testval ) {
* the array
*/
testcases[testcases.length] = new TestCase( SECTION,
"number of elements enumerated:",
testval.length,
e );
new TestCase( SECTION,
"number of elements enumerated:",
testval.length,
e );
// Check type
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
// Check class.
testcases[testcases.length ] = new TestCase( SECTION,
@ -145,8 +144,8 @@ function JavaValue( value ) {
this.classname = this.value.toString();
jlo_class = java.lang.Class.forName("java.lang.Object")
jlo_getClass_method = jlo_class.getMethod("getClass", null)
this.lcclass = jlo_getClass_method.invoke(value, null );
jlo_getClass_method = jlo_class.getMethod("getClass", null)
this.lcclass = jlo_getClass_method.invoke(value, null );
return this;
}
@ -159,16 +158,3 @@ function TestValue( description, value, lcclass ) {
this.classname = E_CLASS;
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -38,75 +39,73 @@
File Name: array-004.js
Description:
Access array indices that are out of bounds.
Access array indices that are out of bounds.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Array to JavaScript JavaArray object";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Array to JavaScript JavaArray object";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// In all test cases, the expected type is "object, and the expected
// class is "JavaArray"
// In all test cases, the expected type is "object, and the expected
// class is "JavaArray"
var E_TYPE = "object";
var E_CLASS = "[object JavaArray]";
var E_TYPE = "object";
var E_CLASS = "[object JavaArray]";
// Create arrays of actual results (java_array) and expected results
// (test_array).
// Create arrays of actual results (java_array) and expected results
// (test_array).
var java_array = new Array();
var test_array = new Array();
var java_array = new Array();
var test_array = new Array();
var i = 0;
var i = 0;
// byte[]
// byte[]
var byte_array = ( new java.lang.String("ABCDEFGHIJKLMNOPQRSTUVWXYZ") ).getBytes();
var byte_array = ( new java.lang.String("ABCDEFGHIJKLMNOPQRSTUVWXYZ") ).getBytes();
java_array[i] = new JavaValue( byte_array );
test_array[i] = new TestValue( "( new java.lang.String('ABCDEFGHIJKLMNOPQRSTUVWXYZ') ).getBytes()",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ".length
);
i++;
java_array[i] = new JavaValue( byte_array );
test_array[i] = new TestValue( "( new java.lang.String('ABCDEFGHIJKLMNOPQRSTUVWXYZ') ).getBytes()",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ".length
);
i++;
// char[]
var char_array = ( new java.lang.String("rhino") ).toCharArray();
// char[]
var char_array = ( new java.lang.String("rhino") ).toCharArray();
java_array[i] = new JavaValue( char_array );
test_array[i] = new TestValue( "( new java.lang.String('rhino') ).toCharArray()",
"rhino".length );
i++;
java_array[i] = new JavaValue( char_array );
test_array[i] = new TestValue( "( new java.lang.String('rhino') ).toCharArray()",
"rhino".length );
i++;
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
test();
test();
function CompareValues( javaval, testval ) {
// Check length
testcases[testcases.length] = new TestCase( SECTION,
"("+ testval.description +").length",
testval.value,
javaval.length );
new TestCase( SECTION,
"("+ testval.description +").length",
testval.value,
javaval.length );
// access element [-1]
testcases[testcases.length] = new TestCase(
new TestCase(
SECTION,
"("+testval.description+")[-1]",
void 0,
javaval[-1] );
// access element [length]
testcases[testcases.length] = new TestCase(
new TestCase(
SECTION,
"("+testval.description+")["+testval.value+"]",
void 0,
@ -125,21 +124,8 @@ function JavaValue( value ) {
function TestValue( description, value ) {
this.description = description;
this.length = value
this.value = value;
this.value = value;
this.type = E_TYPE;
this.classname = E_CLASS;
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -38,100 +39,84 @@
File Name: array-005.js
Description:
Put and Get JavaArray Elements
Put and Get JavaArray Elements
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Array to JavaScript JavaArray object";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Array to JavaScript JavaArray object";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// In all test cases, the expected type is "object, and the expected
// class is "JavaArray"
// In all test cases, the expected type is "object, and the expected
// class is "JavaArray"
var E_TYPE = "object";
var E_CLASS = "[object JavaArray]";
var E_TYPE = "object";
var E_CLASS = "[object JavaArray]";
var byte_array = ( new java.lang.String("hi") ).getBytes();
var byte_array = ( new java.lang.String("hi") ).getBytes();
new TestCase(
SECTION,
"byte_array = new java.lang.String(\"hi\")).getBytes(); delete byte_array.length",
false,
delete byte_array.length );
testcases[testcases.length] = new TestCase(
SECTION,
"byte_array = new java.lang.String(\"hi\")).getBytes(); delete byte_array.length",
false,
delete byte_array.length );
new TestCase(
SECTION,
"byte_array[0]",
("hi").charCodeAt(0),
byte_array[0]);
testcases[testcases.length] = new TestCase(
SECTION,
"byte_array[0]",
("hi").charCodeAt(0),
byte_array[0]);
new TestCase(
SECTION,
"byte_array[1]",
("hi").charCodeAt(1),
byte_array[1]);
testcases[testcases.length] = new TestCase(
SECTION,
"byte_array[1]",
("hi").charCodeAt(1),
byte_array[1]);
byte_array.length = 0;
byte_array.length = 0;
new TestCase(
SECTION,
"byte_array.length = 0; byte_array.length",
2,
byte_array.length );
testcases[testcases.length] = new TestCase(
SECTION,
"byte_array.length = 0; byte_array.length",
2,
byte_array.length );
var properties = "";
for ( var p in byte_array ) {
properties += ( p == "length" ) ? p : "";
}
testcases[testcases.length] = new TestCase(
SECTION,
"for ( var p in byte_array ) { properties += p ==\"length\" ? p : \"\" }; properties",
"",
properties );
testcases[testcases.length] = new TestCase(
SECTION,
"byte_array[\"length\"]",
2,
byte_array["length"] );
byte_array["0"] = 127;
testcases[testcases.length] = new TestCase(
SECTION,
"byte_array[\"0\"] = 127; byte_array[0]",
127,
byte_array[0] );
byte_array[1] = 99;
testcases[testcases.length] = new TestCase(
SECTION,
"byte_array[1] = 99; byte_array[\"1\"]",
99,
byte_array["1"] );
test();
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
var properties = "";
for ( var p in byte_array ) {
properties += ( p == "length" ) ? p : "";
}
new TestCase(
SECTION,
"for ( var p in byte_array ) { properties += p ==\"length\" ? p : \"\" }; properties",
"",
properties );
new TestCase(
SECTION,
"byte_array[\"length\"]",
2,
byte_array["length"] );
byte_array["0"] = 127;
new TestCase(
SECTION,
"byte_array[\"0\"] = 127; byte_array[0]",
127,
byte_array[0] );
byte_array[1] = 99;
new TestCase(
SECTION,
"byte_array[1] = 99; byte_array[\"1\"]",
99,
byte_array["1"] );
test();

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -38,46 +39,34 @@
File Name: array-005.js
Description:
Put and Get JavaArray Elements
Put and Get JavaArray Elements
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Array to JavaScript JavaArray object";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Array to JavaScript JavaArray object";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// In all test cases, the expected type is "object, and the expected
// class is "JavaArray"
// In all test cases, the expected type is "object, and the expected
// class is "JavaArray"
var E_TYPE = "object";
var E_CLASS = "[object JavaArray]";
var E_TYPE = "object";
var E_CLASS = "[object JavaArray]";
var byte_array = ( new java.lang.String("hi") ).getBytes();
var byte_array = ( new java.lang.String("hi") ).getBytes();
DESCRIPTION = "byte_array[\"foo\"]";
EXPECTED = "error";
testcases[testcases.length] = new TestCase(
SECTION,
"byte_array[\"foo\"]",
void 0,
byte_array["foo"] );
new TestCase(
SECTION,
"byte_array[\"foo\"]",
void 0,
byte_array["foo"] );
test();
test();
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -38,50 +39,38 @@
File Name: array-005.js
Description:
Put and Get JavaArray Elements
Put and Get JavaArray Elements
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Array to JavaScript JavaArray object";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Array to JavaScript JavaArray object";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// In all test cases, the expected type is "object, and the expected
// class is "JavaArray"
// In all test cases, the expected type is "object, and the expected
// class is "JavaArray"
var E_TYPE = "object";
var E_CLASS = "[object JavaArray]";
var E_TYPE = "object";
var E_CLASS = "[object JavaArray]";
var byte_array = ( new java.lang.String("hi") ).getBytes();
var byte_array = ( new java.lang.String("hi") ).getBytes();
byte_array.name = "name";
byte_array.name = "name";
DESCRIPTION = "byte_array.name = \"name\"; byte_array.name";
EXPECTED = "error";
testcases[testcases.length] = new TestCase(
SECTION,
"byte_array.name = \"name\"; byte_array.name",
void 0,
byte_array.name );
new TestCase(
SECTION,
"byte_array.name = \"name\"; byte_array.name",
void 0,
byte_array.name );
byte_array["0"] = 127;
byte_array["0"] = 127;
test();
test();
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -38,47 +39,35 @@
File Name: array-008-n.js
Description:
JavaArrays should have a length property that specifies the number of
elements in the array.
JavaArrays should have a length property that specifies the number of
elements in the array.
JavaArray elements can be referenced with the [] array index operator.
JavaArray elements can be referenced with the [] array index operator.
This attempts to access an array index that is out of bounds. It should
fail with a JS runtime error.
This attempts to access an array index that is out of bounds. It should
fail with a JS runtime error.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Array to JavaScript JavaArray object";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Array to JavaScript JavaArray object";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
dt = new Packages.com.netscape.javascript.qa.liveconnect.DataTypeClass;
dt = new Packages.com.netscape.javascript.qa.liveconnect.DataTypeClass;
var ba_length = dt.PUB_ARRAY_BYTE.length;
var ba_length = dt.PUB_ARRAY_BYTE.length;
DESCRIPTION = "dt.PUB_ARRAY_BYTE.length = "+ ba_length;
EXPECTED = "error";
testcases[tc++] = new TestCase(
SECTION,
"dt.PUB_ARRAY_BYTE.length = "+ ba_length,
"error",
dt.PUB_ARRAY_BYTE[ba_length] );
new TestCase(
SECTION,
"dt.PUB_ARRAY_BYTE.length = "+ ba_length,
"error",
dt.PUB_ARRAY_BYTE[ba_length] );
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}
test();

0
js/tests/lc2/Arrays/browser.js Executable file
Просмотреть файл

0
js/tests/lc2/Arrays/shell.js Executable file
Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,97 +35,96 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: class-001.js
Description:
File Name: class-001.js
Description:
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect Classes";
var VERSION = "1_3";
var TITLE = "JavaClass objects";
var SECTION = "LiveConnect Classes";
var VERSION = "1_3";
var TITLE = "JavaClass objects";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// All packages are of the type "function", since they implement [[Construct]]
// and [[Call]]
// All packages are of the type "function", since they implement [[Construct]]
// and [[Call]]
var E_TYPE = "function";
var E_TYPE = "function";
// The JavaScript [[Class]] property for all Classes is "[object JavaClass]"
var E_JSCLASS = "[object JavaClass]";
// The JavaScript [[Class]] property for all Classes is "[object JavaClass]"
var E_JSCLASS = "[object JavaClass]";
// Create arrays of actual results (java_array) and
// expected results (test_array).
// Create arrays of actual results (java_array) and
// expected results (test_array).
var java_array = new Array();
var test_array = new Array();
var java_array = new Array();
var test_array = new Array();
var i = 0;
var i = 0;
java_array[i] = new JavaValue( java.awt.Image );
test_array[i] = new TestValue( "java.awt.Image" );
i++;
java_array[i] = new JavaValue( java.awt.Image );
test_array[i] = new TestValue( "java.awt.Image" );
i++;
java_array[i] = new JavaValue( java.beans.Beans );
test_array[i] = new TestValue( "java.beans.Beans" );
i++;
java_array[i] = new JavaValue( java.beans.Beans );
test_array[i] = new TestValue( "java.beans.Beans" );
i++;
java_array[i] = new JavaValue( java.io.File );
test_array[i] = new TestValue( "java.io.File" );
i++;
java_array[i] = new JavaValue( java.io.File );
test_array[i] = new TestValue( "java.io.File" );
i++;
java_array[i] = new JavaValue( java.lang.String );
test_array[i] = new TestValue( "java.lang.String" );
i++;
java_array[i] = new JavaValue( java.lang.String );
test_array[i] = new TestValue( "java.lang.String" );
i++;
java_array[i] = new JavaValue( java.math.BigDecimal );
test_array[i] = new TestValue( "java.math.BigDecimal" );
i++;
java_array[i] = new JavaValue( java.math.BigDecimal );
test_array[i] = new TestValue( "java.math.BigDecimal" );
i++;
java_array[i] = new JavaValue( java.net.URL );
test_array[i] = new TestValue( "java.net.URL" );
i++;
java_array[i] = new JavaValue( java.net.URL );
test_array[i] = new TestValue( "java.net.URL" );
i++;
java_array[i] = new JavaValue( java.text.DateFormat );
test_array[i] = new TestValue( "java.text.DateFormat" );
i++;
java_array[i] = new JavaValue( java.text.DateFormat );
test_array[i] = new TestValue( "java.text.DateFormat" );
i++;
java_array[i] = new JavaValue( java.util.Vector );
test_array[i] = new TestValue( "java.util.Vector" );
i++;
java_array[i] = new JavaValue( java.util.Vector );
test_array[i] = new TestValue( "java.util.Vector" );
i++;
/*
java_array[i] = new JavaValue( Packages.com.netscape.javascript.Context );
test_array[i] = new TestValue( "Packages.com.netscape.javascript.Context" );
i++;
java_array[i] = new JavaValue( Packages.com.netscape.javascript.Context );
test_array[i] = new TestValue( "Packages.com.netscape.javascript.Context" );
i++;
*/
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
test();
test();
function CompareValues( javaval, testval ) {
// Check type, which should be E_TYPE
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
/*
// Check JavaScript class, which should be E_JSCLASS
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +".)getJSClass()",
testval.jsclass,
javaval.jsclass );
// Check JavaScript class, which should be E_JSCLASS
new TestCase( SECTION,
"(" + testval.description +".)getJSClass()",
testval.jsclass,
javaval.jsclass );
*/
// Check the class's name, which should be the description, minus the "Package." part.
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +") +''",
testval.classname,
javaval.classname );
new TestCase( SECTION,
"(" + testval.description +") +''",
testval.classname,
javaval.classname );
}
function JavaValue( value ) {
// Object.prototype.toString will show its JavaScript wrapper object.
@ -142,24 +142,11 @@ function TestValue( description, value ) {
this.lcclass = java.lang.Class.forName( description );
this.classname = "[JavaClass " +
( ( description.substring(0,9) == "Packages." )
? description.substring(9,description.length)
: description
) + "]"
( ( description.substring(0,9) == "Packages." )
? description.substring(9,description.length)
: description
) + "]"
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
return this;
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,99 +35,98 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: class-001.js
Description:
File Name: class-001.js
Description:
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect Classes";
var VERSION = "1_3";
var TITLE = "JavaClass objects";
var SECTION = "LiveConnect Classes";
var VERSION = "1_3";
var TITLE = "JavaClass objects";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// All packages are of the type "function", since they implement [[Construct]]
// and [[Call]]
// All packages are of the type "function", since they implement [[Construct]]
// and [[Call]]
var E_TYPE = "function";
var E_TYPE = "function";
// The JavaScript [[Class]] property for all Classes is "[object JavaClass]"
var E_JSCLASS = "[object JavaClass]";
// The JavaScript [[Class]] property for all Classes is "[object JavaClass]"
var E_JSCLASS = "[object JavaClass]";
// Create arrays of actual results (java_array) and
// expected results (test_array).
// Create arrays of actual results (java_array) and
// expected results (test_array).
var java_array = new Array();
var test_array = new Array();
var java_array = new Array();
var test_array = new Array();
var i = 0;
var i = 0;
java_array[i] = new JavaValue( java.awt.Image );
test_array[i] = new TestValue( "java.awt.Image" );
i++;
java_array[i] = new JavaValue( java.awt.Image );
test_array[i] = new TestValue( "java.awt.Image" );
i++;
java_array[i] = new JavaValue( java.beans.Beans );
test_array[i] = new TestValue( "java.beans.Beans" );
i++;
java_array[i] = new JavaValue( java.beans.Beans );
test_array[i] = new TestValue( "java.beans.Beans" );
i++;
java_array[i] = new JavaValue( java.io.File );
test_array[i] = new TestValue( "java.io.File" );
i++;
java_array[i] = new JavaValue( java.io.File );
test_array[i] = new TestValue( "java.io.File" );
i++;
java_array[i] = new JavaValue( java.lang.String );
test_array[i] = new TestValue( "java.lang.String" );
i++;
java_array[i] = new JavaValue( java.lang.String );
test_array[i] = new TestValue( "java.lang.String" );
i++;
java_array[i] = new JavaValue( java.math.BigDecimal );
test_array[i] = new TestValue( "java.math.BigDecimal" );
i++;
java_array[i] = new JavaValue( java.math.BigDecimal );
test_array[i] = new TestValue( "java.math.BigDecimal" );
i++;
java_array[i] = new JavaValue( java.net.URL );
test_array[i] = new TestValue( "java.net.URL" );
i++;
java_array[i] = new JavaValue( java.net.URL );
test_array[i] = new TestValue( "java.net.URL" );
i++;
java_array[i] = new JavaValue( java.text.DateFormat );
test_array[i] = new TestValue( "java.text.DateFormat" );
i++;
java_array[i] = new JavaValue( java.text.DateFormat );
test_array[i] = new TestValue( "java.text.DateFormat" );
i++;
java_array[i] = new JavaValue( java.util.Vector );
test_array[i] = new TestValue( "java.util.Vector" );
i++;
java_array[i] = new JavaValue( java.util.Vector );
test_array[i] = new TestValue( "java.util.Vector" );
i++;
/*
works for rhino only
java_array[i] = new JavaValue( Packages.com.netscape.javascript.Context );
test_array[i] = new TestValue( "Packages.com.netscape.javascript.Context" );
i++;
works for rhino only
java_array[i] = new JavaValue( Packages.com.netscape.javascript.Context );
test_array[i] = new TestValue( "Packages.com.netscape.javascript.Context" );
i++;
*/
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
test();
test();
function CompareValues( javaval, testval ) {
// Check type, which should be E_TYPE
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
/*
// Check JavaScript class, which should be E_JSCLASS
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +").getJSClass()",
testval.jsclass,
javaval.jsclass );
// Check JavaScript class, which should be E_JSCLASS
new TestCase( SECTION,
"(" + testval.description +").getJSClass()",
testval.jsclass,
javaval.jsclass );
*/
// Check the class's name, which should be the description, minus the "Package." part.
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +") +''",
testval.classname,
javaval.classname );
new TestCase( SECTION,
"(" + testval.description +") +''",
testval.classname,
javaval.classname );
}
function JavaValue( value ) {
// this suceeds in LC1, but fails in LC2
@ -143,24 +143,11 @@ function TestValue( description, value ) {
this.jsclass = E_JSCLASS;
this.classname = "[JavaClass " +
( ( description.substring(0,9) == "Packages." )
? description.substring(9,description.length)
: description
) + "]"
( ( description.substring(0,9) == "Packages." )
? description.substring(9,description.length)
: description
) + "]"
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
return this;
}

0
js/tests/lc2/Classes/shell.js Executable file
Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,105 +35,104 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
Template for LiveConnect Tests
Template for LiveConnect Tests
File Name: number-006.js
Description:
File Name: number-006.js
Description:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
byte
short
int
long
float
double
char
java.lang.Double
byte
short
int
long
float
double
char
java.lang.Double
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
test for creating java.lang.Short objects.
test for creating java.lang.Short objects.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// typeof all resulting objects is "object";
var E_TYPE = "object";
// typeof all resulting objects is "object";
var E_TYPE = "object";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
var a = new Array();
var i = 0;
var a = new Array();
var i = 0;
a[i++] = new TestObject( "new java.lang.Character(\"0.0\")",
new java.lang.Character("a"), "a".charCodeAt(0) );
a[i++] = new TestObject( "new java.lang.Character(\"0.0\")",
new java.lang.Character("a"), "a".charCodeAt(0) );
a[i++] = new TestObject( "new java.lang.Character(\"0.\")",
new java.lang.Character("0"), "0".charCodeAt(0) );
a[i++] = new TestObject( "new java.lang.Character(\"0.\")",
new java.lang.Character("0"), "0".charCodeAt(0) );
a[i++] = new TestObject( "new java.lang.Character( 5 )",
new java.lang.Character(5), 5 );
a[i++] = new TestObject( "new java.lang.Character( 5 )",
new java.lang.Character(5), 5 );
a[i++] = new TestObject( "new java.lang.Character( 5.5 )",
new java.lang.Character(5.5), 5 );
a[i++] = new TestObject( "new java.lang.Character( 5.5 )",
new java.lang.Character(5.5), 5 );
a[i++] = new TestObject( "new java.lang.Character( Number(5) )",
new java.lang.Character(Number(5)), 5 );
a[i++] = new TestObject( "new java.lang.Character( Number(5) )",
new java.lang.Character(Number(5)), 5 );
a[i++] = new TestObject( "new java.lang.Character( Number(5.5) )",
new java.lang.Character(Number(5.5)), 5 );
a[i++] = new TestObject( "new java.lang.Character( Number(5.5) )",
new java.lang.Character(Number(5.5)), 5 );
for ( var i = 0; i < a.length; i++ ) {
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 typeof
new TestCase(
SECTION,
"typeof (" + a[i].description +")",
a[i].type,
typeof a[i].javavalue );
/*
// check the js class
testcases[testcases.length] = new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
// check the js class
new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
*/
// check the number value of the object
testcases[testcases.length] = new TestCase(
SECTION,
"Number(" + a[i].description +")",
a[i].jsvalue,
Number( a[i].javavalue.charValue() ) );
}
// check the number value of the object
new TestCase(
SECTION,
"Number(" + a[i].description +")",
a[i].jsvalue,
Number( a[i].javavalue.charValue() ) );
}
test();
test();
function TestObject( description, javavalue, jsvalue ) {
// LC2 does not support the proto property of liveconnect object
@ -145,16 +145,3 @@ function TestObject( description, javavalue, jsvalue ) {
this.type = E_TYPE;
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,106 +35,105 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
Template for LiveConnect Tests
Template for LiveConnect Tests
File Name: number-002.js
Description:
File Name: number-002.js
Description:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
byte
short
int
long
float
double
char
java.lang.Double
byte
short
int
long
float
double
char
java.lang.Double
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
test for creating java.lang.Double objects.
test for creating java.lang.Double objects.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "double-001";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var SECTION = "double-001";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// typeof all resulting objects is "object";
var E_TYPE = "object";
// typeof all resulting objects is "object";
var E_TYPE = "object";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
var a = new Array();
var i = 0;
var a = new Array();
var i = 0;
a[i++] = new TestObject( "new java.lang.Double(\"0.0\")",
new java.lang.Double("0.0"), 0 );
a[i++] = new TestObject( "new java.lang.Double(\"0.0\")",
new java.lang.Double("0.0"), 0 );
a[i++] = new TestObject( "new java.lang.Double(\"0.0\")",
new java.lang.Double("0"), 0 );
a[i++] = new TestObject( "new java.lang.Double(\"0.0\")",
new java.lang.Double("0"), 0 );
a[i++] = new TestObject( "new java.lang.Double( 5 )",
new java.lang.Double(5), 5 );
a[i++] = new TestObject( "new java.lang.Double( 5 )",
new java.lang.Double(5), 5 );
a[i++] = new TestObject( "new java.lang.Double( 5.5 )",
new java.lang.Double(5.5), 5.5 );
a[i++] = new TestObject( "new java.lang.Double( 5.5 )",
new java.lang.Double(5.5), 5.5 );
a[i++] = new TestObject( "new java.lang.Double( Number(5) )",
new java.lang.Double(Number(5)), 5 );
a[i++] = new TestObject( "new java.lang.Double( Number(5) )",
new java.lang.Double(Number(5)), 5 );
a[i++] = new TestObject( "new java.lang.Double( Number(5.5) )",
new java.lang.Double(Number(5.5)), 5.5 );
a[i++] = new TestObject( "new java.lang.Double( Number(5.5) )",
new java.lang.Double(Number(5.5)), 5.5 );
for ( var i = 0; i < a.length; i++ ) {
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 typeof
new TestCase(
SECTION,
"typeof (" + a[i].description +")",
a[i].type,
typeof a[i].javavalue );
/*
// check the js class
testcases[testcases.length] = new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
// check the js class
new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
*/
// check the number value of the object
testcases[testcases.length] = new TestCase(
SECTION,
"Number(" + a[i].description +")",
a[i].jsvalue,
Number( a[i].javavalue ) );
}
// check the number value of the object
new TestCase(
SECTION,
"Number(" + a[i].description +")",
a[i].jsvalue,
Number( a[i].javavalue ) );
}
test();
test();
function TestObject( description, javavalue, jsvalue ) {
this.description = description;
@ -145,16 +145,3 @@ function TestObject( description, javavalue, jsvalue ) {
// this.jsclass = this.javavalue.getJSClass();
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,103 +35,102 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
Template for LiveConnect Tests
Template for LiveConnect Tests
File Name: number-001.js
Description:
File Name: number-001.js
Description:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
byte
short
int
long
float
double
char
java.lang.Double
byte
short
int
long
float
double
char
java.lang.Double
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
Test for passing JavasScript numbers to static java.lang.Integer methods.
Test for passing JavasScript numbers to static java.lang.Integer methods.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "double-001";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var SECTION = "double-001";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// typeof all resulting objects is "object";
var E_TYPE = "object";
// typeof all resulting objects is "object";
var E_TYPE = "object";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
var a = new Array();
var i = 0;
var a = new Array();
var i = 0;
a[i++] = new TestObject( "java.lang.Double.toString(0)",
java.lang.Double.toString(0), "0.0" );
a[i++] = new TestObject( "java.lang.Double.toString(0)",
java.lang.Double.toString(0), "0.0" );
a[i++] = new TestObject( "java.lang.Double.toString(NaN)",
java.lang.Double.toString(NaN), "NaN" );
a[i++] = new TestObject( "java.lang.Double.toString(NaN)",
java.lang.Double.toString(NaN), "NaN" );
a[i++] = new TestObject( "java.lang.Double.toString(5)",
java.lang.Double.toString(5), "5.0" );
a[i++] = new TestObject( "java.lang.Double.toString(5)",
java.lang.Double.toString(5), "5.0" );
a[i++] = new TestObject( "java.lang.Double.toString(9.9)",
java.lang.Double.toString(9.9), "9.9" );
a[i++] = new TestObject( "java.lang.Double.toString(9.9)",
java.lang.Double.toString(9.9), "9.9" );
a[i++] = new TestObject( "java.lang.Double.toString(-9.9)",
java.lang.Double.toString(-9.9), "-9.9" );
a[i++] = new TestObject( "java.lang.Double.toString(-9.9)",
java.lang.Double.toString(-9.9), "-9.9" );
for ( var i = 0; i < a.length; i++ ) {
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 typeof
new TestCase(
SECTION,
"typeof (" + a[i].description +")",
a[i].type,
typeof a[i].javavalue );
/*
// check the js class
testcases[testcases.length] = new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
// check the js class
new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
*/
// check the number value of the object
testcases[testcases.length] = new TestCase(
SECTION,
"String(" + a[i].description +")",
a[i].jsvalue,
String( a[i].javavalue ) );
}
// check the number value of the object
new TestCase(
SECTION,
"String(" + a[i].description +")",
a[i].jsvalue,
String( a[i].javavalue ) );
}
test();
test();
function TestObject( description, javavalue, jsvalue ) {
this.description = description;
@ -142,16 +142,3 @@ function TestObject( description, javavalue, jsvalue ) {
// this.jsclass = this.javavalue.getJSClass();
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,108 +35,107 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
Template for LiveConnect Tests
Template for LiveConnect Tests
File Name: number-002.js
Description:
File Name: number-002.js
Description:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
byte
short
int
long
float
double
char
java.lang.Double
byte
short
int
long
float
double
char
java.lang.Double
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
test for creating java.lang.Float objects.
test for creating java.lang.Float objects.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// typeof all resulting objects is "object";
var E_TYPE = "object";
// typeof all resulting objects is "object";
var E_TYPE = "object";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
var a = new Array();
var i = 0;
var a = new Array();
var i = 0;
a[i++] = new TestObject( "new java.lang.Float(\"0.0\")",
new java.lang.Float("0.0"), 0 );
a[i++] = new TestObject( "new java.lang.Float(\"0.0\")",
new java.lang.Float("0.0"), 0 );
a[i++] = new TestObject( "new java.lang.Float(\"0.\")",
new java.lang.Float("0"), 0 );
a[i++] = new TestObject( "new java.lang.Float(\"0.\")",
new java.lang.Float("0"), 0 );
a[i++] = new TestObject( "new java.lang.Float( 5 )",
new java.lang.Float(5), 5 );
a[i++] = new TestObject( "new java.lang.Float( 5 )",
new java.lang.Float(5), 5 );
a[i++] = new TestObject( "new java.lang.Float( 5.5 )",
new java.lang.Float(5.5), 5.5 );
a[i++] = new TestObject( "new java.lang.Float( 5.5 )",
new java.lang.Float(5.5), 5.5 );
a[i++] = new TestObject( "new java.lang.Float( Number(5) )",
new java.lang.Float(Number(5)), 5 );
a[i++] = new TestObject( "new java.lang.Float( Number(5) )",
new java.lang.Float(Number(5)), 5 );
a[i++] = new TestObject( "new java.lang.Float( Number(5.5) )",
new java.lang.Float(Number(5.5)), 5.5 );
a[i++] = new TestObject( "new java.lang.Float( Number(5.5) )",
new java.lang.Float(Number(5.5)), 5.5 );
for ( var i = 0; i < a.length; i++ ) {
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 typeof
new TestCase(
SECTION,
"typeof (" + a[i].description +")",
a[i].type,
typeof a[i].javavalue );
/*
// check the js class
testcases[testcases.length] = new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
// check the js class
new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
*/
// check the number value of the object
testcases[testcases.length] = new TestCase(
SECTION,
"Number(" + a[i].description +")",
a[i].jsvalue,
Number( a[i].javavalue ) );
}
// check the number value of the object
new TestCase(
SECTION,
"Number(" + a[i].description +")",
a[i].jsvalue,
Number( a[i].javavalue ) );
}
test();
test();
function TestObject( description, javavalue, jsvalue ) {
this.description = description;
@ -147,16 +147,3 @@ function TestObject( description, javavalue, jsvalue ) {
// this.jsclass = this.javavalue.getJSClass();
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,103 +35,102 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
Template for LiveConnect Tests
Template for LiveConnect Tests
File Name: number-001.js
Description:
File Name: number-001.js
Description:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
byte
short
int
long
float
double
char
java.lang.Double
byte
short
int
long
float
double
char
java.lang.Double
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
Test for passing JavasScript numbers to static java.lang.Integer methods.
Test for passing JavasScript numbers to static java.lang.Integer methods.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// typeof all resulting objects is "object";
var E_TYPE = "object";
// typeof all resulting objects is "object";
var E_TYPE = "object";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
var a = new Array();
var i = 0;
var a = new Array();
var i = 0;
a[i++] = new TestObject( "java.lang.Float.toString(0)",
java.lang.Float.toString(0), "0.0" );
a[i++] = new TestObject( "java.lang.Float.toString(0)",
java.lang.Float.toString(0), "0.0" );
a[i++] = new TestObject( "java.lang.Float.toString(NaN)",
java.lang.Float.toString(NaN), "NaN" );
a[i++] = new TestObject( "java.lang.Float.toString(NaN)",
java.lang.Float.toString(NaN), "NaN" );
a[i++] = new TestObject( "java.lang.Float.toString(5)",
java.lang.Float.toString(5), "5.0" );
a[i++] = new TestObject( "java.lang.Float.toString(5)",
java.lang.Float.toString(5), "5.0" );
a[i++] = new TestObject( "java.lang.Float.toString(9.9)",
java.lang.Float.toString(9.9), "9.9" );
a[i++] = new TestObject( "java.lang.Float.toString(9.9)",
java.lang.Float.toString(9.9), "9.9" );
a[i++] = new TestObject( "java.lang.Float.toString(-9.9)",
java.lang.Float.toString(-9.9), "-9.9" );
a[i++] = new TestObject( "java.lang.Float.toString(-9.9)",
java.lang.Float.toString(-9.9), "-9.9" );
for ( var i = 0; i < a.length; i++ ) {
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 typeof
new TestCase(
SECTION,
"typeof (" + a[i].description +")",
a[i].type,
typeof a[i].javavalue );
/*
// check the js class
testcases[testcases.length] = new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
// check the js class
new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
*/
// check the number value of the object
testcases[testcases.length] = new TestCase(
SECTION,
"String(" + a[i].description +")",
a[i].jsvalue,
String( a[i].javavalue ) );
}
// check the number value of the object
new TestCase(
SECTION,
"String(" + a[i].description +")",
a[i].jsvalue,
String( a[i].javavalue ) );
}
test();
test();
function TestObject( description, javavalue, jsvalue ) {
this.description = description;
@ -142,16 +142,3 @@ function TestObject( description, javavalue, jsvalue ) {
// this.jsclass = this.javavalue.getJSClass();
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,108 +35,107 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
Template for LiveConnect Tests
Template for LiveConnect Tests
File Name: number-001.js
Description:
File Name: number-001.js
Description:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
byte
short
int
long
float
double
char
java.lang.Double
byte
short
int
long
float
double
char
java.lang.Double
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
test for creating java.lang.Integer objects.
test for creating java.lang.Integer objects.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var BUGNUMBER="196276";
var BUGNUMBER="196276";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// typeof all resulting objects is "object";
var E_TYPE = "object";
// typeof all resulting objects is "object";
var E_TYPE = "object";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
var a = new Array();
var i = 0;
var a = new Array();
var i = 0;
a[i++] = new TestObject( "new java.lang.Integer(\"0.\")",
new java.lang.Integer("0"), 0 );
a[i++] = new TestObject( "new java.lang.Integer(\"0.\")",
new java.lang.Integer("0"), 0 );
a[i++] = new TestObject( "new java.lang.Integer( 5 )",
new java.lang.Integer(5), 5 );
a[i++] = new TestObject( "new java.lang.Integer( 5 )",
new java.lang.Integer(5), 5 );
a[i++] = new TestObject( "new java.lang.Integer( 5.5 )",
new java.lang.Integer(5.5), 5 );
a[i++] = new TestObject( "new java.lang.Integer( 5.5 )",
new java.lang.Integer(5.5), 5 );
a[i++] = new TestObject( "new java.lang.Integer( Number(5) )",
new java.lang.Integer(Number(5)), 5 );
a[i++] = new TestObject( "new java.lang.Integer( Number(5) )",
new java.lang.Integer(Number(5)), 5 );
a[i++] = new TestObject( "new java.lang.Integer( Number(5.5) )",
new java.lang.Integer(Number(5.5)), 5 );
a[i++] = new TestObject( "new java.lang.Integer( Number(5.5) )",
new java.lang.Integer(Number(5.5)), 5 );
for ( var i = 0; i < a.length; i++ ) {
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 typeof
new TestCase(
SECTION,
"typeof (" + a[i].description +")",
a[i].type,
typeof a[i].javavalue );
/*
// check the js class
testcases[testcases.length] = new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
// check the js class
new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
*/
// check the number value of the object
testcases[testcases.length] = new TestCase(
SECTION,
"Number(" + a[i].description +")",
a[i].jsvalue,
Number( a[i].javavalue ) );
}
// check the number value of the object
new TestCase(
SECTION,
"Number(" + a[i].description +")",
a[i].jsvalue,
Number( a[i].javavalue ) );
}
test();
test();
function TestObject( description, javavalue, jsvalue ) {
this.description = description;
@ -147,16 +147,3 @@ function TestObject( description, javavalue, jsvalue ) {
// this.jsclass = this.javavalue.getJSClass();
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,103 +35,102 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
Template for LiveConnect Tests
Template for LiveConnect Tests
File Name: number-001.js
Description:
File Name: number-001.js
Description:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
byte
short
int
long
float
double
char
java.lang.Double
byte
short
int
long
float
double
char
java.lang.Double
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
Test for passing JavasScript numbers to static java.lang.Integer methods.
Test for passing JavasScript numbers to static java.lang.Integer methods.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// typeof all resulting objects is "object";
var E_TYPE = "object";
// typeof all resulting objects is "object";
var E_TYPE = "object";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
var a = new Array();
var i = 0;
var a = new Array();
var i = 0;
a[i++] = new TestObject( "java.lang.Integer.toString(0)",
java.lang.Integer.toString(0), "0" );
a[i++] = new TestObject( "java.lang.Integer.toString(0)",
java.lang.Integer.toString(0), "0" );
// a[i++] = new TestObject( "java.lang.Integer.toString(NaN)",
// java.lang.Integer.toString(NaN), "NaN" );
a[i++] = new TestObject( "java.lang.Integer.toString(5)",
java.lang.Integer.toString(5), "5" );
a[i++] = new TestObject( "java.lang.Integer.toString(5)",
java.lang.Integer.toString(5), "5" );
a[i++] = new TestObject( "java.lang.Integer.toString(9.9)",
java.lang.Integer.toString(9.9), "9" );
a[i++] = new TestObject( "java.lang.Integer.toString(9.9)",
java.lang.Integer.toString(9.9), "9" );
a[i++] = new TestObject( "java.lang.Integer.toString(-9.9)",
java.lang.Integer.toString(-9.9), "-9" );
a[i++] = new TestObject( "java.lang.Integer.toString(-9.9)",
java.lang.Integer.toString(-9.9), "-9" );
for ( var i = 0; i < a.length; i++ ) {
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 typeof
new TestCase(
SECTION,
"typeof (" + a[i].description +")",
a[i].type,
typeof a[i].javavalue );
/*
// check the js class
testcases[testcases.length] = new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
// check the js class
new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
*/
// check the number value of the object
testcases[testcases.length] = new TestCase(
SECTION,
"String(" + a[i].description +")",
a[i].jsvalue,
String( a[i].javavalue ) );
}
// check the number value of the object
new TestCase(
SECTION,
"String(" + a[i].description +")",
a[i].jsvalue,
String( a[i].javavalue ) );
}
test();
test();
function TestObject( description, javavalue, jsvalue ) {
this.description = description;
@ -141,16 +141,3 @@ function TestObject( description, javavalue, jsvalue ) {
// this.jsclass = this.javavalue.getJSClass();
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,105 +35,104 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
Template for LiveConnect Tests
Template for LiveConnect Tests
File Name: number-004.js
Description:
File Name: number-004.js
Description:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
byte
short
int
long
float
double
char
java.lang.Double
byte
short
int
long
float
double
char
java.lang.Double
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
test for creating java.lang.Long objects.
test for creating java.lang.Long objects.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// typeof all resulting objects is "object";
var E_TYPE = "object";
// typeof all resulting objects is "object";
var E_TYPE = "object";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
var a = new Array();
var i = 0;
var a = new Array();
var i = 0;
/*
a[i++] = new TestObject( "new java.lang.Long(\"0.0\")",
new java.lang.Long("0.0"), 0 );
a[i++] = new TestObject( "new java.lang.Long(\"0.0\")",
new java.lang.Long("0.0"), 0 );
*/
a[i++] = new TestObject( "new java.lang.Long(\"0.\")",
new java.lang.Long("0"), 0 );
a[i++] = new TestObject( "new java.lang.Long(\"0.\")",
new java.lang.Long("0"), 0 );
a[i++] = new TestObject( "new java.lang.Long( 5 )",
new java.lang.Long(5), 5 );
a[i++] = new TestObject( "new java.lang.Long( 5 )",
new java.lang.Long(5), 5 );
a[i++] = new TestObject( "new java.lang.Long( 5.5 )",
new java.lang.Long(5.5), 5 );
a[i++] = new TestObject( "new java.lang.Long( 5.5 )",
new java.lang.Long(5.5), 5 );
a[i++] = new TestObject( "new java.lang.Long( Number(5) )",
new java.lang.Long(Number(5)), 5 );
a[i++] = new TestObject( "new java.lang.Long( Number(5) )",
new java.lang.Long(Number(5)), 5 );
a[i++] = new TestObject( "new java.lang.Long( Number(5.5) )",
new java.lang.Long(Number(5.5)), 5 );
a[i++] = new TestObject( "new java.lang.Long( Number(5.5) )",
new java.lang.Long(Number(5.5)), 5 );
for ( var i = 0; i < a.length; i++ ) {
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 typeof
new TestCase(
SECTION,
"typeof (" + a[i].description +")",
a[i].type,
typeof a[i].javavalue );
/*
// check the js class
testcases[testcases.length] = new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
// check the js class
new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
*/
// check the number value of the object
testcases[testcases.length] = new TestCase(
SECTION,
"Number(" + a[i].description +")",
a[i].jsvalue,
Number( a[i].javavalue ) );
}
// check the number value of the object
new TestCase(
SECTION,
"Number(" + a[i].description +")",
a[i].jsvalue,
Number( a[i].javavalue ) );
}
test();
test();
function TestObject( description, javavalue, jsvalue ) {
this.description = description;
@ -144,16 +144,3 @@ function TestObject( description, javavalue, jsvalue ) {
// this.jsclass = this.javavalue.getJSClass();
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -35,102 +35,100 @@
*
* ***** END LICENSE BLOCK ***** */
/**
Template for LiveConnect Tests
Template for LiveConnect Tests
File Name: number-001.js
Description:
File Name: number-001.js
Description:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
byte
short
int
long
float
double
char
java.lang.Double
byte
short
int
long
float
double
char
java.lang.Double
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
Test for passing JavasScript numbers to static java.lang.Integer methods.
Test for passing JavasScript numbers to static java.lang.Integer methods.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// typeof all resulting objects is "object";
var E_TYPE = "object";
// typeof all resulting objects is "object";
var E_TYPE = "object";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
var a = new Array();
var i = 0;
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(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(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" );
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++ ) {
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 typeof
new TestCase(
SECTION,
"typeof (" + a[i].description +")",
a[i].type,
typeof a[i].javavalue );
/*
// check the js class
testcases[testcases.length] = new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
// check the js class
new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
*/
// check the number value of the object
testcases[testcases.length] = new TestCase(
SECTION,
"String(" + a[i].description +")",
a[i].jsvalue,
String( a[i].javavalue ) );
}
// check the number value of the object
new TestCase(
SECTION,
"String(" + a[i].description +")",
a[i].jsvalue,
String( a[i].javavalue ) );
}
test();
test();
function TestObject( description, javavalue, jsvalue ) {
this.description = description;
@ -142,16 +140,3 @@ function TestObject( description, javavalue, jsvalue ) {
// this.jsclass = this.javavalue.getJSClass();
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,64 +35,63 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
Template for LiveConnect Tests
Template for LiveConnect Tests
File Name: number-001.js
Description:
File Name: number-001.js
Description:
This test fails in lc3, but will succeed if the underlying version
of liveconnect only supports LC2.
This test fails in lc3, but will succeed if the underlying version
of liveconnect only supports LC2.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// typeof all resulting objects is "object";
var E_TYPE = "object";
// typeof all resulting objects is "object";
var E_TYPE = "object";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
var a = new Array();
var i = 0;
var a = new Array();
var i = 0;
a[i++] = new TestObject( "java.lang.Long.toString(NaN)",
java.lang.Long.toString(NaN), "0" );
a[i++] = new TestObject( "java.lang.Long.toString(NaN)",
java.lang.Long.toString(NaN), "0" );
for ( var i = 0; i < a.length; i++ ) {
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 typeof
new TestCase(
SECTION,
"typeof (" + a[i].description +")",
a[i].type,
typeof a[i].javavalue );
/*
// check the js class
testcases[testcases.length] = new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
// check the js class
new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
*/
// check the number value of the object
testcases[testcases.length] = new TestCase(
SECTION,
"String(" + a[i].description +")",
a[i].jsvalue,
String( a[i].javavalue ) );
}
// check the number value of the object
new TestCase(
SECTION,
"String(" + a[i].description +")",
a[i].jsvalue,
String( a[i].javavalue ) );
}
test();
test();
function TestObject( description, javavalue, jsvalue ) {
this.description = description;
@ -103,16 +103,3 @@ function TestObject( description, javavalue, jsvalue ) {
// this.jsclass = this.javavalue.getJSClass();
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

0
js/tests/lc2/JSToJava/shell.js Executable file
Просмотреть файл

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,103 +35,102 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
Template for LiveConnect Tests
Template for LiveConnect Tests
File Name: number-004.js
Description:
File Name: number-004.js
Description:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
byte
short
int
long
float
double
char
java.lang.Double
byte
short
int
long
float
double
char
java.lang.Double
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
test for creating java.lang.Short objects.
test for creating java.lang.Short objects.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// typeof all resulting objects is "object";
var E_TYPE = "object";
// typeof all resulting objects is "object";
var E_TYPE = "object";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
var a = new Array();
var i = 0;
var a = new Array();
var i = 0;
a[i++] = new TestObject( "new java.lang.Short(\"0\")",
new java.lang.Short("0"), 0 );
a[i++] = new TestObject( "new java.lang.Short(\"0\")",
new java.lang.Short("0"), 0 );
a[i++] = new TestObject( "new java.lang.Short( 5 )",
new java.lang.Short(5), 5 );
a[i++] = new TestObject( "new java.lang.Short( 5 )",
new java.lang.Short(5), 5 );
a[i++] = new TestObject( "new java.lang.Short( 5.5 )",
new java.lang.Short(5.5), 5 );
a[i++] = new TestObject( "new java.lang.Short( 5.5 )",
new java.lang.Short(5.5), 5 );
a[i++] = new TestObject( "new java.lang.Short( Number(5) )",
new java.lang.Short(Number(5)), 5 );
a[i++] = new TestObject( "new java.lang.Short( Number(5) )",
new java.lang.Short(Number(5)), 5 );
a[i++] = new TestObject( "new java.lang.Short( Number(5.5) )",
new java.lang.Short(Number(5.5)), 5 );
a[i++] = new TestObject( "new java.lang.Short( Number(5.5) )",
new java.lang.Short(Number(5.5)), 5 );
for ( var i = 0; i < a.length; i++ ) {
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 typeof
new TestCase(
SECTION,
"typeof (" + a[i].description +")",
a[i].type,
typeof a[i].javavalue );
/*
// check the js class
testcases[testcases.length] = new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
// check the js class
new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
*/
// check the number value of the object
testcases[testcases.length] = new TestCase(
SECTION,
"Number(" + a[i].description +")",
a[i].jsvalue,
Number( a[i].javavalue ) );
}
// check the number value of the object
new TestCase(
SECTION,
"Number(" + a[i].description +")",
a[i].jsvalue,
Number( a[i].javavalue ) );
}
test();
test();
function TestObject( description, javavalue, jsvalue ) {
this.description = description;
@ -142,16 +142,3 @@ function TestObject( description, javavalue, jsvalue ) {
// this.jsclass = this.javavalue.getJSClass();
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,103 +35,102 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
Template for LiveConnect Tests
Template for LiveConnect Tests
File Name: number-001.js
Description:
File Name: number-001.js
Description:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
byte
short
int
long
float
double
char
java.lang.Double
byte
short
int
long
float
double
char
java.lang.Double
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
Test for passing JavasScript numbers to static java.lang.Integer methods.
Test for passing JavasScript numbers to static java.lang.Integer methods.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// typeof all resulting objects is "object";
var E_TYPE = "object";
// typeof all resulting objects is "object";
var E_TYPE = "object";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
var a = new Array();
var i = 0;
var a = new Array();
var i = 0;
a[i++] = new TestObject( "java.lang.Short.toString(0)",
java.lang.Short.toString(0), "0" );
a[i++] = new TestObject( "java.lang.Short.toString(0)",
java.lang.Short.toString(0), "0" );
// a[i++] = new TestObject( "java.lang.Short.toString(NaN)",
// java.lang.Short.toString(NaN), "0" );
a[i++] = new TestObject( "java.lang.Short.toString(5)",
java.lang.Short.toString(5), "5" );
a[i++] = new TestObject( "java.lang.Short.toString(5)",
java.lang.Short.toString(5), "5" );
a[i++] = new TestObject( "java.lang.Short.toString(9.9)",
java.lang.Short.toString(9.9), "9" );
a[i++] = new TestObject( "java.lang.Short.toString(9.9)",
java.lang.Short.toString(9.9), "9" );
a[i++] = new TestObject( "java.lang.Short.toString(-9.9)",
java.lang.Short.toString(-9.9), "-9" );
a[i++] = new TestObject( "java.lang.Short.toString(-9.9)",
java.lang.Short.toString(-9.9), "-9" );
for ( var i = 0; i < a.length; i++ ) {
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 typeof
new TestCase(
SECTION,
"typeof (" + a[i].description +")",
a[i].type,
typeof a[i].javavalue );
/*
// check the js class
testcases[testcases.length] = new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
// check the js class
new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
*/
// check the number value of the object
testcases[testcases.length] = new TestCase(
SECTION,
"String(" + a[i].description +")",
a[i].jsvalue,
String( a[i].javavalue ) );
}
// check the number value of the object
new TestCase(
SECTION,
"String(" + a[i].description +")",
a[i].jsvalue,
String( a[i].javavalue ) );
}
test();
test();
function TestObject( description, javavalue, jsvalue ) {
this.description = description;
@ -141,16 +141,3 @@ function TestObject( description, javavalue, jsvalue ) {
// this.jsclass = this.javavalue.getJSClass();
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,91 +35,90 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
Template for LiveConnect Tests
Template for LiveConnect Tests
File Name: number-001.js
Description:
File Name: number-001.js
Description:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
When setting the value of a Java field with a JavaScript number or
when passing a JavaScript number to a Java method as an argument,
LiveConnect should be able to convert the number to any one of the
following types:
byte
short
int
long
float
double
char
java.lang.Double
byte
short
int
long
float
double
char
java.lang.Double
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
Note that the value of the Java field may not be as precise as the
JavaScript value's number, if for example, you pass a large number to
a short or byte, or a float to integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
JavaScript numbers cannot be converted to instances of java.lang.Float
or java.lang.Integer.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
This test does not cover the cases in which a Java method returns one
of the above primitive Java types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
Currently split up into numerous tests, since rhino live connect fails
to translate numbers into the correct types.
Test for passing JavasScript numbers to static java.lang.Integer methods.
Test for passing JavasScript numbers to static java.lang.Integer methods.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// typeof all resulting objects is "object";
var E_TYPE = "object";
// typeof all resulting objects is "object";
var E_TYPE = "object";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
// JS class of all resulting objects is "JavaObject";
var E_JSCLASS = "[object JavaObject]";
var a = new Array();
var i = 0;
var a = new Array();
var i = 0;
a[i++] = new TestObject( "java.lang.Short.toString(NaN)",
java.lang.Short.toString(NaN), "0" );
a[i++] = new TestObject( "java.lang.Short.toString(NaN)",
java.lang.Short.toString(NaN), "0" );
for ( var i = 0; i < a.length; i++ ) {
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 typeof
new TestCase(
SECTION,
"typeof (" + a[i].description +")",
a[i].type,
typeof a[i].javavalue );
/*
// check the js class
testcases[testcases.length] = new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
// check the js class
new TestCase(
SECTION,
"("+ a[i].description +").getJSClass()",
E_JSCLASS,
a[i].jsclass );
*/
// check the number value of the object
testcases[testcases.length] = new TestCase(
SECTION,
"String(" + a[i].description +")",
a[i].jsvalue,
String( a[i].javavalue ) );
}
// check the number value of the object
new TestCase(
SECTION,
"String(" + a[i].description +")",
a[i].jsvalue,
String( a[i].javavalue ) );
}
test();
test();
function TestObject( description, javavalue, jsvalue ) {
this.description = description;
@ -129,16 +129,3 @@ function TestObject( description, javavalue, jsvalue ) {
// this.jsclass = this.javavalue.getJSClass();
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,59 +35,45 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: String-001.js
Description:
File Name: String-001.js
Description:
When accessing a Java field whose value is a java.lang.String,
JavaScript should read the value as the JavaScript JavaObject,
an object whose class is JavaObject.
When accessing a Java field whose value is a java.lang.String,
JavaScript should read the value as the JavaScript JavaObject,
an object whose class is JavaObject.
To test this:
To test this:
1. Call a java method that returns a java.lang.String
2. Check the value of the returned object, which should be the value
of the string
3. Check the type of the returned object, which should be "object"
4. Check the class of the object, using Object.prototype.toString,
which should be "[object JavaObject]"
5. Check the class of the JavaObject, using getClass, and compare
it to java.lang.Class.forName("java.lang.String");
1. Call a java method that returns a java.lang.String
2. Check the value of the returned object, which should be the value
of the string
3. Check the type of the returned object, which should be "object"
4. Check the class of the object, using Object.prototype.toString,
which should be "[object JavaObject]"
5. Check the class of the JavaObject, using getClass, and compare
it to java.lang.Class.forName("java.lang.String");
NOT DONE. need a test class with a string field.
NOT DONE. need a test class with a string field.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Number Primitive to JavaScript Object";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Number Primitive to JavaScript Object";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// display test information
test();
test();
function CheckType( et, at ) {
}
function CheckValue( ev, av ) {
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,77 +35,76 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: boolean-001.js
Description:
File Name: boolean-001.js
Description:
If a Java method returns a Java boolean primitive, JavaScript should
read the value as a JavaScript boolean primitive.
If a Java method returns a Java boolean primitive, JavaScript should
read the value as a JavaScript boolean primitive.
To test this:
To test this:
1. Call a java method that returns a Java boolean primitive.
2. Check the type of the returned type, which should be "boolean"
3. Check the value of the returned type, which should be true or false.
1. Call a java method that returns a Java boolean primitive.
2. Check the type of the returned type, which should be "boolean"
3. Check the value of the returned type, which should be true or false.
It is an error if the returned value is read as a JavaScript Boolean
object.
It is an error if the returned value is read as a JavaScript Boolean
object.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Boolean Primitive to JavaScript Object";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Boolean Primitive to JavaScript Object";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// In all test cases, the expected type is "boolean"
// In all test cases, the expected type is "boolean"
var E_TYPE = "boolean";
var E_TYPE = "boolean";
// Create arrays of actual results (java_array) and expected results
// (test_array).
// Create arrays of actual results (java_array) and expected results
// (test_array).
var java_array = new Array();
var test_array = new Array();
var java_array = new Array();
var test_array = new Array();
var i = 0;
var i = 0;
// Call a java method that returns true
java_array[i] = new JavaValue( (new java.lang.Boolean(true)).booleanValue() );
test_array[i] = new TestValue( "(new java.lang.Boolean(true)).booleanValue()",
true )
// Call a java method that returns true
java_array[i] = new JavaValue( (new java.lang.Boolean(true)).booleanValue() );
test_array[i] = new TestValue( "(new java.lang.Boolean(true)).booleanValue()",
true )
i++;
// Call a java method that returns false
java_array[i] = new JavaValue( (new java.lang.Boolean(false)).booleanValue() );
test_array[i] = new TestValue( "(new java.lang.Boolean(false)).booleanValue()",
false )
// Call a java method that returns false
java_array[i] = new JavaValue( (new java.lang.Boolean(false)).booleanValue() );
test_array[i] = new TestValue( "(new java.lang.Boolean(false)).booleanValue()",
false )
i++;
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
}
test();
test();
function CompareValues( javaval, testval ) {
// Check value
testcases[testcases.length] = new TestCase( SECTION,
testval.description,
testval.value,
javaval.value );
new TestCase( SECTION,
testval.description,
testval.value,
javaval.value );
// Check type.
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
}
function JavaValue( value ) {
this.value = value;
@ -117,16 +117,3 @@ function TestValue( description, value ) {
this.type = E_TYPE;
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,88 +35,87 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: boolean-005.js
Description:
File Name: boolean-005.js
Description:
A java.lang.Boolean object field should be read as a JavaScript JavaObject.
A java.lang.Boolean object field should be read as a JavaScript JavaObject.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Boolean Object to JavaScript Object";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Boolean Object to JavaScript Object";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// In all test cases, the expected type is "object"
// In all test cases, the expected type is "object"
var E_TYPE = "object";
var E_TYPE = "object";
// The JavaScrpt [[Class]] of a JavaObject should be JavaObject"
// The JavaScrpt [[Class]] of a JavaObject should be JavaObject"
var E_JSCLASS = "[object JavaObject]";
var E_JSCLASS = "[object JavaObject]";
// The Java class of this object is java.lang.Boolean.
// The Java class of this object is java.lang.Boolean.
var E_JAVACLASS = java.lang.Class.forName( "java.lang.Boolean" );
var E_JAVACLASS = java.lang.Class.forName( "java.lang.Boolean" );
// Create arrays of actual results (java_array) and expected results
// (test_array).
// Create arrays of actual results (java_array) and expected results
// (test_array).
var java_array = new Array();
var test_array = new Array();
var java_array = new Array();
var test_array = new Array();
var i = 0;
var i = 0;
// Test for java.lang.Boolean.FALSE, which is a Boolean object.
java_array[i] = new JavaValue( java.lang.Boolean.FALSE );
test_array[i] = new TestValue( "java.lang.Boolean.FALSE",
false );
// Test for java.lang.Boolean.FALSE, which is a Boolean object.
java_array[i] = new JavaValue( java.lang.Boolean.FALSE );
test_array[i] = new TestValue( "java.lang.Boolean.FALSE",
false );
i++;
i++;
// Test for java.lang.Boolean.TRUE, which is a Boolean object.
java_array[i] = new JavaValue( java.lang.Boolean.TRUE );
test_array[i] = new TestValue( "java.lang.Boolean.TRUE",
true );
// Test for java.lang.Boolean.TRUE, which is a Boolean object.
java_array[i] = new JavaValue( java.lang.Boolean.TRUE );
test_array[i] = new TestValue( "java.lang.Boolean.TRUE",
true );
i++;
i++;
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
}
test();
test();
function CompareValues( javaval, testval ) {
// Check booleanValue()
testcases[testcases.length] = new TestCase( SECTION,
"("+testval.description+").booleanValue()",
testval.value,
javaval.value );
new TestCase( SECTION,
"("+testval.description+").booleanValue()",
testval.value,
javaval.value );
// Check typeof, which should be E_TYPE
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
/*
// Check JavaScript class, which should be E_JSCLASS
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +").getJSClass()",
testval.jsclass,
javaval.jsclass );
// Check JavaScript class, which should be E_JSCLASS
new TestCase( SECTION,
"(" + testval.description +").getJSClass()",
testval.jsclass,
javaval.jsclass );
*/
// Check Java class, which should equal() E_JAVACLASS
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +").getClass().equals( " + E_JAVACLASS +" )",
true,
javaval.javaclass.equals( testval.javaclass ) );
new TestCase( SECTION,
"(" + testval.description +").getClass().equals( " + E_JAVACLASS +" )",
true,
javaval.javaclass.equals( testval.javaclass ) );
}
function JavaValue( value ) {
// java.lang.Object.getClass() returns the Java Object's class.
@ -137,16 +137,3 @@ function TestValue( description, value ) {
this.jsclass = E_JSCLASS;
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,98 +35,97 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: boolean-004.js
Description:
File Name: boolean-004.js
Description:
A java.lang.Boolean object should be read as a JavaScript JavaObject.
To test this:
A java.lang.Boolean object should be read as a JavaScript JavaObject.
To test this:
1. The object should have a method called booleanValue(), which should
return the object's value.
2. The typeof the object should be "object"
3. The object should have a method called getClass(), which should
return the class java.lang.Boolean.
4. Add a method to the object's prototype, called getJSClass() that
is Object.prototype.toString. Calling getJSClass() should return the
object's internal [[Class]] property, which should be JavaObject.
1. The object should have a method called booleanValue(), which should
return the object's value.
2. The typeof the object should be "object"
3. The object should have a method called getClass(), which should
return the class java.lang.Boolean.
4. Add a method to the object's prototype, called getJSClass() that
is Object.prototype.toString. Calling getJSClass() should return the
object's internal [[Class]] property, which should be JavaObject.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Boolean Object to JavaScript Object";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Boolean Object to JavaScript Object";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// In all test cases, the expected type is "object"
// In all test cases, the expected type is "object"
var E_TYPE = "object";
var E_TYPE = "object";
// ToString of a JavaObject should return "[object JavaObject]"
// ToString of a JavaObject should return "[object JavaObject]"
var E_JSCLASS = "[object JavaObject]";
var E_JSCLASS = "[object JavaObject]";
// The class of this object is java.lang.Boolean.
// The class of this object is java.lang.Boolean.
var E_JAVACLASS = java.lang.Class.forName( "java.lang.Boolean" );
var E_JAVACLASS = java.lang.Class.forName( "java.lang.Boolean" );
// Create arrays of actual results (java_array) and expected results
// (test_array).
// Create arrays of actual results (java_array) and expected results
// (test_array).
var java_array = new Array();
var test_array = new Array();
var java_array = new Array();
var test_array = new Array();
var i = 0;
var i = 0;
// Instantiate a new java.lang.Boolean object whose value is Boolean.TRUE
java_array[i] = new JavaValue( new java.lang.Boolean( true ) );
test_array[i] = new TestValue( "new java.lang.Boolean( true )",
true );
// Instantiate a new java.lang.Boolean object whose value is Boolean.TRUE
java_array[i] = new JavaValue( new java.lang.Boolean( true ) );
test_array[i] = new TestValue( "new java.lang.Boolean( true )",
true );
i++;
i++;
// Instantiate a new java.lang.Boolean object whose value is Boolean.FALSE
java_array[i] = new JavaValue( new java.lang.Boolean( true ) );
test_array[i] = new TestValue( "new java.lang.Boolean( true )",
true );
// Instantiate a new java.lang.Boolean object whose value is Boolean.FALSE
java_array[i] = new JavaValue( new java.lang.Boolean( true ) );
test_array[i] = new TestValue( "new java.lang.Boolean( true )",
true );
i++;
i++;
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
}
test();
test();
function CompareValues( javaval, testval ) {
// Check value
testcases[testcases.length] = new TestCase( SECTION,
"("+testval.description+").booleanValue()",
testval.value,
javaval.value );
new TestCase( SECTION,
"("+testval.description+").booleanValue()",
testval.value,
javaval.value );
// Check type, which should be E_TYPE
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
/*
// Check JavaScript class, which should be E_JSCLASS
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +").getJSClass()",
testval.jsclass,
javaval.jsclass );
// Check JavaScript class, which should be E_JSCLASS
new TestCase( SECTION,
"(" + testval.description +").getJSClass()",
testval.jsclass,
javaval.jsclass );
*/
// Check Java class, which should equal() E_JAVACLASS
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +").getClass().equals( " + E_JAVACLASS +" )",
true,
javaval.javaclass.equals( testval.javaclass ) );
new TestCase( SECTION,
"(" + testval.description +").getClass().equals( " + E_JAVACLASS +" )",
true,
javaval.javaclass.equals( testval.javaclass ) );
}
function JavaValue( value ) {
// java.lang.Object.getClass() returns the Java Object's class.
@ -147,16 +147,3 @@ function TestValue( description, value ) {
this.jsclass = E_JSCLASS;
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,94 +35,93 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: boolean-005.js
Description:
File Name: boolean-005.js
Description:
A java.lang.Boolean object should be read as a JavaScript JavaObject.
A java.lang.Boolean object should be read as a JavaScript JavaObject.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Boolean Object to JavaScript Object";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Boolean Object to JavaScript Object";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// In all test cases, the expected type is "object"
// In all test cases, the expected type is "object"
var E_TYPE = "object";
var E_TYPE = "object";
// The JavaScrpt [[Class]] of a JavaObject should be JavaObject"
// The JavaScrpt [[Class]] of a JavaObject should be JavaObject"
var E_JSCLASS = "[object JavaObject]";
var E_JSCLASS = "[object JavaObject]";
// The Java class of this object is java.lang.Boolean.
// The Java class of this object is java.lang.Boolean.
var E_JAVACLASS = java.lang.Class.forName( "java.lang.Boolean" );
var E_JAVACLASS = java.lang.Class.forName( "java.lang.Boolean" );
// Create arrays of actual results (java_array) and expected results
// (test_array).
// Create arrays of actual results (java_array) and expected results
// (test_array).
var java_array = new Array();
var test_array = new Array();
var java_array = new Array();
var test_array = new Array();
var i = 0;
var i = 0;
// Test for java.lang.Boolean.FALSE, which is a Boolean object.
java_array[i] = new JavaValue( java.lang.Boolean.FALSE );
test_array[i] = new TestValue( "java.lang.Boolean.FALSE",
false );
// Test for java.lang.Boolean.FALSE, which is a Boolean object.
java_array[i] = new JavaValue( java.lang.Boolean.FALSE );
test_array[i] = new TestValue( "java.lang.Boolean.FALSE",
false );
i++;
i++;
// Test for java.lang.Boolean.TRUE, which is a Boolean object.
java_array[i] = new JavaValue( java.lang.Boolean.TRUE );
test_array[i] = new TestValue( "java.lang.Boolean.TRUE",
true );
// Test for java.lang.Boolean.TRUE, which is a Boolean object.
java_array[i] = new JavaValue( java.lang.Boolean.TRUE );
test_array[i] = new TestValue( "java.lang.Boolean.TRUE",
true );
i++;
i++;
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
}
test();
test();
function CompareValues( javaval, testval ) {
// Check booleanValue()
testcases[testcases.length] = new TestCase( SECTION,
"("+testval.description+").booleanValue()",
testval.value,
javaval.value );
new TestCase( SECTION,
"("+testval.description+").booleanValue()",
testval.value,
javaval.value );
// Check typeof, which should be E_TYPE
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
/*
// Check JavaScript class, which should be E_JSCLASS
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +").getJSClass()",
testval.jsclass,
javaval.jsclass );
// Check JavaScript class, which should be E_JSCLASS
new TestCase( SECTION,
"(" + testval.description +").getJSClass()",
testval.jsclass,
javaval.jsclass );
*/
// Check Java class, which should equal() E_JAVACLASS
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +").getClass().equals( " + E_JAVACLASS +" )",
true,
javaval.javaclass.equals( testval.javaclass ) );
new TestCase( SECTION,
"(" + testval.description +").getClass().equals( " + E_JAVACLASS +" )",
true,
javaval.javaclass.equals( testval.javaclass ) );
// Check string representation
testcases[testcases.length] = new TestCase( SECTION,
"("+ testval.description+") + ''",
testval.string,
javaval.string );
new TestCase( SECTION,
"("+ testval.description+") + ''",
testval.string,
javaval.string );
}
function JavaValue( value ) {
// java.lang.Object.getClass() returns the Java Object's class.
@ -134,7 +134,7 @@ function JavaValue( value ) {
// this.jsclass = value.getJSClass();
this.string = value + "";
print( this.string );
writeLineToLog( this.string );
this.value = value.booleanValue();
this.type = typeof value;
@ -149,16 +149,3 @@ function TestValue( description, value ) {
this.jsclass = E_JSCLASS;
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,73 +35,72 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: char-001.js
Description:
File Name: char-001.js
Description:
Java methods that return a char value should be read as a
JavaScript number.
Java methods that return a char value should be read as a
JavaScript number.
To test this:
To test this:
1. Call a method that returns a char.
2. Set the value of a JavaScript variable to the char value.
3. Check the value of the returned type, which should be "number"
4. Check the type of the returned type, which should be the Unicode
encoding of that character.
1. Call a method that returns a char.
2. Set the value of a JavaScript variable to the char value.
3. Check the value of the returned type, which should be "number"
4. Check the type of the returned type, which should be the Unicode
encoding of that character.
It is an error if the JavaScript variable is an object, or JavaObject
whose class is java.lang.Character.
It is an error if the JavaScript variable is an object, or JavaObject
whose class is java.lang.Character.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java char return value to JavaScript Object";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java char return value to JavaScript Object";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// In all cases, the expected type is "number"
var E_TYPE = "number";
var E_TYPE = "number";
// Create arrays of actual results (java_array) and expected results
// (test_array).
// Create arrays of actual results (java_array) and expected results
// (test_array).
var java_array = new Array();
var test_array = new Array();
var java_array = new Array();
var test_array = new Array();
var i = 0;
var i = 0;
// Get a char using String.charAt()
// Get a char using String.charAt()
java_array[i] = new JavaValue( (new java.lang.String( "JavaScript" )).charAt(0) );
test_array[i] = new TestValue( "(new java.lang.String( 'JavaScript' )).charAt(0)",
74 );
java_array[i] = new JavaValue( (new java.lang.String( "JavaScript" )).charAt(0) );
test_array[i] = new TestValue( "(new java.lang.String( 'JavaScript' )).charAt(0)",
74 );
i++;
i++;
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
}
test();
test();
function CompareValues( javaval, testval ) {
// Check value
testcases[testcases.length] = new TestCase( SECTION,
testval.description,
testval.value,
javaval.value );
new TestCase( SECTION,
testval.description,
testval.value,
javaval.value );
// Check type, which should be E_TYPE
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
}
function JavaValue( value ) {
@ -114,16 +114,3 @@ function TestValue( description, value ) {
this.type = E_TYPE;
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,85 +35,84 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: char-002.js
Description:
File Name: char-002.js
Description:
Java fields whose value is char should be read as a JavaScript number.
Java fields whose value is char should be read as a JavaScript number.
To test this:
To test this:
1. Instantiate a Java object that has fields with char values,
or reference a classes static field whose value is a char.
2. Reference the field, and set the value of a JavaScript variable
to that field's value.
3. Check the value of the returned type, which should be "number"
4. Check the type of the returned type, which should be a number
1. Instantiate a Java object that has fields with char values,
or reference a classes static field whose value is a char.
2. Reference the field, and set the value of a JavaScript variable
to that field's value.
3. Check the value of the returned type, which should be "number"
4. Check the type of the returned type, which should be a number
It is an error if the JavaScript variable is an object, or JavaObject
whose class is java.lang.Character.
It is an error if the JavaScript variable is an object, or JavaObject
whose class is java.lang.Character.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java char return value to JavaScript Object";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java char return value to JavaScript Object";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// In all cases, the expected type is "number"
var E_TYPE = "number";
var E_TYPE = "number";
// Create arrays of actual results (java_array) and expected results
// (test_array).
// Create arrays of actual results (java_array) and expected results
// (test_array).
var java_array = new Array();
var test_array = new Array();
var java_array = new Array();
var test_array = new Array();
var i = 0;
var i = 0;
// Get File.separator char
// Get File.separator char
var os = java.lang.System.getProperty( "os.name" );
var v;
var os = java.lang.System.getProperty( "os.name" );
var v;
if ( os.startsWith( "Windows" ) ) {
v = 92;
if ( os.startsWith( "Windows" ) ) {
v = 92;
} else {
if ( os.startsWith( "Mac" ) ) {
v = 58;
} else {
if ( os.startsWith( "Mac" ) ) {
v = 58;
} else {
v = 47;
}
v = 47;
}
}
java_array[i] = new JavaValue( java.io.File.separatorChar );
test_array[i] = new TestValue( "java.io.File.separatorChar", v );
java_array[i] = new JavaValue( java.io.File.separatorChar );
test_array[i] = new TestValue( "java.io.File.separatorChar", v );
i++;
i++;
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
}
test();
test();
function CompareValues( javaval, testval ) {
// Check value
testcases[testcases.length] = new TestCase( SECTION,
testval.description,
testval.value,
javaval.value );
new TestCase( SECTION,
testval.description,
testval.value,
javaval.value );
// Check type, which should be E_TYPE
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
}
function JavaValue( value ) {
@ -126,16 +126,3 @@ function TestValue( description, value ) {
this.type = E_TYPE;
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,59 +35,45 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: enum-001.js
Section: LiveConnect
Description:
File Name: enum-001.js
Section: LiveConnect
Description:
Tests enumeration of a java object.
Tests enumeration of a java object.
Regression test for bug:
Regression test for bug:
http://scopus.mcom.com/bugsplat/show_bug.cgi?id=107638
http://scopus.mcom.com/bugsplat/show_bug.cgi?id=107638
Author: christine@netscape.com
Date: 12 november 1997
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "enum-001";
var VERSION = "JS1_3";
var TITLE = "The variable statment";
var SECTION = "enum-001";
var VERSION = "JS1_3";
var TITLE = "The variable statement";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = new Array();
var v = new java.util.Vector();
v.addElement("PASSED!");
v.addElement("PASSED!");
v.addElement("PASSED!");
var v = new java.util.Vector();
v.addElement("PASSED!");
v.addElement("PASSED!");
v.addElement("PASSED!");
for (e = v.elements(), result = new Array(), i = 0 ; e.hasMoreElements();
i++ )
{
result[i] = String( e.nextElement() );
}
for ( i = 0; i < result.length; i++ ) {
testcases[testcases.length] = new TestCase( SECTION,
"test enumeration of a java object: element at " + i,
"PASSED!",
result[i] );
}
test();
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
for (e = v.elements(), result = new Array(), i = 0 ; e.hasMoreElements();
i++ )
{
result[i] = String( e.nextElement() );
}
for ( i = 0; i < result.length; i++ ) {
new TestCase( SECTION,
"test enumeration of a java object: element at " + i,
"PASSED!",
result[i] );
}
test();

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,58 +35,44 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: enum-002.js
Section: LiveConnect
Description:
File Name: enum-002.js
Section: LiveConnect
Description:
Tests enumeration of a java object. This also does some
conversions.
Tests enumeration of a java object. This also does some
conversions.
Regression test for bug:
Regression test for bug:
http://scopus.mcom.com/bugsplat/show_bug.cgi?id=107638
http://scopus.mcom.com/bugsplat/show_bug.cgi?id=107638
Author: christine@netscape.com
Date: 12 november 1997
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "enum-002";
var VERSION = "JS1_3";
var TITLE = "The variable statment";
var SECTION = "enum-002";
var VERSION = "JS1_3";
var TITLE = "The variable statement";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = new Array();
var v = new java.util.Vector();
v.addElement("TRUE");
var v = new java.util.Vector();
v.addElement("TRUE");
for (e = v.elements(), result = new Array(), i = 0 ; e.hasMoreElements();
i++ )
{
result[i] = (new java.lang.Boolean(e.nextElement())).booleanValue();
}
for ( i = 0; i < result.length; i++ ) {
testcases[testcases.length] = new TestCase( SECTION,
"test enumeration of a java object: element at " + i,
"true",
String( result[i] ) );
}
test();
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
for (e = v.elements(), result = new Array(), i = 0 ; e.hasMoreElements();
i++ )
{
result[i] = (new java.lang.Boolean(e.nextElement())).booleanValue();
}
for ( i = 0; i < result.length; i++ ) {
new TestCase( SECTION,
"test enumeration of a java object: element at " + i,
"true",
String( result[i] ) );
}
test();

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,64 +35,50 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: null-001.js
Description:
File Name: null-001.js
Description:
When accessing a Java field whose value is null, JavaScript should read
the value as the JavaScript null object.
When accessing a Java field whose value is null, JavaScript should read
the value as the JavaScript null object.
To test this:
To test this:
1. Call a java method that returns the Java null value
2. Check the value of the returned object, which should be null
3. Check the type of the returned object, which should be "object"
1. Call a java method that returns the Java null value
2. Check the value of the returned object, which should be null
3. Check the type of the returned object, which should be "object"
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java null to JavaScript Object";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java null to JavaScript Object";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// display test information
var choice = new java.awt.Choice();
var choice = new java.awt.Choice();
testcases[testcases.length] = new TestCase(
SECTION,
"var choice = new java.awt.Choice(); choice.getSelectedObjects()",
null,
choice.getSelectedObjects() );
testcases[testcases.length] = new TestCase(
SECTION,
"var choice = new java.awt.Choice(); choice.getSelectedObjects()",
null,
choice.getSelectedObjects() );
testcases[testcases.length] = new TestCase(
SECTION,
"typeof choice.getSelectedObjects()",
"object",
typeof choice.getSelectedObjects() );
testcases[testcases.length] = new TestCase(
SECTION,
"typeof choice.getSelectedObjects()",
"object",
typeof choice.getSelectedObjects() );
test();
test();
function CheckType( et, at ) {
}
function CheckValue( ev, av ) {
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,128 +35,127 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: number-001.js
Description:
File Name: number-001.js
Description:
If a Java method returns one of the primitive Java types below,
JavaScript should read the value as JavaScript number primitive.
* byte
* short
* int
* long
* float
* double
* char
If a Java method returns one of the primitive Java types below,
JavaScript should read the value as JavaScript number primitive.
* byte
* short
* int
* long
* float
* double
* char
To test this:
To test this:
1. Call a java method that returns one of the primitive java types above.
2. Check the value of the returned type
3. Check the type of the returned type, which should be "number"
1. Call a java method that returns one of the primitive java types above.
2. Check the value of the returned type
3. Check the type of the returned type, which should be "number"
It is an error if the type of the JavaScript variable is "object" or if
its class is JavaObject or Number.
It is an error if the type of the JavaScript variable is "object" or if
its class is JavaObject or Number.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Number Primitive to JavaScript Object";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Number Primitive to JavaScript Object";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// In all test cases, the expected type is "number"
// In all test cases, the expected type is "number"
var E_TYPE = "number";
var E_TYPE = "number";
// Create arrays of actual results (java_array) and
// expected results (test_array).
// Create arrays of actual results (java_array) and
// expected results (test_array).
var java_array = new Array();
var test_array = new Array();
var java_array = new Array();
var test_array = new Array();
var i = 0;
var i = 0;
// Call a java function that returns a value whose type is int.
java_array[i] = new JavaValue( java.lang.Integer.parseInt('255') );
test_array[i] = new TestValue( "java.lang.Integer.parseInt('255')",
255,
E_TYPE );
// Call a java function that returns a value whose type is int.
java_array[i] = new JavaValue( java.lang.Integer.parseInt('255') );
test_array[i] = new TestValue( "java.lang.Integer.parseInt('255')",
255,
E_TYPE );
i++;
i++;
java_array[i] = new JavaValue( (new java.lang.Double( '123456789' )).intValue() );
test_array[i] = new TestValue( "(new java.lang.Double( '123456789' )).intValue()",
123456789,
E_TYPE );
java_array[i] = new JavaValue( (new java.lang.Double( '123456789' )).intValue() );
test_array[i] = new TestValue( "(new java.lang.Double( '123456789' )).intValue()",
123456789,
E_TYPE );
i++;
i++;
// Call a java function that returns a value whose type is double
java_array[i] = new JavaValue( (new java.lang.Integer( '123456789' )).doubleValue() );
test_array[i] = new TestValue( "(new java.lang.Integer( '123456789' )).doubleValue()",
123456789,
E_TYPE );
// Call a java function that returns a value whose type is double
java_array[i] = new JavaValue( (new java.lang.Integer( '123456789' )).doubleValue() );
test_array[i] = new TestValue( "(new java.lang.Integer( '123456789' )).doubleValue()",
123456789,
E_TYPE );
// Call a java function that returns a value whose type is long
java_array[i] = new JavaValue( (new java.lang.Long('1234567891234567' )).longValue() );
test_array[i] = new TestValue( "(new java.lang.Long( '1234567891234567' )).longValue()",
1234567891234567,
E_TYPE );
// Call a java function that returns a value whose type is long
java_array[i] = new JavaValue( (new java.lang.Long('1234567891234567' )).longValue() );
test_array[i] = new TestValue( "(new java.lang.Long( '1234567891234567' )).longValue()",
1234567891234567,
E_TYPE );
// Call a java function that returns a value whose type is float
// Call a java function that returns a value whose type is float
java_array[i] = new JavaValue( (new java.lang.Float( '1.23456789' )).floatValue() );
test_array[i] = new TestValue( "(new java.lang.Float( '1.23456789' )).floatValue()",
1.23456789,
E_TYPE );
java_array[i] = new JavaValue( (new java.lang.Float( '1.23456789' )).floatValue() );
test_array[i] = new TestValue( "(new java.lang.Float( '1.23456789' )).floatValue()",
1.23456789,
E_TYPE );
i++;
i++;
// Call a java function that returns a value whose type is char
java_array[i] = new JavaValue( (new java.lang.String("hello")).charAt(0) );
test_array[i] = new TestValue( "(new java.lang.String('hello')).charAt(0)",
"h".charCodeAt(0),
E_TYPE );
i++;
// Call a java function that returns a value whose type is char
java_array[i] = new JavaValue( (new java.lang.String("hello")).charAt(0) );
test_array[i] = new TestValue( "(new java.lang.String('hello')).charAt(0)",
"h".charCodeAt(0),
E_TYPE );
i++;
// Call a java function that returns a value whose type is short
java_array[i] = new JavaValue( (new java.lang.Byte(127)).shortValue() );
test_array[i] = new TestValue( "(new java.lang.Byte(127)).shortValue()",
127,
E_TYPE );
i++;
// Call a java function that returns a value whose type is short
java_array[i] = new JavaValue( (new java.lang.Byte(127)).shortValue() );
test_array[i] = new TestValue( "(new java.lang.Byte(127)).shortValue()",
127,
E_TYPE );
i++;
// Call a java function that returns a value whose type is byte
java_array[i] = new JavaValue( (new java.lang.Byte(127)).byteValue() );
test_array[i] = new TestValue( "(new java.lang.Byte(127)).byteValue()",
127,
E_TYPE );
// Call a java function that returns a value whose type is byte
java_array[i] = new JavaValue( (new java.lang.Byte(127)).byteValue() );
test_array[i] = new TestValue( "(new java.lang.Byte(127)).byteValue()",
127,
E_TYPE );
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
test();
test();
function CompareValues( javaval, testval ) {
// Check value
testcases[testcases.length] = new TestCase( SECTION,
testval.description,
testval.value,
javaval.value );
new TestCase( SECTION,
testval.description,
testval.value,
javaval.value );
// Check type.
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
}
function JavaValue( value ) {
this.value = value.valueOf();
@ -168,16 +168,3 @@ function TestValue( description, value, type, classname ) {
this.type = type;
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,129 +35,128 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: number-001.js
Description:
File Name: number-001.js
Description:
Accessing a Java field whose value is one of the primitive Java types
below, JavaScript should read this as a JavaScript Number object.
byte
short
int
long
float
double
char
Accessing a Java field whose value is one of the primitive Java types
below, JavaScript should read this as a JavaScript Number object.
byte
short
int
long
float
double
char
To test this:
1. Instantiate a new Java object that has a field whose type one of
the above primitive Java types, OR get the value of a class's static
field.
2. Check the value of the returned object
3. Check the type of the returned object, which should be "object"
4. Check the class of the returned object using Object.prototype.toString,
which should return "[object Number]"
To test this:
1. Instantiate a new Java object that has a field whose type one of
the above primitive Java types, OR get the value of a class's static
field.
2. Check the value of the returned object
3. Check the type of the returned object, which should be "object"
4. Check the class of the returned object using Object.prototype.toString,
which should return "[object Number]"
It is an error if the type of the JavaScript variable is "number" or if
its class is JavaObject.
It is an error if the type of the JavaScript variable is "number" or if
its class is JavaObject.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Number Primitive to JavaScript Object";
var SECTION = "LiveConnect";
var VERSION = "1_3";
var TITLE = "Java Number Primitive to JavaScript Object";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// In all test cases, the expected type is "object, and the expected
// class is "Number"
// In all test cases, the expected type is "object, and the expected
// class is "Number"
var E_TYPE = "number";
var E_TYPE = "number";
// Create arrays of actual results (java_array) and expected results
// (test_array).
// Create arrays of actual results (java_array) and expected results
// (test_array).
var java_array = new Array();
var test_array = new Array();
var java_array = new Array();
var test_array = new Array();
var i = 0;
var i = 0;
// Get a static java field whose type is byte.
// Get a static java field whose type is byte.
java_array[i] = new JavaValue( java.lang.Byte.MIN_VALUE );
test_array[i] = new TestValue( "java.lang.Byte.MIN_VALUE",
-128 )
java_array[i] = new JavaValue( java.lang.Byte.MIN_VALUE );
test_array[i] = new TestValue( "java.lang.Byte.MIN_VALUE",
-128 )
i++;
// Get a static java field whose type is short.
java_array[i] = new JavaValue( java.lang.Short.MIN_VALUE );
test_array[i] = new TestValue( "java.lang.Short.MIN_VALUE",
-32768 )
// Get a static java field whose type is short.
java_array[i] = new JavaValue( java.lang.Short.MIN_VALUE );
test_array[i] = new TestValue( "java.lang.Short.MIN_VALUE",
-32768 )
i++;
// Get a static java field whose type is int.
// Get a static java field whose type is int.
java_array[i] = new JavaValue( java.lang.Integer.MIN_VALUE );
test_array[i] = new TestValue( "java.lang.Integer.MIN_VALUE",
-2147483648 )
java_array[i] = new JavaValue( java.lang.Integer.MIN_VALUE );
test_array[i] = new TestValue( "java.lang.Integer.MIN_VALUE",
-2147483648 )
i++;
// Instantiate a class, and get a field in that class whose type is int.
// Instantiate a class, and get a field in that class whose type is int.
var java_rect = new java.awt.Rectangle( 1,2,3,4 );
var java_rect = new java.awt.Rectangle( 1,2,3,4 );
java_array[i] = new JavaValue( java_rect.width );
test_array[i] = new TestValue( "java_object = new java.awt.Rectangle( 1,2,3,4 ); java_object.width",
3 );
java_array[i] = new JavaValue( java_rect.width );
test_array[i] = new TestValue( "java_object = new java.awt.Rectangle( 1,2,3,4 ); java_object.width",
3 );
i++;
// Get a static java field whose type is long.
java_array[i] = new JavaValue( java.lang.Long.MIN_VALUE );
test_array[i] = new TestValue( "java.lang.Long.MIN_VALUE",
-9223372036854776000 );
i++;
// Get a static java field whose type is float.
java_array[i] = new JavaValue( java.lang.Float.MAX_VALUE );
test_array[i] = new TestValue( "java.lang.Float.MAX_VALUE",
3.4028234663852886e+38 )
i++;
// Get a static java field whose type is long.
java_array[i] = new JavaValue( java.lang.Long.MIN_VALUE );
test_array[i] = new TestValue( "java.lang.Long.MIN_VALUE",
-9223372036854776000 );
// Get a static java field whose type is double.
java_array[i] = new JavaValue( java.lang.Double.MAX_VALUE );
test_array[i] = new TestValue( "java.lang.Double.MAX_VALUE",
1.7976931348623157e+308 )
i++;
// Get a static java field whose type is float.
java_array[i] = new JavaValue( java.lang.Float.MAX_VALUE );
test_array[i] = new TestValue( "java.lang.Float.MAX_VALUE",
3.4028234663852886e+38 )
i++;
// Get a static java field whose type is char.
java_array[i] = new JavaValue( java.lang.Character.MAX_VALUE );
test_array[i] = new TestValue( "java.lang.Character.MAX_VALUE",
65535 );
i++;
// Get a static java field whose type is double.
java_array[i] = new JavaValue( java.lang.Double.MAX_VALUE );
test_array[i] = new TestValue( "java.lang.Double.MAX_VALUE",
1.7976931348623157e+308 )
i++;
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
// Get a static java field whose type is char.
java_array[i] = new JavaValue( java.lang.Character.MAX_VALUE );
test_array[i] = new TestValue( "java.lang.Character.MAX_VALUE",
65535 );
i++;
}
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
test();
test();
function CompareValues( javaval, testval ) {
// Check value
testcases[testcases.length] = new TestCase( SECTION,
testval.description,
testval.value,
javaval.value );
new TestCase( SECTION,
testval.description,
testval.value,
javaval.value );
// Check type.
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
}
function JavaValue( value ) {
this.value = value.valueOf();
@ -170,16 +170,3 @@ function TestValue( description, value, type ) {
// this.classname = classname;
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

0
js/tests/lc2/JavaToJS/shell.js Executable file
Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,82 +35,81 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: method-001.js
Description:
File Name: method-001.js
Description:
Call a static method of an object and verify return value.
This is covered more thoroughly in the type conversion test cases.
This only covers cases in which JavaObjects are returned.
Call a static method of an object and verify return value.
This is covered more thoroughly in the type conversion test cases.
This only covers cases in which JavaObjects are returned.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Calling Static Methods";
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Calling Static Methods";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// All JavaObjects are of the type "object"
// All JavaObjects are of the type "object"
var E_TYPE = "object";
var E_TYPE = "object";
// All JavaObjects [[Class]] property is JavaObject
var E_JSCLASS = "[object JavaObject]";
// All JavaObjects [[Class]] property is JavaObject
var E_JSCLASS = "[object JavaObject]";
// Create arrays of actual results (java_array) and
// expected results (test_array).
// Create arrays of actual results (java_array) and
// expected results (test_array).
var java_array = new Array();
var test_array = new Array();
var java_array = new Array();
var test_array = new Array();
var i = 0;
var i = 0;
java_array[i] = new JavaValue( java.lang.String.valueOf(true) );
test_array[i] = new TestValue( "java.lang.String.valueOf(true)",
"object", "java.lang.String", "true" );
java_array[i] = new JavaValue( java.lang.String.valueOf(true) );
test_array[i] = new TestValue( "java.lang.String.valueOf(true)",
"object", "java.lang.String", "true" );
i++;
i++;
java_array[i] = new JavaValue( java.awt.Color.getHSBColor(0.0, 0.0, 0.0) );
test_array[i] = new TestValue( "java.awt.Color.getHSBColor(0.0, 0.0, 0.0)",
"object", "java.awt.Color", "java.awt.Color[r=0,g=0,b=0]" );
java_array[i] = new JavaValue( java.awt.Color.getHSBColor(0.0, 0.0, 0.0) );
test_array[i] = new TestValue( "java.awt.Color.getHSBColor(0.0, 0.0, 0.0)",
"object", "java.awt.Color", "java.awt.Color[r=0,g=0,b=0]" );
i++;
i++;
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
test();
test();
function CompareValues( javaval, testval ) {
// Check type, which should be E_TYPE
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +" )",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +" )",
testval.type,
javaval.type );
/*
// Check JavaScript class, which should be E_JSCLASS
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +" ).getJSClass()",
E_JSCLASS,
javaval.jsclass );
// Check JavaScript class, which should be E_JSCLASS
new TestCase( SECTION,
"(" + testval.description +" ).getJSClass()",
E_JSCLASS,
javaval.jsclass );
*/
// Check the JavaClass, which should be the same as the result as Class.forName(description).
testcases[testcases.length] = new TestCase( SECTION,
"("+testval.description +").getClass().equals( " +
"java.lang.Class.forName( '" + testval.classname +
"' ) )",
true,
(javaval.javaclass).equals( testval.javaclass ) );
new TestCase( SECTION,
"("+testval.description +").getClass().equals( " +
"java.lang.Class.forName( '" + testval.classname +
"' ) )",
true,
(javaval.javaclass).equals( testval.javaclass ) );
// check the string value
testcases[testcases.length] = new TestCase(
new TestCase(
SECTION,
"("+testval.description+") +''",
testval.stringval,
@ -135,16 +135,3 @@ function TestValue( description, type, classname, stringval ) {
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,80 +35,79 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: method-002.js
Description:
File Name: method-002.js
Description:
Call a method of a JavaObject instance and verify that return value.
This is covered more thouroughly in the type conversion test cases.
Call a method of a JavaObject instance and verify that return value.
This is covered more thouroughly in the type conversion test cases.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Invoking Java Methods";
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Invoking Java Methods";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// All JavaObjects are of the type "object"
// All JavaObjects are of the type "object"
var E_TYPE = "object";
var E_TYPE = "object";
// All JavaObjects [[Class]] property is JavaObject
var E_JSCLASS = "[object JavaObject]";
// All JavaObjects [[Class]] property is JavaObject
var E_JSCLASS = "[object JavaObject]";
// Create arrays of actual results (java_array) and
// expected results (test_array).
// Create arrays of actual results (java_array) and
// expected results (test_array).
var java_array = new Array();
var test_array = new Array();
var java_array = new Array();
var test_array = new Array();
var i = 0;
var i = 0;
// method returns an object
// method returns an object
var rect = new java.awt.Rectangle(1,2,3,4);
var size = rect.getSize();
var rect = new java.awt.Rectangle(1,2,3,4);
var size = rect.getSize();
new TestCase(
SECTION,
"var size = (new java.awt.Rectangle(1,2,3,4)).getSize(); "+
"size.getClass().equals(java.lang.Class.forName(\""+
"java.awt.Dimension\"))",
true,
size.getClass().equals(java.lang.Class.forName("java.awt.Dimension")));
testcases[testcases.length] = new TestCase(
SECTION,
"var size = (new java.awt.Rectangle(1,2,3,4)).getSize(); "+
"size.getClass().equals(java.lang.Class.forName(\""+
"java.awt.Dimension\"))",
true,
size.getClass().equals(java.lang.Class.forName("java.awt.Dimension")));
new TestCase(
SECTION,
"size.width",
3,
size.width );
testcases[testcases.length] = new TestCase(
SECTION,
"size.width",
3,
size.width );
new TestCase(
SECTION,
"size.height",
4,
size.height );
testcases[testcases.length] = new TestCase(
SECTION,
"size.height",
4,
size.height );
// method returns void
var r = rect.setSize(5,6);
// method returns void
var r = rect.setSize(5,6);
new TestCase(
SECTION,
"var r = rect.setSize(5,6); r",
void 0,
r );
testcases[testcases.length] = new TestCase(
SECTION,
"var r = rect.setSize(5,6); r",
void 0,
r );
// method returns a string
// method returns a string
var string = new java.lang.String( " hello " );
s = string.trim()
var string = new java.lang.String( " hello " );
s = string.trim()
testcases[testcases.length] = new TestCase(
new TestCase(
SECTION,
"var string = new java.lang.String(\" hello \"); "+
"var s = string.trim(); s.getClass().equals("+
@ -115,34 +115,34 @@
true,
s.getClass().equals(java.lang.Class.forName("java.lang.String")) );
// method returns an int
testcases[testcases.length] = new TestCase(
SECTION,
"s.length()",
5,
s.length() );
// method returns an int
new TestCase(
SECTION,
"s.length()",
5,
s.length() );
test();
test();
function CompareValues( javaval, testval ) {
// Check type, which should be E_TYPE
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +" )",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +" )",
testval.type,
javaval.type );
// Check JavaScript class, which should be E_JSCLASS
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +" ).getJSClass()",
testval.jsclass,
javaval.jsclass );
new TestCase( SECTION,
"(" + testval.description +" ).getJSClass()",
testval.jsclass,
javaval.jsclass );
// Check the JavaClass, which should be the same as the result as Class.forName(description).
testcases[testcases.length] = new TestCase( SECTION,
testval.description +".getClass().equals( " +
"java.lang.Class.forName( '" + testval.classname +
"' ) )",
true,
javaval.javaclass.equals( testval.javaclass ) );
new TestCase( SECTION,
testval.description +".getClass().equals( " +
"java.lang.Class.forName( '" + testval.classname +
"' ) )",
true,
javaval.javaclass.equals( testval.javaclass ) );
}
function JavaValue( value ) {
this.type = typeof value;
@ -160,16 +160,3 @@ function TestValue( description, classname ) {
this.javaclass = java.lang.Class.forName( classname );
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,62 +35,61 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: method-003.js
Description:
File Name: method-003.js
Description:
JavaMethod objects are of the type "function" since they implement the
[[Call]] method.
JavaMethod objects are of the type "function" since they implement the
[[Call]] method.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Type and Class of Java Methods";
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Type and Class of Java Methods";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// All JavaMethods are of the type "function"
var E_TYPE = "function";
// All JavaMethods are of the type "function"
var E_TYPE = "function";
// All JavaMethods [[Class]] property is Function
var E_JSCLASS = "[object Function]";
// All JavaMethods [[Class]] property is Function
var E_JSCLASS = "[object Function]";
// Create arrays of actual results (java_array) and
// expected results (test_array).
// Create arrays of actual results (java_array) and
// expected results (test_array).
var java_array = new Array();
var test_array = new Array();
var java_array = new Array();
var test_array = new Array();
var i = 0;
var i = 0;
java_array[i] = new JavaValue( java.lang.System.out.println );
test_array[i] = new TestValue( "java.lang.System.out.println" );
i++;
java_array[i] = new JavaValue( java.lang.System.out.println );
test_array[i] = new TestValue( "java.lang.System.out.println" );
i++;
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
test();
test();
function CompareValues( javaval, testval ) {
// Check type, which should be E_TYPE
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +" )",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +" )",
testval.type,
javaval.type );
// Check JavaScript class, which should be E_JSCLASS
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +" ).getJSClass()",
testval.jsclass,
javaval.jsclass );
new TestCase( SECTION,
"(" + testval.description +" ).getJSClass()",
testval.jsclass,
javaval.jsclass );
}
function JavaValue( value ) {
this.type = typeof value;
@ -104,16 +104,3 @@ function TestValue( description ) {
this.jsclass = E_JSCLASS;
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,45 +35,34 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: method-004-n.js
Description:
File Name: method-004-n.js
Description:
Passing arguments of the wrong type, or the wrong number of arguments,
should cause a runtime error.
Passing arguments of the wrong type, or the wrong number of arguments,
should cause a runtime error.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Passing bad arguments to a method";
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Passing bad arguments to a method";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
DESCRIPTION = "var string = new java.lang.String(\"\"); string.charAt(\"foo\")";
EXPECTED = "error";
var string = new java.lang.String("");
var string = new java.lang.String("");
testcases[testcases.length] = new TestCase(
SECTION,
"var string = new java.lang.String(\"\"); string.charAt(\"foo\")",
"error",
string.charAt("foo") );
new TestCase(
SECTION,
"var string = new java.lang.String(\"\"); string.charAt(\"foo\")",
"error",
string.charAt("foo") );
test();
test();
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,55 +35,54 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: method-005.js
Description:
File Name: method-005.js
Description:
Assigning a Java method to a JavaScript object should not change the
context associated with the Java method -- its this object should
be the Java object, not the JavaScript object.
Assigning a Java method to a JavaScript object should not change the
context associated with the Java method -- its this object should
be the Java object, not the JavaScript object.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Assigning a Static Java Method to a JavaScript object";
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Assigning a Static Java Method to a JavaScript object";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var java_string = new java.lang.String("LiveConnect");
var js_string = "JavaScript";
var java_string = new java.lang.String("LiveConnect");
var js_string = "JavaScript";
js_string.startsWith = java_string.startsWith;
js_string.startsWith = java_string.startsWith;
/*
testcases[testcases.length] = new TestCase(
SECTION,
"var java_string = new java.lang.String(\"LiveConnect\");" +
"var js_string = \"JavaScript\"" +
"js_string.startsWith = java_string.startsWith"+
"js_string.startsWith(\"J\")",
false,
js_string.startsWith("J") );
new TestCase(
SECTION,
"var java_string = new java.lang.String(\"LiveConnect\");" +
"var js_string = \"JavaScript\"" +
"js_string.startsWith = java_string.startsWith"+
"js_string.startsWith(\"J\")",
false,
js_string.startsWith("J") );
*/
var mo = new MyObject();
var mo = new MyObject();
var c = mo.classForName( "java.lang.String" );
var c = mo.classForName( "java.lang.String" );
testcases[testcases.length] = new TestCase(
SECTION,
"var mo = new MyObject(); "+
"var c = mo.classForName(\"java.lang.String\");" +
"c.equals(java.lang.Class.forName(\"java.lang.String\))",
true,
c.equals(java.lang.Class.forName("java.lang.String")) );
new TestCase(
SECTION,
"var mo = new MyObject(); "+
"var c = mo.classForName(\"java.lang.String\");" +
"c.equals(java.lang.Class.forName(\"java.lang.String\))",
true,
c.equals(java.lang.Class.forName("java.lang.String")) );
test();
test();
function MyObject() {
this.println = java.lang.System.out.println;
@ -90,16 +90,3 @@ function MyObject() {
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,43 +35,49 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: method-006-n.js
Description:
File Name: method-006-n.js
Description:
Assigning a Java method to a JavaScript object should not change the
context associated with the Java method -- its this object should
be the Java object, not the JavaScript object.
Assigning a Java method to a JavaScript object should not change the
context associated with the Java method -- its this object should
be the Java object, not the JavaScript object.
That is from Flanagan. In practice, this fails all implementations.
That is from Flanagan. In practice, this fails all implementations.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Assigning a Non-Static Java Method to a JavaScript Object";
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Assigning a Non-Static Java Method to a JavaScript Object";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var java_string = new java.lang.String("LiveConnect");
var js_string = "JavaScript";
var java_string = new java.lang.String("LiveConnect");
var js_string = "JavaScript";
DESCRIPTION = "var java_string = new java.lang.String(\"LiveConnect\");" +
"var js_string = \"JavaScript\"" +
"js_string.startsWith = java_string.startsWith"+
"js_string.startsWith(\"J\")";
js_string.startsWith = java_string.startsWith;
EXPECTED = "error";
testcases[testcases.length] = new TestCase(
SECTION,
"var java_string = new java.lang.String(\"LiveConnect\");" +
"var js_string = \"JavaScript\"" +
"js_string.startsWith = java_string.startsWith"+
"js_string.startsWith(\"J\")",
false,
js_string.startsWith("J") );
js_string.startsWith = java_string.startsWith;
test();
new TestCase(
SECTION,
"var java_string = new java.lang.String(\"LiveConnect\");" +
"var js_string = \"JavaScript\"" +
"js_string.startsWith = java_string.startsWith"+
"js_string.startsWith(\"J\")",
false,
js_string.startsWith("J") );
test();
function MyObject() {
this.println = java.lang.System.out.println;
@ -78,16 +85,3 @@ function MyObject() {
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,47 +35,33 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: println-001.js
Section: LiveConnect
Description:
File Name: println-001.js
Section: LiveConnect
Description:
Regression test for
http://scopus.mcom.com/bugsplat/show_bug.cgi?id=114820
Regression test for
http://scopus.mcom.com/bugsplat/show_bug.cgi?id=114820
Verify that java.lang.System.out.println does not cause an error.
Not sure how to get to the error any other way.
Verify that java.lang.System.out.println does not cause an error.
Not sure how to get to the error any other way.
Author: christine@netscape.com
Date: 12 november 1997
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "println-001.js";
var VERSION = "JS1_3";
var TITLE = "java.lang.System.out.println";
var SECTION = "println-001.js";
var VERSION = "JS1_3";
var TITLE = "java.lang.System.out.println";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = new Array();
new TestCase(
SECTION,
"java.lang.System.out.println( \"output from test live/Methods/println-001.js\")",
void 0,
java.lang.System.out.println( "output from test live/Methods/println-001.js" ) );
testcases[testcases.length] = new TestCase(
SECTION,
"java.lang.System.out.println( \"output from test live/Methods/println-001.js\")",
void 0,
java.lang.System.out.println( "output from test live/Methods/println-001.js" ) );
test();
test();
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

0
js/tests/lc2/Methods/shell.js Executable file
Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,117 +35,116 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: object-001.js
Description:
File Name: object-001.js
Description:
Given a JavaObject, calling the getClass() method of java.lang.Object
should return the java.lang.Class of that object.
Given a JavaObject, calling the getClass() method of java.lang.Object
should return the java.lang.Class of that object.
To test this:
To test this:
1. Create a JavaObject by instantiating a new object OR call
a java method that returns a JavaObject.
1. Create a JavaObject by instantiating a new object OR call
a java method that returns a JavaObject.
2. Call getClass() on that object. Compare it to the result of
java.lang.Class.forName( "<classname>" ).
2. Call getClass() on that object. Compare it to the result of
java.lang.Class.forName( "<classname>" ).
3. Also compare the result of getClass() to the literal classname
3. Also compare the result of getClass() to the literal classname
Note: this test does not use the LiveConnect getClass function, which
currently is not available.
Note: this test does not use the LiveConnect getClass function, which
currently is not available.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Getting the Class of JavaObjects";
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Getting the Class of JavaObjects";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// All JavaObjects are of the type "object"
// All JavaObjects are of the type "object"
var E_TYPE = "object";
var E_TYPE = "object";
// All JavaObjects [[Class]] property is JavaObject
var E_JSCLASS = "[object JavaObject]";
// All JavaObjects [[Class]] property is JavaObject
var E_JSCLASS = "[object JavaObject]";
// Create arrays of actual results (java_array) and
// expected results (test_array).
// Create arrays of actual results (java_array) and
// expected results (test_array).
var java_array = new Array();
var test_array = new Array();
var java_array = new Array();
var test_array = new Array();
var i = 0;
var i = 0;
java_array[i] = new JavaValue( new java.awt.Rectangle(1,2,3,4) );
test_array[i] = new TestValue( "new java.awt.Rectangle(1,2,3,4)", "java.awt.Rectangle" );
i++;
java_array[i] = new JavaValue( new java.awt.Rectangle(1,2,3,4) );
test_array[i] = new TestValue( "new java.awt.Rectangle(1,2,3,4)", "java.awt.Rectangle" );
i++;
java_array[i] = new JavaValue( new java.io.PrintStream( java.lang.System.out ) );
test_array[i] = new TestValue( "new java.io.PrintStream(java.lang.System.out)", "java.io.PrintStream" );
i++;
java_array[i] = new JavaValue( new java.io.PrintStream( java.lang.System.out ) );
test_array[i] = new TestValue( "new java.io.PrintStream(java.lang.System.out)", "java.io.PrintStream" );
i++;
java_array[i] = new JavaValue( new java.lang.String("hello") );
test_array[i] = new TestValue( "new java.lang.String('hello')", "java.lang.String" );
i++;
java_array[i] = new JavaValue( new java.lang.String("hello") );
test_array[i] = new TestValue( "new java.lang.String('hello')", "java.lang.String" );
i++;
java_array[i] = new JavaValue( new java.net.URL("http://home.netscape.com/") );
test_array[i] = new TestValue( "new java.net.URL('http://home.netscape.com')", "java.net.URL" );
i++;
java_array[i] = new JavaValue( new java.net.URL("http://home.netscape.com/") );
test_array[i] = new TestValue( "new java.net.URL('http://home.netscape.com')", "java.net.URL" );
i++;
/*
java_array[i] = new JavaValue( java.rmi.RMISecurityManager );
test_array[i] = new TestValue( "java.rmi.RMISecurityManager" );
i++;
java_array[i] = new JavaValue( java.text.DateFormat );
test_array[i] = new TestValue( "java.text.DateFormat" );
i++;
java_array[i] = new JavaValue( java.rmi.RMISecurityManager );
test_array[i] = new TestValue( "java.rmi.RMISecurityManager" );
i++;
java_array[i] = new JavaValue( java.text.DateFormat );
test_array[i] = new TestValue( "java.text.DateFormat" );
i++;
*/
java_array[i] = new JavaValue( new java.util.Vector() );
test_array[i] = new TestValue( "new java.util.Vector()", "java.util.Vector" );
i++;
java_array[i] = new JavaValue( new java.util.Vector() );
test_array[i] = new TestValue( "new java.util.Vector()", "java.util.Vector" );
i++;
/*
java_array[i] = new JavaValue( new Packages.com.netscape.javascript.Context() );
test_array[i] = new TestValue( "new Packages.com.netscape.javascript.Context()", "com.netscape.javascript.Context" );
i++;
java_array[i] = new JavaValue( new Packages.com.netscape.javascript.Context() );
test_array[i] = new TestValue( "new Packages.com.netscape.javascript.Context()", "com.netscape.javascript.Context" );
i++;
java_array[i] = new JavaValue( Packages.com.netscape.javascript.examples.Shell );
test_array[i] = new TestValue( "Packages.com.netscape.javascript.examples.Shell" );
i++;
java_array[i] = new JavaValue( Packages.com.netscape.javascript.examples.Shell );
test_array[i] = new TestValue( "Packages.com.netscape.javascript.examples.Shell" );
i++;
*/
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
test();
test();
function CompareValues( javaval, testval ) {
// Check type, which should be E_TYPE
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +" )",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +" )",
testval.type,
javaval.type );
/*
// Check JavaScript class, which should be E_JSCLASS
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +" ).getJSClass()",
testval.jsclass,
javaval.jsclass );
// Check JavaScript class, which should be E_JSCLASS
new TestCase( SECTION,
"(" + testval.description +" ).getJSClass()",
testval.jsclass,
javaval.jsclass );
*/
// Check the JavaClass, which should be the same as the result as Class.forName(description).
testcases[testcases.length] = new TestCase( SECTION,
testval.description +".getClass().equals( " +
"java.lang.Class.forName( '" + testval.classname +
"' ) )",
true,
javaval.javaclass.equals( testval.javaclass ) );
new TestCase( SECTION,
testval.description +".getClass().equals( " +
"java.lang.Class.forName( '" + testval.classname +
"' ) )",
true,
javaval.javaclass.equals( testval.javaclass ) );
}
function JavaValue( value ) {
this.type = typeof value;
@ -163,16 +163,3 @@ function TestValue( description, classname ) {
this.javaclass = java.lang.Class.forName( classname );
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,116 +35,115 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: object-002.js
Description:
File Name: object-002.js
Description:
Given a JavaObject, calling the getClass() method of java.lang.Object
should return the java.lang.Class of that object.
Given a JavaObject, calling the getClass() method of java.lang.Object
should return the java.lang.Class of that object.
This tests the LiveConnect function getClass( <javaobject> ), which
should be a defined function that returns the JavaClass object for
a JavaObject instance.
This tests the LiveConnect function getClass( <javaobject> ), which
should be a defined function that returns the JavaClass object for
a JavaObject instance.
The absense of the getClass function is
http://scopus/bugsplat/show_bug.cgi?id=106560
The absense of the getClass function is
http://scopus/bugsplat/show_bug.cgi?id=106560
To test this:
To test this:
1. Create a JavaObject by instantiating a new object OR call
a java method that returns a JavaObject.
1. Create a JavaObject by instantiating a new object OR call
a java method that returns a JavaObject.
2. Call the getClass() function with the object as its argument.
2. Call the getClass() function with the object as its argument.
3. Compare the result of 2 to the Class.
3. Compare the result of 2 to the Class.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Getting the Class of JavaObjects";
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Getting the Class of JavaObjects";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// All JavaObjects are of the type "object"
// All JavaObjects are of the type "object"
var E_TYPE = "object";
var E_TYPE = "object";
// All JavaObjects [[Class]] property is JavaObject
var E_JSCLASS = "[object JavaObject]";
// All JavaObjects [[Class]] property is JavaObject
var E_JSCLASS = "[object JavaObject]";
// Create arrays of actual results (java_array) and
// expected results (test_array).
// Create arrays of actual results (java_array) and
// expected results (test_array).
var java_array = new Array();
var test_array = new Array();
var java_array = new Array();
var test_array = new Array();
var i = 0;
var i = 0;
java_array[i] = new JavaValue( new java.awt.Rectangle(1,2,3,4) );
test_array[i] = new TestValue( "new java.awt.Rectangle(1,2,3,4)", "java.awt.Rectangle" );
i++;
java_array[i] = new JavaValue( new java.awt.Rectangle(1,2,3,4) );
test_array[i] = new TestValue( "new java.awt.Rectangle(1,2,3,4)", "java.awt.Rectangle" );
i++;
java_array[i] = new JavaValue( new java.io.PrintStream( java.lang.System.out ) );
test_array[i] = new TestValue( "new java.io.PrintStream(java.lang.System.out)", "java.io.PrintStream" );
i++;
java_array[i] = new JavaValue( new java.io.PrintStream( java.lang.System.out ) );
test_array[i] = new TestValue( "new java.io.PrintStream(java.lang.System.out)", "java.io.PrintStream" );
i++;
java_array[i] = new JavaValue( new java.lang.String("hello") );
test_array[i] = new TestValue( "new java.lang.String('hello')", "java.lang.String" );
i++;
java_array[i] = new JavaValue( new java.lang.String("hello") );
test_array[i] = new TestValue( "new java.lang.String('hello')", "java.lang.String" );
i++;
java_array[i] = new JavaValue( new java.net.URL("http://home.netscape.com/") );
test_array[i] = new TestValue( "new java.net.URL('http://home.netscape.com')", "java.net.URL" );
i++;
java_array[i] = new JavaValue( new java.net.URL("http://home.netscape.com/") );
test_array[i] = new TestValue( "new java.net.URL('http://home.netscape.com')", "java.net.URL" );
i++;
/*
java_array[i] = new JavaValue( java.rmi.RMISecurityManager );
test_array[i] = new TestValue( "java.rmi.RMISecurityManager" );
i++;
java_array[i] = new JavaValue( java.text.DateFormat );
test_array[i] = new TestValue( "java.text.DateFormat" );
i++;
java_array[i] = new JavaValue( java.rmi.RMISecurityManager );
test_array[i] = new TestValue( "java.rmi.RMISecurityManager" );
i++;
java_array[i] = new JavaValue( java.text.DateFormat );
test_array[i] = new TestValue( "java.text.DateFormat" );
i++;
*/
java_array[i] = new JavaValue( new java.util.Vector() );
test_array[i] = new TestValue( "new java.util.Vector()", "java.util.Vector" );
i++;
java_array[i] = new JavaValue( new java.util.Vector() );
test_array[i] = new TestValue( "new java.util.Vector()", "java.util.Vector" );
i++;
/*
java_array[i] = new JavaValue( new Packages.com.netscape.javascript.Context() );
test_array[i] = new TestValue( "new Packages.com.netscape.javascript.Context()", "com.netscape.javascript.Context" );
i++;
java_array[i] = new JavaValue( new Packages.com.netscape.javascript.Context() );
test_array[i] = new TestValue( "new Packages.com.netscape.javascript.Context()", "com.netscape.javascript.Context" );
i++;
*/
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
test();
test();
function CompareValues( javaval, testval ) {
// Check type, which should be E_TYPE
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +" )",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +" )",
testval.type,
javaval.type );
/*
// Check JavaScript class, which should be E_JSCLASS
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +" ).getJSClass()",
testval.jsclass,
javaval.jsclass );
// Check JavaScript class, which should be E_JSCLASS
new TestCase( SECTION,
"(" + testval.description +" ).getJSClass()",
testval.jsclass,
javaval.jsclass );
*/
// Check the JavaClass, which should be the same as the result as Class.forName(description).
testcases[testcases.length] = new TestCase( SECTION,
testval.description +".getClass().equals( " +
"java.lang.Class.forName( '" + testval.classname +
"' ) )",
true,
javaval.javaclass.equals( testval.javaclass ) );
new TestCase( SECTION,
testval.description +".getClass().equals( " +
"java.lang.Class.forName( '" + testval.classname +
"' ) )",
true,
javaval.javaclass.equals( testval.javaclass ) );
}
function JavaValue( value ) {
this.type = typeof value;
@ -162,16 +162,3 @@ function TestValue( description, classname ) {
this.javaclass = java.lang.Class.forName( classname );
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,48 +35,34 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: object-003.js
Description:
File Name: object-003.js
Description:
Getting and Setting Java Object properties by index value.
Getting and Setting Java Object properties by index value.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Getting and setting JavaObject properties by index value";
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Getting and setting JavaObject properties by index value";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var vector = new java.util.Vector();
var vector = new java.util.Vector();
new TestCase(
SECTION,
"var vector = new java.util.Vector(); vector.addElement(\"hi\")",
void 0,
vector.addElement("hi") );
testcases[testcases.length] = new TestCase(
SECTION,
"var vector = new java.util.Vector(); vector.addElement(\"hi\")",
void 0,
vector.addElement("hi") );
test();
test();
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}
function EnumerateJavaObject( javaobject ) {
var properties = new Array();
for ( var p in javaobject ) {

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,62 +35,48 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: object-004.js
Description:
File Name: object-004.js
Description:
Getting and Setting Java Object properties by index value.
Getting and Setting Java Object properties by index value.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Getting and setting JavaObject properties by index value";
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Getting and setting JavaObject properties by index value";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var vector = new java.util.Vector();
var vector = new java.util.Vector();
new TestCase(
SECTION,
"var vector = new java.util.Vector(); vector.addElement(\"hi\")",
void 0,
vector.addElement("hi") );
testcases[testcases.length] = new TestCase(
SECTION,
"var vector = new java.util.Vector(); vector.addElement(\"hi\")",
void 0,
vector.addElement("hi") );
new TestCase(
SECTION,
"vector.elementAt(0) +''",
"hi",
vector.elementAt(0)+"" );
testcases[testcases.length] = new TestCase(
SECTION,
"vector.elementAt(0) +''",
"hi",
vector.elementAt(0)+"" );
new TestCase(
SECTION,
"vector.setElementAt( \"hello\", 0)",
void 0,
vector.setElementAt( "hello", 0) );
testcases[testcases.length] = new TestCase(
SECTION,
"vector.setElementAt( \"hello\", 0)",
void 0,
vector.setElementAt( "hello", 0) );
new TestCase(
SECTION,
"vector.elementAt(0) +''",
"hello",
vector.elementAt(0)+"" );
testcases[testcases.length] = new TestCase(
SECTION,
"vector.elementAt(0) +''",
"hello",
vector.elementAt(0)+"" );
test();
test();
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,75 +35,74 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: object-005.js
Description:
File Name: object-005.js
Description:
Call ToNumber, ToString, and use the addition operator to
access the DefaultValue with hints Number, String, and no
hint (respectively).
Call ToNumber, ToString, and use the addition operator to
access the DefaultValue with hints Number, String, and no
hint (respectively).
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Getting the Class of JavaObjects";
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Getting the Class of JavaObjects";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var a = new Array();
var i = 0;
var a = new Array();
var i = 0;
// here's an object that should be converted to a number
a[i++] = new TestObject( "new java.lang.Integer(999)",
new java.lang.Integer(999), "Number", 999, "number" );
// here's an object that should be converted to a number
a[i++] = new TestObject( "new java.lang.Integer(999)",
new java.lang.Integer(999), "Number", 999, "number" );
a[i++] = new TestObject(
"new java.lang.Float(999.0)",
new java.lang.Float(999.0),
"Number",
999,
"number" );
a[i++] = new TestObject(
"new java.lang.Float(999.0)",
new java.lang.Float(999.0),
"Number",
999,
"number" );
a[i++] = new TestObject(
"new java.lang.String(\"hi\")",
new java.lang.String("hi"),
"String",
"hi",
"string" );
a[i++] = new TestObject(
"new java.lang.String(\"hi\")",
new java.lang.String("hi"),
"String",
"hi",
"string" );
a[i++] = new TestObject(
"new java.lang.Integer(2134)",
new java.lang.Integer(2134),
"0 + ",
"21340",
"string" );
a[i++] = new TestObject(
"new java.lang.Integer(2134)",
new java.lang.Integer(2134),
"0 + ",
"21340",
"string" );
a[i++] = new TestObject(
"new java.lang.Integer(666)",
new java.lang.Integer(666),
"Boolean",
true,
"boolean" );
a[i++] = new TestObject(
"new java.lang.Integer(666)",
new java.lang.Integer(666),
"Boolean",
true,
"boolean" );
for ( i = 0; i < a.length; i++ ) {
CompareValues( a[i] );
}
for ( i = 0; i < a.length; i++ ) {
CompareValues( a[i] );
}
test();
test();
function CompareValues( t ) {
testcases[testcases.length] = new TestCase(
new TestCase(
SECTION,
t.converter +"("+ t.description +")",
t.expect,
t.actual );
testcases[testcases.length] = new TestCase(
new TestCase(
SECTION,
"typeof (" + t.converter +"( "+ t.description +" ) )",
t.type,
@ -111,28 +111,15 @@ function CompareValues( t ) {
function TestObject( description, javaobject, converter, expect, type ) {
this.description = description;
this.javavalue = javaobject
this.converter = converter;
this.converter = converter;
this.expect = expect;
this.type = type;
switch ( converter ) {
case( "Number" ) : this.actual = Number( javaobject ); break;
case( "String" ) : this.actual = String( javaobject ); break;
case( "Boolean") : this.actual = Boolean(javaobject ); break;
default: this.actual = javaobject + 0;
case( "Number" ) : this.actual = Number( javaobject ); break;
case( "String" ) : this.actual = String( javaobject ); break;
case( "Boolean") : this.actual = Boolean(javaobject ); break;
default: this.actual = javaobject + 0;
}
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,52 +35,36 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: object-006.js
Description:
File Name: object-006.js
Description:
Attempt to construct a java.lang.Character. currently this fails because of
http://scopus/bugsplat/show_bug.cgi?id=106464
Attempt to construct a java.lang.Character. currently this fails because of
http://scopus/bugsplat/show_bug.cgi?id=106464
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Construct a java.lang.Character";
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Construct a java.lang.Character";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var error = err;
var testcase = new TestCase (
SECTION,
"var string = new java.lang.String(\"hi\"); "+
"var c = new java.lang.Character(string.charAt(0)); String(c.toString())",
"h",
"" );
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var string = new java.lang.String("hi");
var c = new java.lang.Character( string.charAt(0) );
testcases[testcases.length] = new TestCase (
SECTION,
"var string = new java.lang.String(\"hi\"); "+
"var c = new java.lang.Character(string.charAt(0)); String(c.toString())",
"h",
"" )
testcase.actual = String(c.toString());
var string = new java.lang.String("hi");
var c = new java.lang.Character( string.charAt(0) );
test();
testcases[0].actual = String(c.toString());
test();
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

0
js/tests/lc2/Objects/shell.js Executable file
Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,116 +35,115 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: package-001.js
Description:
File Name: package-001.js
Description:
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect Packages";
var VERSION = "1_3";
var TITLE = "LiveConnect Packages";
var SECTION = "LiveConnect Packages";
var VERSION = "1_3";
var TITLE = "LiveConnect Packages";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// All packages are of the type "object"
var E_TYPE = "object";
// All packages are of the type "object"
var E_TYPE = "object";
// The JavaScript [[Class]] property for all Packages is "[JavaPackage <packagename>]"
var E_JSCLASS = "[JavaPackage ";
// The JavaScript [[Class]] property for all Packages is "[JavaPackage <packagename>]"
var E_JSCLASS = "[JavaPackage ";
// Create arrays of actual results (java_array) and
// expected results (test_array).
// Create arrays of actual results (java_array) and
// expected results (test_array).
var java_array = new Array();
var test_array = new Array();
var java_array = new Array();
var test_array = new Array();
var i = 0;
var i = 0;
java_array[i] = new JavaValue( java );
test_array[i] = new TestValue( "java" );
i++;
java_array[i] = new JavaValue( java );
test_array[i] = new TestValue( "java" );
i++;
java_array[i] = new JavaValue( java.awt );
test_array[i] = new TestValue( "java.awt" );
i++;
java_array[i] = new JavaValue( java.awt );
test_array[i] = new TestValue( "java.awt" );
i++;
java_array[i] = new JavaValue( java.beans );
test_array[i] = new TestValue( "java.beans" );
i++;
java_array[i] = new JavaValue( java.beans );
test_array[i] = new TestValue( "java.beans" );
i++;
java_array[i] = new JavaValue( java.io );
test_array[i] = new TestValue( "java.io" );
i++;
java_array[i] = new JavaValue( java.io );
test_array[i] = new TestValue( "java.io" );
i++;
java_array[i] = new JavaValue( java.lang );
test_array[i] = new TestValue( "java.lang" );
i++;
java_array[i] = new JavaValue( java.lang );
test_array[i] = new TestValue( "java.lang" );
i++;
java_array[i] = new JavaValue( java.math );
test_array[i] = new TestValue( "java.math" );
i++;
java_array[i] = new JavaValue( java.math );
test_array[i] = new TestValue( "java.math" );
i++;
java_array[i] = new JavaValue( java.net );
test_array[i] = new TestValue( "java.net" );
i++;
java_array[i] = new JavaValue( java.net );
test_array[i] = new TestValue( "java.net" );
i++;
java_array[i] = new JavaValue( java.rmi );
test_array[i] = new TestValue( "java.rmi" );
i++;
java_array[i] = new JavaValue( java.rmi );
test_array[i] = new TestValue( "java.rmi" );
i++;
java_array[i] = new JavaValue( java.text );
test_array[i] = new TestValue( "java.text" );
i++;
java_array[i] = new JavaValue( java.text );
test_array[i] = new TestValue( "java.text" );
i++;
java_array[i] = new JavaValue( java.util );
test_array[i] = new TestValue( "java.util" );
i++;
java_array[i] = new JavaValue( java.util );
test_array[i] = new TestValue( "java.util" );
i++;
java_array[i] = new JavaValue( Packages.javax );
test_array[i] = new TestValue( "Packages.javax" );
i++;
java_array[i] = new JavaValue( Packages.javax );
test_array[i] = new TestValue( "Packages.javax" );
i++;
java_array[i] = new JavaValue( Packages.javax.javascript );
test_array[i] = new TestValue( "Packages.javax.javascript" );
i++;
java_array[i] = new JavaValue( Packages.javax.javascript );
test_array[i] = new TestValue( "Packages.javax.javascript" );
i++;
java_array[i] = new JavaValue( Packages.javax.javascript.examples );
test_array[i] = new TestValue( "Packages.javax.javascript.examples" );
i++;
java_array[i] = new JavaValue( Packages.javax.javascript.examples );
test_array[i] = new TestValue( "Packages.javax.javascript.examples" );
i++;
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
}
test();
test();
function CompareValues( javaval, testval ) {
// Check typeof, which should be E_TYPE
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
// Check JavaScript class, which should be E_JSCLASS + the package name
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +").getJSClass()",
testval.jsclass,
javaval.jsclass );
new TestCase( SECTION,
"(" + testval.description +").getJSClass()",
testval.jsclass,
javaval.jsclass );
}
function JavaValue( value ) {
this.value = value;
this.type = typeof value;
this.jsclass = value +""
return this;
return this;
}
function TestValue( description ) {
this.packagename = (description.substring(0, "Packages.".length) ==
"Packages.") ? description.substring("Packages.".length, description.length ) :
"Packages.") ? description.substring("Packages.".length, description.length ) :
description;
this.description = description;
@ -151,16 +151,3 @@ function TestValue( description ) {
this.jsclass = E_JSCLASS + this.packagename +"]";
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,76 +35,75 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: package-001.js
Description:
File Name: package-001.js
Description:
Use package names that are not in the classpath.
Use package names that are not in the classpath.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect Packages";
var VERSION = "1_3";
var TITLE = "LiveConnect Packages";
var SECTION = "LiveConnect Packages";
var VERSION = "1_3";
var TITLE = "LiveConnect Packages";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// All packages are of the type "object"
var E_TYPE = "object";
// All packages are of the type "object"
var E_TYPE = "object";
// The JavaScript [[Class]] property for all Packages is "[JavaPackage <packagename>]"
var E_JSCLASS = "[JavaPackage ";
// The JavaScript [[Class]] property for all Packages is "[JavaPackage <packagename>]"
var E_JSCLASS = "[JavaPackage ";
// Create arrays of actual results (java_array) and
// expected results (test_array).
// Create arrays of actual results (java_array) and
// expected results (test_array).
var java_array = new Array();
var test_array = new Array();
var java_array = new Array();
var test_array = new Array();
var i = 0;
var i = 0;
java_array[i] = new JavaValue( java.bad.packagename );
test_array[i] = new TestValue( "java.bad.packagename" );
i++;
java_array[i] = new JavaValue( java.bad.packagename );
test_array[i] = new TestValue( "java.bad.packagename" );
i++;
java_array[i] = new JavaValue( Packages.javax.badpackage );
test_array[i] = new TestValue( "Packages.javax.badpackage" );
i++;
java_array[i] = new JavaValue( Packages.javax.badpackage );
test_array[i] = new TestValue( "Packages.javax.badpackage" );
i++;
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
}
test();
test();
function CompareValues( javaval, testval ) {
// Check typeof, which should be E_TYPE
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
// Check JavaScript class, which should be E_JSCLASS + the package name
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +").getJSClass()",
testval.jsclass,
javaval.jsclass );
new TestCase( SECTION,
"(" + testval.description +").getJSClass()",
testval.jsclass,
javaval.jsclass );
}
function JavaValue( value ) {
this.value = value;
this.type = typeof value;
this.jsclass = value +""
return this;
return this;
}
function TestValue( description ) {
this.packagename = (description.substring(0, "Packages.".length) ==
"Packages.") ? description.substring("Packages.".length, description.length ) :
"Packages.") ? description.substring("Packages.".length, description.length ) :
description;
this.description = description;
@ -111,16 +111,3 @@ function TestValue( description ) {
this.jsclass = E_JSCLASS + this.packagename +"]";
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,111 +35,110 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: package-003.js
Description:
File Name: package-003.js
Description:
Set the package name to a JavaScript variable, and attempt to access
classes relative to the package name.
Set the package name to a JavaScript variable, and attempt to access
classes relative to the package name.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect Packages";
var VERSION = "1_3";
var TITLE = "LiveConnect Packages";
var SECTION = "LiveConnect Packages";
var VERSION = "1_3";
var TITLE = "LiveConnect Packages";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
// All packages are of the type "object"
var E_TYPE = "object";
// All packages are of the type "object"
var E_TYPE = "object";
// The JavaScript [[Class]] property for all Packages is "[JavaPackage <packagename>]"
var E_JSCLASS = "[JavaPackage ";
// The JavaScript [[Class]] property for all Packages is "[JavaPackage <packagename>]"
var E_JSCLASS = "[JavaPackage ";
// Create arrays of actual results (java_array) and
// expected results (test_array).
// Create arrays of actual results (java_array) and
// expected results (test_array).
var java_array = new Array();
var test_array = new Array();
var java_array = new Array();
var test_array = new Array();
var i = 0;
var i = 0;
var js = Packages.javax.javascript;
var js = Packages.javax.javascript;
java_array[i] = new JavaValue( js );
test_array[i] = new TestValue( "javax.javascript" );
i++;
java_array[i] = new JavaValue( js );
test_array[i] = new TestValue( "javax.javascript" );
i++;
var util = java.util;
var util = java.util;
java_array[i] = new JavaValue( util );
test_array[i] = new TestValue( "java.util" );
i++;
java_array[i] = new JavaValue( util );
test_array[i] = new TestValue( "java.util" );
i++;
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
for ( i = 0; i < java_array.length; i++ ) {
CompareValues( java_array[i], test_array[i] );
}
}
var v = new util.Vector();
var v = new util.Vector();
test();
test();
function CompareValues( javaval, testval ) {
// Check typeof, which should be E_TYPE
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
// Check JavaScript class, which should be E_JSCLASS + the package name
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +").getJSClass()",
testval.jsclass,
javaval.jsclass );
new TestCase( SECTION,
"(" + testval.description +").getJSClass()",
testval.jsclass,
javaval.jsclass );
// Number( package ) is NaN
testcases[testcases.length] = new TestCase( SECTION,
"Number (" + testval.description +")",
NaN,
Number( javaval.value ) );
new TestCase( SECTION,
"Number (" + testval.description +")",
NaN,
Number( javaval.value ) );
// String( package ) is string value
testcases[testcases.length] = new TestCase( SECTION,
"String (" + testval.description +")",
testval.jsclass,
String(javaval.value) );
new TestCase( SECTION,
"String (" + testval.description +")",
testval.jsclass,
String(javaval.value) );
/*
// ( package ).toString() is string value
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +").toString()",
testval.jsclass,
(javaval.value).toString() );
// ( package ).toString() is string value
new TestCase( SECTION,
"(" + testval.description +").toString()",
testval.jsclass,
(javaval.value).toString() );
*/
// Boolean( package ) is true
testcases[testcases.length] = new TestCase( SECTION,
"Boolean (" + testval.description +")",
true,
Boolean( javaval.value ) );
// add 0 is name + "0"
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +") +0",
testval.jsclass +"0",
javaval.value + 0);
// Boolean( package ) is true
new TestCase( SECTION,
"Boolean (" + testval.description +")",
true,
Boolean( javaval.value ) );
// add 0 is name + "0"
new TestCase( SECTION,
"(" + testval.description +") +0",
testval.jsclass +"0",
javaval.value + 0);
}
function JavaValue( value ) {
this.value = value;
this.type = typeof value;
this.jsclass = value +""
return this;
return this;
}
function TestValue( description ) {
this.packagename = (description.substring(0, "Packages.".length) ==
"Packages.") ? description.substring("Packages.".length, description.length ) :
"Packages.") ? description.substring("Packages.".length, description.length ) :
description;
this.description = description;
@ -146,16 +146,3 @@ function TestValue( description ) {
this.jsclass = E_JSCLASS + this.packagename +"]";
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,95 +35,94 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: package-003.js
Description:
File Name: package-004.js
Description:
Set the package name to a JavaScript variable, and attempt to access
classes relative to the package name.
Set the package name to a JavaScript variable, and attempt to access
classes relative to the package name.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect Packages";
var VERSION = "1_3";
var TITLE = "LiveConnect Packages";
var SECTION = "LiveConnect Packages";
var VERSION = "1_3";
var TITLE = "LiveConnect Packages";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var util = java.util;
var v = new util.Vector();
var util = java.util;
var v = new util.Vector();
new TestCase( SECTION,
"var v = new util.Vector(); v.size()",
0,
v.size() );
testcases[testcases.length] = new TestCase( SECTION,
"var v = new util.Vector(); v.size()",
0,
v.size() );
var h = util.Hashcode;
var hString = String(h);
util.Hashcode = null;
var h = util.Hashcode;
var hString = String(h);
util.Hashcode = null;
new TestCase( SECTION,
"util.Hashcode = null; String( util.Hashcode )",
hString,
String( util.Hashcode ) );
testcases[testcases.length] = new TestCase( SECTION,
"util.Hashcode = null; String( util.Hashcode )",
hString,
String( util.Hashcode ) );
test();
test();
function CompareValues( javaval, testval ) {
// Check typeof, which should be E_TYPE
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
// Check JavaScript class, which should be E_JSCLASS + the package name
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +").getJSClass()",
testval.jsclass,
javaval.getJSClass() );
new TestCase( SECTION,
"(" + testval.description +").getJSClass()",
testval.jsclass,
javaval.getJSClass() );
// Number( package ) is NaN
testcases[testcases.length] = new TestCase( SECTION,
"Number (" + testval.description +")",
NaN,
Number( javaval ) );
new TestCase( SECTION,
"Number (" + testval.description +")",
NaN,
Number( javaval ) );
// String( package ) is string value
testcases[testcases.length] = new TestCase( SECTION,
"String (" + testval.description +")",
testval.jsclass,
String(javaval) );
new TestCase( SECTION,
"String (" + testval.description +")",
testval.jsclass,
String(javaval) );
// ( package ).toString() is string value
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +").toString()",
testval.jsclass,
(javaval).toString() );
new TestCase( SECTION,
"(" + testval.description +").toString()",
testval.jsclass,
(javaval).toString() );
// Boolean( package ) is true
testcases[testcases.length] = new TestCase( SECTION,
"Boolean (" + testval.description +")",
true,
Boolean( javaval ) );
new TestCase( SECTION,
"Boolean (" + testval.description +")",
true,
Boolean( javaval ) );
// add 0 is name + "0"
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +") +0",
testval.jsclass +"0",
javaval + 0);
new TestCase( SECTION,
"(" + testval.description +") +0",
testval.jsclass +"0",
javaval + 0);
}
function JavaValue( value ) {
this.value = value;
this.type = typeof value;
this.getJSClass = Object.prototype.toString;
this.jsclass = value +""
return this;
return this;
}
function TestValue( description ) {
this.packagename = (description.substring(0, "Packages.".length) ==
"Packages.") ? description.substring("Packages.".length, description.length ) :
"Packages.") ? description.substring("Packages.".length, description.length ) :
description;
this.description = description;
@ -130,16 +130,3 @@ function TestValue( description ) {
this.jsclass = E_JSCLASS + this.packagename +"]";
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,92 +35,91 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: package-005.js
Description:
File Name: package-005.js
Description:
Access a package property that does not exist.
Access a package property that does not exist.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var error = err;
var SECTION = "LiveConnect Packages";
var VERSION = "1_3";
var TITLE = "LiveConnect Packages";
var testcases = new Array();
var SECTION = "LiveConnect Packages";
var VERSION = "1_3";
var TITLE = "LiveConnect Packages";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var util = java.util;
var v = new util.Vector();
var util = java.util;
var v = new util.Vector();
testcases[testcases.length] = new TestCase( SECTION,
"java.util[\"0\"]",
void 0,
java.util["0"] );
new TestCase( SECTION,
"java.util[\"0\"]",
void 0,
java.util["0"] );
testcases[testcases.length] = new TestCase( SECTION,
"java.util[1]",
void 0,
java.util[1] );
new TestCase( SECTION,
"java.util[1]",
void 0,
java.util[1] );
test();
test();
function CompareValues( javaval, testval ) {
// Check typeof, which should be E_TYPE
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
// Check JavaScript class, which should be E_JSCLASS + the package name
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +").getJSClass()",
testval.jsclass,
javaval.getJSClass() );
new TestCase( SECTION,
"(" + testval.description +").getJSClass()",
testval.jsclass,
javaval.getJSClass() );
// Number( package ) is NaN
testcases[testcases.length] = new TestCase( SECTION,
"Number (" + testval.description +")",
NaN,
Number( javaval ) );
new TestCase( SECTION,
"Number (" + testval.description +")",
NaN,
Number( javaval ) );
// String( package ) is string value
testcases[testcases.length] = new TestCase( SECTION,
"String (" + testval.description +")",
testval.jsclass,
String(javaval) );
new TestCase( SECTION,
"String (" + testval.description +")",
testval.jsclass,
String(javaval) );
// ( package ).toString() is string value
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +").toString()",
testval.jsclass,
(javaval).toString() );
new TestCase( SECTION,
"(" + testval.description +").toString()",
testval.jsclass,
(javaval).toString() );
// Boolean( package ) is true
testcases[testcases.length] = new TestCase( SECTION,
"Boolean (" + testval.description +")",
true,
Boolean( javaval ) );
new TestCase( SECTION,
"Boolean (" + testval.description +")",
true,
Boolean( javaval ) );
// add 0 is name + "0"
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +") +0",
testval.jsclass +"0",
javaval + 0);
new TestCase( SECTION,
"(" + testval.description +") +0",
testval.jsclass +"0",
javaval + 0);
}
function JavaValue( value ) {
this.value = value;
this.type = typeof value;
this.getJSClass = Object.prototype.toString;
this.jsclass = value +""
return this;
return this;
}
function TestValue( description ) {
this.packagename = (description.substring(0, "Packages.".length) ==
"Packages.") ? description.substring("Packages.".length, description.length ) :
"Packages.") ? description.substring("Packages.".length, description.length ) :
description;
this.description = description;
@ -127,16 +127,3 @@ function TestValue( description ) {
this.jsclass = E_JSCLASS + this.packagename +"]";
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,45 +35,31 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: package-006.js
Description:
File Name: package-006.js
Description:
Access a package property that does not exist.
Access a package property that does not exist.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var error = err;
var SECTION = "LiveConnect Packages";
var VERSION = "1_3";
var TITLE = "LiveConnect Packages";
var testcases = new Array();
var SECTION = "LiveConnect Packages";
var VERSION = "1_3";
var TITLE = "LiveConnect Packages";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var util = java.util;
var v = new util.Vector();
var util = java.util;
var v = new util.Vector();
testcases[testcases.length] = new TestCase( SECTION,
"java.util[1]",
void 0,
java.util[1] );
new TestCase( SECTION,
"java.util[1]",
void 0,
java.util[1] );
test();
test();
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -34,86 +34,85 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: package-003.js
Description:
File Name: package-007-n.js
Description:
Set the package name to a JavaScript variable, and attempt to access
classes relative to the package name.
Set the package name to a JavaScript variable, and attempt to access
classes relative to the package name.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect Packages";
var VERSION = "1_3";
var TITLE = "LiveConnect Packages";
var SECTION = "LiveConnect Packages";
var VERSION = "1_3";
var TITLE = "LiveConnect Packages";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
java.util[0] ="hi";
java.util["x"] = "bye";
java.util[0] ="hi";
java.util["x"] = "bye";
new TestCase( SECTION,
"java.util[0] = \"hi\"; typeof java.util[0]",
"undefined",
typeof java.util[0] );
testcases[testcases.length] = new TestCase( SECTION,
"java.util[0] = \"hi\"; typeof java.util[0]",
"undefined",
typeof java.util[0] );
test();
test();
function CompareValues( javaval, testval ) {
// Check typeof, which should be E_TYPE
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
// Check JavaScript class, which should be E_JSCLASS + the package name
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +").getJSClass()",
testval.jsclass,
javaval.getJSClass() );
new TestCase( SECTION,
"(" + testval.description +").getJSClass()",
testval.jsclass,
javaval.getJSClass() );
// Number( package ) is NaN
testcases[testcases.length] = new TestCase( SECTION,
"Number (" + testval.description +")",
NaN,
Number( javaval ) );
new TestCase( SECTION,
"Number (" + testval.description +")",
NaN,
Number( javaval ) );
// String( package ) is string value
testcases[testcases.length] = new TestCase( SECTION,
"String (" + testval.description +")",
testval.jsclass,
String(javaval) );
new TestCase( SECTION,
"String (" + testval.description +")",
testval.jsclass,
String(javaval) );
// ( package ).toString() is string value
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +").toString()",
testval.jsclass,
(javaval).toString() );
new TestCase( SECTION,
"(" + testval.description +").toString()",
testval.jsclass,
(javaval).toString() );
// Boolean( package ) is true
testcases[testcases.length] = new TestCase( SECTION,
"Boolean (" + testval.description +")",
true,
Boolean( javaval ) );
new TestCase( SECTION,
"Boolean (" + testval.description +")",
true,
Boolean( javaval ) );
// add 0 is name + "0"
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +") +0",
testval.jsclass +"0",
javaval + 0);
new TestCase( SECTION,
"(" + testval.description +") +0",
testval.jsclass +"0",
javaval + 0);
}
function JavaValue( value ) {
this.value = value;
this.type = typeof value;
this.getJSClass = Object.prototype.toString;
this.jsclass = value +""
return this;
return this;
}
function TestValue( description ) {
this.packagename = (description.substring(0, "Packages.".length) ==
"Packages.") ? description.substring("Packages.".length, description.length ) :
"Packages.") ? description.substring("Packages.".length, description.length ) :
description;
this.description = description;
@ -121,16 +120,3 @@ function TestValue( description ) {
this.jsclass = E_JSCLASS + this.packagename +"]";
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,85 +35,84 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: package-003.js
Description:
File Name: package-008-n.js
Description:
Set the package name to a JavaScript variable, and attempt to access
classes relative to the package name.
Set the package name to a JavaScript variable, and attempt to access
classes relative to the package name.
@author christine@netscape.com
@version 1.00
@author christine@netscape.com
@version 1.00
*/
var SECTION = "LiveConnect Packages";
var VERSION = "1_3";
var TITLE = "LiveConnect Packages";
var SECTION = "LiveConnect Packages";
var VERSION = "1_3";
var TITLE = "LiveConnect Packages";
var testcases = new Array();
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
java.util[0] ="hi";
java.util["x"] = "bye";
java.util[0] ="hi";
java.util["x"] = "bye";
testcases[testcases.length] = new TestCase( SECTION,
"String(java.util[\"x\"])",
"[JavaPackage java.util.x]",
String(java.util["x"]) );
test();
new TestCase( SECTION,
"String(java.util[\"x\"])",
"[JavaPackage java.util.x]",
String(java.util["x"]) );
test();
function CompareValues( javaval, testval ) {
// Check typeof, which should be E_TYPE
testcases[testcases.length] = new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
new TestCase( SECTION,
"typeof (" + testval.description +")",
testval.type,
javaval.type );
// Check JavaScript class, which should be E_JSCLASS + the package name
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +").getJSClass()",
testval.jsclass,
javaval.getJSClass() );
new TestCase( SECTION,
"(" + testval.description +").getJSClass()",
testval.jsclass,
javaval.getJSClass() );
// Number( package ) is NaN
testcases[testcases.length] = new TestCase( SECTION,
"Number (" + testval.description +")",
NaN,
Number( javaval ) );
new TestCase( SECTION,
"Number (" + testval.description +")",
NaN,
Number( javaval ) );
// String( package ) is string value
testcases[testcases.length] = new TestCase( SECTION,
"String (" + testval.description +")",
testval.jsclass,
String(javaval) );
new TestCase( SECTION,
"String (" + testval.description +")",
testval.jsclass,
String(javaval) );
// ( package ).toString() is string value
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +").toString()",
testval.jsclass,
(javaval).toString() );
new TestCase( SECTION,
"(" + testval.description +").toString()",
testval.jsclass,
(javaval).toString() );
// Boolean( package ) is true
testcases[testcases.length] = new TestCase( SECTION,
"Boolean (" + testval.description +")",
true,
Boolean( javaval ) );
new TestCase( SECTION,
"Boolean (" + testval.description +")",
true,
Boolean( javaval ) );
// add 0 is name + "0"
testcases[testcases.length] = new TestCase( SECTION,
"(" + testval.description +") +0",
testval.jsclass +"0",
javaval + 0);
new TestCase( SECTION,
"(" + testval.description +") +0",
testval.jsclass +"0",
javaval + 0);
}
function JavaValue( value ) {
this.value = value;
this.type = typeof value;
this.getJSClass = Object.prototype.toString;
this.jsclass = value +""
return this;
return this;
}
function TestValue( description ) {
this.packagename = (description.substring(0, "Packages.".length) ==
"Packages.") ? description.substring("Packages.".length, description.length ) :
"Packages.") ? description.substring("Packages.".length, description.length ) :
description;
this.description = description;
@ -120,16 +120,3 @@ function TestValue( description ) {
this.jsclass = E_JSCLASS + this.packagename +"]";
return this;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

0
js/tests/lc2/Packages/shell.js Executable file
Просмотреть файл

1
js/tests/lc2/README Executable file
Просмотреть файл

@ -0,0 +1 @@
LiveConnect 2

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -37,124 +38,110 @@
var completed = false;
var testcases;
var TT = "<tt>";
var TT_ = "<tt>";
var BR = "<br>";
var NBSP = "&nbsp;";
var CR = "\n";
var FONT = "";
var FONT_ = "</font>";
var FONT_RED = "<font color=\"red\">";
var FONT_GREEN = "<font color=\"green\">";
var B = "<b>";
var B_ = "</b>"
var H2 = "<h2>";
var H2_ = "</h2>";
var HR = "<hr>";
SECTION = "";
VERSION = "";
BUGNUMBER = "";
DEBUG = false;
TZ_DIFF = -8;
var GLOBAL = "[object Window]";
var HTML_OUTPUT = false;
function TestCase( n, d, e, a ) {
this.name = n;
this.description = d;
this.expect = e;
this.actual = a;
this.reason = "";
this.bugnumber = BUGNUMBER;
this.passed = getTestCaseResult( this.expect, this.actual );
}
function startTest() {
// document.open();
}
function getTestCaseResult( expect, actual ) {
// because ( NaN == NaN ) always returns false, need to do
// a special compare to see if we got the right result.
if ( actual != actual ) {
if ( typeof actual == "object" ) {
actual = "NaN object";
} else {
actual = "NaN number";
}
}
if ( expect != expect ) {
if ( typeof expect == "object" ) {
expect = "NaN object";
} else {
expect = "NaN number";
}
}
var passed = ( expect == actual ) ? true : false;
// if both objects are numbers, give a little leeway for rounding.
if ( !passed
&& typeof(actual) == "number"
&& typeof(expect) == "number"
) {
if ( Math.abs(actual-expect) < 0.0000001 ) {
passed = true;
}
}
// verify type is the same
if ( typeof(expect) != typeof(actual) ) {
passed = false;
}
return passed;
}
function writeTestCaseResult( expect, actual, string ) {
var passed = getTestCaseResult( expect, actual );
writeFormattedResult( expect, actual, string, passed );
return passed;
}
function writeFormattedResult( expect, actual, string, passed ) {
var s = "<tt >" + string ;
for ( k = 0;
k < (60 - string.length >= 0 ? 60 - string.length : 5) ;
k++ ) {
s += "&nbsp;" ;
}
s += "<b ><font color=" ;
s += (( passed ) ? "'#009900' >&nbsp;PASSED!"
: "'#990000' >&nbsp;FAILED: expected </tt><tt >" +
expect ) + "</tt>";
writeLineToLog( s + "</font ></b ></tt >" );
return passed;
}
function writeLineToLog( string ) {
document.write( string + "<br>\n" );
document.write( string + "<br>\n" );
}
function writeHeaderToLog( string ) {
document.write( "<h2>" + string + "</h2>\n" );
document.write( "<h2>" + string + "</h2>\n" );
}
function stopTest() {
// document.write("<hr>");
// document.close();
completed = true;
function writeFormattedResult( expect, actual, string, passed ) {
var s = "<tt>"+ string ;
s += "<b>" ;
s += ( passed ) ? "<font color=#009900> &nbsp;" + PASSED
: "<font color=#aa0000>&nbsp;" + FAILED + expect + "</tt>";
writeLineToLog( s + "</font></b></tt>" );
return passed;
}
function ToInteger( t ) {
t = Number( t );
t = Number( t );
if ( isNaN( t ) ){
return ( Number.NaN );
}
if ( t == 0 || t == -0 ||
t == Number.POSITIVE_INFINITY || t == Number.NEGATIVE_INFINITY ) {
return 0;
}
if ( isNaN( t ) ){
return ( Number.NaN );
}
if ( t == 0 || t == -0 ||
t == Number.POSITIVE_INFINITY || t == Number.NEGATIVE_INFINITY ) {
return 0;
}
var sign = ( t < 0 ) ? -1 : 1;
var sign = ( t < 0 ) ? -1 : 1;
return ( sign * Math.floor( Math.abs( t ) ) );
return ( sign * Math.floor( Math.abs( t ) ) );
}
function Enumerate ( o ) {
var p;
for ( p in o ) {
print( p +": " + o[p] );
}
var p;
for ( p in o ) {
writeLineToLog( p +": " + o[p] );
}
}
/*
* The earlier versions of the test code used exceptions
* to terminate the test script in "negative" test cases
* before the failure reporting code could run. In order
* to be able to capture errors for the "negative" case
* where the exception is a sign the test actually passed,
* the err online handler will assume that any error is a
* failure unless gExceptionExpected is true.
*/
window.onerror = err;
var gExceptionExpected = false;
function err( msg, page, line ) {
var testcase;
if (typeof(EXPECTED) == "undefined" || EXPECTED != "error") {
/*
* an unexpected exception occured
*/
writeLineToLog( "Test failed with the message: " + msg );
testcase = new TestCase(SECTION, "unknown", "unknown", "unknown");
testcase.passed = false;
testcase.reason = "Error: " + msg +
" Source File: " + page + " Line: " + line + ".";
return;
}
if (typeof SECTION == 'undefined')
{
SECTION = 'Unknown';
}
if (typeof DESCRIPTION == 'undefined')
{
DESCRIPTION = 'Unknown';
}
if (typeof EXPECTED == 'undefined')
{
EXPECTED = 'Unknown';
}
testcase = new TestCase(SECTION, DESCRIPTION, EXPECTED, "error");
testcase.reason += "Error: " + msg +
" Source File: " + page + " Line: " + line + ".";
stopTest();
}
var gVersion = 0;
function version(v)
{
if (v) {
gVersion = v;
}
return gVersion;
}

0
js/tests/lc2/misc/browser.js Executable file
Просмотреть файл

Просмотреть файл

@ -43,73 +43,58 @@
* @author cbegle and mikeang
*/
var SECTION = "wrapUnwrap.js";
var VERSION = "JS1_3";
var TITLE = "LiveConnect";
var SECTION = "wrapUnwrap.js";
var VERSION = "JS1_3";
var TITLE = "LiveConnect";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = new Array();
var char_object = java.lang.Character.forDigit(22, 36);
test_typeof( "string", char_object+"a" );
var char_object = java.lang.Character.forDigit(22, 36);
test_typeof( "string", char_object+"a" );
var boolean_object = new java.lang.Boolean( true );
test_class( "java.lang.Boolean", boolean_object );
var boolean_object = new java.lang.Boolean( true );
test_class( "java.lang.Boolean", boolean_object );
var boolean_object = new java.lang.Boolean( false );
test_class( "java.lang.Boolean", boolean_object );
var boolean_object = new java.lang.Boolean( false );
test_class( "java.lang.Boolean", boolean_object );
var integer_object = new java.lang.Integer( 12345 );
test_class( "java.lang.Integer", integer_object );
var integer_object = new java.lang.Integer( 12345 );
test_class( "java.lang.Integer", integer_object );
var string_object = new java.lang.String( "string object value" );
test_class( "java.lang.String", string_object );
var string_object = new java.lang.String( "string object value" );
test_class( "java.lang.String", string_object );
// This doesn't work - bug #105857
var float_object = new java.lang.Float( .009 * .009 );
test_class( "java.lang.Float", float_object );
// This doesn't work - bug #105857
var float_object = new java.lang.Float( .009 * .009 );
test_class( "java.lang.Float", float_object );
var double_object = new java.lang.Double( java.lang.Math.PI );
test_class( "java.lang.Double", double_object );
var double_object = new java.lang.Double( java.lang.Math.PI );
test_class( "java.lang.Double", double_object );
var long_object = new java.lang.Long( 92233720368547760 );
test_class( "java.lang.Long", long_object );
var long_object = new java.lang.Long( 92233720368547760 );
test_class( "java.lang.Long", long_object );
var rect_object = new java.awt.Rectangle( 0, 0, 100, 100 );
test_class ( "java.awt.Rectangle", rect_object );
var rect_object = new java.awt.Rectangle( 0, 0, 100, 100 );
test_class ( "java.awt.Rectangle", rect_object );
test();
test();
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}
function test_typeof( eType, someObject ) {
testcases[testcases.length] = new TestCase( SECTION,
"typeof( " +someObject+")",
eType,
typeof someObject );
new TestCase( SECTION,
"typeof( " +someObject+")",
eType,
typeof someObject );
}
/**
* Implements Java instanceof keyword.
*/
function test_class( eClass, javaObject ) {
testcases[testcases.length] = new TestCase( SECTION,
javaObject +".getClass().equals( java.lang.Class.forName( " +
eClass +")",
true,
(javaObject.getClass()).equals( java.lang.Class.forName(eClass)) );
}
new TestCase( SECTION,
javaObject +".getClass().equals( java.lang.Class.forName( " +
eClass +")",
true,
(javaObject.getClass()).equals( java.lang.Class.forName(eClass)) );
}

0
js/tests/lc2/misc/shell.js Executable file
Просмотреть файл

Просмотреть файл

@ -34,33 +34,31 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: wrapUnwrap.js
Section: LiveConnect
Description:
Tests wrapping and unwrapping objects.
@author mikeang
/**
File Name: wrapUnwrap.js
Section: LiveConnect
Description:
Tests wrapping and unwrapping objects.
@author mikeang
*/
var SECTION = "wrapUnwrap.js";
var VERSION = "JS1_3";
var TITLE = "LiveConnect";
var SECTION = "wrapUnwrap.js";
var VERSION = "JS1_3";
var TITLE = "LiveConnect";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = new Array();
var hashtable = new java.util.Hashtable();
var sameHashtable = hashtable;
var hashtable = new java.util.Hashtable();
var sameHashtable = hashtable;
jsEquals(hashtable,sameHashtable);
javaEquals(hashtable,sameHashtable);
function returnString(theString) {
return theString;
return theString;
}
var someString = new java.lang.String("foo");
var sameString = returnString(someString);
@ -73,9 +71,9 @@ jsEquals(someString,assignToProperty.assignedString);
javaEquals(someString,assignToProperty.assignedString);
function laConstructor(a,b,c) {
this.one = a;
this.two = b;
this.three = c;
this.one = a;
this.two = b;
this.three = c;
}
var stack1 = new java.util.Stack();
var stack2 = new java.util.Stack();
@ -85,32 +83,18 @@ javaEquals(stack1, constructed.one);
javaEquals(stack2, constructed.two);
jsEquals(num, constructed.three);
test();
test();
function jsEquals(expectedResult, actualResult, message) {
testcases[testcases.length] = new TestCase( SECTION,
expectedResult +" == "+actualResult,
expectedResult,
actualResult );
new TestCase( SECTION,
expectedResult +" == "+actualResult,
expectedResult,
actualResult );
}
function javaEquals(expectedResult, actualResult, message) {
testcases[testcases.length] = new TestCase( SECTION,
expectedResult +" == "+actualResult,
expectedResult,
actualResult );
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
new TestCase( SECTION,
expectedResult +" == "+actualResult,
expectedResult,
actualResult );
}

Просмотреть файл

@ -1,9 +1,39 @@
var completed = false;
var testcases;
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
SECTION = "";
VERSION = "";
BUGNUMBER="";
/*
* JavaScript shared functions file for running the tests in either
* stand-alone JavaScript engine. To run a test, first load this file,
* then load the test script.
*/
var completed = false;
var testcases = new Array();
var tc = testcases.length;
var SECTION = "";
var VERSION = "";
var BUGNUMBER="";
var TT = "";
var TT_ = "";
@ -25,121 +55,197 @@ var HR = "";
var PASSED = " PASSED!"
var FAILED = " FAILED! expected: ";
var DEBUG = false;
/*
* wrapper for test case constructor that doesn't require the SECTION
* argument.
*/
function AddTestCase( description, expect, actual ) {
new TestCase( SECTION, description, expect, actual );
}
/*
* TestCase constructor
*
*/
function TestCase( n, d, e, a ) {
this.name = n;
this.description = d;
this.expect = e;
this.actual = a;
this.passed = true;
this.reason = "";
this.bugnumber = BUGNUMBER;
this.name = n;
this.description = d;
this.expect = e;
this.actual = a;
this.passed = true;
this.reason = "";
this.bugnumber = BUGNUMBER;
this.passed = getTestCaseResult( this.expect, this.actual );
this.passed = getTestCaseResult( this.expect, this.actual );
if ( DEBUG ) {
writeLineToLog( "added " + this.description );
}
/*
* testcases are solely maintained in the TestCase
* constructor. tc will _always_ point to one past the
* last testcase. If an exception occurs during the call
* to the constructor, then we are assured that the tc
* index has not been incremented.
*/
testcases[tc++] = this;
}
/*
* Set up test environment.
*
*/
function startTest() {
// JavaScript 1.3 is supposed to be compliant ecma version 1.0
if ( VERSION == "ECMA_1" ) {
version ( "130" );
}
if ( VERSION == "JS_1.3" ) {
version ( "130" );
}
if ( VERSION == "JS_1.2" ) {
version ( "120" );
}
if ( VERSION == "JS_1.1" ) {
version ( "110" );
}
// for ecma version 2.0, we will leave the javascript version to
// the default ( for now ).
// JavaScript 1.3 is supposed to be compliant ecma version 1.0
if ( VERSION == "ECMA_1" ) {
version ( "130" );
}
if ( VERSION == "JS_1.3" ) {
version ( "130" );
}
if ( VERSION == "JS_1.2" ) {
version ( "120" );
}
if ( VERSION == "JS_1.1" ) {
version ( "110" );
}
// for ecma version 2.0, we will leave the javascript version to
// the default ( for now ).
writeHeaderToLog( SECTION + " "+ TITLE);
if ( BUGNUMBER ) {
writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
}
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
try
{
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
catch(e)
{
writeLineToLog('test(): empty testcase for tc = ' + tc + ' ' + e);
}
}
stopTest();
return ( testcases );
}
/*
* Compare expected result to the actual result and figure out whether
* the test case passed.
*/
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";
}
}
// 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;
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;
}
}
// 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;
}
// verify type is the same
if ( typeof(expect) != typeof(actual) ) {
passed = false;
}
return passed;
return passed;
}
/*
* Begin printing functions. These functions use the shell's
* print function. When running tests in the browser, these
* functions, override these functions with functions that use
* document.write.
*/
function writeTestCaseResult( expect, actual, string ) {
var passed = getTestCaseResult( expect, actual );
writeFormattedResult( expect, actual, string, passed );
return passed;
var passed = getTestCaseResult( expect, actual );
writeFormattedResult( expect, actual, string, passed );
return passed;
}
function writeFormattedResult( expect, actual, string, passed ) {
var s = TT + string ;
var s = TT + string ;
for ( k = 0;
k < (60 - string.length >= 0 ? 60 - string.length : 5) ;
k++ ) {
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_ ;
s += B ;
s += ( passed ) ? FONT_GREEN + NBSP + PASSED : FONT_RED + NBSP + FAILED + expect + TT_ ;
writeLineToLog( s + FONT_ + B_ + TT_ );
writeLineToLog( s + FONT_ + B_ + TT_ );
return passed;
return passed;
}
function writeLineToLog( string ) {
print( string + BR + CR );
print( string + BR + CR );
}
function writeHeaderToLog( string ) {
print( H2 + string + H2_ );
print( H2 + string + H2_ );
}
/*
* When running in the shell, run the garbage collector after the
* test has completed.
*/
function stopTest() {
print( HR );
var gc;
if ( gc != undefined ) {
gc();
}
writeLineToLog( HR );
var gc;
if ( gc != undefined ) {
gc();
}
completed = true;
}
/*
* Convenience function for displaying failed test cases. Useful
* when running tests manually.
*
*/
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 );
}
if ( ! testcases[i].passed ) {
writeLineToLog ( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect );
}
}
}
function err( msg, page, line ) {
testcases[tc].actual = "error";
testcases[tc].reason = msg;
writeTestCaseResult( testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+ testcases[tc].actual +
": " + testcases[tc].reason );
stopTest();
return true;
}