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

Side by Side Diff: pkg/code_transformers/test/entry_point_test.dart

Issue 820513003: remove code-transformers from the repo (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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
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
9 import 'package:barback/barback.dart';
10 import 'package:code_transformers/resolver.dart';
11 import 'package:code_transformers/tests.dart';
12 import 'package:unittest/compact_vm_config.dart';
13 import 'package:unittest/unittest.dart';
14
15 main() {
16 useCompactVMConfiguration();
17
18 Future checkDartEntry({Map<String, String> inputs, bool expectation}) {
19 var transformer = new Validator((transform) {
20 return isPossibleDartEntry(transform.primaryInput).then((value) {
21 expect(value, expectation);
22 });
23 });
24 return applyTransformers(
25 [[transformer]],
26 inputs: inputs);
27 }
28
29 group('isPossibleDartEntry', () {
30 test('should handle empty files', () {
31 return checkDartEntry(
32 inputs: {
33 'a|web/main.dart': '',
34 },
35 expectation: false);
36 });
37
38 test('should detect main methods', () {
39 return checkDartEntry(
40 inputs: {
41 'a|web/main.dart': 'main() {}',
42 },
43 expectation: true);
44 });
45
46 test('should exclude dart mains in lib folder', () {
47 return checkDartEntry(
48 inputs: {
49 'a|lib/main.dart': 'main() {}',
50 },
51 expectation: false);
52 });
53
54 test('should validate file extension', () {
55 return checkDartEntry(
56 inputs: {
57 'a|web/main.not_dart': 'main() {}',
58 },
59 expectation: false);
60 });
61
62 test('should count exports as main', () {
63 return checkDartEntry(
64 inputs: {
65 'a|web/main.dart': 'export "foo.dart";',
66 },
67 expectation: true);
68 });
69
70 test('should count parts as main', () {
71 return checkDartEntry(
72 inputs: {
73 'a|web/main.dart': 'part "foo.dart";',
74 },
75 expectation: true);
76 });
77
78 test('is tolerant of syntax errors with main', () {
79 return checkDartEntry(
80 inputs: {
81 'a|web/main.dart': 'main() {} {',
82 },
83 expectation: true);
84 });
85
86 test('is tolerant of syntax errors without main', () {
87 return checkDartEntry(
88 inputs: {
89 'a|web/main.dart': 'class Foo {',
90 },
91 expectation: false);
92 });
93 });
94 }
95
96 class Validator extends Transformer {
97 final Function validation;
98
99 Validator(this.validation);
100
101 Future apply(Transform transform) {
102 return new Future.value(validation(transform));
103 }
104 }
OLDNEW
« no previous file with comments | « pkg/code_transformers/test/assets_test.dart ('k') | pkg/code_transformers/test/messages_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698