Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Side by Side Diff: language/src/ArithmeticTest.dart

Issue 8935015: Expand ArithmeticTest to include truncate divide corner case and to trigger optimizing compiler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/tests/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // Dart test program to test arithmetic operations. 4 // Dart test program to test arithmetic operations.
5 5
6 class ArithmeticTest { 6 class ArithmeticTest {
7 7
8 static bool exceptionCaughtParseInt(String s) { 8 static bool exceptionCaughtParseInt(String s) {
9 try { 9 try {
10 Math.parseInt(s); 10 Math.parseInt(s);
(...skipping 16 matching lines...) Expand all
27 // No exception allowed for parse double. 27 // No exception allowed for parse double.
28 double d = Math.parseDouble(str); 28 double d = Math.parseDouble(str);
29 try { 29 try {
30 var a = d.toInt(); 30 var a = d.toInt();
31 return false; 31 return false;
32 } catch (BadNumberFormatException e) { 32 } catch (BadNumberFormatException e) {
33 return true; 33 return true;
34 } 34 }
35 } 35 }
36 36
37 static testMain() { 37 static runOne() {
38 var a = 22; 38 var a = 22;
39 var b = 4; 39 var b = 4;
40 // Smi & smi. 40 // Smi & smi.
41 Expect.equals(26, a + b); 41 Expect.equals(26, a + b);
42 Expect.equals(18, a - b); 42 Expect.equals(18, a - b);
43 Expect.equals(88, a * b); 43 Expect.equals(88, a * b);
44 Expect.equals(5, a ~/ b); 44 Expect.equals(5, a ~/ b);
45 Expect.equals(5.5, a / b); 45 Expect.equals(5.5, a / b);
46 Expect.equals(2.0, 10 / 5); 46 Expect.equals(2.0, 10 / 5);
47 Expect.equals(2, a % b); 47 Expect.equals(2, a % b);
48 Expect.equals(2, a.remainder(b)); 48 Expect.equals(2, a.remainder(b));
49 // Smi corner cases.
50 for (int i = 0; i < 80; i++) {
51 a = -(1 << i);
52 b = -1;
53 Expect.equals(1 << i, a ~/ b);
54 }
49 a = 22; 55 a = 22;
50 b = 4.0; 56 b = 4.0;
51 // Smi & double. 57 // Smi & double.
52 Expect.equals(26.0, a + b); 58 Expect.equals(26.0, a + b);
53 Expect.equals(18.0, a - b); 59 Expect.equals(18.0, a - b);
54 Expect.equals(88.0, a * b); 60 Expect.equals(88.0, a * b);
55 Expect.equals(5.0, a ~/ b); 61 Expect.equals(5.0, a ~/ b);
56 Expect.equals(5.5, a / b); 62 Expect.equals(5.5, a / b);
57 Expect.equals(2.0, a % b); 63 Expect.equals(2.0, a % b);
58 Expect.equals(2.0, a.remainder(b)); 64 Expect.equals(2.0, a.remainder(b));
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 Expect.equals(12.0, Math.max(1.0, 12.0)); 387 Expect.equals(12.0, Math.max(1.0, 12.0));
382 Expect.equals(false, 1.0 < Math.min(1.0, 12.0)); 388 Expect.equals(false, 1.0 < Math.min(1.0, 12.0));
383 Expect.equals(true, 1.0 < Math.max(1.0, 12.0)); 389 Expect.equals(true, 1.0 < Math.max(1.0, 12.0));
384 390
385 // Hashcode 391 // Hashcode
386 Expect.equals(false, (3.4).hashCode() == (1.2).hashCode()); 392 Expect.equals(false, (3.4).hashCode() == (1.2).hashCode());
387 Expect.equals(true, (1.2).hashCode() == (1.2).hashCode()); 393 Expect.equals(true, (1.2).hashCode() == (1.2).hashCode());
388 Expect.equals(false, (3).hashCode() == (1).hashCode()); 394 Expect.equals(false, (3).hashCode() == (1).hashCode());
389 Expect.equals(true, (10).hashCode() == (10).hashCode()); 395 Expect.equals(true, (10).hashCode() == (10).hashCode());
390 } 396 }
397
398 static testMain() {
399 for (int i = 0; i < 1500; i++) {
400 runOne();
401 }
402 }
391 } 403 }
392 404
393 main() { 405 main() {
394 ArithmeticTest.testMain(); 406 ArithmeticTest.testMain();
395 } 407 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698