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-2js |
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-2"; |
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 | |
michael@0 | 38 | // NaN cases |
michael@0 | 39 | |
michael@0 | 40 | new TestCase( SECTION, |
michael@0 | 41 | "VAR1 = NaN; VAR2=1; VAR1 /= VAR2", |
michael@0 | 42 | Number.NaN, |
michael@0 | 43 | eval("VAR1 = Number.NaN; VAR2=1; VAR1 /= VAR2") ); |
michael@0 | 44 | |
michael@0 | 45 | new TestCase( SECTION, |
michael@0 | 46 | "VAR1 = NaN; VAR2=1; VAR1 /= VAR2; VAR1", |
michael@0 | 47 | Number.NaN, |
michael@0 | 48 | eval("VAR1 = Number.NaN; VAR2=1; VAR1 /= VAR2; VAR1") ); |
michael@0 | 49 | |
michael@0 | 50 | new TestCase( SECTION, |
michael@0 | 51 | "VAR1 = NaN; VAR2=0; VAR1 /= VAR2", |
michael@0 | 52 | Number.NaN, |
michael@0 | 53 | eval("VAR1 = Number.NaN; VAR2=0; VAR1 /= VAR2") ); |
michael@0 | 54 | |
michael@0 | 55 | new TestCase( SECTION, |
michael@0 | 56 | "VAR1 = NaN; VAR2=0; VAR1 /= VAR2; VAR1", |
michael@0 | 57 | Number.NaN, |
michael@0 | 58 | eval("VAR1 = Number.NaN; VAR2=0; VAR1 /= VAR2; VAR1") ); |
michael@0 | 59 | |
michael@0 | 60 | new TestCase( SECTION, |
michael@0 | 61 | "VAR1 = 0; VAR2=NaN; VAR1 /= VAR2", |
michael@0 | 62 | Number.NaN, |
michael@0 | 63 | eval("VAR1 = 0; VAR2=Number.NaN; VAR1 /= VAR2") ); |
michael@0 | 64 | |
michael@0 | 65 | new TestCase( SECTION, |
michael@0 | 66 | "VAR1 = 0; VAR2=NaN; VAR1 /= VAR2; VAR1", |
michael@0 | 67 | Number.NaN, |
michael@0 | 68 | eval("VAR1 = 0; VAR2=Number.NaN; VAR1 /= VAR2; VAR1") ); |
michael@0 | 69 | |
michael@0 | 70 | // number cases |
michael@0 | 71 | new TestCase( SECTION, |
michael@0 | 72 | "VAR1 = 0; VAR2=1; VAR1 /= VAR2", |
michael@0 | 73 | 0, |
michael@0 | 74 | eval("VAR1 = 0; VAR2=1; VAR1 /= VAR2") ); |
michael@0 | 75 | |
michael@0 | 76 | new TestCase( SECTION, |
michael@0 | 77 | "VAR1 = 0; VAR2=1; VAR1 /= VAR2;VAR1", |
michael@0 | 78 | 0, |
michael@0 | 79 | eval("VAR1 = 0; VAR2=1; VAR1 /= VAR2;VAR1") ); |
michael@0 | 80 | |
michael@0 | 81 | new TestCase( SECTION, |
michael@0 | 82 | "VAR1 = 0xFF; VAR2 = 0xA, VAR1 /= VAR2", |
michael@0 | 83 | 25.5, |
michael@0 | 84 | eval("VAR1 = 0XFF; VAR2 = 0XA, VAR1 /= VAR2") ); |
michael@0 | 85 | |
michael@0 | 86 | // special division cases |
michael@0 | 87 | |
michael@0 | 88 | new TestCase( SECTION, |
michael@0 | 89 | "VAR1 = 0; VAR2= Infinity; VAR1 /= VAR2", |
michael@0 | 90 | 0, |
michael@0 | 91 | eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); |
michael@0 | 92 | |
michael@0 | 93 | new TestCase( SECTION, |
michael@0 | 94 | "VAR1 = -0; VAR2= Infinity; VAR1 /= VAR2", |
michael@0 | 95 | 0, |
michael@0 | 96 | eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); |
michael@0 | 97 | |
michael@0 | 98 | new TestCase( SECTION, |
michael@0 | 99 | "VAR1 = -0; VAR2= -Infinity; VAR1 /= VAR2", |
michael@0 | 100 | 0, |
michael@0 | 101 | eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); |
michael@0 | 102 | |
michael@0 | 103 | new TestCase( SECTION, |
michael@0 | 104 | "VAR1 = 0; VAR2= -Infinity; VAR1 /= VAR2", |
michael@0 | 105 | 0, |
michael@0 | 106 | eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); |
michael@0 | 107 | |
michael@0 | 108 | new TestCase( SECTION, |
michael@0 | 109 | "VAR1 = 0; VAR2= Infinity; VAR2 /= VAR1", |
michael@0 | 110 | Number.POSITIVE_INFINITY, |
michael@0 | 111 | eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR2 /= VAR1; VAR2") ); |
michael@0 | 112 | |
michael@0 | 113 | new TestCase( SECTION, |
michael@0 | 114 | "VAR1 = -0; VAR2= Infinity; VAR2 /= VAR1", |
michael@0 | 115 | Number.NEGATIVE_INFINITY, |
michael@0 | 116 | eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR2 /= VAR1; VAR2") ); |
michael@0 | 117 | |
michael@0 | 118 | new TestCase( SECTION, |
michael@0 | 119 | "VAR1 = -0; VAR2= -Infinity; VAR2 /= VAR1", |
michael@0 | 120 | Number.POSITIVE_INFINITY, |
michael@0 | 121 | eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 /= VAR1; VAR2") ); |
michael@0 | 122 | |
michael@0 | 123 | new TestCase( SECTION, |
michael@0 | 124 | "VAR1 = 0; VAR2= -Infinity; VAR2 /= VAR1", |
michael@0 | 125 | Number.NEGATIVE_INFINITY, |
michael@0 | 126 | eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 /= VAR1; VAR2") ); |
michael@0 | 127 | |
michael@0 | 128 | new TestCase( SECTION, |
michael@0 | 129 | "VAR1 = Infinity; VAR2= Infinity; VAR1 /= VAR2", |
michael@0 | 130 | Number.NaN, |
michael@0 | 131 | eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); |
michael@0 | 132 | |
michael@0 | 133 | new TestCase( SECTION, |
michael@0 | 134 | "VAR1 = Infinity; VAR2= -Infinity; VAR1 /= VAR2", |
michael@0 | 135 | Number.NaN, |
michael@0 | 136 | eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); |
michael@0 | 137 | |
michael@0 | 138 | new TestCase( SECTION, |
michael@0 | 139 | "VAR1 =-Infinity; VAR2= Infinity; VAR1 /= VAR2", |
michael@0 | 140 | Number.NaN, |
michael@0 | 141 | eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); |
michael@0 | 142 | |
michael@0 | 143 | new TestCase( SECTION, |
michael@0 | 144 | "VAR1 =-Infinity; VAR2=-Infinity; VAR1 /= VAR2", |
michael@0 | 145 | Number.NaN, |
michael@0 | 146 | eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); |
michael@0 | 147 | |
michael@0 | 148 | new TestCase( SECTION, |
michael@0 | 149 | "VAR1 = 0; VAR2= 0; VAR1 /= VAR2", |
michael@0 | 150 | Number.NaN, |
michael@0 | 151 | eval("VAR1 = 0; VAR2 = 0; VAR1 /= VAR2; VAR1") ); |
michael@0 | 152 | |
michael@0 | 153 | new TestCase( SECTION, |
michael@0 | 154 | "VAR1 = 0; VAR2= -0; VAR1 /= VAR2", |
michael@0 | 155 | Number.NaN, |
michael@0 | 156 | eval("VAR1 = 0; VAR2 = -0; VAR1 /= VAR2; VAR1") ); |
michael@0 | 157 | |
michael@0 | 158 | new TestCase( SECTION, |
michael@0 | 159 | "VAR1 = -0; VAR2= 0; VAR1 /= VAR2", |
michael@0 | 160 | Number.NaN, |
michael@0 | 161 | eval("VAR1 = -0; VAR2 = 0; VAR1 /= VAR2; VAR1") ); |
michael@0 | 162 | |
michael@0 | 163 | new TestCase( SECTION, |
michael@0 | 164 | "VAR1 = -0; VAR2= -0; VAR1 /= VAR2", |
michael@0 | 165 | Number.NaN, |
michael@0 | 166 | eval("VAR1 = -0; VAR2 = -0; VAR1 /= VAR2; VAR1") ); |
michael@0 | 167 | |
michael@0 | 168 | new TestCase( SECTION, |
michael@0 | 169 | "VAR1 = 1; VAR2= 0; VAR1 /= VAR2", |
michael@0 | 170 | Number.POSITIVE_INFINITY, |
michael@0 | 171 | eval("VAR1 = 1; VAR2 = 0; VAR1 /= VAR2; VAR1") ); |
michael@0 | 172 | |
michael@0 | 173 | new TestCase( SECTION, |
michael@0 | 174 | "VAR1 = 1; VAR2= -0; VAR1 /= VAR2", |
michael@0 | 175 | Number.NEGATIVE_INFINITY, |
michael@0 | 176 | eval("VAR1 = 1; VAR2 = -0; VAR1 /= VAR2; VAR1") ); |
michael@0 | 177 | |
michael@0 | 178 | new TestCase( SECTION, |
michael@0 | 179 | "VAR1 = -1; VAR2= 0; VAR1 /= VAR2", |
michael@0 | 180 | Number.NEGATIVE_INFINITY, |
michael@0 | 181 | eval("VAR1 = -1; VAR2 = 0; VAR1 /= VAR2; VAR1") ); |
michael@0 | 182 | |
michael@0 | 183 | new TestCase( SECTION, |
michael@0 | 184 | "VAR1 = -1; VAR2= -0; VAR1 /= VAR2", |
michael@0 | 185 | Number.POSITIVE_INFINITY, |
michael@0 | 186 | eval("VAR1 = -1; VAR2 = -0; VAR1 /= VAR2; VAR1") ); |
michael@0 | 187 | |
michael@0 | 188 | // string cases |
michael@0 | 189 | new TestCase( SECTION, |
michael@0 | 190 | "VAR1 = 1000; VAR2 = '10', VAR1 /= VAR2; VAR1", |
michael@0 | 191 | 100, |
michael@0 | 192 | eval("VAR1 = 1000; VAR2 = '10', VAR1 /= VAR2; VAR1") ); |
michael@0 | 193 | |
michael@0 | 194 | new TestCase( SECTION, |
michael@0 | 195 | "VAR1 = '1000'; VAR2 = 10, VAR1 /= VAR2; VAR1", |
michael@0 | 196 | 100, |
michael@0 | 197 | eval("VAR1 = '1000'; VAR2 = 10, VAR1 /= VAR2; VAR1") ); |
michael@0 | 198 | /* |
michael@0 | 199 | new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 /= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 /= VAR2") ); |
michael@0 | 200 | new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 /= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 /= VAR2") ); |
michael@0 | 201 | |
michael@0 | 202 | new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 /= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 /= VAR2") ); |
michael@0 | 203 | new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 /= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 /= VAR2") ); |
michael@0 | 204 | new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 /= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 /= VAR2") ); |
michael@0 | 205 | |
michael@0 | 206 | // boolean cases |
michael@0 | 207 | new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 /= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 /= VAR2") ); |
michael@0 | 208 | new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 /= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 /= VAR2") ); |
michael@0 | 209 | |
michael@0 | 210 | // object cases |
michael@0 | 211 | 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 | 212 | 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 | 213 | 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 | 214 | 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 | 215 | |
michael@0 | 216 | */ |
michael@0 | 217 | |
michael@0 | 218 | test(); |
michael@0 | 219 |