Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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/. */
7 /**
8 File Name: 9.9-1.js
9 ECMA Section: 9.9 Type Conversion: ToObject
10 Description:
12 undefined generate a runtime error
13 null generate a runtime error
14 boolean create a new Boolean object whose default
15 value is the value of the boolean.
16 number Create a new Number object whose default
17 value is the value of the number.
18 string Create a new String object whose default
19 value is the value of the string.
20 object Return the input argument (no conversion).
21 Author: christine@netscape.com
22 Date: 17 july 1997
23 */
25 var VERSION = "ECMA_1";
26 startTest();
27 var SECTION = "9.9-1";
29 writeHeaderToLog( SECTION + " Type Conversion: ToObject" );
31 new TestCase( SECTION, "(Object(true)).__proto__", Boolean.prototype, (Object(true)).__proto__ );
33 new TestCase( SECTION, "(Object(true)).__proto__", Boolean.prototype, (Object(true)).__proto__ );
35 new TestCase( SECTION, "(Object(0)).__proto__", Number.prototype, (Object(0)).__proto__ );
37 new TestCase( SECTION, "(Object(-0)).__proto__", Number.prototype, (Object(-0)).__proto__ );
39 new TestCase( SECTION, "(Object(1)).__proto__", Number.prototype, (Object(1)).__proto__ );
41 new TestCase( SECTION, "(Object(-1)).__proto__", Number.prototype, (Object(-1)).__proto__ );
43 new TestCase( SECTION, "(Object(Number.MAX_VALUE)).__proto__", Number.prototype, (Object(Number.MAX_VALUE)).__proto__ );
45 new TestCase( SECTION, "(Object(Number.MIN_VALUE)).__proto__", Number.prototype, (Object(Number.MIN_VALUE)).__proto__ );
47 new TestCase( SECTION, "(Object(Number.POSITIVE_INFINITY)).__proto__", Number.prototype, (Object(Number.POSITIVE_INFINITY)).__proto__ );
49 new TestCase( SECTION, "(Object(Number.NEGATIVE_INFINITY)).__proto__", Number.prototype, (Object(Number.NEGATIVE_INFINITY)).__proto__ );
51 new TestCase( SECTION, "(Object(Number.NaN)).__proto__", Number.prototype, (Object(Number.NaN)).__proto__ );
53 new TestCase( SECTION, "(Object('a string')).__proto__", String.prototype, (Object("a string")).__proto__ );
55 new TestCase( SECTION, "(Object('')).__proto__", String.prototype, (Object("")).__proto__ );
57 new TestCase( SECTION, "(Object('\\r\\t\\b\\n\\v\\f')).__proto__", String.prototype, (Object("\\r\\t\\b\\n\\v\\f")).__proto__ );
59 new TestCase( SECTION, "Object( '\\\'\\\"\\' ).__proto__", String.prototype, (Object("\'\"\\")).__proto__ );
61 new TestCase( SECTION, "(Object( new MyObject(true) )).toString()", "[object Object]", eval("(Object( new MyObject(true) )).toString()") );
63 test();
65 function MyObject( value ) {
66 this.value = value;
67 this.valueOf = new Function ( "return this.value" );
68 }