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

Side by Side Diff: tests/language/arithmetic_test.dart

Issue 10891020: Update almost all tests (except co19) to use the new try-catch syntax. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge. Created 8 years, 3 months 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 | « tests/language/arithmetic2_test.dart ('k') | tests/language/assertion_test.dart » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #library('arithmetic_test'); 6 #library('arithmetic_test');
7 #import('dart:math'); 7 #import('dart:math');
8 8
9 class ArithmeticTest { 9 class ArithmeticTest {
10 10
11 static bool exceptionCaughtParseInt(String s) { 11 static bool exceptionCaughtParseInt(String s) {
12 try { 12 try {
13 parseInt(s); 13 parseInt(s);
14 return false; 14 return false;
15 } catch (FormatException e) { 15 } on FormatException catch (e) {
16 return true; 16 return true;
17 } 17 }
18 } 18 }
19 19
20 static bool exceptionCaughtParseDouble(String s) { 20 static bool exceptionCaughtParseDouble(String s) {
21 try { 21 try {
22 parseDouble(s); 22 parseDouble(s);
23 return false; 23 return false;
24 } catch (FormatException e) { 24 } on FormatException catch (e) {
25 return true; 25 return true;
26 } 26 }
27 } 27 }
28 28
29 static bool toIntThrowsFormatException(String str) { 29 static bool toIntThrowsFormatException(String str) {
30 // No exception allowed for parse double. 30 // No exception allowed for parse double.
31 double d = parseDouble(str); 31 double d = parseDouble(str);
32 try { 32 try {
33 var a = d.toInt(); 33 var a = d.toInt();
34 return false; 34 return false;
35 } catch (FormatException e) { 35 } on FormatException catch (e) {
36 return true; 36 return true;
37 } 37 }
38 } 38 }
39 39
40 static runOne() { 40 static runOne() {
41 var a = 22; 41 var a = 22;
42 var b = 4; 42 var b = 4;
43 // Smi & smi. 43 // Smi & smi.
44 Expect.equals(26, a + b); 44 Expect.equals(26, a + b);
45 Expect.equals(18, a - b); 45 Expect.equals(18, a - b);
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 static testMain() { 414 static testMain() {
415 for (int i = 0; i < 1500; i++) { 415 for (int i = 0; i < 1500; i++) {
416 runOne(); 416 runOne();
417 } 417 }
418 } 418 }
419 } 419 }
420 420
421 main() { 421 main() {
422 ArithmeticTest.testMain(); 422 ArithmeticTest.testMain();
423 } 423 }
OLDNEW
« no previous file with comments | « tests/language/arithmetic2_test.dart ('k') | tests/language/assertion_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698