Fix tdz checks in transform-block-scoping plugin (#9498)

* Better tdz tests

- Use jest's expect.toThrow/expect.not.toThrow
- Add input/output tests

* Fix basic tdz (a = 2; let a)

Fixes #6848

* Make _guessExecutionStatusRelativeTo more robust

* Add tests

* Return less "unkown" execution status

* "function" execution status does not exist

* Fix recursive functions

* Update helper version

* "finally" blocks are always executed

* Typo
This commit is contained in:
Nicolò Ribaudo
2019-07-21 06:34:43 +02:00
committed by GitHub
parent 9bc9571381
commit fced5cea43
65 changed files with 507 additions and 122 deletions

View File

@@ -0,0 +1,17 @@
expect(() => {
function f() {
return function() { x };
}
let g = f();
let x;
g();
}).not.toThrow();
expect(() => {
function f() {
return function() { x };
}
let g = f();
g();
let x;
}).toThrow(ReferenceError);

View File

@@ -0,0 +1,5 @@
function f() {
return function() { x };
}
f();
let x;

View File

@@ -0,0 +1,11 @@
var x = babelHelpers.temporalUndefined;
function f() {
return function () {
babelHelpers.temporalRef(x, "x");
};
}
f();
x = void 0;
void 0;