Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 class CollectionTest { | |
|
Ivan Posva
2012/08/13 16:58:45
To me it feels like this file will explode as you
Anders Johnsen
2012/08/14 05:38:27
I agree that we test two dimensions, but we only h
Lasse Reichstein Nielsen
2012/08/14 09:00:07
I think this is fine. I prefer a templated test to
| |
| 6 CollectionTest(Collection collection) { | |
| 7 testReduce(collection); | |
| 8 } | |
| 9 | |
| 10 void testReduce(Collection collection) { | |
| 11 Expect.equals(28, collection.reduce(0, (prev, element) => prev + element)); | |
| 12 Expect.equals( | |
| 13 3024, collection.reduce(1, (prev, element) => prev * element)); | |
| 14 } | |
| 15 } | |
| 16 | |
| 17 | |
| 18 main() { | |
| 19 final TEST_ELEMENTS = const [4, 2, 6, 7, 9]; | |
| 20 // Const list. | |
| 21 new CollectionTest(TEST_ELEMENTS); | |
| 22 | |
| 23 // Fixed size list. | |
| 24 var fixedList = new List(TEST_ELEMENTS.length); | |
| 25 for (int i = 0; i < TEST_ELEMENTS.length; i++) { | |
| 26 fixedList[i] = TEST_ELEMENTS[i]; | |
| 27 } | |
| 28 new CollectionTest(fixedList); | |
| 29 | |
| 30 // Dynamic size list. | |
| 31 new CollectionTest(new List.from(TEST_ELEMENTS)); | |
| 32 | |
| 33 // Dynamic size set. | |
| 34 new CollectionTest(new Set.from(TEST_ELEMENTS)); | |
| 35 } | |
|
Lasse Reichstein Nielsen
2012/08/14 09:00:07
BTW, you might want to make a test with zero eleme
| |
| OLD | NEW |