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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/kernel/visitor_test.dart
diff --git a/tests/compiler/dart2js/kernel/visitor_test.dart b/tests/compiler/dart2js/kernel/visitor_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2b85948fe0495ca352bd5eaed858e5f38359e89b
--- /dev/null
+++ b/tests/compiler/dart2js/kernel/visitor_test.dart
@@ -0,0 +1,65 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/// Test that the dart2js copy of [KernelVisitor] generates the expected IR as
+/// defined by kernel spec-mode test files.
+
+import 'dart:io';
+import 'package:compiler/src/compiler.dart' show Compiler;
+import 'package:compiler/src/js_backend/backend.dart' show JavaScriptBackend;
+import 'package:compiler/src/commandline_options.dart' show Flags;
+import 'package:kernel/text/ast_to_text.dart';
+import 'package:path/path.dart' as pathlib;
+import 'package:test/test.dart';
+
+import '../memory_compiler.dart';
+
+const String TESTCASE_DIR = 'third_party/pkg/kernel/testcases/';
+
+const List<String> SKIP_TESTS = const <String>[
+ 'DeltaBlue', // Super calls encoded as `super.{...` and not `this.{...`.
+ 'external', // 'dart:_isolate_helper' is imported instead of 'dart:isolate'.
+];
+
+main(List<String> arguments) {
+ Directory directory = new Directory('${TESTCASE_DIR}/input');
+ for (FileSystemEntity file in directory.listSync()) {
+ if (file is File && file.path.endsWith('.dart')) {
+ String name = pathlib.basenameWithoutExtension(file.path);
+ bool selected = arguments.contains(name);
+ if (!selected) {
+ if (arguments.isNotEmpty) continue;
+ if (SKIP_TESTS.contains(name)) continue;
+ }
+
+ test(name, () async {
+ var result = await runCompiler(
+ entryPoint: file.absolute.uri,
+ options: [Flags.analyzeOnly, Flags.useKernel]);
+ Compiler compiler = result.compiler;
+ JavaScriptBackend backend = compiler.backend;
+ StringBuffer buffer = new StringBuffer();
+ new Printer(buffer).writeLibraryFile(
+ backend.kernelTask.kernel.libraryToIr(compiler.mainApp));
+ String actual = buffer.toString();
+ String expected =
+ new File('${TESTCASE_DIR}/spec-mode/$name.baseline.txt')
+ .readAsStringSync();
+ if (selected) {
+ String input =
+ new File('${TESTCASE_DIR}/input/$name.dart').readAsStringSync();
+ print('============================================================');
+ print(name);
+ print('--input-----------------------------------------------------');
+ print(input);
+ print('--expected--------------------------------------------------');
+ print(expected);
+ print('--actual----------------------------------------------------');
+ print(actual);
+ }
+ expect(actual, equals(expected));
+ });
+ }
+ }
+}
« 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