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

Unified Diff: pkg/polymer/test/compiler_test.dart

Issue 23224003: move polymer.dart into dart svn (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: add --deploy to todomvc sample Created 7 years, 4 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/polymer/pubspec.yaml ('k') | pkg/polymer/test/css_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/test/compiler_test.dart
diff --git a/pkg/polymer/test/compiler_test.dart b/pkg/polymer/test/compiler_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..57315587ea71fdd142b64537b547b90dae0081ec
--- /dev/null
+++ b/pkg/polymer/test/compiler_test.dart
@@ -0,0 +1,140 @@
+// Copyright (c) 2012, 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.
+
+/** End-to-end tests for the [Compiler] API. */
+library compiler_test;
+
+import 'package:logging/logging.dart' show Level;
+import 'package:unittest/compact_vm_config.dart';
+import 'package:unittest/unittest.dart';
+import 'package:polymer/src/messages.dart';
+
+import 'testing.dart';
+
+main() {
+ useCompactVMConfiguration();
+
+ test('recursive dependencies', () {
+ var messages = new Messages.silent();
+ var compiler = createCompiler({
+ 'index.html': '<head>'
+ '<link rel="import" href="foo.html">'
+ '<link rel="import" href="bar.html">'
+ '<body><x-foo></x-foo><x-bar></x-bar>'
+ '<script type="application/dart">main() {}</script>',
+ 'foo.html': '<head><link rel="import" href="bar.html">'
+ '<body><polymer-element name="x-foo" constructor="Foo">'
+ '<template><x-bar>',
+ 'bar.html': '<head><link rel="import" href="foo.html">'
+ '<body><polymer-element name="x-bar" constructor="Boo">'
+ '<template><x-foo>',
+ }, messages);
+
+ compiler.run().then(expectAsync1((e) {
+ MockFileSystem fs = compiler.fileSystem;
+ expect(fs.readCount, equals({
+ 'index.html': 1,
+ 'foo.html': 1,
+ 'bar.html': 1
+ }), reason: 'Actual:\n ${fs.readCount}');
+
+ var outputs = compiler.output.map((o) => o.path);
+ expect(outputs, equals([
+ 'out/foo.html.dart',
+ 'out/foo.html.dart.map',
+ 'out/bar.html.dart',
+ 'out/bar.html.dart.map',
+ 'out/index.html.dart',
+ 'out/index.html.dart.map',
+ 'out/index.html_bootstrap.dart',
+ 'out/index.html',
+ ]));
+ }));
+ });
+
+ group('missing files', () {
+ test('main script', () {
+ var messages = new Messages.silent();
+ var compiler = createCompiler({
+ 'index.html': '<head></head><body>'
+ '<script type="application/dart" src="notfound.dart"></script>'
+ '</body>',
+ }, messages);
+
+ compiler.run().then(expectAsync1((e) {
+ var msgs = messages.messages.where((m) =>
+ m.message.contains('unable')).toList();
+
+ expect(msgs.length, 1);
+ expect(msgs[0].level, Level.SEVERE);
+ expect(msgs[0].message, contains('unable to open file'));
+ expect(msgs[0].span, isNotNull);
+ expect(msgs[0].span.sourceUrl, 'index.html');
+
+ MockFileSystem fs = compiler.fileSystem;
+ expect(fs.readCount, { 'index.html': 1, 'notfound.dart': 1 });
+
+ var outputs = compiler.output.map((o) => o.path.toString());
+ expect(outputs, []);
+ }));
+ });
+
+ test('component html', () {
+ var messages = new Messages.silent();
+ var compiler = createCompiler({
+ 'index.html': '<head>'
+ '<link rel="import" href="notfound.html">'
+ '<body><x-foo>'
+ '<script type="application/dart">main() {}</script>',
+ }, messages);
+
+ compiler.run().then(expectAsync1((e) {
+ var msgs = messages.messages.where((m) =>
+ m.message.contains('unable')).toList();
+
+ expect(msgs.length, 1);
+ expect(msgs[0].level, Level.SEVERE);
+ expect(msgs[0].message, contains('unable to open file'));
+ expect(msgs[0].span, isNotNull);
+ expect(msgs[0].span.sourceUrl, 'index.html');
+
+ MockFileSystem fs = compiler.fileSystem;
+ expect(fs.readCount, { 'index.html': 1, 'notfound.html': 1 });
+
+ var outputs = compiler.output.map((o) => o.path.toString());
+ expect(outputs, []);
+ }));
+ });
+
+ test('component script', () {
+ var messages = new Messages.silent();
+ var compiler = createCompiler({
+ 'index.html': '<head>'
+ '<link rel="import" href="foo.html">'
+ '<body><x-foo></x-foo>'
+ '<script type="application/dart">main() {}</script>'
+ '</body>',
+ 'foo.html': '<body><polymer-element name="x-foo" constructor="Foo">'
+ '<template></template>'
+ '<script type="application/dart" src="notfound.dart"></script>',
+ }, messages);
+
+ compiler.run().then(expectAsync1((e) {
+ var msgs = messages.messages.where((m) =>
+ m.message.contains('unable')).toList();
+
+ expect(msgs.length, 1);
+ expect(msgs[0].level, Level.SEVERE);
+ expect(msgs[0].message, contains('unable to open file'));
+
+ MockFileSystem fs = compiler.fileSystem;
+ expect(fs.readCount,
+ { 'index.html': 1, 'foo.html': 1, 'notfound.dart': 1 });
+
+ var outputs = compiler.output.map((o) => o.path.toString());
+ expect(outputs, []);
+ }));
+ });
+ });
+}
« no previous file with comments | « pkg/polymer/pubspec.yaml ('k') | pkg/polymer/test/css_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698