Debian Codegraph @

rhino/testsrc/tests/lc2/Arrays/array-005.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 = 'array-005.js';
7
8 /**
9 File Name: array-005.js
10 Description:
11
12 Put and Get JavaArray Elements
13
14 @author [email protected]
15 @version 1.00
16 */
17 var SECTION = "LiveConnect";
18 var VERSION = "1_3";
19 var TITLE = "Java Array to JavaScript JavaArray object";
20
21 startTest();
22 writeHeaderToLog( SECTION + " "+ TITLE);
23
24 // In all test cases, the expected type is "object, and the expected
25 // class is "JavaArray"
26
27 var E_TYPE = "object";
28 var E_CLASS = "[object JavaArray]";
29
30 var byte_array = ( new java.lang.String("hi") ).getBytes();
31
32 new TestCase(
33 SECTION,
34 "byte_array = new java.lang.String(\"hi\")).getBytes(); delete byte_array.length",
35 false,
36 delete byte_array.length );
37
38 new TestCase(
39 SECTION,
40 "byte_array[0]",
41 ("hi").charCodeAt(0),
42 byte_array[0]);
43
44 new TestCase(
45 SECTION,
46 "byte_array[1]",
47 ("hi").charCodeAt(1),
48 byte_array[1]);
49
50 byte_array.length = 0;
51
52 new TestCase(
53 SECTION,
54 "byte_array.length = 0; byte_array.length",
55 2,
56 byte_array.length );
57
58 var properties = "";
59 for ( var p in byte_array ) {
60 properties += ( p == "length" ) ? p : "";
61 }
62
63 new TestCase(
64 SECTION,
65 "for ( var p in byte_array ) { properties += p ==\"length\" ? p : \"\" }; properties",
66 "",
67 properties );
68
69 new TestCase(
70 SECTION,
71 "byte_array[\"length\"]",
72 2,
73 byte_array["length"] );
74
75 byte_array["0"] = 127;
76
77 new TestCase(
78 SECTION,
79 "byte_array[\"0\"] = 127; byte_array[0]",
80 127,
81 byte_array[0] );
82
83 byte_array[1] = 99;
84
85 new TestCase(
86 SECTION,
87 "byte_array[1] = 99; byte_array[\"1\"]",
88 99,
89 byte_array["1"] );
90
91 test();
92