chore: upgrade guinness to remove a workaround in testlib

This commit is contained in:
vsavkin 2015-03-13 16:47:22 -07:00
parent 33bff17f33
commit 75ecaf02b9
7 changed files with 13 additions and 88 deletions

View File

@ -16,4 +16,4 @@ dependencies:
html5lib: '^0.12.0'
stack_trace: '^1.1.1'
dev_dependencies:
guinness: "^0.1.16"
guinness: "^0.1.17"

View File

@ -3,10 +3,9 @@ library test_lib.test_lib;
import 'package:guinness/guinness.dart' as gns;
export 'package:guinness/guinness.dart' hide Expect, expect, NotExpect, beforeEach, it, iit, xit;
import 'package:unittest/unittest.dart' hide expect;
import 'dart:mirrors';
import 'dart:async';
import 'package:collection/equality.dart';
import 'package:angular2/src/dom/dom_adapter.dart' show DOM;
import 'package:angular2/src/reflection/reflection.dart';
@ -82,10 +81,8 @@ class Expect extends gns.Expect {
NotExpect get not => new NotExpect(actual);
// TODO(tbosch) change back when https://github.com/vsavkin/guinness/issues/41 is fixed
// void toEqual(expected) => toHaveSameProps(expected);
void toEqual(expected) => _expect(actual, new FixedSamePropsMatcher(expected));
void toThrowError([message=""]) => this.toThrowWith(message: message);
void toEqual(expected) => toHaveSameProps(expected);
void toThrowError([message=""]) => toThrowWith(message: message);
void toBePromise() => _expect(actual is Future, equals(true));
void toImplement(expected) => toBeA(expected);
void toBeNaN() => _expect(double.NAN.compareTo(actual) == 0, equals(true));
@ -96,9 +93,7 @@ class Expect extends gns.Expect {
class NotExpect extends gns.NotExpect {
NotExpect(actual) : super(actual);
// TODO(tbosch) change back when https://github.com/vsavkin/guinness/issues/41 is fixed
// void toEqual(expected) => toHaveSameProps(expected);
void toEqual(expected) => _expect(actual, isNot(new FixedSamePropsMatcher(expected)));
void toEqual(expected) => toHaveSameProps(expected);
void toBePromise() => _expect(actual is Future, equals(false));
Function get _expect => gns.guinness.matchers.expect;
}
@ -155,66 +150,6 @@ xit(name, fn) {
_it(gns.xit, name, fn);
}
// TODO(tbosch): remove when https://github.com/vsavkin/guinness/issues/41
// is fixed
class FixedSamePropsMatcher extends Matcher {
final Object _expected;
const FixedSamePropsMatcher(this._expected);
bool matches(actual, Map matchState) {
return compare(toData(_expected), toData(actual));
}
Description describeMismatch(item, Description mismatchDescription,
Map matchState, bool verbose) =>
mismatchDescription.add('is equal to ${toData(item)}. Expected: ${toData(_expected)}');
Description describe(Description description) =>
description.add('has different properties');
toData(obj) => new _FixedObjToData().call(obj);
compare(d1, d2) => new DeepCollectionEquality().equals(d1, d2);
}
// TODO(tbosch): remove when https://github.com/vsavkin/guinness/issues/41
// is fixed
class _FixedObjToData {
final visitedObjects = new Set();
call(obj) {
if (visitedObjects.contains(obj)) return null;
visitedObjects.add(obj);
if (obj is num || obj is String || obj is bool) return obj;
if (obj is Iterable) return obj.map(call).toList();
if (obj is Map) return mapToData(obj);
return toDataUsingReflection(obj);
}
mapToData(obj) {
var res = {};
obj.forEach((k,v) {
res[call(k)] = call(v);
});
return res;
}
toDataUsingReflection(obj) {
final clazz = reflectClass(obj.runtimeType);
final instance = reflect(obj);
return clazz.declarations.values.fold({}, (map, decl) {
if (decl is VariableMirror && !decl.isPrivate && !decl.isStatic) {
final field = instance.getField(decl.simpleName);
final name = MirrorSystem.getName(decl.simpleName);
map[name] = call(field.reflectee);
}
return map;
});
}
}
String elementText(n) {
hasNodes(n) {
var children = DOM.childNodes(n);

View File

@ -1,6 +1,6 @@
import {describe, it, iit, ddescribe, expect, tick, async, SpyObject, beforeEach, proxy} from 'angular2/test_lib';
import {MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
import {IMPLEMENTS, Date, DateWrapper} from 'angular2/src/facade/lang';
import {MapWrapper} from 'angular2/src/facade/collection';
import {IMPLEMENTS} from 'angular2/src/facade/lang';
class TestObj {
prop;
@ -24,19 +24,6 @@ export function main() {
expect(actual).toEqual(expected);
expect(falseActual).not.toEqual(expected);
});
it('should structurally compare objects with private and static fields', () => {
expect(DateWrapper.fromMillis(1)).toEqual(DateWrapper.fromMillis(1));
});
it('should work for arrays of string maps', () => {
expect([{'a':'b'}]).toEqual([{'a':'b'}]);
});
it('should work for arrays of real maps', () => {
expect([MapWrapper.createFromStringMap({'a':'b'})]).toEqual([MapWrapper.createFromStringMap({'a':'b'})]);
expect([MapWrapper.createFromStringMap({'a':'b'})]).not.toEqual([MapWrapper.createFromStringMap({'a':'c'})]);
});
});
describe('toEqual for Maps', () => {

View File

@ -16,4 +16,4 @@ dependency_overrides:
angular2:
path: ../angular2
dev_dependencies:
guinness: '^0.1.16'
guinness: '^0.1.17'

View File

@ -8,7 +8,7 @@ dependency_overrides:
angular2:
path: ../angular2
dev_dependencies:
guinness: ">=0.1.16 <0.2.0"
guinness: ">=0.1.17 <0.2.0"
benchpress:
path: ../benchpress
transformers:

View File

@ -5,4 +5,4 @@ dependencies:
stack_trace: '>=1.1.1 <1.2.0'
dev_dependencies:
guinness: ">=0.1.16 <0.2.0"
guinness: ">=0.1.17 <0.2.0"

View File

@ -64,6 +64,9 @@ module.exports = function(gulp, plugins, config) {
if (line.match(/\/test\/core\/compiler\/view_.*spec\.dart/)) {
return;
}
if (line.match(/\/test_lib_spec\.dart/)) {
return;
}
}
if (line.match(/\[hint\]/)) {
hintCount++;