Merge branch 'ksvitkovsky-github-1180'
- Closes #1404 from @ksvitkovsky - Fixes #1180
This commit is contained in:
@@ -191,6 +191,18 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|||||||
return j$.isA_('AsyncFunction', value);
|
return j$.isA_('AsyncFunction', value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
j$.isTypedArray_ = function(value) {
|
||||||
|
return j$.isA_('Float32Array', value) ||
|
||||||
|
j$.isA_('Float64Array', value) ||
|
||||||
|
j$.isA_('Int16Array', value) ||
|
||||||
|
j$.isA_('Int32Array', value) ||
|
||||||
|
j$.isA_('Int8Array', value) ||
|
||||||
|
j$.isA_('Uint16Array', value) ||
|
||||||
|
j$.isA_('Uint32Array', value) ||
|
||||||
|
j$.isA_('Uint8Array', value) ||
|
||||||
|
j$.isA_('Uint8ClampedArray', value);
|
||||||
|
};
|
||||||
|
|
||||||
j$.isA_ = function(typeName, value) {
|
j$.isA_ = function(typeName, value) {
|
||||||
return j$.getType_(value) === '[object ' + typeName + ']';
|
return j$.getType_(value) === '[object ' + typeName + ']';
|
||||||
};
|
};
|
||||||
@@ -208,7 +220,9 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|||||||
return func.name;
|
return func.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
var matches = func.toString().match(/^\s*function\s*(\w*)\s*\(/);
|
var matches = func.toString().match(/^\s*function\s*(\w*)\s*\(/) ||
|
||||||
|
func.toString().match(/^\s*\[object\s*(\w*)Constructor\]/);
|
||||||
|
|
||||||
return matches ? matches[1] : '<anonymous>';
|
return matches ? matches[1] : '<anonymous>';
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -3761,6 +3775,8 @@ getJasmineRequireObj().pp = function(j$) {
|
|||||||
this.emitSet(value);
|
this.emitSet(value);
|
||||||
} else if (j$.getType_(value) == '[object Map]') {
|
} else if (j$.getType_(value) == '[object Map]') {
|
||||||
this.emitMap(value);
|
this.emitMap(value);
|
||||||
|
} else if (j$.isTypedArray_(value)) {
|
||||||
|
this.emitTypedArray(value);
|
||||||
} else if (value.toString && typeof value === 'object' && !j$.isArray_(value) && hasCustomToString(value)) {
|
} else if (value.toString && typeof value === 'object' && !j$.isArray_(value) && hasCustomToString(value)) {
|
||||||
this.emitScalar(value.toString());
|
this.emitScalar(value.toString());
|
||||||
} else if (j$.util.arrayContains(this.seen, value)) {
|
} else if (j$.util.arrayContains(this.seen, value)) {
|
||||||
@@ -3931,6 +3947,18 @@ getJasmineRequireObj().pp = function(j$) {
|
|||||||
this.append(' })');
|
this.append(' })');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
StringPrettyPrinter.prototype.emitTypedArray = function(arr) {
|
||||||
|
var constructorName = j$.fnNameFor(arr.constructor),
|
||||||
|
limitedArray = Array.prototype.slice.call(arr, 0, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH),
|
||||||
|
itemsString = Array.prototype.join.call(limitedArray, ', ');
|
||||||
|
|
||||||
|
if (limitedArray.length !== arr.length) {
|
||||||
|
itemsString += ', ...';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.append(constructorName + ' [ ' + itemsString + ' ]');
|
||||||
|
};
|
||||||
|
|
||||||
StringPrettyPrinter.prototype.formatProperty = function(obj, property, isGetter) {
|
StringPrettyPrinter.prototype.formatProperty = function(obj, property, isGetter) {
|
||||||
this.append(property);
|
this.append(property);
|
||||||
this.append(': ');
|
this.append(': ');
|
||||||
|
|||||||
@@ -211,6 +211,16 @@ describe("toEqual", function() {
|
|||||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("reports mismatches between arrays of different types", function() {
|
||||||
|
jasmine.getEnv().requireFunctioningTypedArrays();
|
||||||
|
|
||||||
|
var actual = new Uint32Array([1, 2, 3]),
|
||||||
|
expected = new Uint16Array([1, 2, 3]),
|
||||||
|
message = "Expected Uint32Array [ 1, 2, 3 ] to equal Uint16Array [ 1, 2, 3 ].";
|
||||||
|
|
||||||
|
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||||
|
});
|
||||||
|
|
||||||
it("reports mismatches involving NaN", function() {
|
it("reports mismatches involving NaN", function() {
|
||||||
var actual = {x: 0},
|
var actual = {x: 0},
|
||||||
expected = {x: 0/0},
|
expected = {x: 0/0},
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
(function(env) {
|
||||||
|
function hasFunctioningTypedArrays() {
|
||||||
|
if (typeof Uint32Array === 'undefined') { return false; }
|
||||||
|
|
||||||
|
try {
|
||||||
|
var a = new Uint32Array([1, 2, 3]);
|
||||||
|
if (a.length !== 3) { return false; }
|
||||||
|
return true;
|
||||||
|
} catch(e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
env.requireFunctioningTypedArrays = function() {
|
||||||
|
if (!hasFunctioningTypedArrays()) {
|
||||||
|
env.pending("Browser has incomplete or missing support for typed arrays");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
})(jasmine.getEnv());
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
"helpers/asyncAwait.js",
|
"helpers/asyncAwait.js",
|
||||||
"helpers/checkForSet.js",
|
"helpers/checkForSet.js",
|
||||||
"helpers/checkForMap.js",
|
"helpers/checkForMap.js",
|
||||||
|
"helpers/checkForTypedArrays.js",
|
||||||
"helpers/nodeDefineJasmineUnderTest.js"
|
"helpers/nodeDefineJasmineUnderTest.js"
|
||||||
],
|
],
|
||||||
"random": true
|
"random": true
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ helpers:
|
|||||||
- 'helpers/BrowserFlags.js'
|
- 'helpers/BrowserFlags.js'
|
||||||
- 'helpers/checkForSet.js'
|
- 'helpers/checkForSet.js'
|
||||||
- 'helpers/checkForMap.js'
|
- 'helpers/checkForMap.js'
|
||||||
|
- 'helpers/checkForTypedArrays.js'
|
||||||
- 'helpers/defineJasmineUnderTest.js'
|
- 'helpers/defineJasmineUnderTest.js'
|
||||||
spec_files:
|
spec_files:
|
||||||
- '**/*[Ss]pec.js'
|
- '**/*[Ss]pec.js'
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ getJasmineRequireObj().pp = function(j$) {
|
|||||||
this.emitSet(value);
|
this.emitSet(value);
|
||||||
} else if (j$.getType_(value) == '[object Map]') {
|
} else if (j$.getType_(value) == '[object Map]') {
|
||||||
this.emitMap(value);
|
this.emitMap(value);
|
||||||
|
} else if (j$.isTypedArray_(value)) {
|
||||||
|
this.emitTypedArray(value);
|
||||||
} else if (value.toString && typeof value === 'object' && !j$.isArray_(value) && hasCustomToString(value)) {
|
} else if (value.toString && typeof value === 'object' && !j$.isArray_(value) && hasCustomToString(value)) {
|
||||||
this.emitScalar(value.toString());
|
this.emitScalar(value.toString());
|
||||||
} else if (j$.util.arrayContains(this.seen, value)) {
|
} else if (j$.util.arrayContains(this.seen, value)) {
|
||||||
@@ -210,6 +212,18 @@ getJasmineRequireObj().pp = function(j$) {
|
|||||||
this.append(' })');
|
this.append(' })');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
StringPrettyPrinter.prototype.emitTypedArray = function(arr) {
|
||||||
|
var constructorName = j$.fnNameFor(arr.constructor),
|
||||||
|
limitedArray = Array.prototype.slice.call(arr, 0, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH),
|
||||||
|
itemsString = Array.prototype.join.call(limitedArray, ', ');
|
||||||
|
|
||||||
|
if (limitedArray.length !== arr.length) {
|
||||||
|
itemsString += ', ...';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.append(constructorName + ' [ ' + itemsString + ' ]');
|
||||||
|
};
|
||||||
|
|
||||||
StringPrettyPrinter.prototype.formatProperty = function(obj, property, isGetter) {
|
StringPrettyPrinter.prototype.formatProperty = function(obj, property, isGetter) {
|
||||||
this.append(property);
|
this.append(property);
|
||||||
this.append(': ');
|
this.append(': ');
|
||||||
|
|||||||
+15
-1
@@ -63,6 +63,18 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|||||||
return j$.isA_('AsyncFunction', value);
|
return j$.isA_('AsyncFunction', value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
j$.isTypedArray_ = function(value) {
|
||||||
|
return j$.isA_('Float32Array', value) ||
|
||||||
|
j$.isA_('Float64Array', value) ||
|
||||||
|
j$.isA_('Int16Array', value) ||
|
||||||
|
j$.isA_('Int32Array', value) ||
|
||||||
|
j$.isA_('Int8Array', value) ||
|
||||||
|
j$.isA_('Uint16Array', value) ||
|
||||||
|
j$.isA_('Uint32Array', value) ||
|
||||||
|
j$.isA_('Uint8Array', value) ||
|
||||||
|
j$.isA_('Uint8ClampedArray', value);
|
||||||
|
};
|
||||||
|
|
||||||
j$.isA_ = function(typeName, value) {
|
j$.isA_ = function(typeName, value) {
|
||||||
return j$.getType_(value) === '[object ' + typeName + ']';
|
return j$.getType_(value) === '[object ' + typeName + ']';
|
||||||
};
|
};
|
||||||
@@ -80,7 +92,9 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|||||||
return func.name;
|
return func.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
var matches = func.toString().match(/^\s*function\s*(\w*)\s*\(/);
|
var matches = func.toString().match(/^\s*function\s*(\w*)\s*\(/) ||
|
||||||
|
func.toString().match(/^\s*\[object\s*(\w*)Constructor\]/);
|
||||||
|
|
||||||
return matches ? matches[1] : '<anonymous>';
|
return matches ? matches[1] : '<anonymous>';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user