OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 barback.test.asset_test; | 5 library barback.test.asset_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert' show Encoding, UTF8, LATIN1; |
8 import 'dart:io'; | 9 import 'dart:io'; |
9 import 'dart:utf'; | 10 import 'dart:utf'; |
10 | 11 |
11 import 'package:barback/barback.dart'; | 12 import 'package:barback/barback.dart'; |
12 import 'package:path/path.dart' as pathos; | 13 import 'package:path/path.dart' as pathos; |
13 import 'package:unittest/unittest.dart'; | 14 import 'package:unittest/unittest.dart'; |
14 | 15 |
15 import 'utils.dart'; | 16 import 'utils.dart'; |
16 | 17 |
17 /// The contents of the test binary file. | 18 /// The contents of the test binary file. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 group("readAsString()", () { | 102 group("readAsString()", () { |
102 group("byte asset", () { | 103 group("byte asset", () { |
103 test("defaults to UTF-8 if encoding is omitted", () { | 104 test("defaults to UTF-8 if encoding is omitted", () { |
104 var asset = new Asset.fromBytes(id, encodeUtf8("çøñ†éℵ™")); | 105 var asset = new Asset.fromBytes(id, encodeUtf8("çøñ†éℵ™")); |
105 expect(asset.readAsString(), | 106 expect(asset.readAsString(), |
106 completion(equals("çøñ†éℵ™"))); | 107 completion(equals("çøñ†éℵ™"))); |
107 }); | 108 }); |
108 | 109 |
109 test("supports UTF-8", () { | 110 test("supports UTF-8", () { |
110 var asset = new Asset.fromBytes(id, encodeUtf8("çøñ†éℵ™")); | 111 var asset = new Asset.fromBytes(id, encodeUtf8("çøñ†éℵ™")); |
111 expect(asset.readAsString(encoding: Encoding.UTF_8), | 112 expect(asset.readAsString(encoding: UTF8), |
112 completion(equals("çøñ†éℵ™"))); | 113 completion(equals("çøñ†éℵ™"))); |
113 }); | 114 }); |
114 | 115 |
115 // TODO(rnystrom): Test other encodings once #6284 is fixed. | 116 // TODO(rnystrom): Test other encodings once #6284 is fixed. |
116 }); | 117 }); |
117 | 118 |
118 group("string asset", () { | 119 group("string asset", () { |
119 test("gets the string", () { | 120 test("gets the string", () { |
120 var asset = new Asset.fromString(id, "contents"); | 121 var asset = new Asset.fromString(id, "contents"); |
121 expect(asset.readAsString(), | 122 expect(asset.readAsString(), |
122 completion(equals("contents"))); | 123 completion(equals("contents"))); |
123 }); | 124 }); |
124 | 125 |
125 test("ignores the encoding", () { | 126 test("ignores the encoding", () { |
126 var asset = new Asset.fromString(id, "contents"); | 127 var asset = new Asset.fromString(id, "contents"); |
127 expect(asset.readAsString(encoding: Encoding.ISO_8859_1), | 128 expect(asset.readAsString(encoding: LATIN1), |
128 completion(equals("contents"))); | 129 completion(equals("contents"))); |
129 }); | 130 }); |
130 }); | 131 }); |
131 | 132 |
132 group("file asset", () { | 133 group("file asset", () { |
133 test("defaults to UTF-8 if encoding is omitted", () { | 134 test("defaults to UTF-8 if encoding is omitted", () { |
134 var asset = new Asset.fromPath(id, textFilePath); | 135 var asset = new Asset.fromPath(id, textFilePath); |
135 expect(asset.readAsString(), | 136 expect(asset.readAsString(), |
136 completion(equals("çøñ†éℵ™"))); | 137 completion(equals("çøñ†éℵ™"))); |
137 }); | 138 }); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 }); | 172 }); |
172 | 173 |
173 group("file asset", () { | 174 group("file asset", () { |
174 test("shows the file path", () { | 175 test("shows the file path", () { |
175 var asset = new Asset.fromPath(id, "path.txt"); | 176 var asset = new Asset.fromPath(id, "path.txt"); |
176 expect(asset.toString(), equals('File "path.txt"')); | 177 expect(asset.toString(), equals('File "path.txt"')); |
177 }); | 178 }); |
178 }); | 179 }); |
179 }); | 180 }); |
180 } | 181 } |
OLD | NEW |