Debian Codegraph @

rhino/testsrc/tests/lc3/JSNull/ToObject-001.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 = 'ToObject-001.js';
7
8 /* -*- Mode: java; tab-width: 8 -*-
9 * Copyright (C) 1997, 1998 Netscape Communications Corporation,
10 * All Rights Reserved.
11 */
12 /**
13 * JavaScript to Java type conversion.
14 *
15 * This test passes JavaScript number values to several Java methods
16 * that expect arguments of various types, and verifies that the value is
17 * converted to the correct value and type.
18 *
19 * This tests instance methods, and not static methods.
20 *
21 * Running these tests successfully requires you to have
22 * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath.
23 *
24 * Specification: Method Overloading Proposal for Liveconnect 3.0
25 *
26 * @author: [email protected]
27 *
28 */
29 var SECTION = "null";
30 var VERSION = "1_4";
31 var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " +
32 SECTION;
33 startTest();
34
35 var dt = new DT();
36
37 var a = new Array();
38 var i = 0;
39
40 // passing a JavaScript null to a method that expect a class or interface
41 // converts null to a java null. passing null to methods that expect
42 // number types convert null to 0. passing null to methods that expect
43 // a boolean convert null to false.
44
45 a[i++] = new TestObject(
46 "dt.setBooleanObject( null )",
47 "dt.PUB_BOOLEAN_OBJECT",
48 "dt.getBooleanObject()",
49 "typeof dt.getBooleanObject()",
50 null,
51 "object" );
52
53 a[i++] = new TestObject(
54 "dt.setDoubleObject( null )",
55 "dt.PUB_BOOLEAN_OBJECT",
56 "dt.getDoubleObject()",
57 "typeof dt.getDoubleObject()",
58 null,
59 "object" );
60
61 a[i++] = new TestObject(
62 "dt.setStringObject( null )",
63 "dt.PUB_STRING",
64 "dt.getStringObject()",
65 "typeof dt.getStringObject()",
66 null,
67 "object" );
68
69 for ( i = 0; i < a.length; i++ ) {
70 new TestCase(
71 a[i].description +"; "+ a[i].javaFieldName,
72 a[i].jsValue,
73 a[i].javaFieldValue );
74 /*
75 new TestCase(
76 a[i].description +"; " + a[i].javaMethodName,
77 a[i].jsValue,
78 a[i].javaMethodValue );
79 */
80 new TestCase(
81 a[i].javaTypeName,
82 a[i].jsType,
83 a[i].javaTypeValue );
84
85 }
86
87 test();
88
89 function TestObject( description, javaField, javaMethod, javaType,
90 jsValue, jsType )
91 {
92 eval (description );
93
94 this.description = description;
95 this.javaFieldName = javaField;
96 this.javaFieldValue = eval( javaField );
97 // this.javaMethodName = javaMethod;
98 // this.javaMethodValue = eval( javaMethod );
99 this.javaTypeName = javaType,
100 this.javaTypeValue = typeof this.javaFieldValue;
101
102 this.jsValue = jsValue;
103 this.jsType = jsType;
104 }