| 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 // 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 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 // Tests buffer out of bounds exception. | 865 // Tests buffer out of bounds exception. |
| 866 static void testBufferOutOfBoundsException() { | 866 static void testBufferOutOfBoundsException() { |
| 867 bool exceptionCaught = false; | 867 bool exceptionCaught = false; |
| 868 bool wrongExceptionCaught = false; | 868 bool wrongExceptionCaught = false; |
| 869 File file = | 869 File file = |
| 870 new File(tempDirectory.path.concat("/out_buffer_out_of_bounds")); | 870 new File(tempDirectory.path.concat("/out_buffer_out_of_bounds")); |
| 871 RandomAccessFile openedFile = file.openSync(FileMode.WRITE); | 871 RandomAccessFile openedFile = file.openSync(FileMode.WRITE); |
| 872 try { | 872 try { |
| 873 List<int> buffer = new List<int>(10); | 873 List<int> buffer = new List<int>(10); |
| 874 openedFile.readListSync(buffer, 0, 12); | 874 openedFile.readListSync(buffer, 0, 12); |
| 875 } on IndexOutOfRangeException catch (ex) { | 875 } on RangeError catch (ex) { |
| 876 exceptionCaught = true; | 876 exceptionCaught = true; |
| 877 } on Exception catch (ex) { | 877 } on Exception catch (ex) { |
| 878 wrongExceptionCaught = true; | 878 wrongExceptionCaught = true; |
| 879 } | 879 } |
| 880 Expect.equals(true, exceptionCaught); | 880 Expect.equals(true, exceptionCaught); |
| 881 Expect.equals(true, !wrongExceptionCaught); | 881 Expect.equals(true, !wrongExceptionCaught); |
| 882 exceptionCaught = false; | 882 exceptionCaught = false; |
| 883 try { | 883 try { |
| 884 List<int> buffer = new List<int>(10); | 884 List<int> buffer = new List<int>(10); |
| 885 openedFile.readListSync(buffer, 6, 6); | 885 openedFile.readListSync(buffer, 6, 6); |
| 886 } on IndexOutOfRangeException catch (ex) { | 886 } on RangeError catch (ex) { |
| 887 exceptionCaught = true; | 887 exceptionCaught = true; |
| 888 } on Exception catch (ex) { | 888 } on Exception catch (ex) { |
| 889 wrongExceptionCaught = true; | 889 wrongExceptionCaught = true; |
| 890 } | 890 } |
| 891 Expect.equals(true, exceptionCaught); | 891 Expect.equals(true, exceptionCaught); |
| 892 Expect.equals(true, !wrongExceptionCaught); | 892 Expect.equals(true, !wrongExceptionCaught); |
| 893 exceptionCaught = false; | 893 exceptionCaught = false; |
| 894 try { | 894 try { |
| 895 List<int> buffer = new List<int>(10); | 895 List<int> buffer = new List<int>(10); |
| 896 openedFile.readListSync(buffer, -1, 1); | 896 openedFile.readListSync(buffer, -1, 1); |
| 897 } on IndexOutOfRangeException catch (ex) { | 897 } on RangeError catch (ex) { |
| 898 exceptionCaught = true; | 898 exceptionCaught = true; |
| 899 } on Exception catch (ex) { | 899 } on Exception catch (ex) { |
| 900 wrongExceptionCaught = true; | 900 wrongExceptionCaught = true; |
| 901 } | 901 } |
| 902 Expect.equals(true, exceptionCaught); | 902 Expect.equals(true, exceptionCaught); |
| 903 Expect.equals(true, !wrongExceptionCaught); | 903 Expect.equals(true, !wrongExceptionCaught); |
| 904 exceptionCaught = false; | 904 exceptionCaught = false; |
| 905 try { | 905 try { |
| 906 List<int> buffer = new List<int>(10); | 906 List<int> buffer = new List<int>(10); |
| 907 openedFile.readListSync(buffer, 0, -1); | 907 openedFile.readListSync(buffer, 0, -1); |
| 908 } on IndexOutOfRangeException catch (ex) { | 908 } on RangeError catch (ex) { |
| 909 exceptionCaught = true; | 909 exceptionCaught = true; |
| 910 } on Exception catch (ex) { | 910 } on Exception catch (ex) { |
| 911 wrongExceptionCaught = true; | 911 wrongExceptionCaught = true; |
| 912 } | 912 } |
| 913 Expect.equals(true, exceptionCaught); | 913 Expect.equals(true, exceptionCaught); |
| 914 Expect.equals(true, !wrongExceptionCaught); | 914 Expect.equals(true, !wrongExceptionCaught); |
| 915 exceptionCaught = false; | 915 exceptionCaught = false; |
| 916 try { | 916 try { |
| 917 List<int> buffer = new List<int>(10); | 917 List<int> buffer = new List<int>(10); |
| 918 openedFile.writeListSync(buffer, 0, 12); | 918 openedFile.writeListSync(buffer, 0, 12); |
| 919 } on IndexOutOfRangeException catch (ex) { | 919 } on RangeError catch (ex) { |
| 920 exceptionCaught = true; | 920 exceptionCaught = true; |
| 921 } on Exception catch (ex) { | 921 } on Exception catch (ex) { |
| 922 wrongExceptionCaught = true; | 922 wrongExceptionCaught = true; |
| 923 } | 923 } |
| 924 Expect.equals(true, exceptionCaught); | 924 Expect.equals(true, exceptionCaught); |
| 925 Expect.equals(true, !wrongExceptionCaught); | 925 Expect.equals(true, !wrongExceptionCaught); |
| 926 exceptionCaught = false; | 926 exceptionCaught = false; |
| 927 try { | 927 try { |
| 928 List<int> buffer = new List<int>(10); | 928 List<int> buffer = new List<int>(10); |
| 929 openedFile.writeListSync(buffer, 6, 6); | 929 openedFile.writeListSync(buffer, 6, 6); |
| 930 } on IndexOutOfRangeException catch (ex) { | 930 } on RangeError catch (ex) { |
| 931 exceptionCaught = true; | 931 exceptionCaught = true; |
| 932 } on Exception catch (ex) { | 932 } on Exception catch (ex) { |
| 933 wrongExceptionCaught = true; | 933 wrongExceptionCaught = true; |
| 934 } | 934 } |
| 935 Expect.equals(true, exceptionCaught); | 935 Expect.equals(true, exceptionCaught); |
| 936 Expect.equals(true, !wrongExceptionCaught); | 936 Expect.equals(true, !wrongExceptionCaught); |
| 937 exceptionCaught = false; | 937 exceptionCaught = false; |
| 938 try { | 938 try { |
| 939 List<int> buffer = new List<int>(10); | 939 List<int> buffer = new List<int>(10); |
| 940 openedFile.writeListSync(buffer, -1, 1); | 940 openedFile.writeListSync(buffer, -1, 1); |
| 941 } on IndexOutOfRangeException catch (ex) { | 941 } on RangeError catch (ex) { |
| 942 exceptionCaught = true; | 942 exceptionCaught = true; |
| 943 } on Exception catch (ex) { | 943 } on Exception catch (ex) { |
| 944 wrongExceptionCaught = true; | 944 wrongExceptionCaught = true; |
| 945 } | 945 } |
| 946 Expect.equals(true, exceptionCaught); | 946 Expect.equals(true, exceptionCaught); |
| 947 Expect.equals(true, !wrongExceptionCaught); | 947 Expect.equals(true, !wrongExceptionCaught); |
| 948 exceptionCaught = false; | 948 exceptionCaught = false; |
| 949 try { | 949 try { |
| 950 List<int> buffer = new List<int>(10); | 950 List<int> buffer = new List<int>(10); |
| 951 openedFile.writeListSync(buffer, 0, -1); | 951 openedFile.writeListSync(buffer, 0, -1); |
| 952 } on IndexOutOfRangeException catch (ex) { | 952 } on RangeError catch (ex) { |
| 953 exceptionCaught = true; | 953 exceptionCaught = true; |
| 954 } on Exception catch (ex) { | 954 } on Exception catch (ex) { |
| 955 wrongExceptionCaught = true; | 955 wrongExceptionCaught = true; |
| 956 } | 956 } |
| 957 Expect.equals(true, exceptionCaught); | 957 Expect.equals(true, exceptionCaught); |
| 958 Expect.equals(true, !wrongExceptionCaught); | 958 Expect.equals(true, !wrongExceptionCaught); |
| 959 openedFile.closeSync(); | 959 openedFile.closeSync(); |
| 960 file.deleteSync(); | 960 file.deleteSync(); |
| 961 } | 961 } |
| 962 | 962 |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1328 testDirectorySync(); | 1328 testDirectorySync(); |
| 1329 testWriteStringUtf8(); | 1329 testWriteStringUtf8(); |
| 1330 testWriteStringUtf8Sync(); | 1330 testWriteStringUtf8Sync(); |
| 1331 }); | 1331 }); |
| 1332 } | 1332 } |
| 1333 } | 1333 } |
| 1334 | 1334 |
| 1335 main() { | 1335 main() { |
| 1336 FileTest.testMain(); | 1336 FileTest.testMain(); |
| 1337 } | 1337 } |
| OLD | NEW |