| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library matcher.operator_matchers_test; | |
| 6 | |
| 7 import 'package:matcher/matcher.dart'; | |
| 8 import 'package:unittest/unittest.dart' show test, group; | |
| 9 | |
| 10 import 'test_utils.dart'; | |
| 11 | |
| 12 void main() { | |
| 13 initUtils(); | |
| 14 | |
| 15 test('anyOf', () { | |
| 16 // with a list | |
| 17 shouldFail(0, anyOf([equals(1), equals(2)]), | |
| 18 "Expected: (<1> or <2>) Actual: <0>"); | |
| 19 shouldPass(1, anyOf([equals(1), equals(2)])); | |
| 20 | |
| 21 // with individual items | |
| 22 shouldFail(0, anyOf(equals(1), equals(2)), | |
| 23 "Expected: (<1> or <2>) Actual: <0>"); | |
| 24 shouldPass(1, anyOf(equals(1), equals(2))); | |
| 25 }); | |
| 26 | |
| 27 test('allOf', () { | |
| 28 // with a list | |
| 29 shouldPass(1, allOf([lessThan(10), greaterThan(0)])); | |
| 30 shouldFail(-1, allOf([lessThan(10), greaterThan(0)]), | |
| 31 "Expected: (a value less than <10> and a value greater than <0>) " | |
| 32 "Actual: <-1> " | |
| 33 "Which: is not a value greater than <0>"); | |
| 34 | |
| 35 // with individual items | |
| 36 shouldPass(1, allOf(lessThan(10), greaterThan(0))); | |
| 37 shouldFail(-1, allOf(lessThan(10), greaterThan(0)), | |
| 38 "Expected: (a value less than <10> and a value greater than <0>) " | |
| 39 "Actual: <-1> " | |
| 40 "Which: is not a value greater than <0>"); | |
| 41 | |
| 42 // with maximum items | |
| 43 shouldPass(1, allOf(lessThan(10), lessThan(9), lessThan(8), lessThan(7), | |
| 44 lessThan(6), lessThan(5), lessThan(4))); | |
| 45 shouldFail(4, allOf(lessThan(10), lessThan(9), lessThan(8), lessThan(7), | |
| 46 lessThan(6), lessThan(5), lessThan(4)), | |
| 47 "Expected: (a value less than <10> and a value less than <9> and a " | |
| 48 "value less than <8> and a value less than <7> and a value less than " | |
| 49 "<6> and a value less than <5> and a value less than <4>) " | |
| 50 "Actual: <4> " | |
| 51 "Which: is not a value less than <4>"); | |
| 52 }); | |
| 53 | |
| 54 test('If the first argument is a List, the rest must be null', () { | |
| 55 expect(() => allOf([], 5), throwsArgumentError); | |
| 56 expect(() => anyOf([], null, null, null, null, null, 42), | |
| 57 throwsArgumentError); | |
| 58 }); | |
| 59 } | |
| OLD | NEW |