The original asymmetric matcher code for Any did not work with symbols since `symbolInstance instanceof Symbol` is actually `false` (but, `symbolInstance.constructor` is `Symbol). This simply adds an extra clause that explicitly checks for symbol (if available) like the other primitive types. Also added some missing specs for other types, like Map, Set, etc. Fixes #1431.
29 lines
562 B
JavaScript
29 lines
562 B
JavaScript
(function(env) {
|
|
function hasFunctioningSymbols() {
|
|
if (typeof Symbol === 'undefined') {
|
|
return false;
|
|
}
|
|
|
|
try {
|
|
var s1 = Symbol();
|
|
var s2 = Symbol();
|
|
if (typeof s1 !== 'symbol') {
|
|
return false;
|
|
}
|
|
if (s1 === s2) {
|
|
return false;
|
|
}
|
|
return true;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
env.requireFunctioningSymbols = function() {
|
|
if (!hasFunctioningSymbols()) {
|
|
env.pending("Browser has incomplete or missing support for Symbols");
|
|
}
|
|
};
|
|
|
|
})(jasmine.getEnv());
|