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

Side by Side Diff: tests/compiler/dart2js_foreign/native_checked_fields_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 4
5 // Test that type checks occur on assignment to fields of native methods. 5 // Test that type checks occur on assignment to fields of native methods.
6 6
7 @native("*A") 7 @native("*A")
8 class A { 8 class A {
9 int foo; 9 int foo;
10 } 10 }
(...skipping 13 matching lines...) Expand all
24 24
25 makeA = function(){return new A;}; 25 makeA = function(){return new A;};
26 makeB = function(){return new B;}; 26 makeB = function(){return new B;};
27 """) 27 """)
28 void setup(); 28 void setup();
29 29
30 expectThrows(action()) { 30 expectThrows(action()) {
31 bool threw = false; 31 bool threw = false;
32 try { 32 try {
33 action(); 33 action();
34 } catch (var e) { 34 } catch (e) {
35 threw = true; 35 threw = true;
36 } 36 }
37 Expect.isTrue(threw); 37 Expect.isTrue(threw);
38 } 38 }
39 39
40 checkedModeTest() { 40 checkedModeTest() {
41 var things = [makeA(), makeB()]; 41 var things = [makeA(), makeB()];
42 var a = things[0]; 42 var a = things[0];
43 var b = things[1]; 43 var b = things[1];
44 44
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 Expect.equals(b.foo, 124); 93 Expect.equals(b.foo, 124);
94 } 94 }
95 95
96 bool isCheckedMode() { 96 bool isCheckedMode() {
97 var stuff = [1, 'string']; 97 var stuff = [1, 'string'];
98 var a = stuff[0]; 98 var a = stuff[0];
99 // Checked-mode detection. 99 // Checked-mode detection.
100 try { 100 try {
101 String s = a; 101 String s = a;
102 return false; 102 return false;
103 } catch (var e) { } 103 } catch (e) {
104 // Ignore.
105 }
104 return true; 106 return true;
105 } 107 }
106 108
107 main() { 109 main() {
108 setup(); 110 setup();
109 111
110 if (isCheckedMode()) { 112 if (isCheckedMode()) {
111 checkedModeTest(); 113 checkedModeTest();
112 } else { 114 } else {
113 uncheckedModeTest(); 115 uncheckedModeTest();
114 } 116 }
115 } 117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698