Debian Codegraph @

rhino/testsrc/tests/ecma_3/Object/class-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 /*
7 * Date: 14 Mar 2001
8 *
9 * SUMMARY: Testing the internal [[Class]] property of user-defined types.
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 user-defined types here, not
13 * native types. Therefore we expect the [[Class]] property to equal
14 * 'Object' 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-005.js';
20 var i = 0;
21 var UBound = 0;
22 var BUGNUMBER = '(none)';
23 var summary = 'Testing the internal [[Class]] property of user-defined types';
24 var statprefix = 'Current user-defined type is: ';
25 var status = ''; var statusList = [ ];
26 var actual = ''; var actualvalue = [ ];
27 var expect= ''; var expectedvalue = [ ];
28
29
30 Calf.prototype= new Cow();
31
32 /*
33 * We set the expect variable each time only for readability.
34 * We expect 'Object' every time; see discussion above -
35 */
36 status = 'new Cow()';
37 actual = getJSClass(new Cow());
38 expect = 'Object';
39 addThis();
40
41 status = 'new Calf()';
42 actual = getJSClass(new Calf());
43 expect = 'Object';
44 addThis();
45
46
47 //---------------------------------------------------------------------------------
48 test();
49 //---------------------------------------------------------------------------------
50
51
52 function addThis()
53 {
54 statusList[UBound] = status;
55 actualvalue[UBound] = actual;
56 expectedvalue[UBound] = expect;
57 UBound++;
58 }
59
60
61 function test()
62 {
63 enterFunc ('test');
64 printBugNumber(BUGNUMBER);
65 printStatus (summary);
66
67 for (i = 0; i < UBound; i++)
68 {
69 reportCompare(expectedvalue[i], actualvalue[i], getStatus(i));
70 }
71
72 exitFunc ('test');
73 }
74
75
76 function getStatus(i)
77 {
78 return statprefix + statusList[i];
79 }
80
81
82 function Cow(name)
83 {
84 this.name=name;
85 }
86
87
88 function Calf(name)
89 {
90 this.name=name;
91 }