feat(test_lib): implement SpyObject

This commit is contained in:
vsavkin
2014-11-25 15:16:53 -08:00
parent 965f70bfbe
commit f06433fb58
7 changed files with 107 additions and 22 deletions
+12 -1
View File
@@ -13,6 +13,9 @@ function argPositionName(i) {
var primitives = $traceurRuntime.type;
export function proxy(){
}
function assertArgumentTypes(...params) {
var actual, type;
var currentArgErrors;
@@ -78,11 +81,14 @@ function prettyPrint(value) {
}
function isType(value, T, errors) {
if (T === primitives.void) {
return typeof value === 'undefined';
}
if (_isProxy(value)) {
return true;
}
if (T === primitives.any || value === null) {
return true;
}
@@ -143,6 +149,11 @@ function isType(value, T, errors) {
// return res;
}
function _isProxy(obj) {
if (!obj || !obj.constructor || !obj.constructor.annotations) return false;
return obj.constructor.annotations.filter((a) => a instanceof proxy).length > 0;
}
function formatErrors(errors, indent = ' ') {
return errors.map((e) => {
if (typeof e === 'string') return indent + '- ' + e;