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

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

Issue 2768073002: Format all multitests (Closed)
Patch Set: Created 3 years, 9 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
6 import 'package:expect/expect.dart'; 5 import 'package:expect/expect.dart';
7 6
8 import 'dart:async'; 7 import 'dart:async';
9 8
10 topLevelFunction() async { } 9 topLevelFunction() async {}
11 10
12 Future<int> topLevelWithParameter(int a) async { 11 Future<int> topLevelWithParameter(int a) async {
13 return 7 + a; 12 return 7 + a;
14 } 13 }
15 14
16 int //# type-mismatch2: static type warning, dynamic type error 15 int //# type-mismatch2: static type warning, dynamic type error
17 topLevelWithParameterWrongType(int a) async { 16 topLevelWithParameterWrongType(int a) async {
18 return 7 + a; 17 return 7 + a;
19 } 18 }
20 19
21 var what = 'async getter'; 20 var what = 'async getter';
22 Future<String> get topLevelGetter async { 21 Future<String> get topLevelGetter async {
23 return 'I want to be an ${what}'; 22 return 'I want to be an ${what}';
24 } 23 }
25 24
26 class A { 25 class A {
27 static int staticVar = 1; 26 static int staticVar = 1;
28 27
29 static staticMethod(int param) async => staticVar + param; 28 static staticMethod(int param) async => staticVar + param;
30 static get staticGetter async => staticVar + 3; 29 static get staticGetter async => staticVar + 3;
31 30
32 int _x; 31 int _x;
33 A(this._x); 32 A(this._x);
34 33
35 A.fail() async; // //# constructor2: compile-time error 34 A.fail() async; // //# constructor2: compile-time error
36 factory A.create() async {return null; } //# constructor3: compile-time error 35 factory A.create() async {return null; } //# constructor3: compile-time error
37 36
38 int someMethod(int param1, int param2, int param3) async => _x + param2; //# t ype-mismatch3: static type warning, dynamic type error 37 int someMethod(int param1, int param2, int param3) async => _x + param2; //# t ype-mismatch3: static type warning, dynamic type error
39 int get getter async { return 5 + _x; } //# type-mismatch4: static type warnin g, dynamic type error 38 int get getter async { return 5 + _x; } //# type-mismatch4: static type warnin g, dynamic type error
40 operator+(A other) async { 39 operator +(A other) async {
41 return new A(_x + other._x); 40 return new A(_x + other._x);
42 } 41 }
43 42
44 get value => _x; 43 get value => _x;
45 } 44 }
46 45
47 class B { 46 class B {
48 final _y; 47 final _y;
49 const B._internal(this._y); 48 const B._internal(this._y);
50 const factory B.createConst(int y) async = A._internal; // //# constructor4: c ompile-time error 49 const factory B.createConst(int y) async = A._internal; // //# constructor4: c ompile-time error
51 50
52 B() : _y = null; 51 B() : _y = null;
53 52
54 set dontDoThat(value) async {} // //# setter1: compile-time error 53 set dontDoThat(value) async {} // //# setter1: compile-time error
55 } 54 }
56 55
57
58 main() { 56 main() {
59 var asyncReturn; 57 var asyncReturn;
60 58
61 asyncReturn = topLevelFunction(); 59 asyncReturn = topLevelFunction();
62 Expect.isTrue(asyncReturn is Future); 60 Expect.isTrue(asyncReturn is Future);
63 61
64 int a1 = topLevelWithParameter(2); // //# type-mismatch1: static type warning, dynamic type error 62 int a1 = topLevelWithParameter(2); // //# type-mismatch1: static type warning, dynamic type error
65 int a2 = topLevelWithParameterWrongType(2); // //# type-mismatch2: continued 63 int a2 = topLevelWithParameterWrongType(2); // //# type-mismatch2: continued
66 asyncReturn = topLevelWithParameter(4); 64 asyncReturn = topLevelWithParameter(4);
67 Expect.isTrue(asyncReturn is Future); 65 Expect.isTrue(asyncReturn is Future);
(...skipping 25 matching lines...) Expand all
93 var b = new A(9); 91 var b = new A(9);
94 asyncReturn = a + b; 92 asyncReturn = a + b;
95 Expect.isTrue(asyncReturn is Future); 93 Expect.isTrue(asyncReturn is Future);
96 asyncReturn.then((A result) => Expect.equals(result.value, 22)); 94 asyncReturn.then((A result) => Expect.equals(result.value, 22));
97 95
98 var foo = 17; 96 var foo = 17;
99 bar(int p1, p2) async { 97 bar(int p1, p2) async {
100 var z = 8; 98 var z = 8;
101 return p2 + z + foo; 99 return p2 + z + foo;
102 } 100 }
103 asyncReturn = bar(1,2); 101
102 asyncReturn = bar(1, 2);
104 Expect.isTrue(asyncReturn is Future); 103 Expect.isTrue(asyncReturn is Future);
105 asyncReturn.then((int result) => Expect.equals(result, 27)); 104 asyncReturn.then((int result) => Expect.equals(result, 27));
106 105
107 var moreNesting = (int shadowP1, String p2, num p3) { 106 var moreNesting = (int shadowP1, String p2, num p3) {
108 var z = 3; 107 var z = 3;
109 aa(int shadowP1) async { 108 aa(int shadowP1) async {
110 return foo + z + p3 + shadowP1; 109 return foo + z + p3 + shadowP1;
111 } 110 }
111
112 return aa(6); 112 return aa(6);
113 }; 113 };
114 asyncReturn = moreNesting(1, "ignore", 2); 114 asyncReturn = moreNesting(1, "ignore", 2);
115 Expect.isTrue(asyncReturn is Future); 115 Expect.isTrue(asyncReturn is Future);
116 asyncReturn.then((int result) => Expect.equals(result, 28)); 116 asyncReturn.then((int result) => Expect.equals(result, 28));
117 117
118 var b1 = const B.createConst(4); // //# constructor4: compile-time error 118 var b1 = const B.createConst(4); // //# constructor4: compile-time error
119 var b2 = new B(); 119 var b2 = new B();
120 b2.dontDoThat = 4; // //# setter1: compile-time error 120 b2.dontDoThat = 4; // //# setter1: compile-time error
121 121
122 var checkAsync = (var someFunc) { 122 var checkAsync = (var someFunc) {
123 var toTest = someFunc(); 123 var toTest = someFunc();
124 Expect.isTrue(toTest is Future); 124 Expect.isTrue(toTest is Future);
125 toTest.then((int result) => Expect.equals(result, 4)); 125 toTest.then((int result) => Expect.equals(result, 4));
126 }; 126 };
127 checkAsync(() async => 4); 127 checkAsync(() async => 4);
128 128
129 new A.fail(); //# constructor2: continued 129 new A.fail(); //# constructor2: continued
130 new A.create(); //# constructor3: continued 130 new A.create(); //# constructor3: continued
131 } 131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698