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

Side by Side Diff: test/test_utils.dart

Issue 935923002: Re-add minified/unminified tests. (Closed) Base URL: git@github.com:dart-lang/matcher@master
Patch Set: Code review changes Created 5 years, 10 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/minified_test.dart ('k') | test/unminified_test.dart » ('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; 5 library matcher.test_utils;
6 6
7 import 'dart:collection';
8
7 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
8 10
9 void shouldFail(value, Matcher matcher, expected) { 11 void shouldFail(value, Matcher matcher, expected) {
10 var failed = false; 12 var failed = false;
11 try { 13 try {
12 expect(value, matcher); 14 expect(value, matcher);
13 } on TestFailure catch (err) { 15 } on TestFailure catch (err) {
14 failed = true; 16 failed = true;
15 17
16 var _errorString = err.message; 18 var _errorString = err.message;
17 19
18 if (expected is String) { 20 if (expected is String) {
19 expect(_errorString, equalsIgnoringWhitespace(expected)); 21 expect(_errorString, equalsIgnoringWhitespace(expected));
20 } else { 22 } else {
21 expect(_errorString.replaceAll('\n', ''), expected); 23 expect(_errorString.replaceAll('\n', ''), expected);
22 } 24 }
23 } 25 }
24 26
25 expect(failed, isTrue, reason: 'Expected to fail.'); 27 expect(failed, isTrue, reason: 'Expected to fail.');
26 } 28 }
27 29
28 void shouldPass(value, Matcher matcher) { 30 void shouldPass(value, Matcher matcher) {
29 expect(value, matcher); 31 expect(value, matcher);
30 } 32 }
31 33
32 doesNotThrow() {} 34 doesNotThrow() {}
33 doesThrow() { 35 doesThrow() {
34 throw 'X'; 36 throw 'X';
35 } 37 }
38
39 class Widget {
40 int price;
41 }
42
43 class HasPrice extends CustomMatcher {
44 HasPrice(matcher) : super("Widget with a price that is", "price", matcher);
45 featureValueOf(actual) => actual.price;
46 }
47
48 class SimpleIterable extends IterableBase<int> {
49 final int count;
50
51 SimpleIterable(this.count);
52
53 bool contains(int val) => count < val ? false : true;
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 }
68
69 class _SimpleIterator implements Iterator<int> {
70 int _count;
71 int _current;
72
73 _SimpleIterator(this._count);
74
75 bool moveNext() {
76 if (_count > 0) {
77 _current = _count;
78 _count--;
79 return true;
80 }
81 _current = null;
82 return false;
83 }
84
85 int get current => _current;
86 }
OLDNEW
« no previous file with comments | « test/minified_test.dart ('k') | test/unminified_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698