js/src/tests/ecma/extensions/8.6.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.

     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:          8.6.2.1-1.js
     9    ECMA Section:       8.6.2.1 Get (Value)
    10    Description:
    12    When the [[Get]] method of O is called with property name P, the following
    13    steps are taken:
    15    1.  If O doesn't have a property with name P, go to step 4.
    16    2.  Get the value of the property.
    17    3.  Return Result(2).
    18    4.  If the [[Prototype]] of O is null, return undefined.
    19    5.  Call the [[Get]] method of [[Prototype]] with property name P.
    20    6.  Return Result(5).
    22    This tests [[Get]] (Value).
    24    Author:             christine@netscape.com
    25    Date:               12 november 1997
    26 */
    27 var SECTION = "8.6.2.1-1";
    28 var VERSION = "ECMA_1";
    29 startTest();
    31 writeHeaderToLog( SECTION + " [[Get]] (Value)");
    33 new TestCase( SECTION,  "var OBJ = new MyValuelessObject(true); OBJ.valueOf()",     true,           eval("var OBJ = new MyValuelessObject(true); OBJ.valueOf()") );
    34 //    new TestCase( SECTION,  "var OBJ = new MyProtoValuelessObject(true); OBJ + ''",     "undefined",    eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") );
    35 new TestCase( SECTION,  "var OBJ = new MyProtolessObject(true); OBJ.valueOf()",     true,           eval("var OBJ = new MyProtolessObject(true); OBJ.valueOf()") );
    37 new TestCase( SECTION,  "var OBJ = new MyValuelessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()",     Number.POSITIVE_INFINITY,           eval("var OBJ = new MyValuelessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()") );
    38 //    new TestCase( SECTION,  "var OBJ = new MyProtoValuelessObject(Number.POSITIVE_INFINITY); OBJ + ''",     "undefined",                        eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") );
    39 new TestCase( SECTION,  "var OBJ = new MyProtolessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()",     Number.POSITIVE_INFINITY,           eval("var OBJ = new MyProtolessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()") );
    41 new TestCase( SECTION,  "var OBJ = new MyValuelessObject('string'); OBJ.valueOf()",     'string',           eval("var OBJ = new MyValuelessObject('string'); OBJ.valueOf()") );
    42 //    new TestCase( SECTION,  "var OBJ = new MyProtoValuelessObject('string'); OJ + ''",     "undefined",      eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") );
    43 new TestCase( SECTION,  "var OBJ = new MyProtolessObject('string'); OBJ.valueOf()",     'string',           eval("var OBJ = new MyProtolessObject('string'); OBJ.valueOf()") );
    45 test();
    47 function MyProtoValuelessObject(value) {
    48   this.valueOf = new Function ( "" );
    49   this.__proto__ = null;
    50 }
    52 function MyProtolessObject( value ) {
    53   this.valueOf = new Function( "return this.value" );
    54   this.__proto__ = null;
    55   this.value = value;
    56 }
    57 function MyValuelessObject(value) {
    58   this.__proto__ = new MyPrototypeObject(value);
    59 }
    60 function MyPrototypeObject(value) {
    61   this.valueOf = new Function( "return this.value;" );
    62   this.toString = new Function( "return (this.value + '');" );
    63   this.value = value;
    64 }

mercurial