initial import
[vuplus_webkit] / Source / JavaScriptCore / 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/
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.1.2.js
24     ECMA Section:       15.2.1.2  The Object Constructor Called as a Function:
25                                   Object(value)
26     Description:        When Object is called as a function rather than as a
27                         constructor, the following steps are taken:
28
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:
34
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).
44
45     Author:             christine@netscape.com
46     Date:               17 july 1997
47 */
48
49     var SECTION = "15.2.1.2";
50     var VERSION = "ECMA_1";
51     startTest();
52     var TITLE   = "Object()";
53
54     writeHeaderToLog( SECTION + " "+ TITLE);
55
56     var testcases = getTestCases();
57     test();
58
59 function getTestCases() {
60     var array = new Array();
61     var item = 0;
62
63     var MYOB = Object();
64
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()") );
68
69     return ( array );
70 }
71
72 function test() {
73     for ( tc = 0; tc < testcases.length; tc++ ) {
74         testcases[tc].passed = writeTestCaseResult(
75                     testcases[tc].expect,
76                     testcases[tc].actual,
77                     testcases[tc].description +" = "+
78                     testcases[tc].actual );
79
80         testcases[tc].reason +=
81                     ( testcases[tc].passed ) ? "" : "wrong value ";
82     }
83     stopTest();
84     return ( testcases );
85 }