* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / Microsoft.JScript / Test / Mozilla / ecma / Expressions / 11.13.2-2.js
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
4  *
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/
9  *
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
13  * License.
14  *
15  * The Original Code is Mozilla Communicator client code, released
16  * March 31, 1998.
17  *
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.
22  *
23  * Contributor(s):
24  *
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.
36  *
37  * ***** END LICENSE BLOCK ***** */
38 /**
39    File Name:          11.13.2-2js
40    ECMA Section:       11.13.2 Compound Assignment: /=
41    Description:
42
43    *= /= %= += -= <<= >>= >>>= &= ^= |=
44
45    11.13.2 Compound assignment ( op= )
46
47    The production AssignmentExpression :
48    LeftHandSideExpression @ = AssignmentExpression, where @ represents one of
49    the operators indicated above, is evaluated as follows:
50
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)).
57    7.  Return Result(5).
58
59    Author:             christine@netscape.com
60    Date:               12 november 1997
61 */
62 var SECTION = "11.13.2-2";
63 var VERSION = "ECMA_1";
64 startTest();
65
66 writeHeaderToLog( SECTION + " Compound Assignment: /=");
67
68
69 // NaN cases
70
71 new TestCase( SECTION,    
72               "VAR1 = NaN; VAR2=1; VAR1 /= VAR2",       
73               Number.NaN, 
74               eval("VAR1 = Number.NaN; VAR2=1; VAR1 /= VAR2") );
75
76 new TestCase( SECTION,    
77               "VAR1 = NaN; VAR2=1; VAR1 /= VAR2; VAR1", 
78               Number.NaN, 
79               eval("VAR1 = Number.NaN; VAR2=1; VAR1 /= VAR2; VAR1") );
80
81 new TestCase( SECTION,    
82               "VAR1 = NaN; VAR2=0; VAR1 /= VAR2",       
83               Number.NaN, 
84               eval("VAR1 = Number.NaN; VAR2=0; VAR1 /= VAR2") );
85
86 new TestCase( SECTION,    
87               "VAR1 = NaN; VAR2=0; VAR1 /= VAR2; VAR1", 
88               Number.NaN, 
89               eval("VAR1 = Number.NaN; VAR2=0; VAR1 /= VAR2; VAR1") );
90
91 new TestCase( SECTION,    
92               "VAR1 = 0; VAR2=NaN; VAR1 /= VAR2",       
93               Number.NaN, 
94               eval("VAR1 = 0; VAR2=Number.NaN; VAR1 /= VAR2") );
95
96 new TestCase( SECTION,    
97               "VAR1 = 0; VAR2=NaN; VAR1 /= VAR2; VAR1", 
98               Number.NaN, 
99               eval("VAR1 = 0; VAR2=Number.NaN; VAR1 /= VAR2; VAR1") );
100
101 // number cases
102 new TestCase( SECTION,    
103               "VAR1 = 0; VAR2=1; VAR1 /= VAR2",         
104               0,          
105               eval("VAR1 = 0; VAR2=1; VAR1 /= VAR2") );
106
107 new TestCase( SECTION,    
108               "VAR1 = 0; VAR2=1; VAR1 /= VAR2;VAR1",    
109               0,          
110               eval("VAR1 = 0; VAR2=1; VAR1 /= VAR2;VAR1") );
111
112 new TestCase( SECTION,    
113               "VAR1 = 0xFF; VAR2 = 0xA, VAR1 /= VAR2", 
114               25.5,      
115               eval("VAR1 = 0XFF; VAR2 = 0XA, VAR1 /= VAR2") );
116
117 // special division cases
118
119 new TestCase( SECTION,    
120               "VAR1 = 0; VAR2= Infinity; VAR1 /= VAR2",    
121               0,      
122               eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") );
123
124 new TestCase( SECTION,    
125               "VAR1 = -0; VAR2= Infinity; VAR1 /= VAR2",   
126               0,      
127               eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") );
128
129 new TestCase( SECTION,    
130               "VAR1 = -0; VAR2= -Infinity; VAR1 /= VAR2",  
131               0,      
132               eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") );
133
134 new TestCase( SECTION,    
135               "VAR1 = 0; VAR2= -Infinity; VAR1 /= VAR2",   
136               0,      
137               eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") );
138
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") );
143
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") );
148
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") );
153
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") );
158
159 new TestCase( SECTION,    
160               "VAR1 = Infinity; VAR2= Infinity; VAR1 /= VAR2",   
161               Number.NaN,      
162               eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") );
163
164 new TestCase( SECTION,    
165               "VAR1 = Infinity; VAR2= -Infinity; VAR1 /= VAR2",  
166               Number.NaN,      
167               eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") );
168
169 new TestCase( SECTION,    
170               "VAR1 =-Infinity; VAR2= Infinity; VAR1 /= VAR2",   
171               Number.NaN,      
172               eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") );
173
174 new TestCase( SECTION,    
175               "VAR1 =-Infinity; VAR2=-Infinity; VAR1 /= VAR2",   
176               Number.NaN,      
177               eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") );
178
179 new TestCase( SECTION,    
180               "VAR1 = 0; VAR2= 0; VAR1 /= VAR2",    
181               Number.NaN,      
182               eval("VAR1 = 0; VAR2 = 0; VAR1 /= VAR2; VAR1") );
183
184 new TestCase( SECTION,    
185               "VAR1 = 0; VAR2= -0; VAR1 /= VAR2",   
186               Number.NaN,     
187               eval("VAR1 = 0; VAR2 = -0; VAR1 /= VAR2; VAR1") );
188
189 new TestCase( SECTION,    
190               "VAR1 = -0; VAR2= 0; VAR1 /= VAR2",   
191               Number.NaN,      
192               eval("VAR1 = -0; VAR2 = 0; VAR1 /= VAR2; VAR1") );
193
194 new TestCase( SECTION,    
195               "VAR1 = -0; VAR2= -0; VAR1 /= VAR2",  
196               Number.NaN,      
197               eval("VAR1 = -0; VAR2 = -0; VAR1 /= VAR2; VAR1") );
198
199 new TestCase( SECTION,    
200               "VAR1 = 1; VAR2= 0; VAR1 /= VAR2",    
201               Number.POSITIVE_INFINITY,      
202               eval("VAR1 = 1; VAR2 = 0; VAR1 /= VAR2; VAR1") );
203
204 new TestCase( SECTION,    
205               "VAR1 = 1; VAR2= -0; VAR1 /= VAR2",   
206               Number.NEGATIVE_INFINITY,      
207               eval("VAR1 = 1; VAR2 = -0; VAR1 /= VAR2; VAR1") );
208
209 new TestCase( SECTION,    
210               "VAR1 = -1; VAR2= 0; VAR1 /= VAR2",   
211               Number.NEGATIVE_INFINITY,      
212               eval("VAR1 = -1; VAR2 = 0; VAR1 /= VAR2; VAR1") );
213
214 new TestCase( SECTION,    
215               "VAR1 = -1; VAR2= -0; VAR1 /= VAR2",  
216               Number.POSITIVE_INFINITY,      
217               eval("VAR1 = -1; VAR2 = -0; VAR1 /= VAR2; VAR1") );
218
219 // string cases
220 new TestCase( SECTION,    
221               "VAR1 = 1000; VAR2 = '10', VAR1 /= VAR2; VAR1", 
222               100,       
223               eval("VAR1 = 1000; VAR2 = '10', VAR1 /= VAR2; VAR1") );
224
225 new TestCase( SECTION,    
226               "VAR1 = '1000'; VAR2 = 10, VAR1 /= VAR2; VAR1", 
227               100,       
228               eval("VAR1 = '1000'; VAR2 = 10, VAR1 /= VAR2; VAR1") );
229 /*
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") );
232
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") );
236
237   // boolean cases
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") );
240
241   // object cases
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") );
246
247 */
248
249 test();
250