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

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

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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
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 --no-background-compilation 5 // VMOptions=--optimization-counter-threshold=10 --no-background-compilation
6 // VMOptions=--optimization-counter-threshold=10 --no-background-compilation --s tress-async-stacks 6 // VMOptions=--optimization-counter-threshold=10 --no-background-compilation --s tress-async-stacks
7 7
8 import 'package:expect/expect.dart'; 8 import 'package:expect/expect.dart';
9 9
10 import 'dart:async'; 10 import 'dart:async';
11 11
12 int globalVariable = 1; 12 int globalVariable = 1;
13 int topLevelFoo(int param) => 1; 13 int topLevelFoo(int param) => 1;
14 int get topLevelGetter => globalVariable; 14 int get topLevelGetter => globalVariable;
15 void set topLevelSetter(val) { 15 void set topLevelSetter(val) {
16 globalVariable = val; 16 globalVariable = val;
17 } 17 }
18 18
19 class C { 19 class C {
20 static int staticField = 1; 20 static int staticField = 1;
21 static int get staticGetter => staticField; 21 static int get staticGetter => staticField;
22 static void set staticSetter(val) { 22 static void set staticSetter(val) {
23 staticField = val; 23 staticField = val;
24 } 24 }
25
25 static int staticFoo(int param) => param; 26 static int staticFoo(int param) => param;
26 27
27 int field = 1; 28 int field = 1;
28 int get getter => field; 29 int get getter => field;
29 void set setter(val) { 30 void set setter(val) {
30 field = val; 31 field = val;
31 } 32 }
33
32 int foo(int param) => param; 34 int foo(int param) => param;
33 } 35 }
34 36
35 dummy() => 1; 37 dummy() => 1;
36 38
37 staticMembers() async { 39 staticMembers() async {
38 var a = C.staticField + await dummy(); 40 var a = C.staticField + await dummy();
39 Expect.equals(a, 2); 41 Expect.equals(a, 2);
40 var f = (C.staticField = 1) + await dummy(); 42 var f = (C.staticField = 1) + await dummy();
41 Expect.equals(f, 2); 43 Expect.equals(f, 2);
42 var b = C.staticGetter + await dummy(); 44 var b = C.staticGetter + await dummy();
43 Expect.equals(b, 2); 45 Expect.equals(b, 2);
44 var c = (C.staticSetter = 1) + await dummy(); 46 var c = (C.staticSetter = 1) + await dummy();
45 Expect.equals(c, 2); 47 Expect.equals(c, 2);
46 var d = C.staticFoo(2) + await dummy(); 48 var d = C.staticFoo(2) + await dummy();
47 Expect.equals(d, 3); 49 Expect.equals(d, 3);
48 var e = C.staticField + 50 var e = C.staticField +
49 C.staticGetter + 51 C.staticGetter +
50 (C.staticSetter = 1) + 52 (C.staticSetter = 1) +
51 C.staticFoo(1) + 53 C.staticFoo(1) +
52 await dummy(); 54 await dummy();
53 Expect.equals(e, 5); 55 Expect.equals(e, 5);
54 } 56 }
55 57
56 topLevelMembers() async { 58 topLevelMembers() async {
57 var a = globalVariable + await dummy(); 59 var a = globalVariable + await dummy();
58 Expect.equals(a, 2); 60 Expect.equals(a, 2);
59 var b = topLevelGetter + await dummy(); 61 var b = topLevelGetter + await dummy();
60 Expect.equals(b, 2); 62 Expect.equals(b, 2);
61 var c = (topLevelSetter = 1) + await dummy(); 63 var c = (topLevelSetter = 1) + await dummy();
62 Expect.equals(c, 2); 64 Expect.equals(c, 2);
63 var d = topLevelFoo(1) + await dummy(); 65 var d = topLevelFoo(1) + await dummy();
64 Expect.equals(d, 2); 66 Expect.equals(d, 2);
65 var e = globalVariable + 67 var e = globalVariable +
66 topLevelGetter + 68 topLevelGetter +
67 (topLevelSetter = 1) + 69 (topLevelSetter = 1) +
68 topLevelFoo(1) + 70 topLevelFoo(1) +
69 await dummy(); 71 await dummy();
70 Expect.equals(e, 5); 72 Expect.equals(e, 5);
71 } 73 }
72 74
73 instanceMembers() async { 75 instanceMembers() async {
74 var inst = new C(); 76 var inst = new C();
75 var a = inst.field + await dummy(); 77 var a = inst.field + await dummy();
76 Expect.equals(a, 2); 78 Expect.equals(a, 2);
77 var b = inst.getter + await dummy(); 79 var b = inst.getter + await dummy();
78 Expect.equals(b, 2); 80 Expect.equals(b, 2);
79 var c = (inst.setter = 1) + await dummy(); 81 var c = (inst.setter = 1) + await dummy();
80 Expect.equals(c, 2); 82 Expect.equals(c, 2);
81 var d = inst.foo(1) + await dummy(); 83 var d = inst.foo(1) + await dummy();
82 Expect.equals(d, 2); 84 Expect.equals(d, 2);
83 var e = inst.field + 85 var e = inst.field +
84 inst.getter + 86 inst.getter +
85 (inst.setter = 1) + 87 (inst.setter = 1) +
86 inst.foo(1) + 88 inst.foo(1) +
87 await dummy(); 89 await dummy();
88 Expect.equals(e, 5); 90 Expect.equals(e, 5);
89 } 91 }
90 92
91 await() => 4; 93 await() => 4;
92 nonAsyncFunction() => await(); 94 nonAsyncFunction() => await();
93 95
94 others() async { 96 others() async {
95 var a = "${globalVariable} ${await dummy()} " + await "someString"; 97 var a = "${globalVariable} ${await dummy()} " + await "someString";
96 Expect.equals(a, "1 1 someString"); 98 Expect.equals(a, "1 1 someString");
97 try { 99 try {
98 var c = new C(); 100 var c = new C();
99 var d = c.nooooo() + await dummy(); 101 var d = c.nooooo() + await dummy();
100 } catch (e) {} 102 } catch (e) {}
101 var cnt = 2; 103 var cnt = 2;
102 var b = [1,2,3]; 104 var b = [1, 2, 3];
103 b[cnt] = await dummy(); 105 b[cnt] = await dummy();
104 Expect.equals(b[cnt], 1); 106 Expect.equals(b[cnt], 1);
105 var e = b[0] + await dummy(); 107 var e = b[0] + await dummy();
106 Expect.equals(e, 2); 108 Expect.equals(e, 2);
107 Expect.equals(nonAsyncFunction(), 4); 109 Expect.equals(nonAsyncFunction(), 4);
108 } 110 }
109 111
110 conditionals() async { 112 conditionals() async {
111 var a = false; 113 var a = false;
112 var b = true; 114 var b = true;
113 var c = (a || b) || await dummy(); 115 var c = (a || b) || await dummy();
114 Expect.isTrue(c); 116 Expect.isTrue(c);
115 var d = (a || b) ? a : await dummy(); 117 var d = (a || b) ? a : await dummy();
116 Expect.isFalse(d); 118 Expect.isFalse(d);
117 var e = (a is int) ? await dummy() : 2; 119 var e = (a is int) ? await dummy() : 2;
118 Expect.equals(e, 2); 120 Expect.equals(e, 2);
119 try { 121 try {
120 var f = (a is int) ? await dummy() : 2; 122 var f = (a is int) ? await dummy() : 2;
121 } catch(e) {} 123 } catch (e) {}
122 } 124 }
123 125
124 main() { 126 main() {
125 for (int i = 0; i < 10; i++) { 127 for (int i = 0; i < 10; i++) {
126 staticMembers(); 128 staticMembers();
127 topLevelMembers(); 129 topLevelMembers();
128 instanceMembers(); 130 instanceMembers();
129 conditionals(); 131 conditionals();
130 others(); 132 others();
131 } 133 }
132 } 134 }
133
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698