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

Side by Side Diff: packages/matcher/test/test_utils.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 4 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 | « packages/matcher/test/string_matchers_test.dart ('k') | packages/meta/.packages » ('j') | 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 library matcher.test_utils;
6
7 import 'dart:collection';
8
9 import 'package:test/test.dart'; 5 import 'package:test/test.dart';
10 6
11 void shouldFail(value, Matcher matcher, expected) { 7 void shouldFail(value, Matcher matcher, expected) {
12 var failed = false; 8 var failed = false;
13 try { 9 try {
14 expect(value, matcher); 10 expect(value, matcher);
15 } on TestFailure catch (err) { 11 } on TestFailure catch (err) {
16 failed = true; 12 failed = true;
17 13
18 var _errorString = err.message; 14 var _errorString = err.message;
(...skipping 19 matching lines...) Expand all
38 34
39 class Widget { 35 class Widget {
40 int price; 36 int price;
41 } 37 }
42 38
43 class HasPrice extends CustomMatcher { 39 class HasPrice extends CustomMatcher {
44 HasPrice(matcher) : super("Widget with a price that is", "price", matcher); 40 HasPrice(matcher) : super("Widget with a price that is", "price", matcher);
45 featureValueOf(actual) => actual.price; 41 featureValueOf(actual) => actual.price;
46 } 42 }
47 43
48 class SimpleIterable extends IterableBase<int> { 44 class SimpleIterable extends Iterable<int> {
49 final int count; 45 final int count;
50 46
51 SimpleIterable(this.count); 47 SimpleIterable(this.count);
52 48
53 bool contains(int val) => count < val ? false : true; 49 Iterator<int> get iterator => new _SimpleIterator(count);
54
55 bool any(bool f(element)) {
56 for (var i = 0; i <= count; i++) {
57 if (f(i)) return true;
58 }
59 return false;
60 }
61
62 String toString() => "<[$count]>";
63
64 Iterator get iterator {
65 return new _SimpleIterator(count);
66 }
67 } 50 }
68 51
69 class _SimpleIterator implements Iterator<int> { 52 class _SimpleIterator implements Iterator<int> {
70 int _count; 53 int _count;
71 int _current; 54 int _current;
72 55
73 _SimpleIterator(this._count); 56 _SimpleIterator(this._count);
74 57
75 bool moveNext() { 58 bool moveNext() {
76 if (_count > 0) { 59 if (_count > 0) {
77 _current = _count; 60 _current = _count;
78 _count--; 61 _count--;
79 return true; 62 return true;
80 } 63 }
81 _current = null; 64 _current = null;
82 return false; 65 return false;
83 } 66 }
84 67
85 int get current => _current; 68 int get current => _current;
86 } 69 }
OLDNEW
« no previous file with comments | « packages/matcher/test/string_matchers_test.dart ('k') | packages/meta/.packages » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698