Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.

Commit b4d5ee2

Browse files
author
Jan Krems
committed
fix: Work around inconsistent handling of strict directive
1 parent 2b93173 commit b4d5ee2

File tree

10 files changed

+34
-11
lines changed

10 files changed

+34
-11
lines changed

examples/alive.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
let x = 0;
32
function heartbeat() {
43
++x;

examples/backtrace.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
const { exports: moduleScoped } = module;
32

43
function topFn(a, b = false) {

examples/cjs/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
const { add } = require('./other');
32

43
const sum = add(40, 2);

examples/cjs/other.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
exports.add = function add(a, b) {
32
return a + b;
43
};

examples/exceptions.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
let error = null;
32
try {
43
throw new Error('Caught');

examples/three-lines.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
let x = 1;
32
x = x + 1;
43
module.exports = x;

examples/use-strict.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
'use strict';
2+
console.log('first real line');

test/cli/backtrace.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ test('display and navigate backtrace', (t) => {
1919
.then(() => cli.stepCommand('c'))
2020
.then(() => cli.command('bt'))
2121
.then(() => {
22-
t.match(cli.output, `#0 topFn ${script}:8:2`);
22+
t.match(cli.output, `#0 topFn ${script}:7:2`);
2323
})
2424
.then(() => cli.command('backtrace'))
2525
.then(() => {
26-
t.match(cli.output, `#0 topFn ${script}:8:2`);
26+
t.match(cli.output, `#0 topFn ${script}:7:2`);
2727
})
2828
.then(() => cli.quit())
2929
.then(null, onFatal);

test/cli/exceptions.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ test('break on (uncaught) exceptions', (t) => {
3131
.then(() => cli.command('breakOnException'))
3232
.then(() => cli.stepCommand('c'))
3333
.then(() => {
34-
t.match(cli.output, `exception in ${script}:4`);
34+
t.match(cli.output, `exception in ${script}:3`);
3535
})
3636
.then(() => cli.stepCommand('c'))
3737
.then(() => {
38-
t.match(cli.output, `exception in ${script}:10`);
38+
t.match(cli.output, `exception in ${script}:9`);
3939
})
4040

4141
// Next run: With `breakOnUncaught` it only pauses on the 2nd exception
@@ -46,7 +46,7 @@ test('break on (uncaught) exceptions', (t) => {
4646
})
4747
.then(() => cli.stepCommand('c'))
4848
.then(() => {
49-
t.match(cli.output, `exception in ${script}:10`);
49+
t.match(cli.output, `exception in ${script}:9`);
5050
})
5151

5252
// Next run: Back to the initial state! It should die again.

test/cli/use-strict.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
const Path = require('path');
3+
4+
const { test } = require('tap');
5+
6+
const startCLI = require('./start-cli');
7+
8+
test('for whiles that starts with strict directive', (t) => {
9+
const script = Path.join('examples', 'use-strict.js');
10+
const cli = startCLI([script]);
11+
12+
function onFatal(error) {
13+
cli.quit();
14+
throw error;
15+
}
16+
17+
return cli.waitFor(/break/)
18+
.then(() => cli.waitForPrompt())
19+
.then(() => {
20+
t.match(
21+
cli.output,
22+
/break in [^:]+:(?:1|2)[^\d]/,
23+
'pauses either on strict directive or first "real" line');
24+
})
25+
.then(() => cli.quit())
26+
.then(null, onFatal);
27+
});

0 commit comments

Comments
 (0)