forked from TypeScriptToLua/TypeScriptToLua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassignmentDestructuring.spec.ts
More file actions
40 lines (35 loc) · 1.39 KB
/
Copy pathassignmentDestructuring.spec.ts
File metadata and controls
40 lines (35 loc) · 1.39 KB
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
37
38
39
40
import { Expect, Test, TestCase } from "alsatian";
import { LuaTarget, LuaLibImportKind } from "../../src/CompilerOptions";
import * as util from "../src/util";
export class AssignmentDestructuringTests {
private readonly assignmentDestruturingTs = `
declare function myFunc(): [number, string];
let [a, b] = myFunc();`;
@Test("Assignment destructuring [5.1]")
public assignmentDestructuring51(): void {
// Transpile
const lua = util.transpileString(
this.assignmentDestruturingTs, {luaTarget: LuaTarget.Lua51, luaLibImport: LuaLibImportKind.None}
);
// Assert
Expect(lua).toBe(`local a, b = unpack(myFunc());`);
}
@Test("Assignment destructuring [5.2]")
public tupleDestructing52(): void {
// Transpile
const lua = util.transpileString(
this.assignmentDestruturingTs, {luaTarget: LuaTarget.Lua52, luaLibImport: LuaLibImportKind.None}
);
// Assert
Expect(lua).toBe(`local a, b = table.unpack(myFunc());`);
}
@Test("Assignment destructuring [JIT]")
public assignmentDestructuringJIT(): void {
// Transpile
const lua = util.transpileString(
this.assignmentDestruturingTs, {luaTarget: LuaTarget.LuaJIT, luaLibImport: LuaLibImportKind.None}
);
// Assert
Expect(lua).toBe(`local a, b = unpack(myFunc());`);
}
}