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

Side by Side Diff: tests/compiler/dart2js/kernel/visitor_test.dart

Issue 2367793002: Perform MixinFullResolution before baseline test. (Closed)
Patch Set: dartfmt Created 4 years, 2 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
« no previous file with comments | « pkg/compiler/lib/src/kernel/kernel_visitor.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 /// Test that the dart2js copy of [KernelVisitor] generates the expected IR as 5 /// Test that the dart2js copy of [KernelVisitor] generates the expected IR as
6 /// defined by kernel spec-mode test files. 6 /// defined by kernel spec-mode test files.
7 7
8 import 'dart:io'; 8 import 'dart:io';
9 import 'package:compiler/src/compiler.dart' show Compiler; 9 import 'package:compiler/src/compiler.dart' show Compiler;
10 import 'package:compiler/src/js_backend/backend.dart' show JavaScriptBackend; 10 import 'package:compiler/src/js_backend/backend.dart' show JavaScriptBackend;
11 import 'package:compiler/src/commandline_options.dart' show Flags; 11 import 'package:compiler/src/commandline_options.dart' show Flags;
12 import 'package:kernel/ast.dart';
12 import 'package:kernel/text/ast_to_text.dart'; 13 import 'package:kernel/text/ast_to_text.dart';
14 import 'package:kernel/transformations/mixin_full_resolution.dart';
13 import 'package:path/path.dart' as pathlib; 15 import 'package:path/path.dart' as pathlib;
14 import 'package:test/test.dart'; 16 import 'package:test/test.dart';
15 17
16 import '../memory_compiler.dart'; 18 import '../memory_compiler.dart';
17 19
18 const String TESTCASE_DIR = 'third_party/pkg/kernel/testcases/'; 20 const String TESTCASE_DIR = 'third_party/pkg/kernel/testcases/';
19 21
20 const List<String> SKIP_TESTS = const <String>[ 22 const List<String> SKIP_TESTS = const <String>[];
21 'DeltaBlue', // Super calls encoded as `super.{...` and not `this.{...`.
22 ];
23 23
24 main(List<String> arguments) { 24 main(List<String> arguments) {
25 Directory directory = new Directory('${TESTCASE_DIR}/input'); 25 Directory directory = new Directory('${TESTCASE_DIR}/input');
26 for (FileSystemEntity file in directory.listSync()) { 26 for (FileSystemEntity file in directory.listSync()) {
27 if (file is File && file.path.endsWith('.dart')) { 27 if (file is File && file.path.endsWith('.dart')) {
28 String name = pathlib.basenameWithoutExtension(file.path); 28 String name = pathlib.basenameWithoutExtension(file.path);
29 bool selected = arguments.contains(name); 29 bool selected = arguments.contains(name);
30 if (!selected) { 30 if (!selected) {
31 if (arguments.isNotEmpty) continue; 31 if (arguments.isNotEmpty) continue;
32 if (SKIP_TESTS.contains(name)) continue; 32 if (SKIP_TESTS.contains(name)) continue;
33 } 33 }
34 34
35 test(name, () async { 35 test(name, () async {
36 var result = await runCompiler( 36 var result = await runCompiler(
37 entryPoint: file.absolute.uri, 37 entryPoint: file.absolute.uri,
38 options: [Flags.analyzeOnly, Flags.useKernel]); 38 options: [Flags.analyzeOnly, Flags.useKernel]);
39 Compiler compiler = result.compiler; 39 Compiler compiler = result.compiler;
40 JavaScriptBackend backend = compiler.backend; 40 JavaScriptBackend backend = compiler.backend;
41 StringBuffer buffer = new StringBuffer(); 41 StringBuffer buffer = new StringBuffer();
42 Program program = backend.kernelTask.program;
43 new MixinFullResolution().transform(program);
42 new Printer(buffer).writeLibraryFile( 44 new Printer(buffer).writeLibraryFile(
43 backend.kernelTask.kernel.libraryToIr(compiler.mainApp)); 45 backend.kernelTask.program.mainMethod.enclosingLibrary);
44 String actual = buffer.toString(); 46 String actual = buffer.toString();
45 String expected = 47 String expected =
46 new File('${TESTCASE_DIR}/spec-mode/$name.baseline.txt') 48 new File('${TESTCASE_DIR}/spec-mode/$name.baseline.txt')
47 .readAsStringSync(); 49 .readAsStringSync();
48 if (selected) { 50 if (selected) {
49 String input = 51 String input =
50 new File('${TESTCASE_DIR}/input/$name.dart').readAsStringSync(); 52 new File('${TESTCASE_DIR}/input/$name.dart').readAsStringSync();
51 print('============================================================'); 53 print('============================================================');
52 print(name); 54 print(name);
53 print('--input-----------------------------------------------------'); 55 print('--input-----------------------------------------------------');
54 print(input); 56 print(input);
55 print('--expected--------------------------------------------------'); 57 print('--expected--------------------------------------------------');
56 print(expected); 58 print(expected);
57 print('--actual----------------------------------------------------'); 59 print('--actual----------------------------------------------------');
58 print(actual); 60 print(actual);
59 } 61 }
60 expect(actual, equals(expected)); 62 expect(actual, equals(expected));
61 }); 63 });
62 } 64 }
63 } 65 }
64 } 66 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/kernel/kernel_visitor.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698