js/src/tests/ecma/Expressions/11.13.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.

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

mercurial