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 ***** */
39 File Name: 11.13.2-2js
40 ECMA Section: 11.13.2 Compound Assignment: /=
43 *= /= %= += -= <<= >>= >>>= &= ^= |=
45 11.13.2 Compound assignment ( op= )
47 The production AssignmentExpression :
48 LeftHandSideExpression @ = AssignmentExpression, where @ represents one of
49 the operators indicated above, is evaluated as follows:
51 1. Evaluate LeftHandSideExpression.
52 2. Call GetValue(Result(1)).
53 3. Evaluate AssignmentExpression.
54 4. Call GetValue(Result(3)).
55 5. Apply operator @ to Result(2) and Result(4).
56 6. Call PutValue(Result(1), Result(5)).
59 Author: christine@netscape.com
60 Date: 12 november 1997
62 var SECTION = "11.13.2-2";
63 var VERSION = "ECMA_1";
66 writeHeaderToLog( SECTION + " Compound Assignment: /=");
71 new TestCase( SECTION,
72 "VAR1 = NaN; VAR2=1; VAR1 /= VAR2",
74 eval("VAR1 = Number.NaN; VAR2=1; VAR1 /= VAR2") );
76 new TestCase( SECTION,
77 "VAR1 = NaN; VAR2=1; VAR1 /= VAR2; VAR1",
79 eval("VAR1 = Number.NaN; VAR2=1; VAR1 /= VAR2; VAR1") );
81 new TestCase( SECTION,
82 "VAR1 = NaN; VAR2=0; VAR1 /= VAR2",
84 eval("VAR1 = Number.NaN; VAR2=0; VAR1 /= VAR2") );
86 new TestCase( SECTION,
87 "VAR1 = NaN; VAR2=0; VAR1 /= VAR2; VAR1",
89 eval("VAR1 = Number.NaN; VAR2=0; VAR1 /= VAR2; VAR1") );
91 new TestCase( SECTION,
92 "VAR1 = 0; VAR2=NaN; VAR1 /= VAR2",
94 eval("VAR1 = 0; VAR2=Number.NaN; VAR1 /= VAR2") );
96 new TestCase( SECTION,
97 "VAR1 = 0; VAR2=NaN; VAR1 /= VAR2; VAR1",
99 eval("VAR1 = 0; VAR2=Number.NaN; VAR1 /= VAR2; VAR1") );
102 new TestCase( SECTION,
103 "VAR1 = 0; VAR2=1; VAR1 /= VAR2",
105 eval("VAR1 = 0; VAR2=1; VAR1 /= VAR2") );
107 new TestCase( SECTION,
108 "VAR1 = 0; VAR2=1; VAR1 /= VAR2;VAR1",
110 eval("VAR1 = 0; VAR2=1; VAR1 /= VAR2;VAR1") );
112 new TestCase( SECTION,
113 "VAR1 = 0xFF; VAR2 = 0xA, VAR1 /= VAR2",
115 eval("VAR1 = 0XFF; VAR2 = 0XA, VAR1 /= VAR2") );
117 // special division cases
119 new TestCase( SECTION,
120 "VAR1 = 0; VAR2= Infinity; VAR1 /= VAR2",
122 eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") );
124 new TestCase( SECTION,
125 "VAR1 = -0; VAR2= Infinity; VAR1 /= VAR2",
127 eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") );
129 new TestCase( SECTION,
130 "VAR1 = -0; VAR2= -Infinity; VAR1 /= VAR2",
132 eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") );
134 new TestCase( SECTION,
135 "VAR1 = 0; VAR2= -Infinity; VAR1 /= VAR2",
137 eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") );
139 new TestCase( SECTION,
140 "VAR1 = 0; VAR2= Infinity; VAR2 /= VAR1",
141 Number.POSITIVE_INFINITY,
142 eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR2 /= VAR1; VAR2") );
144 new TestCase( SECTION,
145 "VAR1 = -0; VAR2= Infinity; VAR2 /= VAR1",
146 Number.NEGATIVE_INFINITY,
147 eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR2 /= VAR1; VAR2") );
149 new TestCase( SECTION,
150 "VAR1 = -0; VAR2= -Infinity; VAR2 /= VAR1",
151 Number.POSITIVE_INFINITY,
152 eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 /= VAR1; VAR2") );
154 new TestCase( SECTION,
155 "VAR1 = 0; VAR2= -Infinity; VAR2 /= VAR1",
156 Number.NEGATIVE_INFINITY,
157 eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 /= VAR1; VAR2") );
159 new TestCase( SECTION,
160 "VAR1 = Infinity; VAR2= Infinity; VAR1 /= VAR2",
162 eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") );
164 new TestCase( SECTION,
165 "VAR1 = Infinity; VAR2= -Infinity; VAR1 /= VAR2",
167 eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") );
169 new TestCase( SECTION,
170 "VAR1 =-Infinity; VAR2= Infinity; VAR1 /= VAR2",
172 eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") );
174 new TestCase( SECTION,
175 "VAR1 =-Infinity; VAR2=-Infinity; VAR1 /= VAR2",
177 eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") );
179 new TestCase( SECTION,
180 "VAR1 = 0; VAR2= 0; VAR1 /= VAR2",
182 eval("VAR1 = 0; VAR2 = 0; VAR1 /= VAR2; VAR1") );
184 new TestCase( SECTION,
185 "VAR1 = 0; VAR2= -0; VAR1 /= VAR2",
187 eval("VAR1 = 0; VAR2 = -0; VAR1 /= VAR2; VAR1") );
189 new TestCase( SECTION,
190 "VAR1 = -0; VAR2= 0; VAR1 /= VAR2",
192 eval("VAR1 = -0; VAR2 = 0; VAR1 /= VAR2; VAR1") );
194 new TestCase( SECTION,
195 "VAR1 = -0; VAR2= -0; VAR1 /= VAR2",
197 eval("VAR1 = -0; VAR2 = -0; VAR1 /= VAR2; VAR1") );
199 new TestCase( SECTION,
200 "VAR1 = 1; VAR2= 0; VAR1 /= VAR2",
201 Number.POSITIVE_INFINITY,
202 eval("VAR1 = 1; VAR2 = 0; VAR1 /= VAR2; VAR1") );
204 new TestCase( SECTION,
205 "VAR1 = 1; VAR2= -0; VAR1 /= VAR2",
206 Number.NEGATIVE_INFINITY,
207 eval("VAR1 = 1; VAR2 = -0; VAR1 /= VAR2; VAR1") );
209 new TestCase( SECTION,
210 "VAR1 = -1; VAR2= 0; VAR1 /= VAR2",
211 Number.NEGATIVE_INFINITY,
212 eval("VAR1 = -1; VAR2 = 0; VAR1 /= VAR2; VAR1") );
214 new TestCase( SECTION,
215 "VAR1 = -1; VAR2= -0; VAR1 /= VAR2",
216 Number.POSITIVE_INFINITY,
217 eval("VAR1 = -1; VAR2 = -0; VAR1 /= VAR2; VAR1") );
220 new TestCase( SECTION,
221 "VAR1 = 1000; VAR2 = '10', VAR1 /= VAR2; VAR1",
223 eval("VAR1 = 1000; VAR2 = '10', VAR1 /= VAR2; VAR1") );
225 new TestCase( SECTION,
226 "VAR1 = '1000'; VAR2 = 10, VAR1 /= VAR2; VAR1",
228 eval("VAR1 = '1000'; VAR2 = 10, VAR1 /= VAR2; VAR1") );
230 new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 /= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 /= VAR2") );
231 new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 /= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 /= VAR2") );
233 new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 /= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 /= VAR2") );
234 new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 /= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 /= VAR2") );
235 new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 /= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 /= VAR2") );
238 new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 /= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 /= VAR2") );
239 new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 /= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 /= VAR2") );
242 new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 /= VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 /= VAR2; VAR1") );
243 new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 /= VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 /= VAR2; VAR1") );
244 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") );
245 new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 /= VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 /= VAR2") );