| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** End-to-end tests for the [Compiler] API. */ | 5 /** End-to-end tests for the [Compiler] API. */ |
| 6 library compiler_test; | 6 library compiler_test; |
| 7 | 7 |
| 8 import 'package:html5lib/dom.dart'; | 8 import 'package:html5lib/dom.dart'; |
| 9 import 'package:logging/logging.dart' show Level; | 9 import 'package:logging/logging.dart' show Level; |
| 10 import 'package:unittest/compact_vm_config.dart'; | 10 import 'package:unittest/compact_vm_config.dart'; |
| 11 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 12 import 'package:polymer/src/messages.dart'; | 12 import 'package:polymer/src/messages.dart'; |
| 13 | 13 |
| 14 import 'testing.dart'; | 14 import 'testing.dart'; |
| 15 | 15 |
| 16 main() { | 16 main() { |
| 17 useCompactVMConfiguration(); | 17 useCompactVMConfiguration(); |
| 18 | 18 |
| 19 test('recursive dependencies', () { | 19 test('recursive dependencies', () { |
| 20 var messages = new Messages.silent(); | 20 var messages = new Messages.silent(); |
| 21 var compiler = createCompiler({ | 21 var compiler = createCompiler({ |
| 22 'index.html': '<head>' | 22 'index.html': '<head>' |
| 23 '<link rel="import" href="foo.html">' | 23 '<link rel="import" href="foo.html">' |
| 24 '<link rel="import" href="bar.html">' | 24 '<link rel="import" href="bar.html">' |
| 25 '<body><x-foo></x-foo><x-bar></x-bar>' | 25 '<body><x-foo></x-foo><x-bar></x-bar>' |
| 26 '<script type="application/dart">main() {}</script>', | 26 '<script type="application/dart">main() {}</script>', |
| 27 'foo.html': '<head><link rel="import" href="bar.html">' | 27 'foo.html': '<head><link rel="import" href="bar.html">' |
| 28 '<body><element name="x-foo" constructor="Foo">' | 28 '<body><polymer-element name="x-foo" constructor="Foo">' |
| 29 '<template><x-bar>', | 29 '<template><x-bar>', |
| 30 'bar.html': '<head><link rel="import" href="foo.html">' | 30 'bar.html': '<head><link rel="import" href="foo.html">' |
| 31 '<body><element name="x-bar" constructor="Boo">' | 31 '<body><polymer-element name="x-bar" constructor="Boo">' |
| 32 '<template><x-foo>', | 32 '<template><x-foo>', |
| 33 }, messages); | 33 }, messages); |
| 34 | 34 |
| 35 compiler.run().then(expectAsync1((e) { | 35 compiler.run().then(expectAsync1((e) { |
| 36 MockFileSystem fs = compiler.fileSystem; | 36 MockFileSystem fs = compiler.fileSystem; |
| 37 expect(fs.readCount, equals({ | 37 expect(fs.readCount, equals({ |
| 38 'index.html': 1, | 38 'index.html': 1, |
| 39 'foo.html': 1, | 39 'foo.html': 1, |
| 40 'bar.html': 1 | 40 'bar.html': 1 |
| 41 }), reason: 'Actual:\n ${fs.readCount}'); | 41 }), reason: 'Actual:\n ${fs.readCount}'); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 }); | 109 }); |
| 110 | 110 |
| 111 test('component script', () { | 111 test('component script', () { |
| 112 var messages = new Messages.silent(); | 112 var messages = new Messages.silent(); |
| 113 var compiler = createCompiler({ | 113 var compiler = createCompiler({ |
| 114 'index.html': '<head>' | 114 'index.html': '<head>' |
| 115 '<link rel="import" href="foo.html">' | 115 '<link rel="import" href="foo.html">' |
| 116 '<body><x-foo></x-foo>' | 116 '<body><x-foo></x-foo>' |
| 117 '<script type="application/dart">main() {}</script>' | 117 '<script type="application/dart">main() {}</script>' |
| 118 '</body>', | 118 '</body>', |
| 119 'foo.html': '<body><element name="x-foo" constructor="Foo">' | 119 'foo.html': '<body><polymer-element name="x-foo" constructor="Foo">' |
| 120 '<template></template>' | 120 '<template></template>' |
| 121 '<script type="application/dart" src="notfound.dart"></script>', | 121 '<script type="application/dart" src="notfound.dart"></script>', |
| 122 }, messages); | 122 }, messages); |
| 123 | 123 |
| 124 compiler.run().then(expectAsync1((e) { | 124 compiler.run().then(expectAsync1((e) { |
| 125 var msgs = messages.messages.where((m) => | 125 var msgs = messages.messages.where((m) => |
| 126 m.message.contains('unable')).toList(); | 126 m.message.contains('unable')).toList(); |
| 127 | 127 |
| 128 expect(msgs.length, 1); | 128 expect(msgs.length, 1); |
| 129 expect(msgs[0].level, Level.SEVERE); | 129 expect(msgs[0].level, Level.SEVERE); |
| 130 expect(msgs[0].message, contains('unable to open file')); | 130 expect(msgs[0].message, contains('unable to open file')); |
| 131 | 131 |
| 132 MockFileSystem fs = compiler.fileSystem; | 132 MockFileSystem fs = compiler.fileSystem; |
| 133 expect(fs.readCount, | 133 expect(fs.readCount, |
| 134 { 'index.html': 1, 'foo.html': 1, 'notfound.dart': 1 }); | 134 { 'index.html': 1, 'foo.html': 1, 'notfound.dart': 1 }); |
| 135 | 135 |
| 136 var outputs = compiler.output.map((o) => o.path.toString()); | 136 var outputs = compiler.output.map((o) => o.path.toString()); |
| 137 expect(outputs, []); | 137 expect(outputs, []); |
| 138 })); | 138 })); |
| 139 }); | 139 }); |
| 140 }); | 140 }); |
| 141 } | 141 } |
| OLD | NEW |