1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is Mozilla Communicator client code, released
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998
21 * the Initial Developer. All Rights Reserved.
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
41 File Name: 11.13.2-1.js
42 ECMA Section: 11.13.2 Compound Assignment: *=
45 *= /= %= += -= <<= >>= >>>= &= ^= |=
47 11.13.2 Compound assignment ( op= )
49 The production AssignmentExpression :
50 LeftHandSideExpression @ = AssignmentExpression, where @ represents one of
51 the operators indicated above, is evaluated as follows:
53 1. Evaluate LeftHandSideExpression.
54 2. Call GetValue(Result(1)).
55 3. Evaluate AssignmentExpression.
56 4. Call GetValue(Result(3)).
57 5. Apply operator @ to Result(2) and Result(4).
58 6. Call PutValue(Result(1), Result(5)).
61 Author: christine@netscape.com
62 Date: 12 november 1997
64 var SECTION = "11.13.2-1";
65 var VERSION = "ECMA_1";
68 writeHeaderToLog( SECTION + " Compound Assignment: *=");
73 new TestCase( SECTION,
74 "VAR1 = NaN; VAR2=1; VAR1 *= VAR2",
76 eval("VAR1 = Number.NaN; VAR2=1; VAR1 *= VAR2") );
78 new TestCase( SECTION,
79 "VAR1 = NaN; VAR2=1; VAR1 *= VAR2; VAR1",
81 eval("VAR1 = Number.NaN; VAR2=1; VAR1 *= VAR2; VAR1") );
84 new TestCase( SECTION,
85 "VAR1 = 0; VAR2=1; VAR1 *= VAR2",
87 eval("VAR1 = 0; VAR2=1; VAR1 *= VAR2") );
89 new TestCase( SECTION,
90 "VAR1 = 0; VAR2=1; VAR1 *= VAR2;VAR1",
92 eval("VAR1 = 0; VAR2=1; VAR1 *= VAR2;VAR1") );
94 new TestCase( SECTION,
95 "VAR1 = 0xFF; VAR2 = 0xA, VAR1 *= VAR2",
97 eval("VAR1 = 0XFF; VAR2 = 0XA, VAR1 *= VAR2") );
99 // special multiplication cases
101 new TestCase( SECTION,
102 "VAR1 = 0; VAR2= Infinity; VAR1 *= VAR2",
104 eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") );
106 new TestCase( SECTION,
107 "VAR1 = -0; VAR2= Infinity; VAR1 *= VAR2",
109 eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") );
111 new TestCase( SECTION,
112 "VAR1 = -0; VAR2= -Infinity; VAR1 *= VAR2",
114 eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") );
116 new TestCase( SECTION,
117 "VAR1 = 0; VAR2= -Infinity; VAR1 *= VAR2",
119 eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") );
121 new TestCase( SECTION,
122 "VAR1 = 0; VAR2= Infinity; VAR2 *= VAR1",
124 eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR2 *= VAR1; VAR2") );
126 new TestCase( SECTION,
127 "VAR1 = -0; VAR2= Infinity; VAR2 *= VAR1",
129 eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR2 *= VAR1; VAR2") );
131 new TestCase( SECTION,
132 "VAR1 = -0; VAR2= -Infinity; VAR2 *= VAR1",
134 eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 *= VAR1; VAR2") );
136 new TestCase( SECTION,
137 "VAR1 = 0; VAR2= -Infinity; VAR2 *= VAR1",
139 eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 *= VAR1; VAR2") );
141 new TestCase( SECTION,
142 "VAR1 = Infinity; VAR2= Infinity; VAR1 *= VAR2",
143 Number.POSITIVE_INFINITY,
144 eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") );
146 new TestCase( SECTION,
147 "VAR1 = Infinity; VAR2= -Infinity; VAR1 *= VAR2",
148 Number.NEGATIVE_INFINITY,
149 eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") );
151 new TestCase( SECTION,
152 "VAR1 =-Infinity; VAR2= Infinity; VAR1 *= VAR2",
153 Number.NEGATIVE_INFINITY,
154 eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") );
156 new TestCase( SECTION,
157 "VAR1 =-Infinity; VAR2=-Infinity; VAR1 *= VAR2",
158 Number.POSITIVE_INFINITY,
159 eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") );
162 new TestCase( SECTION,
163 "VAR1 = 10; VAR2 = '255', VAR1 *= VAR2",
165 eval("VAR1 = 10; VAR2 = '255', VAR1 *= VAR2") );
167 new TestCase( SECTION,
168 "VAR1 = '255'; VAR2 = 10, VAR1 *= VAR2",
170 eval("VAR1 = '255'; VAR2 = 10, VAR1 *= VAR2") );
172 new TestCase( SECTION,
173 "VAR1 = 10; VAR2 = '0XFF', VAR1 *= VAR2",
175 eval("VAR1 = 10; VAR2 = '0XFF', VAR1 *= VAR2") );
177 new TestCase( SECTION,
178 "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 *= VAR2",
180 eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 *= VAR2") );
182 new TestCase( SECTION,
183 "VAR1 = '10'; VAR2 = '255', VAR1 *= VAR2",
185 eval("VAR1 = '10'; VAR2 = '255', VAR1 *= VAR2") );
187 new TestCase( SECTION,
188 "VAR1 = '10'; VAR2 = '0XFF', VAR1 *= VAR2",
190 eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 *= VAR2") );
192 new TestCase( SECTION,
193 "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 *= VAR2",
195 eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 *= VAR2") );
198 new TestCase( SECTION,
199 "VAR1 = true; VAR2 = false; VAR1 *= VAR2",
201 eval("VAR1 = true; VAR2 = false; VAR1 *= VAR2") );
203 new TestCase( SECTION,
204 "VAR1 = true; VAR2 = true; VAR1 *= VAR2",
206 eval("VAR1 = true; VAR2 = true; VAR1 *= VAR2") );
209 new TestCase( SECTION,
210 "VAR1 = new Boolean(true); VAR2 = 10; VAR1 *= VAR2;VAR1",
212 eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 *= VAR2; VAR1") );
214 new TestCase( SECTION,
215 "VAR1 = new Number(11); VAR2 = 10; VAR1 *= VAR2; VAR1",
217 eval("VAR1 = new Number(11); VAR2 = 10; VAR1 *= VAR2; VAR1") );
219 new TestCase( SECTION,
220 "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 *= VAR2",
222 eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 *= VAR2") );
224 new TestCase( SECTION,
225 "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 *= VAR2",
227 eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 *= VAR2") );