Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: tests/standalone/src/io/FileTest.dart

Issue 9572005: Move all tests using dart:io to a separate directory (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // Dart test program for testing file I/O. 5 // Dart test program for testing file I/O.
6 6
7 #import("dart:io"); 7 #import("dart:io");
8 #import("dart:isolate"); 8 #import("dart:isolate");
9 9
10 class MyListOfOneElement implements List { 10 class MyListOfOneElement implements List {
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 static void testReadAsText() { 881 static void testReadAsText() {
882 var port = new ReceivePort.singleShot(); 882 var port = new ReceivePort.singleShot();
883 port.receive((result, replyTo) { 883 port.receive((result, replyTo) {
884 Expect.equals(1, result); 884 Expect.equals(1, result);
885 }); 885 });
886 var name = getFilename("tests/vm/data/fixed_length_file"); 886 var name = getFilename("tests/vm/data/fixed_length_file");
887 var f = new File(name); 887 var f = new File(name);
888 f.readAsText('UTF-8', (text) { 888 f.readAsText('UTF-8', (text) {
889 Expect.isTrue(text.endsWith("42 bytes.")); 889 Expect.isTrue(text.endsWith("42 bytes."));
890 Expect.equals(42, text.length); 890 Expect.equals(42, text.length);
891 var name = getDataFilename("tests/standalone/src/read_as_text.dat"); 891 var name = getDataFilename("tests/standalone/src/io/read_as_text.dat");
892 var f = new File(name); 892 var f = new File(name);
893 f.onError = (e) => Expect.fail("No errors expected"); 893 f.onError = (e) => Expect.fail("No errors expected");
894 f.readAsText('UTF-8', (text) { 894 f.readAsText('UTF-8', (text) {
895 Expect.equals(6, text.length); 895 Expect.equals(6, text.length);
896 var expected = [955, 120, 46, 32, 120, 10]; 896 var expected = [955, 120, 46, 32, 120, 10];
897 Expect.listEquals(expected, text.charCodes()); 897 Expect.listEquals(expected, text.charCodes());
898 f.readAsText('ISO-8859-1', (text) { 898 f.readAsText('ISO-8859-1', (text) {
899 Expect.equals(7, text.length); 899 Expect.equals(7, text.length);
900 var expected = [206, 187, 120, 46, 32, 120, 10]; 900 var expected = [206, 187, 120, 46, 32, 120, 10];
901 Expect.listEquals(expected, text.charCodes()); 901 Expect.listEquals(expected, text.charCodes());
902 f.onError = (e) { 902 f.onError = (e) {
903 port.toSendPort().send(1); 903 port.toSendPort().send(1);
904 }; 904 };
905 f.readAsText('ASCII', (text) { 905 f.readAsText('ASCII', (text) {
906 Expect.fail("Non-ascii char should cause error"); 906 Expect.fail("Non-ascii char should cause error");
907 }); 907 });
908 }); 908 });
909 }); 909 });
910 }); 910 });
911 f.onError = (e) { 911 f.onError = (e) {
912 Expect.fail("No errors expected: $e"); 912 Expect.fail("No errors expected: $e");
913 }; 913 };
914 } 914 }
915 915
916 static void testReadAsTextSync() { 916 static void testReadAsTextSync() {
917 var name = getFilename("tests/vm/data/fixed_length_file"); 917 var name = getFilename("tests/vm/data/fixed_length_file");
918 var text = new File(name).readAsTextSync(); 918 var text = new File(name).readAsTextSync();
919 Expect.isTrue(text.endsWith("42 bytes.")); 919 Expect.isTrue(text.endsWith("42 bytes."));
920 Expect.equals(42, text.length); 920 Expect.equals(42, text.length);
921 name = getDataFilename("tests/standalone/src/read_as_text.dat"); 921 name = getDataFilename("tests/standalone/src/io/read_as_text.dat");
922 text = new File(name).readAsTextSync(); 922 text = new File(name).readAsTextSync();
923 Expect.equals(6, text.length); 923 Expect.equals(6, text.length);
924 var expected = [955, 120, 46, 32, 120, 10]; 924 var expected = [955, 120, 46, 32, 120, 10];
925 Expect.listEquals(expected, text.charCodes()); 925 Expect.listEquals(expected, text.charCodes());
926 Expect.throws(() { new File(name).readAsTextSync("ASCII"); }); 926 Expect.throws(() { new File(name).readAsTextSync("ASCII"); });
927 text = new File(name).readAsTextSync("ISO-8859-1"); 927 text = new File(name).readAsTextSync("ISO-8859-1");
928 expected = [206, 187, 120, 46, 32, 120, 10]; 928 expected = [206, 187, 120, 46, 32, 120, 10];
929 Expect.equals(7, text.length); 929 Expect.equals(7, text.length);
930 Expect.listEquals(expected, text.charCodes()); 930 Expect.listEquals(expected, text.charCodes());
931 } 931 }
(...skipping 16 matching lines...) Expand all
948 }; 948 };
949 } 949 }
950 950
951 static void testReadAsLinesSync() { 951 static void testReadAsLinesSync() {
952 var name = getFilename("tests/vm/data/fixed_length_file"); 952 var name = getFilename("tests/vm/data/fixed_length_file");
953 var lines = new File(name).readAsLinesSync(); 953 var lines = new File(name).readAsLinesSync();
954 Expect.equals(1, lines.length); 954 Expect.equals(1, lines.length);
955 var line = lines[0]; 955 var line = lines[0];
956 Expect.isTrue(line.endsWith("42 bytes.")); 956 Expect.isTrue(line.endsWith("42 bytes."));
957 Expect.equals(42, line.length); 957 Expect.equals(42, line.length);
958 name = getDataFilename("tests/standalone/src/readline_test1.dat"); 958 name = getDataFilename("tests/standalone/src/io/readline_test1.dat");
959 lines = new File(name).readAsLinesSync(); 959 lines = new File(name).readAsLinesSync();
960 Expect.equals(10, lines.length); 960 Expect.equals(10, lines.length);
961 } 961 }
962 962
963 963
964 static void testReadAsErrors() { 964 static void testReadAsErrors() {
965 var port = new ReceivePort.singleShot(); 965 var port = new ReceivePort.singleShot();
966 port.receive((message, _) { 966 port.receive((message, _) {
967 Expect.equals(1, message); 967 Expect.equals(1, message);
968 }); 968 });
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 testWriteVariousLists(); 1076 testWriteVariousLists();
1077 testDirectory(); 1077 testDirectory();
1078 testDirectorySync(); 1078 testDirectorySync();
1079 }); 1079 });
1080 } 1080 }
1081 } 1081 }
1082 1082
1083 main() { 1083 main() {
1084 FileTest.testMain(); 1084 FileTest.testMain();
1085 } 1085 }
OLDNEW
« no previous file with comments | « tests/standalone/src/io/FileOutputStreamTest.dart ('k') | tests/standalone/src/io/HttpParserTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698