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