]>
Commit | Line | Data |
---|---|---|
b37bf2e1 A |
1 | /* The contents of this file are subject to the Netscape Public |
2 | * License Version 1.1 (the "License"); you may not use this file | |
3 | * except in compliance with the License. You may obtain a copy of | |
4 | * the License at http://www.mozilla.org/NPL/ | |
5 | * | |
6 | * Software distributed under the License is distributed on an "AS | |
7 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | |
8 | * implied. See the License for the specific language governing | |
9 | * rights and limitations under the License. | |
10 | * | |
11 | * The Original Code is Mozilla Communicator client code, released March | |
12 | * 31, 1998. | |
13 | * | |
14 | * The Initial Developer of the Original Code is Netscape Communications | |
15 | * Corporation. Portions created by Netscape are | |
16 | * Copyright (C) 1998 Netscape Communications Corporation. All | |
17 | * Rights Reserved. | |
18 | * | |
19 | * Contributor(s): | |
20 | * | |
21 | */ | |
22 | /** | |
23 | File Name: 15.2.2.2.js | |
24 | ECMA Section: 15.2.2.2 new Object() | |
25 | Description: | |
26 | ||
27 | When the Object constructor is called with no argument, the following | |
28 | step is taken: | |
29 | ||
30 | 1. Create a new native ECMAScript object. | |
31 | The [[Prototype]] property of the newly constructed object is set to | |
32 | the Object prototype object. | |
33 | ||
34 | The [[Class]] property of the newly constructed object is set | |
35 | to "Object". | |
36 | ||
37 | The newly constructed object has no [[Value]] property. | |
38 | ||
39 | Return the newly created native object. | |
40 | ||
41 | Author: christine@netscape.com | |
42 | Date: 7 october 1997 | |
43 | */ | |
44 | var SECTION = "15.2.2.2"; | |
45 | var VERSION = "ECMA_1"; | |
46 | startTest(); | |
47 | var TITLE = "new Object()"; | |
48 | ||
49 | writeHeaderToLog( SECTION + " "+ TITLE); | |
50 | ||
51 | var testcases = getTestCases(); | |
52 | test(); | |
53 | ||
54 | function getTestCases() { | |
55 | var array = new Array(); | |
56 | var item = 0; | |
57 | ||
58 | array[item++] = new TestCase( SECTION, "typeof new Object()", "object", typeof new Object() ); | |
59 | array[item++] = new TestCase( SECTION, "Object.prototype.toString()", "[object Object]", Object.prototype.toString() ); | |
60 | array[item++] = new TestCase( SECTION, "(new Object()).toString()", "[object Object]", (new Object()).toString() ); | |
61 | ||
62 | return ( array ); | |
63 | } | |
64 | function test() { | |
65 | for ( tc = 0; tc < testcases.length; tc++ ) { | |
66 | testcases[tc].passed = writeTestCaseResult( | |
67 | testcases[tc].expect, | |
68 | testcases[tc].actual, | |
69 | testcases[tc].description +" = "+ testcases[tc].actual ); | |
70 | ||
71 | testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; | |
72 | } | |
73 | stopTest(); | |
74 | return ( testcases ); | |
75 | } | |
76 | ||
77 | function MyObject( value ) { | |
78 | this.value = value; | |
79 | this.valueOf = new Function( "return this.value" ); | |
80 | this.toString = new Function( "return this.value+''" ); | |
81 | } |