| 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 native byte arrays. | 5 // Dart test program for testing native byte arrays. |
| 6 | 6 |
| 7 // Library tag to be able to run in html test framework. | 7 // Library tag to be able to run in html test framework. |
| 8 #library("ByteArrayTest.dart"); | 8 #library("ByteArrayTest.dart"); |
| 9 | 9 |
| 10 #import('dart:scalarlist'); | 10 #import('dart:scalarlist'); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 testThrowsIndex(() => array.subByteArray(0, -1)); | 100 testThrowsIndex(() => array.subByteArray(0, -1)); |
| 101 testThrowsIndex(() => array.subByteArray(1, -1)); | 101 testThrowsIndex(() => array.subByteArray(1, -1)); |
| 102 testThrowsIndex(() => array.subByteArray(10, -1)); | 102 testThrowsIndex(() => array.subByteArray(10, -1)); |
| 103 testThrowsIndex(() => array.subByteArray(-1, 0)); | 103 testThrowsIndex(() => array.subByteArray(-1, 0)); |
| 104 testThrowsIndex(() => array.subByteArray(-1)); | 104 testThrowsIndex(() => array.subByteArray(-1)); |
| 105 testThrowsIndex(() => array.subByteArray(-1, null)); | 105 testThrowsIndex(() => array.subByteArray(-1, null)); |
| 106 testThrowsIndex(() => array.subByteArray(11, 0)); | 106 testThrowsIndex(() => array.subByteArray(11, 0)); |
| 107 testThrowsIndex(() => array.subByteArray(11)); | 107 testThrowsIndex(() => array.subByteArray(11)); |
| 108 testThrowsIndex(() => array.subByteArray(11, null)); | 108 testThrowsIndex(() => array.subByteArray(11, null)); |
| 109 testThrowsIndex(() => array.subByteArray(6, 5)); | 109 testThrowsIndex(() => array.subByteArray(6, 5)); |
| 110 Expect.throws(() => array.subByteArray(0, "5"), (e) => e is ArgumentError); | 110 |
| 111 Expect.throws(() => array.subByteArray("0", 5), (e) => e is ArgumentError); | 111 bool checkedMode = false; |
| 112 Expect.throws(() => array.subByteArray("0"), (e) => e is ArgumentError); | 112 assert(checkedMode = true); |
| 113 if (!checkedMode) { |
| 114 // In checked mode these will necessarily throw a TypeError. |
| 115 Expect.throws(() => array.subByteArray(0, "5"), (e) => e is ArgumentError); |
| 116 Expect.throws(() => array.subByteArray("0", 5), (e) => e is ArgumentError); |
| 117 Expect.throws(() => array.subByteArray("0"), (e) => e is ArgumentError); |
| 118 } |
| 113 Expect.throws(() => array.subByteArray(null), (e) => e is ArgumentError); | 119 Expect.throws(() => array.subByteArray(null), (e) => e is ArgumentError); |
| 114 } | 120 } |
| 115 | 121 |
| 116 main() { | 122 main() { |
| 117 for (int i = 0; i < 2000; i++) { | 123 for (int i = 0; i < 2000; i++) { |
| 118 testCreateByteArray(); | 124 testCreateByteArray(); |
| 119 testSetRange(); | 125 testSetRange(); |
| 120 testIndexOutOfRange(); | 126 testIndexOutOfRange(); |
| 121 testIndexOf(); | 127 testIndexOf(); |
| 122 testSubArray(); | 128 testSubArray(); |
| 123 } | 129 } |
| 124 } | 130 } |
| 125 | 131 |
| OLD | NEW |