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

Side by Side Diff: tests/standalone/assert_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
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 // VMOptions=--enable_asserts 4 // VMOptions=--enable_asserts
5 // 5 //
6 // Dart test program testing assert statements. 6 // Dart test program testing assert statements.
7 7
8 class AssertTest { 8 class AssertTest {
9 static test() { 9 static test() {
10 int i = 0; 10 int i = 0;
11 try { 11 try {
12 assert(false); 12 assert(false);
13 } catch (AssertionError error) { 13 } on AssertionError catch (error) {
14 i = 1; 14 i = 1;
15 Expect.equals("false", error.failedAssertion); 15 Expect.equals("false", error.failedAssertion);
16 int pos = error.url.lastIndexOf("/", error.url.length); 16 int pos = error.url.lastIndexOf("/", error.url.length);
17 if (pos == -1) { 17 if (pos == -1) {
18 pos = error.url.lastIndexOf("\\", error.url.length); 18 pos = error.url.lastIndexOf("\\", error.url.length);
19 } 19 }
20 String subs = error.url.substring(pos + 1, error.url.length); 20 String subs = error.url.substring(pos + 1, error.url.length);
21 Expect.equals("assert_test.dart", subs); 21 Expect.equals("assert_test.dart", subs);
22 Expect.equals(12, error.line); 22 Expect.equals(12, error.line);
23 Expect.equals(14, error.column); 23 Expect.equals(14, error.column);
24 } 24 }
25 return i; 25 return i;
26 } 26 }
27 static testClosure() { 27 static testClosure() {
28 int i = 0; 28 int i = 0;
29 try { 29 try {
30 assert(() => false); 30 assert(() => false);
31 } catch (AssertionError error) { 31 } on AssertionError catch (error) {
32 i = 1; 32 i = 1;
33 Expect.equals("() => false", error.failedAssertion); 33 Expect.equals("() => false", error.failedAssertion);
34 int pos = error.url.lastIndexOf("/", error.url.length); 34 int pos = error.url.lastIndexOf("/", error.url.length);
35 if (pos == -1) { 35 if (pos == -1) {
36 pos = error.url.lastIndexOf("\\", error.url.length); 36 pos = error.url.lastIndexOf("\\", error.url.length);
37 } 37 }
38 String subs = error.url.substring(pos + 1, error.url.length); 38 String subs = error.url.substring(pos + 1, error.url.length);
39 Expect.equals("assert_test.dart", subs); 39 Expect.equals("assert_test.dart", subs);
40 Expect.equals(30, error.line); 40 Expect.equals(30, error.line);
41 Expect.equals(14, error.column); 41 Expect.equals(14, error.column);
42 } 42 }
43 return i; 43 return i;
44 } 44 }
45 45
46 static testMain() { 46 static testMain() {
47 Expect.equals(1, test()); 47 Expect.equals(1, test());
48 Expect.equals(1, testClosure()); 48 Expect.equals(1, testClosure());
49 } 49 }
50 } 50 }
51 51
52 main() { 52 main() {
53 AssertTest.testMain(); 53 AssertTest.testMain();
54 } 54 }
OLDNEW
« no previous file with comments | « tests/lib/math/math_test.dart ('k') | tests/standalone/io/directory_invalid_arguments_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698