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

Unified Diff: tests/compiler/dart2js/unparser_test.dart

Issue 10632020: First take on proper dart2dart testing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/unparser_test.dart
diff --git a/tests/compiler/dart2js/unparser_test.dart b/tests/compiler/dart2js/unparser_test.dart
index dab0bc1ded03ffab00caedd7df2ebe75a637ca72..5c1364fe2afb4d24f5e8dad6101d7594ededd368 100644
--- a/tests/compiler/dart2js/unparser_test.dart
+++ b/tests/compiler/dart2js/unparser_test.dart
@@ -2,7 +2,9 @@
// 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.
+#import('dart:uri');
#import('parser_helper.dart');
+#import("../../../lib/compiler/compiler.dart");
#import("../../../lib/compiler/implementation/tree/tree.dart");
testUnparse(String statement) {
@@ -15,6 +17,47 @@ testUnparseMember(String member) {
Expect.equals(member, node.unparse());
}
+final coreLib = @'''
+#library('corelib');
+interface Object {}
+interface bool {}
+interface num {}
+interface int extends num {}
+interface double extends num {}
+interface String {}
+interface Function {}
+interface List {}
+interface Closure {}
+interface Dynamic {}
+interface Null {}
+''';
+
+testDart2Dart(String src, void continuation(String s)) {
+ fileUri(path) => new Uri(scheme: 'file', path: path);
+
+ final scriptUri = fileUri('script.dart');
+
+ provider(uri) {
+ if (uri == scriptUri) return new Future.immediate(src);
+ if (uri.path.endsWith('/core.dart')) return new Future.immediate(coreLib);
+ return new Future.immediate('');
+ }
+
+ handler(uri, begin, end, message, kind) {
+ if (kind === Diagnostic.ERROR || kind === Diagnostic.CRASH) {
+ Expect.fail('$uri: $begin-$end: $message [$kind]');
+ }
+ }
+
+ compile(
+ scriptUri,
+ fileUri('libraryRoot'),
+ fileUri('packageRoot'),
+ provider,
+ handler,
+ const ['--output-type=dart', '--unparse-validation']).then(continuation);
+}
+
testGenericTypes() {
testUnparse('var x=new List<List<int>>();');
testUnparse('var x=new List<List<List<int>>>();');
@@ -45,6 +88,11 @@ testNativeMethods() {
testUnparseMember('foo()native "this.x = 41";');
}
+testSimpleFileUnparse() {
+ testDart2Dart('main() {}', (String s) {
+ });
+}
+
main() {
testGenericTypes();
testForLoop();
@@ -52,4 +100,5 @@ main() {
testClosure();
testIndexedOperatorDecl();
testNativeMethods();
+ testSimpleFileUnparse();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698