Skip to content

Commit f6e0d69

Browse files
committed
fix(power-assert-formatter): fix location detection of infix operator
failed when operator is not a Punctuator fixes power-assert-js/power-assert#27
1 parent aca547d commit f6e0d69

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Diff for: lib/location.js

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ function findOperatorTokenOf(expression, tokens) {
6262
return searchToken(tokens, fromLine, toLine, function (token, index) {
6363
if (fromColumn < token.loc.start.column &&
6464
token.loc.end.column < toColumn &&
65-
token.type === 'Punctuator' && // esprima
6665
token.value === expression.operator) {
6766
return token;
6867
}

Diff for: test/power_assert_formatter_test.js

+20
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,26 @@ suite('power-assert-formatter', function () {
339339
});
340340

341341

342+
(function () {
343+
test.only('assert(foo instanceof Foo);', function () {
344+
var Foo = function () {
345+
};
346+
var foo = 'hoge';
347+
assertPowerAssertContextFormatting(function () {
348+
eval(weave('assert(foo instanceof Foo);'));
349+
}, [
350+
' # test/some_test.js:1',
351+
' ',
352+
' assert(foo instanceof Foo)',
353+
' | | | ',
354+
' | false #function#',
355+
' "hoge" ',
356+
' '
357+
]);
358+
});
359+
})();
360+
361+
342362
test('MemberExpression: assert(ary1.length === ary2.length);', function () {
343363
var ary1 = ['foo', 'bar'];
344364
var ary2 = ['aaa', 'bbb', 'ccc'];

0 commit comments

Comments
 (0)