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

Side by Side Diff: tests/corelib_2/error_stack_trace_test.dart

Issue 2987793002: Migrate test block 7 to Dart 2.0. (Closed)
Patch Set: Final review comment, dropping static multitest Created 3 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 4
5 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 6
7 void argument() { 7 void argument() {
8 throw new ArgumentError(499); 8 throw new ArgumentError(499);
9 } 9 }
10 10
11 // Verify that
11 void noSuchMethod() { 12 void noSuchMethod() {
12 (499).doesNotExist(); 13 (499 as dynamic).doesNotExist();
13 } 14 }
14 15
15 void nullThrown() { 16 void nullThrown() {
16 throw null; 17 throw null;
17 } 18 }
18 19
19 void range() { 20 void range() {
20 throw new RangeError.range(0, 1, 2); 21 throw new RangeError.range(0, 1, 2);
21 } 22 }
22 23
23 void fallThrough() {
24 nested() {}
25
26 switch (5) {
27 case 5:
28 nested();
29 default:
30 Expect.fail("Should not reach");
31 }
32 }
33
34 abstract class A { 24 abstract class A {
35 foo(); 25 foo();
36 } 26 }
37 27
38 void abstractClassInstantiation() {
39 new A();
40 }
41
42 void unsupported() { 28 void unsupported() {
43 throw new UnsupportedError("unsupported"); 29 throw new UnsupportedError("unsupported");
44 } 30 }
45 31
46 void unimplemented() { 32 void unimplemented() {
47 throw new UnimplementedError("unimplemented"); 33 throw new UnimplementedError("unimplemented");
48 } 34 }
49 35
50 void state() { 36 void state() {
51 return [1, 2].single; 37 [1, 2].single;
52 } 38 }
53 39
54 void type() { 40 void cast() {
55 return 1 + "string"; 41 dynamic d = 1;
42 d as String;
56 } 43 }
57 44
58 main() { 45 main() {
59 List<Function> errorFunctions = [ 46 List<Function> errorFunctions = [
60 argument, 47 argument,
61 noSuchMethod, 48 noSuchMethod,
62 nullThrown, 49 nullThrown, //# nullThrown: ok
63 range, 50 range,
64 fallThrough,
65 abstractClassInstantiation,
66 unsupported, 51 unsupported,
67 unimplemented, 52 unimplemented,
68 state, 53 state,
69 type 54 cast,
70 ]; 55 ];
71 56
72 for (var f in errorFunctions) { 57 for (var f in errorFunctions) {
73 bool hasThrown = false; 58 bool hasThrown = false;
74 try { 59 try {
75 f(); 60 f();
76 } catch (e) { 61 } catch (e) {
77 hasThrown = true; 62 hasThrown = true;
78 Expect.isTrue( 63 Expect.isTrue(
79 e.stackTrace is StackTrace, "$e doesn't have a non-null stack trace"); 64 e.stackTrace is StackTrace, "$e doesn't have a non-null stack trace");
80 } 65 }
81 Expect.isTrue(hasThrown); 66 Expect.isTrue(hasThrown);
82 } 67 }
83 } 68 }
OLDNEW
« no previous file with comments | « tests/corelib_2/error_stack_trace2_test.dart ('k') | tests/corelib_strong/double_round2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698