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

Side by Side Diff: tests/compiler/dart2js/js_model/model_test.dart

Issue 2967933002: Bring js_model/model_test on par with compile_from_dill tests. (Closed)
Patch Set: Created 3 years, 5 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) 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/compile_from_dill_test_helper.dart';
13 import '../kernel/compiler_helper.dart'; 14 import '../kernel/compiler_helper.dart';
14 import '../serialization/helper.dart'; 15 import '../serialization/helper.dart';
15 16
16 const Map<String, String> SOURCE = const <String, String>{
17 'main.dart': r'''
18 foo({named}) => 1;
19 bar(a) => !a;
20 class Class {
21 var field;
22 static var staticField;
23
24 Class();
25 Class.named(this.field);
26
27 method() {}
28 }
29
30 class SubClass extends Class {
31 method() {
32 super.method();
33 }
34 }
35
36 main() {
37 foo();
38 bar(true);
39 [];
40 {};
41 new Object();
42 new Class.named('');
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;
52 }
53 '''
54 };
55
56 main(List<String> args) { 17 main(List<String> args) {
57 useJsStrategyForTesting = true; 18 useJsStrategyForTesting = true;
58 asyncTest(() async { 19 asyncTest(() async {
59 await mainInternal(args); 20 await mainInternal(args);
60 }); 21 });
61 } 22 }
62 23
63 Future mainInternal(List<String> args, 24 Future mainInternal(List<String> args,
64 {bool skipWarnings: false, bool skipErrors: false}) async { 25 {bool skipWarnings: false,
26 bool skipErrors: false,
27 List<String> options: const <String>[]}) async {
65 Arguments arguments = new Arguments.from(args); 28 Arguments arguments = new Arguments.from(args);
66 Uri entryPoint; 29 List<Test> tests;
67 Map<String, String> memorySourceFiles;
68 if (arguments.uri != null) { 30 if (arguments.uri != null) {
69 entryPoint = arguments.uri; 31 tests = <Test>[new Test.fromUri(arguments.uri)];
70 memorySourceFiles = const <String, String>{};
71 } else { 32 } else {
72 entryPoint = Uri.parse('memory:main.dart'); 33 tests = TESTS;
73 memorySourceFiles = SOURCE;
74 } 34 }
35 for (Test test in tests) {
36 if (test.uri != null) {
37 print('--- running test uri ${test.uri} -------------------------------');
38 } else {
39 print(
40 '--- running test code -------------------------------------------');
41 print(test.sources.values.first);
42 print('----------------------------------------------------------------');
43 }
75 44
76 enableDebugMode(); 45 enableDebugMode();
77 46
78 Compiler compiler1 = await compileWithDill(entryPoint, memorySourceFiles, [ 47 Compiler compiler1 = await compileWithDill(test.entryPoint, test.sources, [
79 Flags.disableInlining, 48 Flags.disableInlining,
80 Flags.disableTypeInference 49 Flags.disableTypeInference
81 ], beforeRun: (Compiler compiler) { 50 ], beforeRun: (Compiler compiler) {
82 compiler.backendStrategy = new JsBackendStrategy(compiler); 51 compiler.backendStrategy = new JsBackendStrategy(compiler);
83 }, printSteps: true); 52 }, printSteps: true);
84 Expect.isFalse(compiler1.compilationFailed); 53 Expect.isFalse(compiler1.compilationFailed);
54 }
85 } 55 }
OLDNEW
« pkg/compiler/lib/src/world.dart ('K') | « pkg/compiler/lib/src/world.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698