Skip to content

Commit

Permalink
fix ignore range
Browse files Browse the repository at this point in the history
  • Loading branch information
cenfun committed Jan 28, 2024
1 parent c6d6b41 commit f10a284
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions lib/converter/ignore.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const addNextIgnore = (list, content, item, locator) => {
const nextItem = {
type: 'next',
n,
startOffset: item.end,
startOffset: item.start,
endOffset
};

Expand Down Expand Up @@ -93,7 +93,7 @@ const getIgnoredRanges = (locator, options) => {
if (ignoreStart) {
// v8 ignore stop
if (content === 'stop') {
ignoreStart.endOffset = start;
ignoreStart.endOffset = end;
ignoreStart = null;
}
return;
Expand All @@ -104,8 +104,8 @@ const getIgnoredRanges = (locator, options) => {
// add first for sort by start
ignoreStart = {
type: 'start',
startOffset: end,
endOffset: end
startOffset: start,
endOffset: start
};
list.push(ignoreStart);
return;
Expand Down
6 changes: 3 additions & 3 deletions test/mock/src/ignore/v8-ignore-next.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
const a = 99
const b = true ? 1 /* v8 ignore next */ : 2
if (true) {
if (a + b) {
console.info('covered')
/* v8 ignore next 3 */
} else {
console.info('uncovered')
}

/* v8 ignore next */
if (false) console.info('uncovered')
if (a < b) console.info('uncovered')

/* v8 ignore next 3 */
function notExecuted () {

}

if (true) {
if (a + b) {
console.info('covered')
} else { /* c8 ignore next */
console.info('uncovered')
Expand Down
2 changes: 1 addition & 1 deletion test/mock/src/ignore/v8-ignore-return.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function fn() {
return true;
/* v8 ignore next */
/* v8 ignore next */
console.log('never runs');
}

Expand Down
4 changes: 2 additions & 2 deletions test/mock/src/ignore/v8-ignore-start-stop.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const a = 99
const b = true ? 1 : 2
if (true) {
if (a + b) {
console.info('covered')
/* v8 ignore start */
} else {
Expand All @@ -14,7 +14,7 @@ function notExecuted () {
}
/* v8 ignore stop */

if (true) {
if (a + b) {
console.info('covered')
} else { /* v8 ignore start */
console.info('uncovered')
Expand Down

0 comments on commit f10a284

Please sign in to comment.