OLD | NEW |
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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
8 | 8 |
9 get await => 4; | 9 get await => 4; |
10 | 10 |
11 // For functions that are declared with the async modifier we treat await as | 11 // For functions that are declared with the async modifier we treat await as |
12 // keyword. | 12 // keyword. |
13 | 13 |
14 test0() async { | 14 test0() async { |
15 var x = await 7; | 15 var x = await 7; |
16 Expect.equals(7, x); | 16 Expect.equals(7, x); |
17 var await = 1; /// await1: compile-time error | 17 var await = 1; // /// await1: compile-time error |
18 } | 18 } |
19 | 19 |
20 test1() async { | 20 test1() async { |
21 var x = await 9; | 21 var x = await 9; |
22 Expect.equals(9, x); | 22 Expect.equals(9, x); |
23 var y = await; /// await2: compile-time error | 23 var y = await; // /// await2: compile-time error |
24 } | 24 } |
25 | 25 |
26 // For functions that are not declared with the async modifier we allow await to | 26 // For functions that are not declared with the async modifier we allow await to |
27 // be used as an identifier. | 27 // be used as an identifier. |
28 | 28 |
29 test2() { | 29 test2() { |
30 var y = await; | 30 var y = await; |
31 Expect.equals(4, y); | 31 Expect.equals(4, y); |
32 var x = await 1; /// await3: compile-time error | 32 var x = await 1; // /// await3: compile-time error |
33 } | 33 } |
34 | 34 |
35 test3() { | 35 test3() { |
36 var await = 3; | 36 var await = 3; |
37 Expect.equals(3, await); | 37 Expect.equals(3, await); |
38 var x = await 1; /// await4: compile-time error | 38 var x = await 1; // /// await4: compile-time error |
39 } | 39 } |
40 | 40 |
41 main() { | 41 main() { |
42 test0(); | 42 test0(); |
43 test1(); | 43 test1(); |
44 test2(); | 44 test2(); |
45 test3(); | 45 test3(); |
46 } | 46 } |
OLD | NEW |