js/src/tests/ecma/extensions/11.6.2-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:          11.6.2-1.js
     9    ECMA Section:       11.6.2 The Subtraction operator ( - )
    10    Description:
    12    The production AdditiveExpression : AdditiveExpression -
    13    MultiplicativeExpression is evaluated as follows:
    15    1.  Evaluate AdditiveExpression.
    16    2.  Call GetValue(Result(1)).
    17    3.  Evaluate MultiplicativeExpression.
    18    4.  Call GetValue(Result(3)).
    19    5.  Call ToNumber(Result(2)).
    20    6.  Call ToNumber(Result(4)).
    21    7.  Apply the subtraction operation to Result(5) and Result(6). See the
    22    discussion below (11.6.3).
    23    8.  Return Result(7).
    25    Author:             christine@netscape.com
    26    Date:               12 november 1997
    27 */
    28 var SECTION = "11.6.2-1";
    29 var VERSION = "ECMA_1";
    30 startTest();
    32 writeHeaderToLog( SECTION + " The subtraction operator ( - )");
    34 // tests "MyValuelessObject", where the value is
    35 // set in the object's prototype, not the object itself.
    38 new TestCase(   SECTION,
    39                 "var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 - EXP_2",
    40                 1,
    41                 eval("var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 - EXP_2") );
    43 new TestCase(   SECTION,
    44                 "var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 - EXP_2",
    45                 Number.NaN,
    46                 eval("var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 - EXP_2") );
    48 // tests "MyValuelessObject", where the value is
    49 // set in the object's prototype, not the object itself.
    51 new TestCase(   SECTION,
    52                 "var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(1); EXP_1 - EXP_2",
    53                 99,
    54                 eval("var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(1); EXP_1 - EXP_2") );
    55 /*
    56   new TestCase(   SECTION,
    57   "var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(1)); EXP_1 - EXP_2",
    58   Number.NaN,
    59   eval("var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(1)); EXP_1 - EXP_2") );
    60 */
    61 // same thing with string!
    63 test();
    65 function MyProtoValuelessObject() {
    66   this.valueOf = new Function ( "" );
    67   this.__proto__ = null;
    68 }
    69 function MyProtolessObject( value ) {
    70   this.valueOf = new Function( "return this.value" );
    71   this.__proto__ = null;
    72   this.value = value;
    73 }
    74 function MyValuelessObject(value) {
    75   this.__proto__ = new MyPrototypeObject(value);
    76 }
    77 function MyPrototypeObject(value) {
    78   this.valueOf = new Function( "return this.value;" );
    79   this.toString = new Function( "return (this.value + '');" );
    80   this.value = value;
    81 }
    82 function MyObject( value ) {
    83   this.valueOf = new Function( "return this.value" );
    84   this.value = value;
    85 }
    86 function MyOtherObject( value ) {
    87   this.valueOf = new Function( "return this.value" );
    88   this.toString = new Function ( "return this.value + ''" );
    89   this.value = value;
    90 }

mercurial