OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'package:async_helper/async_helper.dart'; | 6 import 'package:async_helper/async_helper.dart'; |
7 import 'package:compiler/src/commandline_options.dart'; | 7 import 'package:compiler/src/commandline_options.dart'; |
8 import 'package:compiler/src/common.dart'; | 8 import 'package:compiler/src/common.dart'; |
9 import 'package:compiler/src/compiler.dart'; | 9 import 'package:compiler/src/compiler.dart'; |
10 import 'package:compiler/src/kernel/kernel_backend_strategy.dart'; | 10 import 'package:compiler/src/kernel/kernel_backend_strategy.dart'; |
11 import 'package:compiler/src/js_model/js_strategy.dart'; | 11 import 'package:compiler/src/js_model/js_strategy.dart'; |
12 import 'package:expect/expect.dart'; | 12 import 'package:expect/expect.dart'; |
13 import '../kernel/compiler_helper.dart'; | 13 import '../kernel/compiler_helper.dart'; |
14 import '../serialization/helper.dart'; | 14 import '../serialization/helper.dart'; |
15 | 15 |
16 const Map<String, String> SOURCE = const <String, String>{ | 16 const Map<String, String> SOURCE = const <String, String>{ |
17 'main.dart': r''' | 17 'main.dart': r''' |
18 foo({named}) => 1; | 18 foo({named}) => 1; |
19 bar(a) => !a; | 19 bar(a) => !a; |
20 class Class { | 20 class Class { |
21 var field; | 21 var field; |
| 22 static var staticField; |
22 | 23 |
23 Class(); | 24 Class(); |
24 Class.named(this.field); | 25 Class.named(this.field); |
25 | 26 |
26 method() {} | 27 method() {} |
27 } | 28 } |
28 | 29 |
29 class SubClass extends Class { | 30 class SubClass extends Class { |
30 method() { | 31 method() { |
31 super.method(); | 32 super.method(); |
32 } | 33 } |
33 } | 34 } |
34 | 35 |
35 main() { | 36 main() { |
36 foo(); | 37 foo(); |
37 bar(true); | 38 bar(true); |
38 []; | 39 []; |
39 {}; | 40 {}; |
40 new Object(); | 41 new Object(); |
41 new Class.named(''); | 42 new Class.named(''); |
42 new SubClass().method(); | 43 new SubClass().method(); |
| 44 Class.staticField; |
| 45 var x = null; |
| 46 var y1 = x == null; |
| 47 var y2 = null == x; |
| 48 var z1 = x?.toString(); |
| 49 var z2 = x ?? y1; |
| 50 var z3 = x ??= y2; |
| 51 return x; |
43 } | 52 } |
44 ''' | 53 ''' |
45 }; | 54 }; |
46 | 55 |
47 main(List<String> args) { | 56 main(List<String> args) { |
48 useJsStrategyForTesting = true; | 57 useJsStrategyForTesting = true; |
49 asyncTest(() async { | 58 asyncTest(() async { |
50 await mainInternal(args); | 59 await mainInternal(args); |
51 }); | 60 }); |
52 } | 61 } |
(...skipping 14 matching lines...) Expand all Loading... |
67 enableDebugMode(); | 76 enableDebugMode(); |
68 | 77 |
69 Compiler compiler1 = await compileWithDill(entryPoint, memorySourceFiles, [ | 78 Compiler compiler1 = await compileWithDill(entryPoint, memorySourceFiles, [ |
70 Flags.disableInlining, | 79 Flags.disableInlining, |
71 Flags.disableTypeInference | 80 Flags.disableTypeInference |
72 ], beforeRun: (Compiler compiler) { | 81 ], beforeRun: (Compiler compiler) { |
73 compiler.backendStrategy = new JsBackendStrategy(compiler); | 82 compiler.backendStrategy = new JsBackendStrategy(compiler); |
74 }, printSteps: true); | 83 }, printSteps: true); |
75 Expect.isFalse(compiler1.compilationFailed); | 84 Expect.isFalse(compiler1.compilationFailed); |
76 } | 85 } |
OLD | NEW |