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