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

Side by Side Diff: tests/language/getter_no_setter_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 // Verifies behavior with a static getter, but no field and no setter. 4 // Verifies behavior with a static getter, but no field and no setter.
5 5
6 class Example { 6 class Example {
7 static int _var = 1; 7 static int _var = 1;
8 static int get nextVar => _var++; 8 static int get nextVar => _var++;
9 Example() { 9 Example() {
10 { 10 {
11 bool flag_exception = false; 11 bool flag_exception = false;
12 try { 12 try {
13 nextVar = 1; // Equivalent to this.nextVar = 1. 13 nextVar = 1; // Equivalent to this.nextVar = 1.
14 } catch (var excpt) { 14 } catch (excpt) {
15 flag_exception = true; 15 flag_exception = true;
16 } 16 }
17 Expect.isTrue(flag_exception); 17 Expect.isTrue(flag_exception);
18 } 18 }
19 { 19 {
20 bool flag_exception = false; 20 bool flag_exception = false;
21 try { 21 try {
22 this.nextVar = 1; /// 00: static type warning 22 this.nextVar = 1; /// 00: static type warning
23 } catch (var excpt) { 23 } catch (excpt) {
24 flag_exception = true; 24 flag_exception = true;
25 } 25 }
26 Expect.isTrue(flag_exception); /// 00: continued 26 Expect.isTrue(flag_exception); /// 00: continued
27 } 27 }
28 } 28 }
29 static test() { 29 static test() {
30 nextVar = 0; /// 01: compile-time error 30 nextVar = 0; /// 01: compile-time error
31 this.nextVar = 0; /// 02: compile-time error 31 this.nextVar = 0; /// 02: compile-time error
32 } 32 }
33 } 33 }
34 34
35 class Example1 { 35 class Example1 {
36 Example1(int i) { } 36 Example1(int i) { }
37 } 37 }
38 38
39 class Example2 extends Example1 { 39 class Example2 extends Example1 {
40 static int _var = 1; 40 static int _var = 1;
41 static int get nextVar => _var++; 41 static int get nextVar => _var++;
42 Example2() : super(nextVar) { } // No 'this' in scope. 42 Example2() : super(nextVar) { } // No 'this' in scope.
43 } 43 }
44 44
45 void main() { 45 void main() {
46 Example x = new Example(); 46 Example x = new Example();
47 Example.test(); 47 Example.test();
48 Example2 x2 = new Example2(); 48 Example2 x2 = new Example2();
49 } 49 }
OLDNEW
« no previous file with comments | « tests/language/getter_closure_execution_order_test.dart ('k') | tests/language/implied_interface_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698