-
-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathvoid.spec.ts
More file actions
34 lines (28 loc) · 873 Bytes
/
void.spec.ts
File metadata and controls
34 lines (28 loc) · 873 Bytes
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
import * as util from "../util";
test.each(["0", "1", '"a"'])("void evaluates to undefined (%p)", value => {
util.testExpression`void (${value})`.expectToMatchJsResult();
});
test("void applies to function declarations", () => {
util.testFunction`
let result = 0;
void function setResult() {
result = 1;
}();
return result;
`.expectToMatchJsResult();
});
test("void used to ignore function return values", () => {
util.testFunction`
let result = 0;
function setResult() {
result = 1;
return 3
};
void(setResult());
return result;
`.expectToMatchJsResult();
});
// https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1102
test("void works with lambdas", () => {
util.testExpression`void (() => {})()`.expectToMatchJsResult();
});