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

Side by Side Diff: tests/language/list_literal4_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/list_literal3_test.dart ('k') | tests/language/local_function3_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) 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_type_checks 4 // VMOptions=--enable_type_checks
5 // 5 //
6 // Dart test program testing type checks in list literals. 6 // Dart test program testing type checks in list literals.
7 7
8 class ListLiteral4Test<T> { 8 class ListLiteral4Test<T> {
9 test() { 9 test() {
10 int result = 0; 10 int result = 0;
11 try { 11 try {
12 var m = <String>[0, 1]; // 0 is not a String. 12 var m = <String>[0, 1]; // 0 is not a String.
13 } catch (TypeError error) { 13 } on TypeError catch (error) {
14 result += 1; 14 result += 1;
15 } 15 }
16 try { 16 try {
17 var m = <int>[0, 1]; 17 var m = <int>[0, 1];
18 m["0"] = 1; // "0" is not an int. 18 m["0"] = 1; // "0" is not an int.
19 } catch (TypeError error) { 19 } on TypeError catch (error) {
20 result += 10; 20 result += 10;
21 } 21 }
22 try { 22 try {
23 var m = <T>["a", "b"]; // "b" is not an int. 23 var m = <T>["a", "b"]; // "b" is not an int.
24 } catch (TypeError error) { 24 } on TypeError catch (error) {
25 result += 100; 25 result += 100;
26 } 26 }
27 try { 27 try {
28 var m = <T>[0, 1]; // OK. 28 var m = <T>[0, 1]; // OK.
29 } catch (TypeError error) { 29 } on TypeError catch (error) {
30 result += 1000; 30 result += 1000;
31 } 31 }
32 try { 32 try {
33 var m = <T>[0, 1]; 33 var m = <T>[0, 1];
34 m["0"] = 1; // "0" is not an int. 34 m["0"] = 1; // "0" is not an int.
35 } catch (TypeError error) { 35 } on TypeError catch (error) {
36 result += 10000; 36 result += 10000;
37 } 37 }
38 try { 38 try {
39 var m = const <int>[0, 1]; 39 var m = const <int>[0, 1];
40 m["0"] = 1; // "0" is not an int. 40 m["0"] = 1; // "0" is not an int.
41 } catch (TypeError error) { 41 } on TypeError catch (error) {
42 result += 100000; 42 result += 100000;
43 } 43 }
44 try { 44 try {
45 var m = <T>[0, 1]; // OK. Tested above. 45 var m = <T>[0, 1]; // OK. Tested above.
46 List<String> ls = m; // m is a List<int>, not a List<String>. 46 List<String> ls = m; // m is a List<int>, not a List<String>.
47 } catch (TypeError error) { 47 } on TypeError catch (error) {
48 result += 1000000; 48 result += 1000000;
49 } 49 }
50 50
51 return result; 51 return result;
52 } 52 }
53 } 53 }
54 54
55 main() { 55 main() {
56 var t = new ListLiteral4Test<int>(); 56 var t = new ListLiteral4Test<int>();
57 Expect.equals(1110111, t.test()); 57 Expect.equals(1110111, t.test());
58 } 58 }
59 59
60 60
OLDNEW
« no previous file with comments | « tests/language/list_literal3_test.dart ('k') | tests/language/local_function3_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698