OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2014 Google Inc. All rights reserved. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style |
| 5 * license that can be found in the LICENSE file or at |
| 6 * https://developers.google.com/open-source/licenses/bsd |
| 7 */ |
| 8 |
| 9 part of charted.test.core; |
| 10 |
| 11 testLists() { |
| 12 group('sum()', () { |
| 13 test('adds all elements in a list', () { |
| 14 expect(sum([10, 20, 30, -10]), equals(50)); |
| 15 }); |
| 16 |
| 17 test('returns 0 when the list is null or empty', () { |
| 18 expect(sum([]), equals(0)); |
| 19 expect(sum(null), equals(0)); |
| 20 }); |
| 21 }); |
| 22 |
| 23 group('Range', () { |
| 24 test('throws ArgumentError when range is infinite', () { |
| 25 expect(() => new Range(0, 1, 0), throwsArgumentError); |
| 26 }); |
| 27 test('returns integers between 0 and [start] when only start is set', () { |
| 28 expect(new Range(5), orderedEquals([0, 1, 2, 3, 4])); |
| 29 }); |
| 30 test('returns a list of increasing step values ' |
| 31 'when start is less than stop', () { |
| 32 expect(new Range(0, 5), orderedEquals([0, 1, 2, 3, 4])); |
| 33 expect(new Range(10, 50, 10), orderedEquals([10, 20, 30, 40])); |
| 34 expect(new Range(-6, 0, 1.2), |
| 35 orderedEquals([-6, -4.8, -3.6, -2.4, -1.2])); |
| 36 expect(new Range(1.2, 1.6, 0.2), orderedEquals([1.2, 1.4])); |
| 37 }); |
| 38 test('returns a list of decreasing step values ' |
| 39 'when start is greater than stop', () { |
| 40 expect(new Range(5, 0, -1), orderedEquals([5, 4, 3, 2, 1])); |
| 41 expect(new Range(-1.2, -1.6, -0.2), orderedEquals([-1.2, -1.4])); |
| 42 }); |
| 43 }); |
| 44 } |
OLD | NEW |