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

Side by Side Diff: tests/standalone/io/file_test.dart

Issue 10252020: test rename overhaul: step 12 - standalone (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 var port = new ReceivePort(); 889 var port = new ReceivePort();
890 port.receive((result, replyTo) { 890 port.receive((result, replyTo) {
891 port.close(); 891 port.close();
892 Expect.equals(1, result); 892 Expect.equals(1, result);
893 }); 893 });
894 var name = getFilename("tests/vm/data/fixed_length_file"); 894 var name = getFilename("tests/vm/data/fixed_length_file");
895 var f = new File(name); 895 var f = new File(name);
896 f.readAsText(Encoding.UTF_8, (text) { 896 f.readAsText(Encoding.UTF_8, (text) {
897 Expect.isTrue(text.endsWith("42 bytes.")); 897 Expect.isTrue(text.endsWith("42 bytes."));
898 Expect.equals(42, text.length); 898 Expect.equals(42, text.length);
899 var name = getDataFilename("tests/standalone/src/io/read_as_text.dat"); 899 var name = getDataFilename("tests/standalone/io/read_as_text.dat");
900 var f = new File(name); 900 var f = new File(name);
901 f.onError = (e) => Expect.fail("No errors expected: $e"); 901 f.onError = (e) => Expect.fail("No errors expected: $e");
902 f.readAsText(Encoding.UTF_8, (text) { 902 f.readAsText(Encoding.UTF_8, (text) {
903 Expect.equals(6, text.length); 903 Expect.equals(6, text.length);
904 var expected = [955, 120, 46, 32, 120, 10]; 904 var expected = [955, 120, 46, 32, 120, 10];
905 Expect.listEquals(expected, text.charCodes()); 905 Expect.listEquals(expected, text.charCodes());
906 f.readAsText(Encoding.ISO_8859_1, (text) { 906 f.readAsText(Encoding.ISO_8859_1, (text) {
907 Expect.equals(7, text.length); 907 Expect.equals(7, text.length);
908 var expected = [206, 187, 120, 46, 32, 120, 10]; 908 var expected = [206, 187, 120, 46, 32, 120, 10];
909 Expect.listEquals(expected, text.charCodes()); 909 Expect.listEquals(expected, text.charCodes());
910 f.onError = (e) { 910 f.onError = (e) {
911 port.toSendPort().send(1); 911 port.toSendPort().send(1);
912 }; 912 };
913 f.readAsText(Encoding.ASCII, (text) { 913 f.readAsText(Encoding.ASCII, (text) {
914 Expect.fail("Non-ascii char should cause error"); 914 Expect.fail("Non-ascii char should cause error");
915 }); 915 });
916 }); 916 });
917 }); 917 });
918 }); 918 });
919 f.onError = (e) { 919 f.onError = (e) {
920 Expect.fail("No errors expected: $e"); 920 Expect.fail("No errors expected: $e");
921 }; 921 };
922 } 922 }
923 923
924 static void testReadAsTextSync() { 924 static void testReadAsTextSync() {
925 var name = getFilename("tests/vm/data/fixed_length_file"); 925 var name = getFilename("tests/vm/data/fixed_length_file");
926 var text = new File(name).readAsTextSync(); 926 var text = new File(name).readAsTextSync();
927 Expect.isTrue(text.endsWith("42 bytes.")); 927 Expect.isTrue(text.endsWith("42 bytes."));
928 Expect.equals(42, text.length); 928 Expect.equals(42, text.length);
929 name = getDataFilename("tests/standalone/src/io/read_as_text.dat"); 929 name = getDataFilename("tests/standalone/io/read_as_text.dat");
930 text = new File(name).readAsTextSync(); 930 text = new File(name).readAsTextSync();
931 Expect.equals(6, text.length); 931 Expect.equals(6, text.length);
932 var expected = [955, 120, 46, 32, 120, 10]; 932 var expected = [955, 120, 46, 32, 120, 10];
933 Expect.listEquals(expected, text.charCodes()); 933 Expect.listEquals(expected, text.charCodes());
934 Expect.throws(() { new File(name).readAsTextSync(Encoding.ASCII); }); 934 Expect.throws(() { new File(name).readAsTextSync(Encoding.ASCII); });
935 text = new File(name).readAsTextSync(Encoding.ISO_8859_1); 935 text = new File(name).readAsTextSync(Encoding.ISO_8859_1);
936 expected = [206, 187, 120, 46, 32, 120, 10]; 936 expected = [206, 187, 120, 46, 32, 120, 10];
937 Expect.equals(7, text.length); 937 Expect.equals(7, text.length);
938 Expect.listEquals(expected, text.charCodes()); 938 Expect.listEquals(expected, text.charCodes());
939 } 939 }
(...skipping 15 matching lines...) Expand all
955 f.onError = (e) => Expect.fail("No errors expected: $e"); 955 f.onError = (e) => Expect.fail("No errors expected: $e");
956 } 956 }
957 957
958 static void testReadAsLinesSync() { 958 static void testReadAsLinesSync() {
959 var name = getFilename("tests/vm/data/fixed_length_file"); 959 var name = getFilename("tests/vm/data/fixed_length_file");
960 var lines = new File(name).readAsLinesSync(); 960 var lines = new File(name).readAsLinesSync();
961 Expect.equals(1, lines.length); 961 Expect.equals(1, lines.length);
962 var line = lines[0]; 962 var line = lines[0];
963 Expect.isTrue(line.endsWith("42 bytes.")); 963 Expect.isTrue(line.endsWith("42 bytes."));
964 Expect.equals(42, line.length); 964 Expect.equals(42, line.length);
965 name = getDataFilename("tests/standalone/src/io/readline_test1.dat"); 965 name = getDataFilename("tests/standalone/io/readline_test1.dat");
966 lines = new File(name).readAsLinesSync(); 966 lines = new File(name).readAsLinesSync();
967 Expect.equals(10, lines.length); 967 Expect.equals(10, lines.length);
968 } 968 }
969 969
970 970
971 static void testReadAsErrors() { 971 static void testReadAsErrors() {
972 var port = new ReceivePort(); 972 var port = new ReceivePort();
973 port.receive((message, _) { 973 port.receive((message, _) {
974 port.close(); 974 port.close();
975 Expect.equals(1, message); 975 Expect.equals(1, message);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 testWriteVariousLists(); 1083 testWriteVariousLists();
1084 testDirectory(); 1084 testDirectory();
1085 testDirectorySync(); 1085 testDirectorySync();
1086 }); 1086 });
1087 } 1087 }
1088 } 1088 }
1089 1089
1090 main() { 1090 main() {
1091 FileTest.testMain(); 1091 FileTest.testMain();
1092 } 1092 }
OLDNEW
« no previous file with comments | « tests/standalone/io/file_output_stream_test.dart ('k') | tests/standalone/io/http_client_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698