Debian Codegraph @

rhino/testsrc/tests/lc3/JSNull/ToBoolean-001-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 = 'ToBoolean-001-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 = "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 results in an error.
44
45 DESCRIPTION = "dt.setBoolean( null )";
46 EXPECTED = "error";
47
48 a[i++] = new TestObject(
49 "dt.setBoolean( null )",
50 "dt.PUB_BOOLEAN",
51 "dt.getBoolean()",
52 "typeof dt.getBoolean()",
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 }