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

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

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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
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([[transformer]], inputs: inputs);
25 }
26
27 group('isPossibleDartEntry', () {
28 test('should handle empty files', () {
29 return checkDartEntry(
30 inputs: {'a|web/main.dart': '',}, expectation: false);
31 });
32
33 test('should detect main methods', () {
34 return checkDartEntry(
35 inputs: {'a|web/main.dart': 'main() {}',}, expectation: true);
36 });
37
38 test('should exclude dart mains in lib folder', () {
39 return checkDartEntry(
40 inputs: {'a|lib/main.dart': 'main() {}',}, expectation: false);
41 });
42
43 test('should validate file extension', () {
44 return checkDartEntry(
45 inputs: {'a|web/main.not_dart': 'main() {}',}, expectation: false);
46 });
47
48 test('should count exports as main', () {
49 return checkDartEntry(
50 inputs: {'a|web/main.dart': 'export "foo.dart";',},
51 expectation: true);
52 });
53
54 test('should count parts as main', () {
55 return checkDartEntry(
56 inputs: {'a|web/main.dart': 'part "foo.dart";',}, expectation: true);
57 });
58
59 test('is tolerant of syntax errors with main', () {
60 return checkDartEntry(
61 inputs: {'a|web/main.dart': 'main() {} {',}, expectation: true);
62 });
63
64 test('is tolerant of syntax errors without main', () {
65 return checkDartEntry(
66 inputs: {'a|web/main.dart': 'class Foo {',}, expectation: false);
67 });
68 });
69 }
70
71 class Validator extends Transformer {
72 final Function validation;
73
74 Validator(this.validation);
75
76 Future apply(Transform transform) {
77 return new Future.value(validation(transform));
78 }
79 }
OLDNEW
« no previous file with comments | « packages/code_transformers/test/benchmarks_test.dart ('k') | packages/code_transformers/test/messages_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698