Debian Codegraph @

rhino/testsrc/tests/lc3/JavaObject/JavaObjectToBoolean-002-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 = 'JavaObjectToBoolean-002-n.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 = "JavaObject to boolean";
30 var VERSION = "1_2";
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 // If JavaScript 1.3 or later:
41 // return true
42
43 DESCRIPTION = "dt.PUB_BOOLEAN_REPRESENTATION = false ;";
44 EXPECTED = "error";
45
46 a[i++] = new TestObject (
47 "dt.PUB_BOOLEAN_REPRESENTATION = false ;"+
48 "dt.setBoolean( dt )",
49 "dt.PUB_BOOLEAN",
50 "dt.getBoolean()",
51 "typeof dt.getBoolean)",
52 "error",
53 "error" );
54 /*
55 a[i++] = new TestObject (
56 "dt.PUB_BOOLEAN_REPRESENTATION = true ;"+
57 "dt.setBoolean( dt )",
58 "dt.PUB_BOOLEAN",
59 "dt.getBoolean()",
60 "typeof dt.getBoolean)",
61 true,
62 "boolean" );
63 */
64 for ( i = 0; i < a.length; i++ ) {
65 new TestCase(
66 a[i].description +"; "+ a[i].javaFieldName,
67 a[i].jsValue,
68 a[i].javaFieldValue );
69
70 new TestCase(
71 a[i].description +"; " + a[i].javaMethodName,
72 a[i].jsValue,
73 a[i].javaMethodValue );
74
75 new TestCase(
76 a[i].javaTypeName,
77 a[i].jsType,
78 a[i].javaTypeValue );
79
80 }
81
82 test();
83
84 function TestObject( description, javaField, javaMethod, javaType,
85 jsValue, jsType )
86 {
87 eval (description );
88
89 this.description = description;
90 this.javaFieldName = javaField;
91 this.javaFieldValue = eval( javaField );
92 this.javaMethodName = javaMethod;
93 this.javaMethodValue = eval( javaMethod );
94 this.javaTypeName = javaType,
95 this.javaTypeValue = typeof this.javaFieldValue;
96
97 this.jsValue = jsValue;
98 this.jsType = jsType;
99 }