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

Side by Side Diff: tests/standalone/assert_test.dart

Issue 21832003: Fix VM implementation of CastError not to extend TypeError (issue 5280). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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 // Dart test program testing assert statements. 6 // Dart test program testing assert statements.
7
6 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
7 9
8 class AssertTest { 10 class AssertTest {
9 static test() { 11 static test() {
10 try { 12 try {
11 assert(false); 13 assert(false);
12 Expect.fail("Assertion 'false' didn't fail."); 14 Expect.fail("Assertion 'false' didn't fail.");
13 } on AssertionError catch (error) { 15 } on AssertionError catch (error, stacktrace) {
14 Expect.equals("false", error.failedAssertion); 16 Expect.isTrue(error.toString().contains("'false'"));
15 int pos = error.url.lastIndexOf("/", error.url.length); 17 Expect.isTrue(stacktrace.toString().contains("assert_test.dart:13:14"));
16 if (pos == -1) {
17 pos = error.url.lastIndexOf("\\", error.url.length);
18 }
19 String subs = error.url.substring(pos + 1, error.url.length);
20 Expect.equals("assert_test.dart", subs);
21 Expect.equals(11, error.line);
22 Expect.equals(14, error.column);
23 } 18 }
24 } 19 }
25 static testClosure() { 20 static testClosure() {
26 try { 21 try {
27 assert(() => false); 22 assert(() => false);
28 Expect.fail("Assertion '() => false' didn't fail."); 23 Expect.fail("Assertion '() => false' didn't fail.");
29 } on AssertionError catch (error) { 24 } on AssertionError catch (error, stacktrace) {
30 Expect.equals("() => false", error.failedAssertion); 25 Expect.isTrue(error.toString().contains("'() => false'"));
31 int pos = error.url.lastIndexOf("/", error.url.length); 26 Expect.isTrue(stacktrace.toString().contains("assert_test.dart:22:14"));
32 if (pos == -1) {
33 pos = error.url.lastIndexOf("\\", error.url.length);
34 }
35 String subs = error.url.substring(pos + 1, error.url.length);
36 Expect.equals("assert_test.dart", subs);
37 Expect.equals(27, error.line);
38 Expect.equals(14, error.column);
39 } 27 }
40 } 28 }
41 29
42 static testMain() { 30 static testMain() {
43 test(); 31 test();
44 testClosure(); 32 testClosure();
45 } 33 }
46 } 34 }
47 35
48 main() { 36 main() {
49 AssertTest.testMain(); 37 AssertTest.testMain();
50 } 38 }
OLDNEW
« tests/language/generic_test.dart ('K') | « tests/lib/analyzer/analyze_tests.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698