| 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 'dart:io'; |
| 6 |
| 7 import "package:async_helper/async_helper.dart"; |
| 5 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 6 import 'dart:io'; | |
| 7 import 'dart:isolate'; | |
| 8 | 9 |
| 9 main() { | 10 main() { |
| 10 ReceivePort port = new ReceivePort(); | 11 asyncStart(); |
| 11 | 12 |
| 12 // On MacOS you get the decomposed utf8 form of file and directory | 13 // On MacOS you get the decomposed utf8 form of file and directory |
| 13 // names from the system. Therefore, we have to check for both here. | 14 // names from the system. Therefore, we have to check for both here. |
| 14 var precomposed = 'æøå'; | 15 var precomposed = 'æøå'; |
| 15 var decomposed = new String.fromCharCodes([47, 230, 248, 97, 778]); | 16 var decomposed = new String.fromCharCodes([47, 230, 248, 97, 778]); |
| 16 | 17 |
| 17 new Directory('').createTemp().then((tempDir) { | 18 new Directory('').createTemp().then((tempDir) { |
| 18 Directory nonAsciiDir = new Directory('${tempDir.path}/æøå'); | 19 Directory nonAsciiDir = new Directory('${tempDir.path}/æøå'); |
| 19 nonAsciiDir.create().then((nonAsciiDir) { | 20 nonAsciiDir.create().then((nonAsciiDir) { |
| 20 nonAsciiDir.exists().then((result) { | 21 nonAsciiDir.exists().then((result) { |
| 21 Expect.isTrue(result); | 22 Expect.isTrue(result); |
| 22 File nonAsciiFile = new File('${nonAsciiDir.path}/æøå.txt'); | 23 File nonAsciiFile = new File('${nonAsciiDir.path}/æøå.txt'); |
| 23 nonAsciiFile.writeAsString('æøå').then((_) { | 24 nonAsciiFile.writeAsString('æøå').then((_) { |
| 24 nonAsciiFile.exists().then((result) { | 25 nonAsciiFile.exists().then((result) { |
| 25 Expect.isTrue(result); | 26 Expect.isTrue(result); |
| 26 nonAsciiFile.readAsString().then((contents) { | 27 nonAsciiFile.readAsString().then((contents) { |
| 27 // The contents of the file is precomposed utf8. | 28 // The contents of the file is precomposed utf8. |
| 28 Expect.equals(precomposed, contents); | 29 Expect.equals(precomposed, contents); |
| 29 nonAsciiFile.create().then((_) { | 30 nonAsciiFile.create().then((_) { |
| 30 var d = nonAsciiFile.directory; | 31 var d = nonAsciiFile.directory; |
| 31 Expect.isTrue(d.path.endsWith(precomposed) || | 32 Expect.isTrue(d.path.endsWith(precomposed) || |
| 32 d.path.endsWith(decomposed)); | 33 d.path.endsWith(decomposed)); |
| 33 nonAsciiFile.length().then((length) { | 34 nonAsciiFile.length().then((length) { |
| 34 Expect.equals(6, length); | 35 Expect.equals(6, length); |
| 35 nonAsciiFile.lastModified().then((_) { | 36 nonAsciiFile.lastModified().then((_) { |
| 36 nonAsciiFile.fullPath().then((path) { | 37 nonAsciiFile.fullPath().then((path) { |
| 37 Expect.isTrue(path.endsWith('${precomposed}.txt') || | 38 Expect.isTrue(path.endsWith('${precomposed}.txt') || |
| 38 path.endsWith('${decomposed}.txt')); | 39 path.endsWith('${decomposed}.txt')); |
| 39 tempDir.delete(recursive: true).then((_) { | 40 tempDir.delete(recursive: true).then((_) { |
| 40 port.close(); | 41 asyncEnd(); |
| 41 }); | 42 }); |
| 42 }); | 43 }); |
| 43 }); | 44 }); |
| 44 }); | 45 }); |
| 45 }); | 46 }); |
| 46 }); | 47 }); |
| 47 }); | 48 }); |
| 48 }); | 49 }); |
| 49 }); | 50 }); |
| 50 }); | 51 }); |
| 51 }).catchError((e) { | 52 }).catchError((e) { |
| 52 port.close(); | 53 port.close(); |
| 53 Expect.fail("File not found"); | 54 Expect.fail("File not found"); |
| 54 }); | 55 }); |
| 55 } | 56 } |
| OLD | NEW |