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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
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.
4
5 library code_transformers.test.assets_test;
6
7 import 'dart:async';
8 import 'dart:io' show File, Platform;
9
10 import 'package:barback/barback.dart';
11 import 'package:code_transformers/resolver.dart';
12 import 'package:code_transformers/tests.dart';
13 import 'package:path/path.dart' as path;
14 import 'package:unittest/compact_vm_config.dart';
15 import 'package:unittest/unittest.dart';
16
17 main() {
18 useCompactVMConfiguration();
19
20 Future checkDartEntry({Map<String, String> inputs, bool expectation}) {
21 var transformer = new Validator((transform) {
22 return isPossibleDartEntry(transform.primaryInput).then((value) {
23 expect(value, expectation);
24 });
25 });
26 return applyTransformers(
27 [[transformer]],
28 inputs: inputs);
29 }
30
31 group('isPossibleDartEntry', () {
32 test('should handle empty files', () {
33 return checkDartEntry(
34 inputs: {
35 'a|web/main.dart': '',
36 },
37 expectation: false);
38 });
39
40 test('should detect main methods', () {
41 return checkDartEntry(
42 inputs: {
43 'a|web/main.dart': 'main() {}',
44 },
45 expectation: true);
46 });
47
48 test('should exclude dart mains in lib folder', () {
49 return checkDartEntry(
50 inputs: {
51 'a|lib/main.dart': 'main() {}',
52 },
53 expectation: false);
54 });
55
56 test('should validate file extension', () {
57 return checkDartEntry(
58 inputs: {
59 'a|web/main.not_dart': 'main() {}',
60 },
61 expectation: false);
62 });
63
64 test('should count exports as main', () {
65 return checkDartEntry(
66 inputs: {
67 'a|web/main.dart': 'export "foo.dart";',
68 },
69 expectation: true);
70 });
71
72 test('should count parts as main', () {
73 return checkDartEntry(
74 inputs: {
75 'a|web/main.dart': 'part "foo.dart";',
76 },
77 expectation: true);
78 });
79 });
80 }
81
82 class Validator extends Transformer {
83 final Function validation;
84
85 Validator(this.validation);
86
87 Future<bool> isPrimary(Asset input) => new Future.value(true);
88
89 Future apply(Transform transform) {
90 return new Future.value(validation(transform));
91 }
92 }
OLDNEW
« 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