js/src/tests/ecma/ObjectObjects/15.2.1.1.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6
michael@0 7 /**
michael@0 8 File Name: 15.2.1.1.js
michael@0 9 ECMA Section: 15.2.1.1 The Object Constructor Called as a Function:
michael@0 10 Object(value)
michael@0 11 Description: When Object is called as a function rather than as a
michael@0 12 constructor, the following steps are taken:
michael@0 13
michael@0 14 1. If value is null or undefined, create and return a
michael@0 15 new object with no properties other than internal
michael@0 16 properties exactly as if the object constructor
michael@0 17 had been called on that same value (15.2.2.1).
michael@0 18 2. Return ToObject (value), whose rules are:
michael@0 19
michael@0 20 undefined generate a runtime error
michael@0 21 null generate a runtime error
michael@0 22 boolean create a new Boolean object whose default
michael@0 23 value is the value of the boolean.
michael@0 24 number Create a new Number object whose default
michael@0 25 value is the value of the number.
michael@0 26 string Create a new String object whose default
michael@0 27 value is the value of the string.
michael@0 28 object Return the input argument (no conversion).
michael@0 29
michael@0 30 Author: christine@netscape.com
michael@0 31 Date: 17 july 1997
michael@0 32 */
michael@0 33
michael@0 34 var SECTION = "15.2.1.1";
michael@0 35 var VERSION = "ECMA_1";
michael@0 36 startTest();
michael@0 37 var TITLE = "Object( value )";
michael@0 38
michael@0 39 writeHeaderToLog( SECTION + " "+ TITLE);
michael@0 40
michael@0 41
michael@0 42 var NULL_OBJECT = Object(null);
michael@0 43
michael@0 44 new TestCase( SECTION, "Object(null).valueOf()", NULL_OBJECT, (NULL_OBJECT).valueOf() );
michael@0 45 new TestCase( SECTION, "typeof Object(null)", "object", typeof (Object(null)) );
michael@0 46
michael@0 47 var UNDEFINED_OBJECT = Object( void 0 );
michael@0 48
michael@0 49 new TestCase( SECTION, "Object(void 0).valueOf()", UNDEFINED_OBJECT, (UNDEFINED_OBJECT).valueOf() );
michael@0 50 new TestCase( SECTION, "typeof Object(void 0)", "object", typeof (Object(void 0)) );
michael@0 51
michael@0 52 new TestCase( SECTION, "Object(true).valueOf()", true, (Object(true)).valueOf() );
michael@0 53 new TestCase( SECTION, "typeof Object(true)", "object", typeof Object(true) );
michael@0 54 new TestCase( SECTION, "var MYOB = Object(true); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("var MYOB = Object(true); MYOB.toString = Object.prototype.toString; MYOB.toString()") );
michael@0 55
michael@0 56 new TestCase( SECTION, "Object(false).valueOf()", false, (Object(false)).valueOf() );
michael@0 57 new TestCase( SECTION, "typeof Object(false)", "object", typeof Object(false) );
michael@0 58 new TestCase( SECTION, "var MYOB = Object(false); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("var MYOB = Object(false); MYOB.toString = Object.prototype.toString; MYOB.toString()") );
michael@0 59
michael@0 60 new TestCase( SECTION, "Object(0).valueOf()", 0, (Object(0)).valueOf() );
michael@0 61 new TestCase( SECTION, "typeof Object(0)", "object", typeof Object(0) );
michael@0 62 new TestCase( SECTION, "var MYOB = Object(0); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(0); MYOB.toString = Object.prototype.toString; MYOB.toString()") );
michael@0 63
michael@0 64 new TestCase( SECTION, "Object(-0).valueOf()", -0, (Object(-0)).valueOf() );
michael@0 65 new TestCase( SECTION, "typeof Object(-0)", "object", typeof Object(-0) );
michael@0 66 new TestCase( SECTION, "var MYOB = Object(-0); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(-0); MYOB.toString = Object.prototype.toString; MYOB.toString()") );
michael@0 67
michael@0 68 new TestCase( SECTION, "Object(1).valueOf()", 1, (Object(1)).valueOf() );
michael@0 69 new TestCase( SECTION, "typeof Object(1)", "object", typeof Object(1) );
michael@0 70 new TestCase( SECTION, "var MYOB = Object(1); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(1); MYOB.toString = Object.prototype.toString; MYOB.toString()") );
michael@0 71
michael@0 72 new TestCase( SECTION, "Object(-1).valueOf()", -1, (Object(-1)).valueOf() );
michael@0 73 new TestCase( SECTION, "typeof Object(-1)", "object", typeof Object(-1) );
michael@0 74 new TestCase( SECTION, "var MYOB = Object(-1); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(-1); MYOB.toString = Object.prototype.toString; MYOB.toString()") );
michael@0 75
michael@0 76 new TestCase( SECTION, "Object(Number.MAX_VALUE).valueOf()", 1.7976931348623157e308, (Object(Number.MAX_VALUE)).valueOf() );
michael@0 77 new TestCase( SECTION, "typeof Object(Number.MAX_VALUE)", "object", typeof Object(Number.MAX_VALUE) );
michael@0 78 new TestCase( SECTION, "var MYOB = Object(Number.MAX_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.MAX_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()") );
michael@0 79
michael@0 80 new TestCase( SECTION, "Object(Number.MIN_VALUE).valueOf()", 5e-324, (Object(Number.MIN_VALUE)).valueOf() );
michael@0 81 new TestCase( SECTION, "typeof Object(Number.MIN_VALUE)", "object", typeof Object(Number.MIN_VALUE) );
michael@0 82 new TestCase( SECTION, "var MYOB = Object(Number.MIN_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.MIN_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()") );
michael@0 83
michael@0 84 new TestCase( SECTION, "Object(Number.POSITIVE_INFINITY).valueOf()", Number.POSITIVE_INFINITY, (Object(Number.POSITIVE_INFINITY)).valueOf() );
michael@0 85 new TestCase( SECTION, "typeof Object(Number.POSITIVE_INFINITY)", "object", typeof Object(Number.POSITIVE_INFINITY) );
michael@0 86 new TestCase( SECTION, "var MYOB = Object(Number.POSITIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.POSITIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()") );
michael@0 87
michael@0 88 new TestCase( SECTION, "Object(Number.NEGATIVE_INFINITY).valueOf()", Number.NEGATIVE_INFINITY, (Object(Number.NEGATIVE_INFINITY)).valueOf() );
michael@0 89 new TestCase( SECTION, "typeof Object(Number.NEGATIVE_INFINITY)", "object", typeof Object(Number.NEGATIVE_INFINITY) );
michael@0 90 new TestCase( SECTION, "var MYOB = Object(Number.NEGATIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.NEGATIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()") );
michael@0 91
michael@0 92 new TestCase( SECTION, "Object(Number.NaN).valueOf()", Number.NaN, (Object(Number.NaN)).valueOf() );
michael@0 93 new TestCase( SECTION, "typeof Object(Number.NaN)", "object", typeof Object(Number.NaN) );
michael@0 94 new TestCase( SECTION, "var MYOB = Object(Number.NaN); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.NaN); MYOB.toString = Object.prototype.toString; MYOB.toString()") );
michael@0 95
michael@0 96 new TestCase( SECTION, "Object('a string').valueOf()", "a string", (Object("a string")).valueOf() );
michael@0 97 new TestCase( SECTION, "typeof Object('a string')", "object", typeof (Object("a string")) );
michael@0 98 new TestCase( SECTION, "var MYOB = Object('a string'); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object('a string'); MYOB.toString = Object.prototype.toString; MYOB.toString()") );
michael@0 99
michael@0 100 new TestCase( SECTION, "Object('').valueOf()", "", (Object("")).valueOf() );
michael@0 101 new TestCase( SECTION, "typeof Object('')", "object", typeof (Object("")) );
michael@0 102 new TestCase( SECTION, "var MYOB = Object(''); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object(''); MYOB.toString = Object.prototype.toString; MYOB.toString()") );
michael@0 103
michael@0 104 new TestCase( SECTION, "Object('\\r\\t\\b\\n\\v\\f').valueOf()", "\r\t\b\n\v\f", (Object("\r\t\b\n\v\f")).valueOf() );
michael@0 105 new TestCase( SECTION, "typeof Object('\\r\\t\\b\\n\\v\\f')", "object", typeof (Object("\\r\\t\\b\\n\\v\\f")) );
michael@0 106 new TestCase( SECTION, "var MYOB = Object('\\r\\t\\b\\n\\v\\f'); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object('\\r\\t\\b\\n\\v\\f'); MYOB.toString = Object.prototype.toString; MYOB.toString()") );
michael@0 107
michael@0 108 new TestCase( SECTION, "Object( '\\\'\\\"\\' ).valueOf()", "\'\"\\", (Object("\'\"\\")).valueOf() );
michael@0 109 new TestCase( SECTION, "typeof Object( '\\\'\\\"\\' )", "object", typeof Object("\'\"\\") );
michael@0 110 // new TestCase( SECTION, "var MYOB = Object( '\\\'\\\"\\' ); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object( '\\\'\\\"\\' ); MYOB.toString = Object.prototype.toString; MYOB.toString()") );
michael@0 111
michael@0 112 test();

mercurial