OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Dart test program for testing arrays. | 4 // Dart test program for testing arrays. |
5 | 5 |
6 class ListTest { | 6 class ListTest { |
7 static void TestIterator() { | 7 static void TestIterator() { |
8 List<int> a = new List<int>(10); | 8 List<int> a = new List<int>(10); |
9 int count = 0; | 9 int count = 0; |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 try { | 52 try { |
53 var x = a[len]; | 53 var x = a[len]; |
54 } catch (IndexOutOfRangeException e) { | 54 } catch (IndexOutOfRangeException e) { |
55 exception_caught = true; | 55 exception_caught = true; |
56 } | 56 } |
57 Expect.equals(true, exception_caught); | 57 Expect.equals(true, exception_caught); |
58 | 58 |
59 exception_caught = false; | 59 exception_caught = false; |
60 try { | 60 try { |
61 List a = new List(4); | 61 List a = new List(4); |
62 a.copyFrom(a, null, 1, 1); | 62 a.setRange(1, 1, a, null); |
63 } catch (IllegalArgumentException e) { | 63 } catch (Exception e) { |
64 exception_caught = true; | 64 exception_caught = true; |
65 } | 65 } |
66 Expect.equals(true, exception_caught); | 66 Expect.equals(true, exception_caught); |
67 | 67 |
68 exception_caught = false; | 68 exception_caught = false; |
69 try { | 69 try { |
70 List a = new List(4); | 70 List a = new List(4); |
71 a.copyFrom(a, 10, 1, 1); | 71 a.setRange(10, 1, a, 1); |
72 } catch (IndexOutOfRangeException e) { | 72 } catch (IndexOutOfRangeException e) { |
73 exception_caught = true; | 73 exception_caught = true; |
74 } | 74 } |
75 Expect.equals(true, exception_caught); | 75 Expect.equals(true, exception_caught); |
76 | 76 |
77 exception_caught = false; | 77 exception_caught = false; |
78 try { | 78 try { |
79 List a = new List(4); | 79 List a = new List(4); |
80 List b = new List(4); | 80 List b = new List(4); |
81 b.copyFrom(a, 0, 0, 4); | 81 b.setRange(0, 4, a, 0); |
82 } catch (var e) { | 82 } catch (var e) { |
83 exception_caught = true; | 83 exception_caught = true; |
84 } | 84 } |
85 Expect.equals(false, exception_caught); | 85 Expect.equals(false, exception_caught); |
86 | 86 |
87 List<int> unsorted = [4, 3, 9, 12, -4, 9]; | 87 List<int> unsorted = [4, 3, 9, 12, -4, 9]; |
88 int compare(a, b) { | 88 int compare(a, b) { |
89 if (a < b) return -1; | 89 if (a < b) return -1; |
90 if (a > b) return 1; | 90 if (a > b) return 1; |
91 return 0; | 91 return 0; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 exceptionCaught = true; | 146 exceptionCaught = true; |
147 } | 147 } |
148 Expect.equals(0, list.length); | 148 Expect.equals(0, list.length); |
149 Expect.equals(true, exceptionCaught); | 149 Expect.equals(true, exceptionCaught); |
150 } | 150 } |
151 } | 151 } |
152 | 152 |
153 main() { | 153 main() { |
154 ListTest.testMain(); | 154 ListTest.testMain(); |
155 } | 155 } |
OLD | NEW |