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

Side by Side Diff: tests/language/await_test.dart

Issue 881403002: Fix for issue 22052 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 // VMOptions=---optimization-counter-threshold=10 5 // VMOptions=---optimization-counter-threshold=10
6 6
7 import 'package:expect/expect.dart'; 7 import 'package:expect/expect.dart';
8 8
9 import 'dart:async'; 9 import 'dart:async';
10 10
11 int globalVariable = 1; 11 int globalVariable = 1;
12 int topLevelFoo(int param) => 1; 12 int topLevelFoo(int param) => 1;
13 int get topLevelGetter => globalVariable; 13 int get topLevelGetter => globalVariable;
14 int set topLevelSetter(val) { 14 void set topLevelSetter(val) {
15 globalVariable = val; 15 globalVariable = val;
16 } 16 }
17 17
18 class C { 18 class C {
19 static int staticField = 1; 19 static int staticField = 1;
20 static int get staticGetter => staticField; 20 static int get staticGetter => staticField;
21 static int set staticSetter(val) { 21 static void set staticSetter(val) {
22 staticField = val; 22 staticField = val;
23 } 23 }
24 static int staticFoo(int param) => param; 24 static int staticFoo(int param) => param;
25 25
26 int field = 1; 26 int field = 1;
27 int get getter => field; 27 int get getter => field;
28 int set setter(val) { 28 void set setter(val) {
29 field = val; 29 field = val;
30 } 30 }
31 int foo(int param) => param; 31 int foo(int param) => param;
32 } 32 }
33 33
34 dummy() => 1; 34 dummy() => 1;
35 35
36 staticMembers() async { 36 staticMembers() async {
37 var a = C.staticField + await dummy(); 37 var a = C.staticField + await dummy();
38 Expect.equals(a, 2); 38 Expect.equals(a, 2);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 88 }
89 89
90 await() => 4; 90 await() => 4;
91 nonAsyncFunction() => await(); 91 nonAsyncFunction() => await();
92 92
93 others() async { 93 others() async {
94 var a = "${globalVariable} ${await dummy()} " + await "someString"; 94 var a = "${globalVariable} ${await dummy()} " + await "someString";
95 Expect.equals(a, "1 1 someString"); 95 Expect.equals(a, "1 1 someString");
96 try { 96 try {
97 var c = new C(); 97 var c = new C();
98 var d = c.nooooo() + await bar(); 98 var d = c.nooooo() + await dummy();
99 } catch (e) {} 99 } catch (e) {}
100 var cnt = 2; 100 var cnt = 2;
101 var b = [1,2,3]; 101 var b = [1,2,3];
102 b[cnt] = await dummy(); 102 b[cnt] = await dummy();
103 Expect.equals(b[cnt], 1); 103 Expect.equals(b[cnt], 1);
104 var e = b[0] + await dummy(); 104 var e = b[0] + await dummy();
105 Expect.equals(e, 2); 105 Expect.equals(e, 2);
106 Expect.equals(nonAsyncFunction(), 4); 106 Expect.equals(nonAsyncFunction(), 4);
107 } 107 }
108 108
109 conditionals() async { 109 conditionals() async {
110 var a = false; 110 var a = false;
111 var b = true; 111 var b = true;
112 var c = (a || b) || await dummy(); 112 var c = (a || b) || await dummy();
113 Expect.isTrue(c); 113 Expect.isTrue(c);
114 var d = (a || b) ? a : await dummy(); 114 var d = (a || b) ? a : await dummy();
115 Expect.isFalse(d); 115 Expect.isFalse(d);
116 var e = (a is int) ? await dummy() : 2; 116 var e = (a is int) ? await dummy() : 2;
117 Expect.equals(e, 2); 117 Expect.equals(e, 2);
118 try { 118 try {
119 var f = (a is intt) ? await dummy() : 2; 119 var f = (a is int) ? await dummy() : 2;
120 } catch(e) {} 120 } catch(e) {}
121 } 121 }
122 122
123 main() { 123 main() {
124 for (int i = 0; i < 10; i++) { 124 for (int i = 0; i < 10; i++) {
125 staticMembers(); 125 staticMembers();
126 topLevelMembers(); 126 topLevelMembers();
127 instanceMembers(); 127 instanceMembers();
128 conditionals(); 128 conditionals();
129 others(); 129 others();
130 } 130 }
131 } 131 }
132 132
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698