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

Side by Side Diff: tests/language/function_malformed_result_type_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) 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 for a function with a malformed result type. 4 // Dart test for a function with a malformed result type.
5 5
6 class C<T, U> {} 6 class C<T, U> {}
7 7
8 isCheckedMode() { 8 isCheckedMode() {
9 try { 9 try {
10 var i = 1; 10 var i = 1;
11 String s = i; 11 String s = i;
12 return false; 12 return false;
13 } catch(var e) { 13 } catch (e) {
14 return true; 14 return true;
15 } 15 }
16 } 16 }
17 17
18 main() { 18 main() {
19 { 19 {
20 C<int> f() => null; 20 C<int> f() => null;
21 bool got_type_error = false; 21 bool got_type_error = false;
22 try { 22 try {
23 f(); 23 f();
24 } catch (TypeError error) { 24 } on TypeError catch (error) {
25 got_type_error = true; 25 got_type_error = true;
26 } 26 }
27 // No type error expected, since returned null is not type checked. 27 // No type error expected, since returned null is not type checked.
28 Expect.isFalse(got_type_error); 28 Expect.isFalse(got_type_error);
29 } 29 }
30 { 30 {
31 C<int> f() => new C<int, String>(); 31 C<int> f() => new C<int, String>();
32 bool got_type_error = false; 32 bool got_type_error = false;
33 try { 33 try {
34 f(); 34 f();
35 } catch (TypeError error) { 35 } on TypeError catch (error) {
36 got_type_error = true; 36 got_type_error = true;
37 } 37 }
38 // Type error expected in checked mode only. 38 // Type error expected in checked mode only.
39 Expect.isTrue(got_type_error == isCheckedMode()); 39 Expect.isTrue(got_type_error == isCheckedMode());
40 } 40 }
41 } 41 }
OLDNEW
« no previous file with comments | « tests/language/f_bounded_quantification_test.dart ('k') | tests/language/function_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698