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

Unified Diff: pkg/code_transformers/test/entry_point_test.dart

Issue 196943024: Adding some asset-related utilities to code_transformers (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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/code_transformers/test/assets_test.dart ('k') | pkg/polymer/lib/src/build/common.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/code_transformers/test/entry_point_test.dart
diff --git a/pkg/code_transformers/test/entry_point_test.dart b/pkg/code_transformers/test/entry_point_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1000aceca62ec2c97e528938efd082f72c5060af
--- /dev/null
+++ b/pkg/code_transformers/test/entry_point_test.dart
@@ -0,0 +1,92 @@
+// Copyright (c) 2014, 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.
+
+library code_transformers.test.assets_test;
+
+import 'dart:async';
+import 'dart:io' show File, Platform;
+
+import 'package:barback/barback.dart';
+import 'package:code_transformers/resolver.dart';
+import 'package:code_transformers/tests.dart';
+import 'package:path/path.dart' as path;
+import 'package:unittest/compact_vm_config.dart';
+import 'package:unittest/unittest.dart';
+
+main() {
+ useCompactVMConfiguration();
+
+ Future checkDartEntry({Map<String, String> inputs, bool expectation}) {
+ var transformer = new Validator((transform) {
+ return isPossibleDartEntry(transform.primaryInput).then((value) {
+ expect(value, expectation);
+ });
+ });
+ return applyTransformers(
+ [[transformer]],
+ inputs: inputs);
+ }
+
+ group('isPossibleDartEntry', () {
+ test('should handle empty files', () {
+ return checkDartEntry(
+ inputs: {
+ 'a|web/main.dart': '',
+ },
+ expectation: false);
+ });
+
+ test('should detect main methods', () {
+ return checkDartEntry(
+ inputs: {
+ 'a|web/main.dart': 'main() {}',
+ },
+ expectation: true);
+ });
+
+ test('should exclude dart mains in lib folder', () {
+ return checkDartEntry(
+ inputs: {
+ 'a|lib/main.dart': 'main() {}',
+ },
+ expectation: false);
+ });
+
+ test('should validate file extension', () {
+ return checkDartEntry(
+ inputs: {
+ 'a|web/main.not_dart': 'main() {}',
+ },
+ expectation: false);
+ });
+
+ test('should count exports as main', () {
+ return checkDartEntry(
+ inputs: {
+ 'a|web/main.dart': 'export "foo.dart";',
+ },
+ expectation: true);
+ });
+
+ test('should count parts as main', () {
+ return checkDartEntry(
+ inputs: {
+ 'a|web/main.dart': 'part "foo.dart";',
+ },
+ expectation: true);
+ });
+ });
+}
+
+class Validator extends Transformer {
+ final Function validation;
+
+ Validator(this.validation);
+
+ Future<bool> isPrimary(Asset input) => new Future.value(true);
+
+ Future apply(Transform transform) {
+ return new Future.value(validation(transform));
+ }
+}
« no previous file with comments | « pkg/code_transformers/test/assets_test.dart ('k') | pkg/polymer/lib/src/build/common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698