Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: test/test_utils.dart

Issue 1827353003: pkg/matcher: a few more strong-mode fixes (Closed) Base URL: https://github.com/dart-lang/matcher.git@master
Patch Set: nit Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/pretty_print_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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 4
5 import 'dart:collection';
6
7 import 'package:test/test.dart'; 5 import 'package:test/test.dart';
8 6
9 void shouldFail(value, Matcher matcher, expected) { 7 void shouldFail(value, Matcher matcher, expected) {
10 var failed = false; 8 var failed = false;
11 try { 9 try {
12 expect(value, matcher); 10 expect(value, matcher);
13 } on TestFailure catch (err) { 11 } on TestFailure catch (err) {
14 failed = true; 12 failed = true;
15 13
16 var _errorString = err.message; 14 var _errorString = err.message;
(...skipping 19 matching lines...) Expand all
36 34
37 class Widget { 35 class Widget {
38 int price; 36 int price;
39 } 37 }
40 38
41 class HasPrice extends CustomMatcher { 39 class HasPrice extends CustomMatcher {
42 HasPrice(matcher) : super("Widget with a price that is", "price", matcher); 40 HasPrice(matcher) : super("Widget with a price that is", "price", matcher);
43 featureValueOf(actual) => actual.price; 41 featureValueOf(actual) => actual.price;
44 } 42 }
45 43
46 class SimpleIterable extends IterableBase<int> { 44 class SimpleIterable extends Iterable<int> {
47 final int count; 45 final int count;
48 46
49 SimpleIterable(this.count); 47 SimpleIterable(this.count);
50 48
51 bool contains(int val) => count < val ? false : true; 49 Iterator<int> get iterator => new _SimpleIterator(count);
52
53 bool any(bool f(element)) {
54 for (var i = 0; i <= count; i++) {
55 if (f(i)) return true;
56 }
57 return false;
58 }
59
60 String toString() => "<[$count]>";
61
62 Iterator get iterator {
63 return new _SimpleIterator(count);
64 }
65 } 50 }
66 51
67 class _SimpleIterator implements Iterator<int> { 52 class _SimpleIterator implements Iterator<int> {
68 int _count; 53 int _count;
69 int _current; 54 int _current;
70 55
71 _SimpleIterator(this._count); 56 _SimpleIterator(this._count);
72 57
73 bool moveNext() { 58 bool moveNext() {
74 if (_count > 0) { 59 if (_count > 0) {
75 _current = _count; 60 _current = _count;
76 _count--; 61 _count--;
77 return true; 62 return true;
78 } 63 }
79 _current = null; 64 _current = null;
80 return false; 65 return false;
81 } 66 }
82 67
83 int get current => _current; 68 int get current => _current;
84 } 69 }
OLDNEW
« no previous file with comments | « test/pretty_print_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698