OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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 library code_transformers.test.assets_test; | 5 library code_transformers.test.assets_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:barback/barback.dart'; | 9 import 'package:barback/barback.dart'; |
10 import 'package:code_transformers/assets.dart'; | 10 import 'package:code_transformers/assets.dart'; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 result: new AssetId('foo', 'lib/foo.dart')); | 59 result: new AssetId('foo', 'lib/foo.dart')); |
60 | 60 |
61 testAssetUri('resolves relative packages paths', | 61 testAssetUri('resolves relative packages paths', |
62 source: new AssetId('a', 'web/main.dart'), | 62 source: new AssetId('a', 'web/main.dart'), |
63 uri: 'packages/foo/foo.dart', | 63 uri: 'packages/foo/foo.dart', |
64 result: new AssetId('foo', 'lib/foo.dart')); | 64 result: new AssetId('foo', 'lib/foo.dart')); |
65 | 65 |
66 testAssetUri('does not allow packages from non-dart lib files', | 66 testAssetUri('does not allow packages from non-dart lib files', |
67 source: new AssetId('a', 'lib/index.html'), | 67 source: new AssetId('a', 'lib/index.html'), |
68 uri: 'packages/foo/bar', | 68 uri: 'packages/foo/bar', |
69 message: 'error: Invalid url to reach to another package: ' | 69 message: 'warning: Invalid url to reach to another package: ' |
70 'packages/foo/bar. Path reaching to other packages must first ' | 70 'packages/foo/bar. Path reaching to other packages must first ' |
71 'reach up all the way to the packages folder. For example, try ' | 71 'reach up all the way to the packages folder. For example, try ' |
72 'changing the url above to: ../../packages/foo/bar'); | 72 'changing the url above to: ../../packages/foo/bar'); |
73 | 73 |
74 testAssetUri('allows relative packages from non-dart lib files', | 74 testAssetUri('allows relative packages from non-dart lib files', |
75 source: new AssetId('a', 'lib/index.html'), | 75 source: new AssetId('a', 'lib/index.html'), |
76 uri: '../../packages/foo/bar', | 76 uri: '../../packages/foo/bar', |
77 result: new AssetId('foo', 'lib/bar')); | 77 result: new AssetId('foo', 'lib/bar')); |
78 | 78 |
79 testAssetUri('does not allow package: imports from non-dart files', | 79 testAssetUri('does not allow package: imports from non-dart files', |
80 source: new AssetId('a', 'lib/index.html'), | 80 source: new AssetId('a', 'lib/index.html'), |
81 uri: 'package:foo/bar.dart', | 81 uri: 'package:foo/bar.dart', |
82 message: 'error: absolute paths not allowed: "package:foo/bar.dart"'); | 82 message: 'warning: absolute paths not allowed: "package:foo/bar.dart"'); |
83 | 83 |
84 testAssetUri('does not allow absolute /packages by default', | 84 testAssetUri('does not allow absolute /packages by default', |
85 source: new AssetId('a', 'lib/index.html'), | 85 source: new AssetId('a', 'lib/index.html'), |
86 uri: '/packages/foo/bar.dart', | 86 uri: '/packages/foo/bar.dart', |
87 message: 'error: absolute paths not allowed: "/packages/foo/bar.dart"'); | 87 message: |
| 88 'warning: absolute paths not allowed: "/packages/foo/bar.dart"'); |
88 | 89 |
89 testAssetUri('can suppress error on absolute /packages ', | 90 testAssetUri('can suppress error on absolute /packages ', |
90 source: new AssetId('a', 'lib/index.html'), | 91 source: new AssetId('a', 'lib/index.html'), |
91 uri: '/packages/foo/bar.dart', | 92 uri: '/packages/foo/bar.dart', |
92 errorOnAbsolute: false, | 93 errorOnAbsolute: false, |
93 result: null); | 94 result: null); |
94 }); | 95 }); |
95 } | 96 } |
96 | 97 |
97 class Validator extends Transformer { | 98 class Validator extends Transformer { |
98 final Function validation; | 99 final Function validation; |
99 | 100 |
100 Validator(this.validation); | 101 Validator(this.validation); |
101 | 102 |
102 Future<bool> isPrimary(Asset input) => new Future.value(true); | 103 Future<bool> isPrimary(Asset input) => new Future.value(true); |
103 | 104 |
104 Future apply(Transform transform) { | 105 Future apply(Transform transform) { |
105 return new Future.value(validation(transform)); | 106 return new Future.value(validation(transform)); |
106 } | 107 } |
107 } | 108 } |
OLD | NEW |