2019-12-24 16:53:48 +03:00
|
|
|
#![feature(box_syntax)]
|
|
|
|
#![feature(test)]
|
|
|
|
#![feature(box_patterns)]
|
|
|
|
#![feature(specialization)]
|
|
|
|
|
2020-04-30 17:48:52 +03:00
|
|
|
use swc_common::{chain, Mark};
|
2019-12-09 15:02:51 +03:00
|
|
|
use swc_ecma_parser::Syntax;
|
2019-12-24 16:53:48 +03:00
|
|
|
use swc_ecma_transforms::{
|
|
|
|
compat::es2015::for_of::{for_of, Config},
|
|
|
|
modules::{amd::amd, common_js::common_js},
|
|
|
|
};
|
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
mod common;
|
2019-12-09 15:02:51 +03:00
|
|
|
|
|
|
|
fn syntax() -> Syntax {
|
|
|
|
Default::default()
|
|
|
|
}
|
2018-12-21 15:39:42 +03:00
|
|
|
|
2019-02-05 06:50:19 +03:00
|
|
|
test!(
|
2019-12-09 15:02:51 +03:00
|
|
|
syntax(),
|
|
|
|
|_| for_of(Default::default()),
|
2018-12-21 15:39:42 +03:00
|
|
|
spec_identifier,
|
|
|
|
r#"for (i of arr) {
|
|
|
|
}"#,
|
|
|
|
r#"var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
|
|
|
|
|
|
try {
|
2019-02-05 06:50:19 +03:00
|
|
|
for (var _iterator = arr[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step =
|
|
|
|
_iterator.next()).done); _iteratorNormalCompletion = true) {
|
2018-12-21 15:39:42 +03:00
|
|
|
i = _step.value;
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
_didIteratorError = true;
|
|
|
|
_iteratorError = err;
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
|
|
_iterator.return();
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
if (_didIteratorError) {
|
|
|
|
throw _iteratorError;
|
|
|
|
}
|
|
|
|
}
|
2019-02-05 06:50:19 +03:00
|
|
|
}"#,
|
|
|
|
ok_if_code_eq
|
2018-12-21 15:39:42 +03:00
|
|
|
);
|
|
|
|
|
2019-02-05 06:50:19 +03:00
|
|
|
test!(
|
2019-12-09 15:02:51 +03:00
|
|
|
syntax(),
|
|
|
|
|_| for_of(Default::default()),
|
2019-02-05 06:50:19 +03:00
|
|
|
spec_ignore_cases,
|
|
|
|
r#"for (var i of foo) {
|
2018-12-21 15:39:42 +03:00
|
|
|
switch (i) {
|
|
|
|
case 1:
|
|
|
|
break;
|
|
|
|
}
|
2019-02-05 06:50:19 +03:00
|
|
|
}"#,
|
|
|
|
r#"var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
2018-12-21 15:39:42 +03:00
|
|
|
|
|
|
|
try {
|
2019-02-05 06:50:19 +03:00
|
|
|
for (var _iterator = foo[Symbol.iterator](), _step; !(_iteratorNormalCompletion =
|
|
|
|
(_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
2018-12-21 15:39:42 +03:00
|
|
|
var i = _step.value;
|
|
|
|
|
|
|
|
switch (i) {
|
|
|
|
case 1:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
_didIteratorError = true;
|
|
|
|
_iteratorError = err;
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
|
|
_iterator.return();
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
if (_didIteratorError) {
|
|
|
|
throw _iteratorError;
|
|
|
|
}
|
|
|
|
}
|
2019-02-05 06:50:19 +03:00
|
|
|
}"#,
|
|
|
|
ok_if_code_eq
|
|
|
|
);
|
2018-12-21 15:39:42 +03:00
|
|
|
|
2019-02-05 06:50:19 +03:00
|
|
|
test!(
|
2019-12-09 15:02:51 +03:00
|
|
|
syntax(),
|
|
|
|
|_| for_of(Default::default()),
|
2019-02-05 06:50:19 +03:00
|
|
|
spec_let,
|
|
|
|
r#"for (let i of arr) {
|
2018-12-21 15:39:42 +03:00
|
|
|
|
2019-02-05 06:50:19 +03:00
|
|
|
}"#,
|
|
|
|
r#"
|
2018-12-21 15:39:42 +03:00
|
|
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
|
|
|
|
|
|
try {
|
2019-02-05 06:50:19 +03:00
|
|
|
for (var _iterator = arr[Symbol.iterator](), _step; !(_iteratorNormalCompletion =
|
|
|
|
(_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
2018-12-21 15:39:42 +03:00
|
|
|
let i = _step.value;
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
_didIteratorError = true;
|
|
|
|
_iteratorError = err;
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
|
|
_iterator.return();
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
if (_didIteratorError) {
|
|
|
|
throw _iteratorError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}"#,
|
2019-02-05 06:50:19 +03:00
|
|
|
ok_if_code_eq
|
|
|
|
);
|
2018-12-21 15:39:42 +03:00
|
|
|
|
2019-02-05 06:50:19 +03:00
|
|
|
test!(
|
2019-12-09 15:02:51 +03:00
|
|
|
syntax(),
|
|
|
|
|_| for_of(Default::default()),
|
2019-02-05 06:50:19 +03:00
|
|
|
spec_member_expr,
|
|
|
|
r#"for (obj.prop of arr) {
|
2018-12-21 15:39:42 +03:00
|
|
|
|
2019-02-05 06:50:19 +03:00
|
|
|
}"#,
|
|
|
|
r#"var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
2018-12-21 15:39:42 +03:00
|
|
|
|
|
|
|
try {
|
2019-02-05 06:50:19 +03:00
|
|
|
for (var _iterator = arr[Symbol.iterator](), _step; !(_iteratorNormalCompletion =
|
|
|
|
(_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
2018-12-21 15:39:42 +03:00
|
|
|
obj.prop = _step.value;
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
_didIteratorError = true;
|
|
|
|
_iteratorError = err;
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
|
|
_iterator.return();
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
if (_didIteratorError) {
|
|
|
|
throw _iteratorError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}"#,
|
2019-02-05 06:50:19 +03:00
|
|
|
ok_if_code_eq
|
|
|
|
);
|
2018-12-21 15:39:42 +03:00
|
|
|
|
2019-02-05 06:50:19 +03:00
|
|
|
test!(
|
2019-12-09 15:02:51 +03:00
|
|
|
syntax(),
|
|
|
|
|_| for_of(Default::default()),
|
2019-02-05 06:50:19 +03:00
|
|
|
spec_multiple,
|
|
|
|
r#"for (var i of arr) {
|
2018-12-21 15:39:42 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i of numbers) {
|
|
|
|
|
|
|
|
}
|
2019-02-05 06:50:19 +03:00
|
|
|
"#,
|
|
|
|
r#"var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
2018-12-21 15:39:42 +03:00
|
|
|
|
|
|
|
try {
|
2019-02-05 06:50:19 +03:00
|
|
|
for (var _iterator = arr[Symbol.iterator](), _step; !(_iteratorNormalCompletion =
|
|
|
|
(_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
2018-12-21 15:39:42 +03:00
|
|
|
var i = _step.value;
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
_didIteratorError = true;
|
|
|
|
_iteratorError = err;
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
|
|
_iterator.return();
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
if (_didIteratorError) {
|
|
|
|
throw _iteratorError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
|
|
|
|
|
|
try {
|
2019-02-05 06:50:19 +03:00
|
|
|
for (var _iterator1 = numbers[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 =
|
|
|
|
(_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
2018-12-21 15:39:42 +03:00
|
|
|
var i = _step1.value;
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
_didIteratorError1 = true;
|
|
|
|
_iteratorError1 = err;
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
|
|
_iterator1.return();
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
if (_didIteratorError1) {
|
|
|
|
throw _iteratorError1;
|
|
|
|
}
|
|
|
|
}
|
2019-02-05 06:50:19 +03:00
|
|
|
}"#,
|
|
|
|
ok_if_code_eq
|
|
|
|
);
|
2018-12-21 15:39:42 +03:00
|
|
|
|
2019-02-05 06:50:19 +03:00
|
|
|
test!(
|
2019-12-09 15:02:51 +03:00
|
|
|
syntax(),
|
|
|
|
|_| for_of(Default::default()),
|
2019-02-05 06:50:19 +03:00
|
|
|
spec_nested_label_for_of,
|
|
|
|
r#"b: for (let c of d()) {
|
2018-12-21 15:39:42 +03:00
|
|
|
for (let e of f()) {
|
|
|
|
continue b;
|
|
|
|
}
|
2019-02-05 06:50:19 +03:00
|
|
|
}"#,
|
|
|
|
r#"var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
2018-12-21 15:39:42 +03:00
|
|
|
|
|
|
|
try {
|
2019-02-05 06:50:19 +03:00
|
|
|
b: for (var _iterator = d()[Symbol.iterator](), _step; !(_iteratorNormalCompletion =
|
|
|
|
(_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
2018-12-21 15:39:42 +03:00
|
|
|
let c = _step.value;
|
|
|
|
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
|
|
|
|
|
|
try {
|
2019-02-05 06:50:19 +03:00
|
|
|
for (var _iterator1 = f()[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 =
|
|
|
|
(_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
2018-12-21 15:39:42 +03:00
|
|
|
let e = _step1.value;
|
|
|
|
continue b;
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
_didIteratorError1 = true;
|
|
|
|
_iteratorError1 = err;
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
|
|
_iterator1.return();
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
if (_didIteratorError1) {
|
|
|
|
throw _iteratorError1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
_didIteratorError = true;
|
|
|
|
_iteratorError = err;
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
|
|
_iterator.return();
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
if (_didIteratorError) {
|
|
|
|
throw _iteratorError;
|
|
|
|
}
|
|
|
|
}
|
2019-02-05 06:50:19 +03:00
|
|
|
}"#,
|
|
|
|
ok_if_code_eq
|
|
|
|
);
|
2018-12-21 15:39:42 +03:00
|
|
|
|
2019-02-05 06:50:19 +03:00
|
|
|
test!(
|
2019-12-09 15:02:51 +03:00
|
|
|
syntax(),
|
|
|
|
|_| for_of(Default::default()),
|
2019-02-05 06:50:19 +03:00
|
|
|
spec_var,
|
|
|
|
r#"for (var i of arr) {
|
2018-12-21 15:39:42 +03:00
|
|
|
|
2019-02-05 06:50:19 +03:00
|
|
|
}"#,
|
|
|
|
r#"var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
2018-12-21 15:39:42 +03:00
|
|
|
|
|
|
|
try {
|
2019-02-05 06:50:19 +03:00
|
|
|
for (var _iterator = arr[Symbol.iterator](), _step; !(_iteratorNormalCompletion =
|
|
|
|
(_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
2018-12-21 15:39:42 +03:00
|
|
|
var i = _step.value;
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
_didIteratorError = true;
|
|
|
|
_iteratorError = err;
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
|
|
_iterator.return();
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
if (_didIteratorError) {
|
|
|
|
throw _iteratorError;
|
|
|
|
}
|
|
|
|
}
|
2019-02-05 06:50:19 +03:00
|
|
|
}"#,
|
|
|
|
ok_if_code_eq
|
|
|
|
);
|
2019-12-09 15:02:51 +03:00
|
|
|
|
|
|
|
// for_of_as_array_for_of_import_commonjs
|
|
|
|
test!(
|
|
|
|
syntax(),
|
|
|
|
|_| chain!(
|
|
|
|
for_of(Config { assume_array: true }),
|
2020-04-30 17:48:52 +03:00
|
|
|
common_js(Mark::fresh(Mark::root()), Default::default())
|
2019-12-09 15:02:51 +03:00
|
|
|
),
|
|
|
|
for_of_as_array_for_of_import_commonjs,
|
|
|
|
r#"
|
|
|
|
import { array } from "foo";
|
|
|
|
|
|
|
|
for (const elm of array) {
|
|
|
|
console.log(elm);
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var _foo = require("foo");
|
|
|
|
|
|
|
|
for(let _i = 0; _i < _foo.array.length; _i++){
|
|
|
|
const elm = _foo.array[_i];
|
|
|
|
console.log(elm);
|
|
|
|
}
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// for_of_as_array_for_of
|
|
|
|
test!(
|
|
|
|
syntax(),
|
|
|
|
|_| for_of(Config { assume_array: true }),
|
|
|
|
for_of_as_array_for_of,
|
|
|
|
r#"
|
|
|
|
let elm;
|
|
|
|
|
|
|
|
for (elm of array) {
|
|
|
|
console.log(elm);
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
let elm;
|
|
|
|
|
|
|
|
for(let _i = 0; _i < array.length; _i++){
|
|
|
|
elm = array[_i];
|
|
|
|
console.log(elm);
|
|
|
|
}
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// for_of_as_array_for_of_import_amd
|
|
|
|
test!(
|
|
|
|
syntax(),
|
|
|
|
|_| chain!(
|
|
|
|
for_of(Config { assume_array: true }),
|
|
|
|
amd(Default::default())
|
|
|
|
),
|
|
|
|
for_of_as_array_for_of_import_amd,
|
|
|
|
r#"
|
|
|
|
import { array } from "foo";
|
|
|
|
|
|
|
|
for (const elm of array) {
|
|
|
|
console.log(elm);
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
define(["foo"], function (_foo) {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
for(let _i = 0; _i < _foo.array.length; _i++){
|
|
|
|
const elm = _foo.array[_i];
|
|
|
|
console.log(elm);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// for_of_as_array_for_of_array_pattern
|
|
|
|
test!(
|
|
|
|
syntax(),
|
|
|
|
|_| for_of(Config { assume_array: true }),
|
|
|
|
for_of_as_array_for_of_array_pattern,
|
|
|
|
r#"
|
|
|
|
let elm;
|
|
|
|
for ([elm] of array) {
|
|
|
|
console.log(elm);
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
let elm;
|
|
|
|
|
|
|
|
for(let _i = 0; _i < array.length; _i++){
|
|
|
|
[elm] = array[_i];
|
|
|
|
console.log(elm);
|
|
|
|
}
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// regression_redeclare_array_8913
|
|
|
|
test!(
|
|
|
|
syntax(),
|
|
|
|
|_| for_of(Config { assume_array: true }),
|
|
|
|
regression_redeclare_array_8913,
|
|
|
|
r#"
|
|
|
|
function f(...t) {
|
|
|
|
for (let o of t) {
|
|
|
|
const t = o;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
function f(...t) {
|
|
|
|
for(let _i = 0; _i < t.length; _i++){
|
|
|
|
let o = t[_i];
|
|
|
|
const t = o;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// for_of_as_array_for_of_declaration_array_pattern
|
|
|
|
test!(
|
|
|
|
syntax(),
|
|
|
|
|_| for_of(Config { assume_array: true }),
|
|
|
|
for_of_as_array_for_of_declaration_array_pattern,
|
|
|
|
r#"
|
|
|
|
for (const [elm] of array) {
|
|
|
|
console.log(elm);
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
for(let _i = 0; _i < array.length; _i++){
|
|
|
|
const [elm] = array[_i];
|
|
|
|
console.log(elm);
|
|
|
|
}
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// for_of_as_array_for_of_expression
|
|
|
|
test!(
|
|
|
|
syntax(),
|
|
|
|
|_| for_of(Config { assume_array: true }),
|
|
|
|
for_of_as_array_for_of_expression,
|
|
|
|
r#"
|
|
|
|
let i;
|
|
|
|
for (i of items) i;
|
|
|
|
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
let i;
|
|
|
|
|
|
|
|
for(let _i = 0; _i < items.length; _i++){
|
|
|
|
i = items[_i];
|
|
|
|
i;
|
|
|
|
}
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// for_of_as_array_for_of_declaration
|
|
|
|
test!(
|
|
|
|
syntax(),
|
|
|
|
|_| for_of(Config { assume_array: true }),
|
|
|
|
for_of_as_array_for_of_declaration,
|
|
|
|
r#"
|
|
|
|
for (const elm of array) {
|
|
|
|
console.log(elm);
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
for(let _i = 0; _i < array.length; _i++){
|
|
|
|
const elm = array[_i];
|
|
|
|
console.log(elm);
|
|
|
|
}
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// regression_scope_9696
|
|
|
|
test_exec!(
|
|
|
|
syntax(),
|
|
|
|
|_| for_of(Config {
|
|
|
|
..Default::default()
|
|
|
|
}),
|
|
|
|
regression_scope_9696_exec,
|
|
|
|
r#"
|
|
|
|
var arr = [1, 2, 3];
|
|
|
|
var results = [];
|
|
|
|
|
|
|
|
for (let v of arr) {
|
|
|
|
results.push(v);
|
|
|
|
arr = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(results).toEqual([1, 2, 3]);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// for_of_as_array_for_of_static_declaration
|
|
|
|
test!(
|
|
|
|
syntax(),
|
|
|
|
|_| for_of(Config { assume_array: true }),
|
|
|
|
for_of_as_array_for_of_static_declaration,
|
|
|
|
r#"
|
|
|
|
const array = [];
|
|
|
|
|
|
|
|
for (const elm of array) {
|
|
|
|
console.log(elm);
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
const array = [];
|
|
|
|
|
|
|
|
for(let _i = 0; _i < array.length; _i++){
|
|
|
|
const elm = array[_i];
|
|
|
|
console.log(elm);
|
|
|
|
}
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// for_of_as_array_for_of_static
|
|
|
|
test!(
|
|
|
|
syntax(),
|
|
|
|
|_| for_of(Config { assume_array: true }),
|
|
|
|
for_of_as_array_for_of_static,
|
|
|
|
r#"
|
|
|
|
const array = [];
|
|
|
|
let elm;
|
|
|
|
|
|
|
|
for (elm of array) {
|
|
|
|
console.log(elm);
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
const array = [];
|
|
|
|
let elm;
|
|
|
|
|
|
|
|
for (let _i = 0; _i < array.length; _i++) {
|
|
|
|
elm = array[_i];
|
|
|
|
console.log(elm);
|
|
|
|
}
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// for_of_as_array_for_of_import_es2015
|
|
|
|
test!(
|
|
|
|
syntax(),
|
|
|
|
|_| for_of(Config { assume_array: true }),
|
|
|
|
for_of_as_array_for_of_import_es2015,
|
|
|
|
r#"
|
|
|
|
import { array } from "foo";
|
|
|
|
|
|
|
|
for (const elm of array) {
|
|
|
|
console.log(elm);
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
import { array } from "foo";
|
|
|
|
|
|
|
|
for(let _i = 0; _i < array.length; _i++){
|
|
|
|
const elm = array[_i];
|
|
|
|
console.log(elm);
|
|
|
|
}
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// regression_label_object_with_comment_4995
|
|
|
|
test!(
|
|
|
|
syntax(),
|
|
|
|
|_| for_of(Config {
|
|
|
|
..Default::default()
|
|
|
|
}),
|
|
|
|
regression_label_object_with_comment_4995,
|
|
|
|
r#"
|
|
|
|
myLabel: //woops
|
|
|
|
for (let a of b) {
|
|
|
|
continue myLabel;
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
|
|
|
|
|
|
try {
|
|
|
|
myLabel: //woops
|
|
|
|
for (var _iterator = b[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
|
|
let a = _step.value;
|
|
|
|
continue myLabel;
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
_didIteratorError = true;
|
|
|
|
_iteratorError = err;
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
|
|
_iterator.return();
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
if (_didIteratorError) {
|
|
|
|
throw _iteratorError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// regression_if_label_3858
|
|
|
|
test!(
|
|
|
|
syntax(),
|
|
|
|
|_| for_of(Config { assume_array: true }),
|
|
|
|
regression_if_label_3858,
|
|
|
|
r#"
|
|
|
|
if ( true )
|
|
|
|
loop: for (let ch of []) {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
if (true) loop: for(let _i = 0, _iter = []; _i < _iter.length; _i++){
|
|
|
|
let ch = _iter[_i];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|