Debian Codegraph @

rhino/testsrc/tests/lc3/JSBoolean/boolean-006-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-006-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 an short
42 // should be an error
43
44 a[i++] = new TestObject(
45 "dt.setShort( true )",
46 "dt.PUB_SHORT",
47 "dt.getShort()",
48 "typeof dt.getShort()",
49 "error",
50 "error" );
51
52 for ( i = 0; i < a.length; i++ ) {
53 new TestCase(
54 a[i].description +"; "+ a[i].javaFieldName,
55 a[i].jsValue,
56 a[i].javaFieldValue );
57
58 new TestCase(
59 a[i].description +"; " + a[i].javaMethodName,
60 a[i].jsValue,
61 a[i].javaMethodValue );
62
63 new TestCase(
64 a[i].javaTypeName,
65 a[i].jsType,
66 a[i].javaTypeValue );
67 }
68
69 test();
70
71 function TestObject( description, javaField, javaMethod, javaType,
72 jsValue, jsType )
73 {
74 eval (description );
75
76 this.description = description;
77 this.javaFieldName = javaField;
78 this.javaFieldValue = eval( javaField );
79 this.javaMethodName = javaMethod;
80 this.javaMethodValue = eval( javaMethod );
81 this.javaTypeName = javaType,
82 this.javaTypeValue = eval( javaType );
83
84 this.jsValue = jsValue;
85 this.jsType = jsType;
86 }