diff --git a/lib/converter/ignore.js b/lib/converter/ignore.js index da319e90..eb01594d 100644 --- a/lib/converter/ignore.js +++ b/lib/converter/ignore.js @@ -42,7 +42,7 @@ const addNextIgnore = (list, content, item, locator) => { const nextItem = { type: 'next', n, - startOffset: item.end, + startOffset: item.start, endOffset }; @@ -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; @@ -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; diff --git a/test/mock/src/ignore/v8-ignore-next.js b/test/mock/src/ignore/v8-ignore-next.js index ece622cc..e839303d 100644 --- a/test/mock/src/ignore/v8-ignore-next.js +++ b/test/mock/src/ignore/v8-ignore-next.js @@ -1,6 +1,6 @@ const a = 99 const b = true ? 1 /* v8 ignore next */ : 2 -if (true) { +if (a + b) { console.info('covered') /* v8 ignore next 3 */ } else { @@ -8,14 +8,14 @@ if (true) { } /* 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') diff --git a/test/mock/src/ignore/v8-ignore-return.js b/test/mock/src/ignore/v8-ignore-return.js index cd0241cd..c03a1238 100644 --- a/test/mock/src/ignore/v8-ignore-return.js +++ b/test/mock/src/ignore/v8-ignore-return.js @@ -1,6 +1,6 @@ function fn() { return true; - /* v8 ignore next */ + /* v8 ignore next */ console.log('never runs'); } diff --git a/test/mock/src/ignore/v8-ignore-start-stop.js b/test/mock/src/ignore/v8-ignore-start-stop.js index dc078905..e57a131a 100644 --- a/test/mock/src/ignore/v8-ignore-start-stop.js +++ b/test/mock/src/ignore/v8-ignore-start-stop.js @@ -1,6 +1,6 @@ const a = 99 const b = true ? 1 : 2 -if (true) { +if (a + b) { console.info('covered') /* v8 ignore start */ } else { @@ -14,7 +14,7 @@ function notExecuted () { } /* v8 ignore stop */ -if (true) { +if (a + b) { console.info('covered') } else { /* v8 ignore start */ console.info('uncovered')