OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 import 'dart:io'; | 6 import 'dart:io'; |
7 | 7 |
8 main() { | 8 main() { |
9 Directory tempDir = | 9 Directory tempDir = |
10 Directory.systemTemp.createTempSync('dart_file_non_ascii_sync'); | 10 Directory.systemTemp.createTempSync('dart_file_non_ascii_sync'); |
11 Directory nonAsciiDir = new Directory('${tempDir.path}/æøå'); | 11 Directory nonAsciiDir = new Directory('${tempDir.path}/æøå'); |
12 nonAsciiDir.createSync(); | 12 nonAsciiDir.createSync(); |
13 Expect.isTrue(nonAsciiDir.existsSync()); | 13 Expect.isTrue(nonAsciiDir.existsSync()); |
14 File nonAsciiFile = new File('${nonAsciiDir.path}/æøå.txt'); | 14 File nonAsciiFile = new File('${nonAsciiDir.path}/æøå.txt'); |
15 nonAsciiFile.writeAsStringSync('æøå'); | 15 nonAsciiFile.writeAsStringSync('æøå'); |
16 Expect.isTrue(nonAsciiFile.existsSync()); | 16 Expect.isTrue(nonAsciiFile.existsSync()); |
17 // On MacOS you get the decomposed utf8 form of file and directory | 17 // On MacOS you get the decomposed utf8 form of file and directory |
18 // names from the system. Therefore, we have to check for both here. | 18 // names from the system. Therefore, we have to check for both here. |
19 var precomposed = 'æøå'; | 19 var precomposed = 'æøå'; |
20 var decomposed = new String.fromCharCodes([47, 230, 248, 97, 778]); | 20 var decomposed = new String.fromCharCodes([47, 230, 248, 97, 778]); |
21 // The contents of the file is precomposed utf8. | 21 // The contents of the file is precomposed utf8. |
22 Expect.equals(precomposed, nonAsciiFile.readAsStringSync()); | 22 Expect.equals(precomposed, nonAsciiFile.readAsStringSync()); |
23 nonAsciiFile.createSync(); | 23 nonAsciiFile.createSync(); |
24 var path = nonAsciiFile.parent.path; | 24 var path = nonAsciiFile.parent.path; |
25 Expect.isTrue(path.endsWith(precomposed) || path.endsWith(decomposed)); | 25 Expect.isTrue(path.endsWith(precomposed) || path.endsWith(decomposed)); |
26 Expect.equals(6, nonAsciiFile.lengthSync()); | 26 Expect.equals(6, nonAsciiFile.lengthSync()); |
27 nonAsciiFile.lastModifiedSync(); | 27 nonAsciiFile.lastModifiedSync(); |
28 path = nonAsciiFile.resolveSymbolicLinksSync(); | 28 path = nonAsciiFile.resolveSymbolicLinksSync(); |
29 Expect.isTrue(path.endsWith('${precomposed}.txt') || | 29 Expect.isTrue(path.endsWith('${precomposed}.txt') || |
30 path.endsWith('${decomposed}.txt')); | 30 path.endsWith('${decomposed}.txt')); |
31 tempDir.deleteSync(recursive: true); | 31 tempDir.deleteSync(recursive: true); |
32 } | 32 } |
OLD | NEW |