]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/ObjectObjects/15.2.1.2.js
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/
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.
11 * The Original Code is Mozilla Communicator client code, released March
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
23 File Name: 15.2.1.2.js
24 ECMA Section: 15.2.1.2 The Object Constructor Called as a Function:
26 Description: When Object is called as a function rather than as a
27 constructor, the following steps are taken:
29 1. If value is null or undefined, create and return a
30 new object with no proerties other than internal
31 properties exactly as if the object constructor
32 had been called on that same value (15.2.2.1).
33 2. Return ToObject (value), whose rules are:
35 undefined generate a runtime error
36 null generate a runtime error
37 boolean create a new Boolean object whose default
38 value is the value of the boolean.
39 number Create a new Number object whose default
40 value is the value of the number.
41 string Create a new String object whose default
42 value is the value of the string.
43 object Return the input argument (no conversion).
45 Author: christine@netscape.com
49 var SECTION
= "15.2.1.2";
50 var VERSION
= "ECMA_1";
52 var TITLE
= "Object()";
54 writeHeaderToLog( SECTION
+ " "+ TITLE
);
56 var testcases
= getTestCases();
59 function getTestCases() {
60 var array
= new Array();
65 array
[item
++] = new TestCase( SECTION
, "var MYOB = Object(); MYOB.valueOf()", MYOB
, MYOB
.valueOf() );
66 array
[item
++] = new TestCase( SECTION
, "typeof Object()", "object", typeof (Object(null)) );
67 array
[item
++] = new TestCase( SECTION
, "var MYOB = Object(); MYOB.toString()", "[object Object]", eval("var MYOB = Object(); MYOB.toString()") );
73 for ( tc
= 0; tc
< testcases
.length
; tc
++ ) {
74 testcases
[tc
].passed
= writeTestCaseResult(
77 testcases
[tc
].description
+" = "+
78 testcases
[tc
].actual
);
80 testcases
[tc
].reason
+=
81 ( testcases
[tc
].passed
) ? "" : "wrong value ";