Skip to content

Commit 75ecaf0

Browse files
committed
chore: upgrade guinness to remove a workaround in testlib
1 parent 33bff17 commit 75ecaf0

File tree

7 files changed

+13
-88
lines changed

7 files changed

+13
-88
lines changed

modules/angular2/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ dependencies:
1616
html5lib: '^0.12.0'
1717
stack_trace: '^1.1.1'
1818
dev_dependencies:
19-
guinness: "^0.1.16"
19+
guinness: "^0.1.17"

modules/angular2/src/test_lib/test_lib.dart

Lines changed: 4 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ library test_lib.test_lib;
33
import 'package:guinness/guinness.dart' as gns;
44
export 'package:guinness/guinness.dart' hide Expect, expect, NotExpect, beforeEach, it, iit, xit;
55
import 'package:unittest/unittest.dart' hide expect;
6-
import 'dart:mirrors';
6+
77
import 'dart:async';
88

9-
import 'package:collection/equality.dart';
109
import 'package:angular2/src/dom/dom_adapter.dart' show DOM;
1110

1211
import 'package:angular2/src/reflection/reflection.dart';
@@ -82,10 +81,8 @@ class Expect extends gns.Expect {
8281

8382
NotExpect get not => new NotExpect(actual);
8483

85-
// TODO(tbosch) change back when https://github.com/vsavkin/guinness/issues/41 is fixed
86-
// void toEqual(expected) => toHaveSameProps(expected);
87-
void toEqual(expected) => _expect(actual, new FixedSamePropsMatcher(expected));
88-
void toThrowError([message=""]) => this.toThrowWith(message: message);
84+
void toEqual(expected) => toHaveSameProps(expected);
85+
void toThrowError([message=""]) => toThrowWith(message: message);
8986
void toBePromise() => _expect(actual is Future, equals(true));
9087
void toImplement(expected) => toBeA(expected);
9188
void toBeNaN() => _expect(double.NAN.compareTo(actual) == 0, equals(true));
@@ -96,9 +93,7 @@ class Expect extends gns.Expect {
9693
class NotExpect extends gns.NotExpect {
9794
NotExpect(actual) : super(actual);
9895

99-
// TODO(tbosch) change back when https://github.com/vsavkin/guinness/issues/41 is fixed
100-
// void toEqual(expected) => toHaveSameProps(expected);
101-
void toEqual(expected) => _expect(actual, isNot(new FixedSamePropsMatcher(expected)));
96+
void toEqual(expected) => toHaveSameProps(expected);
10297
void toBePromise() => _expect(actual is Future, equals(false));
10398
Function get _expect => gns.guinness.matchers.expect;
10499
}
@@ -155,66 +150,6 @@ xit(name, fn) {
155150
_it(gns.xit, name, fn);
156151
}
157152

158-
// TODO(tbosch): remove when https://github.com/vsavkin/guinness/issues/41
159-
// is fixed
160-
class FixedSamePropsMatcher extends Matcher {
161-
final Object _expected;
162-
163-
const FixedSamePropsMatcher(this._expected);
164-
165-
bool matches(actual, Map matchState) {
166-
return compare(toData(_expected), toData(actual));
167-
}
168-
169-
Description describeMismatch(item, Description mismatchDescription,
170-
Map matchState, bool verbose) =>
171-
mismatchDescription.add('is equal to ${toData(item)}. Expected: ${toData(_expected)}');
172-
173-
Description describe(Description description) =>
174-
description.add('has different properties');
175-
176-
toData(obj) => new _FixedObjToData().call(obj);
177-
compare(d1, d2) => new DeepCollectionEquality().equals(d1, d2);
178-
}
179-
180-
// TODO(tbosch): remove when https://github.com/vsavkin/guinness/issues/41
181-
// is fixed
182-
class _FixedObjToData {
183-
final visitedObjects = new Set();
184-
185-
call(obj) {
186-
if (visitedObjects.contains(obj)) return null;
187-
visitedObjects.add(obj);
188-
189-
if (obj is num || obj is String || obj is bool) return obj;
190-
if (obj is Iterable) return obj.map(call).toList();
191-
if (obj is Map) return mapToData(obj);
192-
return toDataUsingReflection(obj);
193-
}
194-
195-
mapToData(obj) {
196-
var res = {};
197-
obj.forEach((k,v) {
198-
res[call(k)] = call(v);
199-
});
200-
return res;
201-
}
202-
203-
toDataUsingReflection(obj) {
204-
final clazz = reflectClass(obj.runtimeType);
205-
final instance = reflect(obj);
206-
207-
return clazz.declarations.values.fold({}, (map, decl) {
208-
if (decl is VariableMirror && !decl.isPrivate && !decl.isStatic) {
209-
final field = instance.getField(decl.simpleName);
210-
final name = MirrorSystem.getName(decl.simpleName);
211-
map[name] = call(field.reflectee);
212-
}
213-
return map;
214-
});
215-
}
216-
}
217-
218153
String elementText(n) {
219154
hasNodes(n) {
220155
var children = DOM.childNodes(n);

modules/angular2/test/test_lib/test_lib_spec.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {describe, it, iit, ddescribe, expect, tick, async, SpyObject, beforeEach, proxy} from 'angular2/test_lib';
2-
import {MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
3-
import {IMPLEMENTS, Date, DateWrapper} from 'angular2/src/facade/lang';
2+
import {MapWrapper} from 'angular2/src/facade/collection';
3+
import {IMPLEMENTS} from 'angular2/src/facade/lang';
44

55
class TestObj {
66
prop;
@@ -24,19 +24,6 @@ export function main() {
2424
expect(actual).toEqual(expected);
2525
expect(falseActual).not.toEqual(expected);
2626
});
27-
28-
it('should structurally compare objects with private and static fields', () => {
29-
expect(DateWrapper.fromMillis(1)).toEqual(DateWrapper.fromMillis(1));
30-
});
31-
32-
it('should work for arrays of string maps', () => {
33-
expect([{'a':'b'}]).toEqual([{'a':'b'}]);
34-
});
35-
36-
it('should work for arrays of real maps', () => {
37-
expect([MapWrapper.createFromStringMap({'a':'b'})]).toEqual([MapWrapper.createFromStringMap({'a':'b'})]);
38-
expect([MapWrapper.createFromStringMap({'a':'b'})]).not.toEqual([MapWrapper.createFromStringMap({'a':'c'})]);
39-
});
4027
});
4128

4229
describe('toEqual for Maps', () => {

modules/benchpress/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ dependency_overrides:
1616
angular2:
1717
path: ../angular2
1818
dev_dependencies:
19-
guinness: '^0.1.16'
19+
guinness: '^0.1.17'

modules/examples/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependency_overrides:
88
angular2:
99
path: ../angular2
1010
dev_dependencies:
11-
guinness: ">=0.1.16 <0.2.0"
11+
guinness: ">=0.1.17 <0.2.0"
1212
benchpress:
1313
path: ../benchpress
1414
transformers:

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ dependencies:
55
stack_trace: '>=1.1.1 <1.2.0'
66

77
dev_dependencies:
8-
guinness: ">=0.1.16 <0.2.0"
8+
guinness: ">=0.1.17 <0.2.0"

tools/build/dartanalyzer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ module.exports = function(gulp, plugins, config) {
6464
if (line.match(/\/test\/core\/compiler\/view_.*spec\.dart/)) {
6565
return;
6666
}
67+
if (line.match(/\/test_lib_spec\.dart/)) {
68+
return;
69+
}
6770
}
6871
if (line.match(/\[hint\]/)) {
6972
hintCount++;

0 commit comments

Comments
 (0)