forked from babel/babel
/
exec.js
36 lines (31 loc) 路 1.29 KB
/
exec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
expect(function () {
var [] = null;
}).toThrow("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
expect(function () {
var [] = 42;
}).toThrow("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
expect(function () {
var [] = {};
}).toThrow("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
expect(function () {
var [] = { [Symbol.iterator]: function() {} };
}).toThrow("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
var [] = [];
var [] = [0, 1, 2];
var [] = "foo";
var [] = (function*() { throw new Error("Should not throw"); })();
var [] = { [Symbol.iterator]: function() { return {}; } }
var [] = { [Symbol.iterator]: function() { return function() {}; } }
var [] = { [Symbol.iterator]: async function*() {} }
var returnCalled = false;
var [] = {
[Symbol.iterator]: function() {
return {
return: function() {
returnCalled = true;
return {};
}
};
}
};
expect(returnCalled).toStrictEqual(true);