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

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

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

Powered by Google App Engine
This is Rietveld 408576698