js/src/tests/ecma/extensions/9.9-1.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma/extensions/9.9-1.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,68 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +
    1.10 +/**
    1.11 +   File Name:          9.9-1.js
    1.12 +   ECMA Section:       9.9  Type Conversion:  ToObject
    1.13 +   Description:
    1.14 +
    1.15 +   undefined   generate a runtime error
    1.16 +   null        generate a runtime error
    1.17 +   boolean     create a new Boolean object whose default
    1.18 +   value is the value of the boolean.
    1.19 +   number      Create a new Number object whose default
    1.20 +   value is the value of the number.
    1.21 +   string      Create a new String object whose default
    1.22 +   value is the value of the string.
    1.23 +   object      Return the input argument (no conversion).
    1.24 +   Author:             christine@netscape.com
    1.25 +   Date:               17 july 1997
    1.26 +*/
    1.27 +
    1.28 +var VERSION = "ECMA_1";
    1.29 +startTest();
    1.30 +var SECTION = "9.9-1";
    1.31 +
    1.32 +writeHeaderToLog( SECTION + " Type Conversion: ToObject" );
    1.33 +
    1.34 +new TestCase( SECTION, "(Object(true)).__proto__",  Boolean.prototype,      (Object(true)).__proto__ );
    1.35 +
    1.36 +new TestCase( SECTION, "(Object(true)).__proto__",  Boolean.prototype,      (Object(true)).__proto__ );
    1.37 +
    1.38 +new TestCase( SECTION, "(Object(0)).__proto__",     Number.prototype,      (Object(0)).__proto__ );
    1.39 +
    1.40 +new TestCase( SECTION, "(Object(-0)).__proto__",    Number.prototype,      (Object(-0)).__proto__ );
    1.41 +
    1.42 +new TestCase( SECTION, "(Object(1)).__proto__",     Number.prototype,      (Object(1)).__proto__ );
    1.43 +
    1.44 +new TestCase( SECTION, "(Object(-1)).__proto__",    Number.prototype,      (Object(-1)).__proto__ );
    1.45 +
    1.46 +new TestCase( SECTION, "(Object(Number.MAX_VALUE)).__proto__",  Number.prototype,               (Object(Number.MAX_VALUE)).__proto__ );
    1.47 +
    1.48 +new TestCase( SECTION, "(Object(Number.MIN_VALUE)).__proto__",  Number.prototype, (Object(Number.MIN_VALUE)).__proto__ );
    1.49 +
    1.50 +new TestCase( SECTION, "(Object(Number.POSITIVE_INFINITY)).__proto__",  Number.prototype,               (Object(Number.POSITIVE_INFINITY)).__proto__ );
    1.51 +
    1.52 +new TestCase( SECTION, "(Object(Number.NEGATIVE_INFINITY)).__proto__",  Number.prototype,   (Object(Number.NEGATIVE_INFINITY)).__proto__ );
    1.53 +
    1.54 +new TestCase( SECTION, "(Object(Number.NaN)).__proto__",    Number.prototype,          (Object(Number.NaN)).__proto__ );
    1.55 +
    1.56 +new TestCase( SECTION, "(Object('a string')).__proto__",    String.prototype,   (Object("a string")).__proto__ );
    1.57 +
    1.58 +new TestCase( SECTION, "(Object('')).__proto__",            String.prototype,   (Object("")).__proto__ );
    1.59 +
    1.60 +new TestCase( SECTION, "(Object('\\r\\t\\b\\n\\v\\f')).__proto__", String.prototype,   (Object("\\r\\t\\b\\n\\v\\f")).__proto__ );
    1.61 +
    1.62 +new TestCase( SECTION,  "Object( '\\\'\\\"\\' ).__proto__",      String.prototype,   (Object("\'\"\\")).__proto__ );
    1.63 +
    1.64 +new TestCase( SECTION, "(Object( new MyObject(true) )).toString()",  "[object Object]",       eval("(Object( new MyObject(true) )).toString()") );
    1.65 +
    1.66 +test();
    1.67 +
    1.68 +function MyObject( value ) {
    1.69 +  this.value = value;
    1.70 +  this.valueOf = new Function ( "return this.value" );
    1.71 +}

mercurial