Debian Codegraph @

rhino/testsrc/tests/ecma_3/Object/class-002.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 /*
7 * Date: 14 Mar 2001
8 *
9 * SUMMARY: Testing the [[Class]] property of native constructors.
10 * See ECMA-262 Edition 3 13-Oct-1999, Section 8.6.2 re [[Class]] property.
11 *
12 * Same as class-001.js - but testing the constructors here, not
13 * object instances. Therefore we expect the [[Class]] property to
14 * equal 'Function' in each case.
15 *
16 * The getJSClass() function we use is in a utility file, e.g. "shell.js"
17 */
18 //-----------------------------------------------------------------------------
19 var gTestfile = 'class-002.js';
20 var i = 0;
21 var UBound = 0;
22 var BUGNUMBER = '(none)';
23 var summary = 'Testing the internal [[Class]] property of native constructors';
24 var statprefix = 'Current constructor is: ';
25 var status = ''; var statusList = [ ];
26 var actual = ''; var actualvalue = [ ];
27 var expect= ''; var expectedvalue = [ ];
28
29 /*
30 * We set the expect variable each time only for readability.
31 * We expect 'Function' every time; see discussion above -
32 */
33 status = 'Object';
34 actual = getJSClass(Object);
35 expect = 'Function';
36 addThis();
37
38 status = 'Function';
39 actual = getJSClass(Function);
40 expect = 'Function';
41 addThis();
42
43 status = 'Array';
44 actual = getJSClass(Array);
45 expect = 'Function';
46 addThis();
47
48 status = 'String';
49 actual = getJSClass(String);
50 expect = 'Function';
51 addThis();
52
53 status = 'Boolean';
54 actual = getJSClass(Boolean);
55 expect = 'Function';
56 addThis();
57
58 status = 'Number';
59 actual = getJSClass(Number);
60 expect = 'Function';
61 addThis();
62
63 status = 'Date';
64 actual = getJSClass(Date);
65 expect = 'Function';
66 addThis();
67
68 status = 'RegExp';
69 actual = getJSClass(RegExp);
70 expect = 'Function';
71 addThis();
72
73 status = 'Error';
74 actual = getJSClass(Error);
75 expect = 'Function';
76 addThis();
77
78
79
80 //---------------------------------------------------------------------------------
81 test();
82 //---------------------------------------------------------------------------------
83
84
85
86 function addThis()
87 {
88 statusList[UBound] = status;
89 actualvalue[UBound] = actual;
90 expectedvalue[UBound] = expect;
91 UBound++;
92 }
93
94
95 function test()
96 {
97 enterFunc ('test');
98 printBugNumber(BUGNUMBER);
99 printStatus (summary);
100
101 for (i = 0; i < UBound; i++)
102 {
103 reportCompare(expectedvalue[i], actualvalue[i], getStatus(i));
104 }
105
106 exitFunc ('test');
107 }
108
109
110 function getStatus(i)
111 {
112 return statprefix + statusList[i];
113 }