OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 // PackageRoot=none | 5 // PackageRoot=none |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 import 'dart:isolate'; | 8 import 'dart:isolate'; |
9 | 9 |
10 import "package:flu"; | 10 import "package:flu"; |
11 | 11 |
12 var PACKAGE_FLU = "package:flu"; | 12 var PACKAGE_FLU = "package:flu"; |
13 var FLU_TEXT = "flu.text"; | 13 var FLU_TEXT = "flu.text"; |
14 | 14 |
15 testShortResolution(package_uri) async { | 15 testShortResolution(package_uri) async { |
16 var fluPackage = await Isolate.resolvePackageUri(Uri.parse(package_uri)); | 16 var fluPackage = await Isolate.resolvePackageUri(Uri.parse(package_uri)); |
17 print("Resolved $package_uri to $fluPackage"); | 17 print("Resolved $package_uri to $fluPackage"); |
18 var fluText = fluPackage.resolve(FLU_TEXT); | 18 var fluText = fluPackage.resolve(FLU_TEXT); |
19 print("Resolved $FLU_TEXT from $package_uri to $fluText"); | 19 print("Resolved $FLU_TEXT from $package_uri to $fluText"); |
20 var fluFile = new File.fromUri(fluText); | 20 var fluFile = new File.fromUri(fluText); |
21 var fluString = await fluFile.readAsString(); | 21 var fluString = await fluFile.readAsString(); |
22 if (fluString != "Bar") { | 22 if (fluString != "Bar") { |
23 throw "Contents of $FLU_TEXT not matching.\n" | 23 throw "Contents of $FLU_TEXT not matching.\n" |
24 "Got: $fluString\n" | 24 "Got: $fluString\n" |
25 "Expected: Bar"; | 25 "Expected: Bar"; |
26 } | 26 } |
27 } | 27 } |
28 | 28 |
29 main([args, port]) async { | 29 main([args, port]) async { |
30 if (Flu.value != "Flu") { | 30 if (Flu.value != "Flu") { |
31 throw "Import of wrong Flu package."; | 31 throw "Import of wrong Flu package."; |
32 } | 32 } |
33 await testShortResolution(PACKAGE_FLU); | 33 await testShortResolution(PACKAGE_FLU); |
34 await testShortResolution(PACKAGE_FLU + "/"); | 34 await testShortResolution(PACKAGE_FLU + "/"); |
35 await testShortResolution(PACKAGE_FLU + "/abc.def"); | 35 await testShortResolution(PACKAGE_FLU + "/abc.def"); |
36 print("SUCCESS"); | 36 print("SUCCESS"); |
37 } | 37 } |
OLD | NEW |