js/src/tests/ecma/Number/15.7.2.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.7.2.js
michael@0 9 ECMA Section: 15.7.2 The Number Constructor
michael@0 10 15.7.2.1
michael@0 11 15.7.2.2
michael@0 12
michael@0 13 Description: 15.7.2 When Number is called as part of a new
michael@0 14 expression, it is a constructor: it initializes
michael@0 15 the newly created object.
michael@0 16
michael@0 17 15.7.2.1 The [[Prototype]] property of the newly
michael@0 18 constructed object is set to othe original Number
michael@0 19 prototype object, the one that is the initial value
michael@0 20 of Number.prototype(0). The [[Class]] property is
michael@0 21 set to "Number". The [[Value]] property of the
michael@0 22 newly constructed object is set to ToNumber(value)
michael@0 23
michael@0 24 15.7.2.2 new Number(). same as in 15.7.2.1, except
michael@0 25 the [[Value]] property is set to +0.
michael@0 26
michael@0 27 need to add more test cases. see the testcases for
michael@0 28 TypeConversion ToNumber.
michael@0 29
michael@0 30 Author: christine@netscape.com
michael@0 31 Date: 29 september 1997
michael@0 32 */
michael@0 33
michael@0 34 var SECTION = "15.7.2";
michael@0 35 var VERSION = "ECMA_1";
michael@0 36 startTest();
michael@0 37 var TITLE = "The Number Constructor";
michael@0 38
michael@0 39 writeHeaderToLog( SECTION + " "+ TITLE);
michael@0 40
michael@0 41 // To verify that the object's prototype is the Number.prototype, check to see if the object's
michael@0 42 // constructor property is the same as Number.prototype.constructor.
michael@0 43
michael@0 44 new TestCase(SECTION, "(new Number()).constructor", Number.prototype.constructor, (new Number()).constructor );
michael@0 45
michael@0 46 new TestCase(SECTION, "typeof (new Number())", "object", typeof (new Number()) );
michael@0 47 new TestCase(SECTION, "(new Number()).valueOf()", 0, (new Number()).valueOf() );
michael@0 48 new TestCase(SECTION,
michael@0 49 "NUMB = new Number();NUMB.toString=Object.prototype.toString;NUMB.toString()",
michael@0 50 "[object Number]",
michael@0 51 eval("NUMB = new Number();NUMB.toString=Object.prototype.toString;NUMB.toString()") );
michael@0 52
michael@0 53 new TestCase(SECTION, "(new Number(0)).constructor", Number.prototype.constructor, (new Number(0)).constructor );
michael@0 54 new TestCase(SECTION, "typeof (new Number(0))", "object", typeof (new Number(0)) );
michael@0 55 new TestCase(SECTION, "(new Number(0)).valueOf()", 0, (new Number(0)).valueOf() );
michael@0 56 new TestCase(SECTION,
michael@0 57 "NUMB = new Number(0);NUMB.toString=Object.prototype.toString;NUMB.toString()",
michael@0 58 "[object Number]",
michael@0 59 eval("NUMB = new Number(0);NUMB.toString=Object.prototype.toString;NUMB.toString()") );
michael@0 60
michael@0 61 new TestCase(SECTION, "(new Number(1)).constructor", Number.prototype.constructor, (new Number(1)).constructor );
michael@0 62 new TestCase(SECTION, "typeof (new Number(1))", "object", typeof (new Number(1)) );
michael@0 63 new TestCase(SECTION, "(new Number(1)).valueOf()", 1, (new Number(1)).valueOf() );
michael@0 64 new TestCase(SECTION,
michael@0 65 "NUMB = new Number(1);NUMB.toString=Object.prototype.toString;NUMB.toString()",
michael@0 66 "[object Number]",
michael@0 67 eval("NUMB = new Number(1);NUMB.toString=Object.prototype.toString;NUMB.toString()") );
michael@0 68
michael@0 69 new TestCase(SECTION, "(new Number(-1)).constructor", Number.prototype.constructor, (new Number(-1)).constructor );
michael@0 70 new TestCase(SECTION, "typeof (new Number(-1))", "object", typeof (new Number(-1)) );
michael@0 71 new TestCase(SECTION, "(new Number(-1)).valueOf()", -1, (new Number(-1)).valueOf() );
michael@0 72 new TestCase(SECTION,
michael@0 73 "NUMB = new Number(-1);NUMB.toString=Object.prototype.toString;NUMB.toString()",
michael@0 74 "[object Number]",
michael@0 75 eval("NUMB = new Number(-1);NUMB.toString=Object.prototype.toString;NUMB.toString()") );
michael@0 76
michael@0 77 new TestCase(SECTION, "(new Number(Number.NaN)).constructor", Number.prototype.constructor, (new Number(Number.NaN)).constructor );
michael@0 78 new TestCase(SECTION, "typeof (new Number(Number.NaN))", "object", typeof (new Number(Number.NaN)) );
michael@0 79 new TestCase(SECTION, "(new Number(Number.NaN)).valueOf()", Number.NaN, (new Number(Number.NaN)).valueOf() );
michael@0 80 new TestCase(SECTION,
michael@0 81 "NUMB = new Number(Number.NaN);NUMB.toString=Object.prototype.toString;NUMB.toString()",
michael@0 82 "[object Number]",
michael@0 83 eval("NUMB = new Number(Number.NaN);NUMB.toString=Object.prototype.toString;NUMB.toString()") );
michael@0 84
michael@0 85 new TestCase(SECTION, "(new Number('string')).constructor", Number.prototype.constructor, (new Number('string')).constructor );
michael@0 86 new TestCase(SECTION, "typeof (new Number('string'))", "object", typeof (new Number('string')) );
michael@0 87 new TestCase(SECTION, "(new Number('string')).valueOf()", Number.NaN, (new Number('string')).valueOf() );
michael@0 88 new TestCase(SECTION,
michael@0 89 "NUMB = new Number('string');NUMB.toString=Object.prototype.toString;NUMB.toString()",
michael@0 90 "[object Number]",
michael@0 91 eval("NUMB = new Number('string');NUMB.toString=Object.prototype.toString;NUMB.toString()") );
michael@0 92
michael@0 93 new TestCase(SECTION, "(new Number(new String())).constructor", Number.prototype.constructor, (new Number(new String())).constructor );
michael@0 94 new TestCase(SECTION, "typeof (new Number(new String()))", "object", typeof (new Number(new String())) );
michael@0 95 new TestCase(SECTION, "(new Number(new String())).valueOf()", 0, (new Number(new String())).valueOf() );
michael@0 96 new TestCase(SECTION,
michael@0 97 "NUMB = new Number(new String());NUMB.toString=Object.prototype.toString;NUMB.toString()",
michael@0 98 "[object Number]",
michael@0 99 eval("NUMB = new Number(new String());NUMB.toString=Object.prototype.toString;NUMB.toString()") );
michael@0 100
michael@0 101 new TestCase(SECTION, "(new Number('')).constructor", Number.prototype.constructor, (new Number('')).constructor );
michael@0 102 new TestCase(SECTION, "typeof (new Number(''))", "object", typeof (new Number('')) );
michael@0 103 new TestCase(SECTION, "(new Number('')).valueOf()", 0, (new Number('')).valueOf() );
michael@0 104 new TestCase(SECTION,
michael@0 105 "NUMB = new Number('');NUMB.toString=Object.prototype.toString;NUMB.toString()",
michael@0 106 "[object Number]",
michael@0 107 eval("NUMB = new Number('');NUMB.toString=Object.prototype.toString;NUMB.toString()") );
michael@0 108
michael@0 109 new TestCase(SECTION, "(new Number(Number.POSITIVE_INFINITY)).constructor", Number.prototype.constructor, (new Number(Number.POSITIVE_INFINITY)).constructor );
michael@0 110 new TestCase(SECTION, "typeof (new Number(Number.POSITIVE_INFINITY))", "object", typeof (new Number(Number.POSITIVE_INFINITY)) );
michael@0 111 new TestCase(SECTION, "(new Number(Number.POSITIVE_INFINITY)).valueOf()", Number.POSITIVE_INFINITY, (new Number(Number.POSITIVE_INFINITY)).valueOf() );
michael@0 112 new TestCase(SECTION,
michael@0 113 "NUMB = new Number(Number.POSITIVE_INFINITY);NUMB.toString=Object.prototype.toString;NUMB.toString()",
michael@0 114 "[object Number]",
michael@0 115 eval("NUMB = new Number(Number.POSITIVE_INFINITY);NUMB.toString=Object.prototype.toString;NUMB.toString()") );
michael@0 116
michael@0 117 new TestCase(SECTION, "(new Number(Number.NEGATIVE_INFINITY)).constructor", Number.prototype.constructor, (new Number(Number.NEGATIVE_INFINITY)).constructor );
michael@0 118 new TestCase(SECTION, "typeof (new Number(Number.NEGATIVE_INFINITY))", "object", typeof (new Number(Number.NEGATIVE_INFINITY)) );
michael@0 119 new TestCase(SECTION, "(new Number(Number.NEGATIVE_INFINITY)).valueOf()", Number.NEGATIVE_INFINITY, (new Number(Number.NEGATIVE_INFINITY)).valueOf() );
michael@0 120 new TestCase(SECTION,
michael@0 121 "NUMB = new Number(Number.NEGATIVE_INFINITY);NUMB.toString=Object.prototype.toString;NUMB.toString()",
michael@0 122 "[object Number]",
michael@0 123 eval("NUMB = new Number(Number.NEGATIVE_INFINITY);NUMB.toString=Object.prototype.toString;NUMB.toString()") );
michael@0 124
michael@0 125
michael@0 126 new TestCase(SECTION, "(new Number()).constructor", Number.prototype.constructor, (new Number()).constructor );
michael@0 127 new TestCase(SECTION, "typeof (new Number())", "object", typeof (new Number()) );
michael@0 128 new TestCase(SECTION, "(new Number()).valueOf()", 0, (new Number()).valueOf() );
michael@0 129 new TestCase(SECTION,
michael@0 130 "NUMB = new Number();NUMB.toString=Object.prototype.toString;NUMB.toString()",
michael@0 131 "[object Number]",
michael@0 132 eval("NUMB = new Number();NUMB.toString=Object.prototype.toString;NUMB.toString()") );
michael@0 133
michael@0 134 test();

mercurial