Skip to content

Commit ce2ca36

Browse files
committed
fix Object.prototype.toString() comparison
1 parent 6034d56 commit ce2ca36

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

test/why.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,14 @@ test('functions', function (t) {
358358
var genFnStar = Function('return function* () {};')();
359359
var genFnSpaceStar = Function('return function *() {};')();
360360
var genNoSpaces = Function('return function*(){};')();
361-
st.equal(
362-
'second argument is a Generator; first is not',
363-
isEqualWhy(fnNoSpace, genNoSpaces),
364-
'generator and fn that are otherwise identical are not equal'
365-
);
361+
var reasonsMap = {
362+
'second argument is a Generator; first is not': true,
363+
'toStringTag is not the same: [object Function] !== [object GeneratorFunction]': true
364+
};
365+
var reasons = objectEntries(reasonsMap);
366+
var actual = isEqualWhy(fnNoSpace, genNoSpaces);
367+
reasonsMap[actual] = true;
368+
st.deepEqual(objectEntries(reasonsMap), reasons, 'generator and fn that are otherwise identical are not equal');
366369

367370
var generators = [genFnStar, genFnSpaceStar, genNoSpaces];
368371
forEach(generators, function (generator) {

why.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ module.exports = function whyNotEqual(value, other) {
8383
}
8484

8585
var valToStr = toStr.call(value);
86-
var otherToStr = toStr.call(value);
86+
var otherToStr = toStr.call(other);
8787
if (valToStr !== otherToStr) {
8888
return 'toStringTag is not the same: ' + valToStr + ' !== ' + otherToStr;
8989
}

0 commit comments

Comments
 (0)