Wed, 31 Dec 2014 06:09:35 +0100
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: 11.13.2-5.js |
michael@0 | 9 | ECMA Section: 11.13.2 Compound Assignment: -= |
michael@0 | 10 | Description: |
michael@0 | 11 | |
michael@0 | 12 | *= /= %= -= -= <<= >>= >>>= &= ^= |= |
michael@0 | 13 | |
michael@0 | 14 | 11.13.2 Compound assignment ( op= ) |
michael@0 | 15 | |
michael@0 | 16 | The production AssignmentExpression : |
michael@0 | 17 | LeftHandSideExpression @ = AssignmentExpression, where @ represents one of |
michael@0 | 18 | the operators indicated above, is evaluated as follows: |
michael@0 | 19 | |
michael@0 | 20 | 1. Evaluate LeftHandSideExpression. |
michael@0 | 21 | 2. Call GetValue(Result(1)). |
michael@0 | 22 | 3. Evaluate AssignmentExpression. |
michael@0 | 23 | 4. Call GetValue(Result(3)). |
michael@0 | 24 | 5. Apply operator @ to Result(2) and Result(4). |
michael@0 | 25 | 6. Call PutValue(Result(1), Result(5)). |
michael@0 | 26 | 7. Return Result(5). |
michael@0 | 27 | |
michael@0 | 28 | Author: christine@netscape.com |
michael@0 | 29 | Date: 12 november 1997 |
michael@0 | 30 | */ |
michael@0 | 31 | var SECTION = "11.13.2-5"; |
michael@0 | 32 | var VERSION = "ECMA_1"; |
michael@0 | 33 | startTest(); |
michael@0 | 34 | |
michael@0 | 35 | writeHeaderToLog( SECTION + " Compound Assignment: -="); |
michael@0 | 36 | |
michael@0 | 37 | // If either operand is NaN, result is NaN |
michael@0 | 38 | |
michael@0 | 39 | new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 -= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 -= VAR2") ); |
michael@0 | 40 | new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 -= VAR2; VAR1") ); |
michael@0 | 41 | new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 -= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 -= VAR2") ); |
michael@0 | 42 | new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 -= VAR2; VAR1") ); |
michael@0 | 43 | new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 -= VAR2", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 -= VAR2") ); |
michael@0 | 44 | new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 -= VAR2; VAR1") ); |
michael@0 | 45 | |
michael@0 | 46 | // the sum of two Infinities the same sign is the infinity of that sign |
michael@0 | 47 | // the sum of two Infinities of opposite sign is NaN |
michael@0 | 48 | |
michael@0 | 49 | new TestCase( SECTION, "VAR1 = Infinity; VAR2= Infinity; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); |
michael@0 | 50 | new TestCase( SECTION, "VAR1 = Infinity; VAR2= -Infinity; VAR1 -= VAR2; VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); |
michael@0 | 51 | new TestCase( SECTION, "VAR1 =-Infinity; VAR2= Infinity; VAR1 -= VAR2; VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); |
michael@0 | 52 | new TestCase( SECTION, "VAR1 =-Infinity; VAR2=-Infinity; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); |
michael@0 | 53 | |
michael@0 | 54 | // the sum of an infinity and a finite value is equal to the infinite operand |
michael@0 | 55 | |
michael@0 | 56 | new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR1 -= VAR2;VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); |
michael@0 | 57 | new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR1 -= VAR2;VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); |
michael@0 | 58 | new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR1 -= VAR2;VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); |
michael@0 | 59 | new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR1 -= VAR2;VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); |
michael@0 | 60 | |
michael@0 | 61 | // the sum of two negative zeros is -0. the sum of two positive zeros, or of two zeros of opposite sign, is +0 |
michael@0 | 62 | |
michael@0 | 63 | new TestCase( SECTION, "VAR1 = 0; VAR2= -0; VAR1 -= VAR2", 0, eval("VAR1 = 0; VAR2 = 0; VAR1 -= VAR2; VAR1") ); |
michael@0 | 64 | new TestCase( SECTION, "VAR1 = 0; VAR2= 0; VAR1 -= VAR2", 0, eval("VAR1 = 0; VAR2 = -0; VAR1 -= VAR2; VAR1") ); |
michael@0 | 65 | new TestCase( SECTION, "VAR1 = -0; VAR2= -0; VAR1 -= VAR2", 0, eval("VAR1 = -0; VAR2 = 0; VAR1 -= VAR2; VAR1") ); |
michael@0 | 66 | new TestCase( SECTION, "VAR1 = -0; VAR2= 0; VAR1 -= VAR2", -0, eval("VAR1 = -0; VAR2 = -0; VAR1 -= VAR2; VAR1") ); |
michael@0 | 67 | |
michael@0 | 68 | // the sum of a zero and a nonzero finite value is eqal to the nonzero operand |
michael@0 | 69 | |
michael@0 | 70 | new TestCase( SECTION, "VAR1 = 0; VAR2= -1; VAR1 -= VAR2; VAR1", 1, eval("VAR1 = 0; VAR2 = -1; VAR1 -= VAR2; VAR1") ); |
michael@0 | 71 | new TestCase( SECTION, "VAR1 = -0; VAR2= -1; VAR1 -= VAR2; VAR1", 1, eval("VAR1 = -0; VAR2 = -1; VAR1 -= VAR2; VAR1") ); |
michael@0 | 72 | new TestCase( SECTION, "VAR1 = -0; VAR2= 1; VAR1 -= VAR2; VAR1", -1, eval("VAR1 = -0; VAR2 = 1; VAR1 -= VAR2; VAR1") ); |
michael@0 | 73 | new TestCase( SECTION, "VAR1 = 0; VAR2= 1; VAR1 -= VAR2; VAR1", -1, eval("VAR1 = 0; VAR2 = 1; VAR1 -= VAR2; VAR1") ); |
michael@0 | 74 | |
michael@0 | 75 | // the sum of a zero and a nozero finite value is equal to the nonzero operand. |
michael@0 | 76 | new TestCase( SECTION, "VAR1 = 0; VAR2=-1; VAR1 -= VAR2", 1, eval("VAR1 = 0; VAR2=-1; VAR1 -= VAR2;VAR1") ); |
michael@0 | 77 | new TestCase( SECTION, "VAR1 = 0; VAR2=-1; VAR1 -= VAR2;VAR1", 1, eval("VAR1 = 0; VAR2=-1; VAR1 -= VAR2;VAR1") ); |
michael@0 | 78 | |
michael@0 | 79 | // the sum of two nonzero finite values of the same magnitude and opposite sign is +0 |
michael@0 | 80 | new TestCase( SECTION, "VAR1 = Number.MAX_VALUE; VAR2= Number.MAX_VALUE; VAR1 -= VAR2; VAR1", 0, eval("VAR1 = Number.MAX_VALUE; VAR2= Number.MAX_VALUE; VAR1 -= VAR2; VAR1") ); |
michael@0 | 81 | new TestCase( SECTION, "VAR1 = Number.MIN_VALUE; VAR2= Number.MIN_VALUE; VAR1 -= VAR2; VAR1", 0, eval("VAR1 = Number.MIN_VALUE; VAR2= Number.MIN_VALUE; VAR1 -= VAR2; VAR1") ); |
michael@0 | 82 | |
michael@0 | 83 | /* |
michael@0 | 84 | new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 -= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 -= VAR2") ); |
michael@0 | 85 | new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 -= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 -= VAR2") ); |
michael@0 | 86 | |
michael@0 | 87 | new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 -= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 -= VAR2") ); |
michael@0 | 88 | new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 -= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 -= VAR2") ); |
michael@0 | 89 | new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 -= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 -= VAR2") ); |
michael@0 | 90 | |
michael@0 | 91 | // boolean cases |
michael@0 | 92 | new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 -= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 -= VAR2") ); |
michael@0 | 93 | new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 -= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 -= VAR2") ); |
michael@0 | 94 | |
michael@0 | 95 | // object cases |
michael@0 | 96 | new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 -= VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 -= VAR2; VAR1") ); |
michael@0 | 97 | new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 -= VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 -= VAR2; VAR1") ); |
michael@0 | 98 | new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 -= VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 -= VAR2") ); |
michael@0 | 99 | new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 -= VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 -= VAR2") ); |
michael@0 | 100 | |
michael@0 | 101 | */ |
michael@0 | 102 | |
michael@0 | 103 | test(); |