Debian Codegraph @

rhino/testsrc/tests/lc3/JSBoolean/boolean-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 = 'boolean-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 /**
14 * JavaScript to Java type conversion.
15 *
16 * This test passes JavaScript boolean values to several Java methods
17 * that expect arguments of various types, and verifies that the value is
18 * converted to the correct value and type.
19 *
20 * This tests instance methods, and not static methods.
21 *
22 * Running these tests successfully requires you to have
23 * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath.
24 *
25 * Specification: Method Overloading Proposal for Liveconnect 3.0
26 *
27 * @author: [email protected]
28 *
29 */
30 var SECTION = "boolean conversion";
31 var VERSION = "1_4";
32 var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " +
33 SECTION;
34 startTest();
35
36 var dt = new DT();
37
38 var a = new Array();
39 var i = 0;
40
41 // passing a boolean to a java method that expects a boolean should map
42 // directly to the Java true / false equivalent
43
44
45 // passing a boolean to a java method that expects a double
46 // should be an error
47
48 a[i++] = new TestObject(
49 "dt.setDouble( true )",
50 "dt.PUB_DOUBLE",
51 "dt.getDouble()",
52 "typeof dt.getDouble()",
53 "error",
54 "error" );
55
56 for ( i = 0; i < a.length; i++ ) {
57 new TestCase(
58 a[i].description +"; "+ a[i].javaFieldName,
59 a[i].jsValue,
60 a[i].javaFieldValue );
61
62 new TestCase(
63 a[i].description +"; " + a[i].javaMethodName,
64 a[i].jsValue,
65 a[i].javaMethodValue );
66
67 new TestCase(
68 a[i].javaTypeName,
69 a[i].jsType,
70 a[i].javaTypeValue );
71 }
72
73 test();
74
75 function TestObject( description, javaField, javaMethod, javaType,
76 jsValue, jsType )
77 {
78 eval (description );
79
80 this.description = description;
81 this.javaFieldName = javaField;
82 this.javaFieldValue = eval( javaField );
83 this.javaMethodName = javaMethod;
84 this.javaMethodValue = eval( javaMethod );
85 this.javaTypeName = javaType,
86 this.javaTypeValue = eval( javaType );
87
88 this.jsValue = jsValue;
89 this.jsType = jsType;
90 }