feat(benchpress): rewritten implementation

Limitations:
- cloud reporter is not yet supported any more
This commit is contained in:
Tobias Bosch
2015-02-11 10:13:49 -08:00
parent 44845839a6
commit f6284f2a55
78 changed files with 2666 additions and 1018 deletions

View File

@ -1,6 +1,5 @@
import {ListWrapper, List} from 'angular2/src/facade/collection';
import {stringify} from 'angular2/src/facade/lang';
import {Key} from './key';
function findFirstClosedCycle(keys:List) {
var res = [];
@ -31,14 +30,16 @@ export class ProviderError extends Error {
keys:List;
constructResolvingMessage:Function;
message;
constructor(key:Key, constructResolvingMessage:Function) {
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
constructor(key, constructResolvingMessage:Function) {
super();
this.keys = [key];
this.constructResolvingMessage = constructResolvingMessage;
this.message = this.constructResolvingMessage(this.keys);
}
addKey(key:Key) {
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
addKey(key) {
ListWrapper.push(this.keys, key);
this.message = this.constructResolvingMessage(this.keys);
}
@ -49,7 +50,8 @@ export class ProviderError extends Error {
}
export class NoProviderError extends ProviderError {
constructor(key:Key) {
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
constructor(key) {
super(key, function (keys:List) {
var first = stringify(ListWrapper.first(keys).token);
return `No provider for ${first}!${constructResolvingPath(keys)}`;
@ -58,7 +60,8 @@ export class NoProviderError extends ProviderError {
}
export class AsyncBindingError extends ProviderError {
constructor(key:Key) {
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
constructor(key) {
super(key, function (keys:List) {
var first = stringify(ListWrapper.first(keys).token);
return `Cannot instantiate ${first} synchronously. ` +
@ -68,7 +71,8 @@ export class AsyncBindingError extends ProviderError {
}
export class CyclicDependencyError extends ProviderError {
constructor(key:Key) {
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
constructor(key) {
super(key, function (keys:List) {
return `Cannot instantiate cyclic dependency!${constructResolvingPath(keys)}`;
});
@ -76,7 +80,8 @@ export class CyclicDependencyError extends ProviderError {
}
export class InstantiationError extends ProviderError {
constructor(originalException, key:Key) {
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
constructor(originalException, key) {
super(key, function (keys:List) {
var first = stringify(ListWrapper.first(keys).token);
return `Error during instantiation of ${first}!${constructResolvingPath(keys)}.` +

View File

@ -98,8 +98,7 @@ class ListWrapper {
l.add(e);
}
static List concat(List a, List b) {
a.addAll(b);
return a;
return []..addAll(a)..addAll(b);
}
static bool isList(l) => l is List;
static void insert(List l, int index, value) {

View File

@ -2,6 +2,7 @@ library angular.core.facade.lang;
export 'dart:core' show Type, RegExp, print;
import 'dart:math' as math;
import 'dart:convert' as convert;
class Math {
static final _random = new math.Random();
@ -176,3 +177,9 @@ bool assertionsEnabled() {
return true;
}
}
// Can't be all uppercase as our transpiler would think it is a special directive...
class Json {
static parse(String s) => convert.JSON.decode(s);
static stringify(data) => convert.JSON.encode(data);
}

View File

@ -247,3 +247,6 @@ export function print(obj) {
console.log(obj);
}
}
// Can't be all uppercase as our transpiler would think it is a special directive...
export var Json = _global.JSON;

View File

@ -1,7 +1,10 @@
library angular.core.facade.math;
import 'dart:core' show double, num;
import 'dart:math' as math;
var NaN = double.NAN;
class Math {
static num pow(num x, num exponent) {
return math.pow(x, exponent);
@ -10,4 +13,8 @@ class Math {
static num min(num a, num b) => math.min(a, b);
static num floor(num a) => a.floor();
static num ceil(num a) => a.ceil();
static num sqrt(num x) => math.sqrt(x);
}

View File

@ -1,3 +1,4 @@
import {global} from 'angular2/src/facade/lang';
export var Math = global.Math;
export var Math = global.Math;
export var NaN = global.NaN;

View File

@ -26,6 +26,7 @@ class Expect extends gns.Expect {
void toThrowError([message=""]) => this.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));
Function get _expect => gns.guinness.matchers.expect;
}