X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/targets/Transpiler.JIT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ export class LuaTranspilerJIT extends LuaTranspiler52 {
throw TSTLErrors.UnsupportedKind("bitwise operator", node.operatorToken.kind, node);
}
}

/** @override */
public transpileDestructingAssignmentValue(node: ts.Expression): string {
return `table.unpack(${this.transpileExpression(node)})`;
}
}
14 changes: 12 additions & 2 deletions test/unit/assignmentDestructuring.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class AssignmentDestructuringTests {
let [a, b] = myFunc();`;

@Test("Assignment destructuring [5.1]")
public assignmentDestructuring51() {
public assignmentDestructuring51(): void {
// Transpile
const lua = util.transpileString(
this.assignmentDestruturingTs, {luaTarget: LuaTarget.Lua51, luaLibImport: "none"}
Expand All @@ -19,12 +19,22 @@ export class AssignmentDestructuringTests {
}

@Test("Assignment destructuring [5.2]")
public tupleDestructing52() {
public tupleDestructing52(): void {
// Transpile
const lua = util.transpileString(
this.assignmentDestruturingTs, {luaTarget: LuaTarget.Lua52, luaLibImport: "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: "none"}
);
// Assert
Expect(lua).toBe(`local a,b=table.unpack(myFunc());`);
}
}
X Tutup