Debian Codegraph @

rhino/testsrc/tests/lc2/JSToJava/long-003-n.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 gTestfile = 'long-003-n.js';
7
8 /**
9 Template for LiveConnect Tests
10
11 File Name: number-001.js
12 Description:
13
14 This test fails in lc3, but will succeed if the underlying version
15 of liveconnect only supports LC2.
16
17 @author [email protected]
18 @version 1.00
19 */
20 var SECTION = "LiveConnect";
21 var VERSION = "1_3";
22 var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
23
24 startTest();
25 writeHeaderToLog( SECTION + " "+ TITLE);
26
27 // typeof all resulting objects is "object";
28 var E_TYPE = "object";
29
30 // JS class of all resulting objects is "JavaObject";
31 var E_JSCLASS = "[object JavaObject]";
32
33 var a = new Array();
34 var i = 0;
35
36 a[i++] = new TestObject( "java.lang.Long.toString(NaN)",
37 java.lang.Long.toString(NaN), "0" );
38
39 for ( var i = 0; i < a.length; i++ ) {
40
41 // check typeof
42 new TestCase(
43 SECTION,
44 "typeof (" + a[i].description +")",
45 a[i].type,
46 typeof a[i].javavalue );
47 /*
48 // check the js class
49 new TestCase(
50 SECTION,
51 "("+ a[i].description +").getJSClass()",
52 E_JSCLASS,
53 a[i].jsclass );
54 */
55 // check the number value of the object
56 new TestCase(
57 SECTION,
58 "String(" + a[i].description +")",
59 a[i].jsvalue,
60 String( a[i].javavalue ) );
61 }
62
63 test();
64
65 function TestObject( description, javavalue, jsvalue ) {
66 this.description = description;
67 this.javavalue = javavalue;
68 this.jsvalue = jsvalue;
69 this.type = E_TYPE;
70 // LC2 does not support the __proto__ property in Java objects.
71 // this.javavalue.__proto__.getJSClass = Object.prototype.toString;
72 // this.jsclass = this.javavalue.getJSClass();
73 return this;
74 }