OLD | NEW |
1 #library('ElementListTest'); | 1 #library('ElementListTest'); |
2 #import('../../pkg/unittest/unittest.dart'); | 2 #import('../../pkg/unittest/unittest.dart'); |
3 #import('../../pkg/unittest/html_config.dart'); | 3 #import('../../pkg/unittest/html_config.dart'); |
4 #import('dart:html'); | 4 #import('dart:html'); |
5 | 5 |
6 // Test that List<Element> implements List<T> | 6 // Test that List<Element> implements List<T> |
7 main() { | 7 main() { |
8 Element insertTestDiv() { | 8 Element insertTestDiv() { |
9 Element element = new Element.tag('div'); | 9 Element element = new Element.tag('div'); |
10 element.innerHTML = r""" | 10 element.innerHTML = r""" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 List<Element> someChecked = | 124 List<Element> someChecked = |
125 document.query('#someChecked').elements; | 125 document.query('#someChecked').elements; |
126 | 126 |
127 List<Element> emptyDiv = | 127 List<Element> emptyDiv = |
128 document.query('#emptyDiv').elements; | 128 document.query('#emptyDiv').elements; |
129 | 129 |
130 Expect.equals(4, someChecked.length); | 130 Expect.equals(4, someChecked.length); |
131 Expect.equals(0, emptyDiv.length); | 131 Expect.equals(0, emptyDiv.length); |
132 | 132 |
133 Expect.isFalse(someChecked.isEmpty()); | 133 Expect.isFalse(someChecked.isEmpty); |
134 Expect.isTrue(emptyDiv.isEmpty()); | 134 Expect.isTrue(emptyDiv.isEmpty); |
135 | 135 |
136 root.remove(); | 136 root.remove(); |
137 }); | 137 }); |
138 | 138 |
139 int countWithForEach(collection, predicate) { | 139 int countWithForEach(collection, predicate) { |
140 int count = 0; | 140 int count = 0; |
141 collection.forEach((element) { | 141 collection.forEach((element) { |
142 if (predicate(element)) count++; | 142 if (predicate(element)) count++; |
143 }); | 143 }); |
144 return count; | 144 return count; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 Expect.equals(-1, someChecked.lastIndexOf(someChecked[3], 2)); | 268 Expect.equals(-1, someChecked.lastIndexOf(someChecked[3], 2)); |
269 | 269 |
270 Expect.equals(-1, someChecked.lastIndexOf(noneChecked[0], 3)); | 270 Expect.equals(-1, someChecked.lastIndexOf(noneChecked[0], 3)); |
271 Expect.equals(-1, noneChecked.lastIndexOf(someChecked[0], 3)); | 271 Expect.equals(-1, noneChecked.lastIndexOf(someChecked[0], 3)); |
272 Expect.equals(-1, someChecked.lastIndexOf(noneChecked[1], 3)); | 272 Expect.equals(-1, someChecked.lastIndexOf(noneChecked[1], 3)); |
273 Expect.equals(-1, noneChecked.lastIndexOf(someChecked[1], 3)); | 273 Expect.equals(-1, noneChecked.lastIndexOf(someChecked[1], 3)); |
274 | 274 |
275 root.remove(); | 275 root.remove(); |
276 }); | 276 }); |
277 } | 277 } |
OLD | NEW |