Skip to content
Open
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
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"jest": "^29.5.0",
"jest-circus": "^29.7.0",
"lua-types": "^2.13.0",
"lua-wasm-bindings": "^0.3.1",
"lua-wasm-bindings": "^0.5.3",
"prettier": "^2.8.8",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
Expand Down
1 change: 1 addition & 0 deletions src/CompilerOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export enum LuaTarget {
Lua52 = "5.2",
Lua53 = "5.3",
Lua54 = "5.4",
Lua55 = "5.5",
LuaJIT = "JIT",
Luau = "Luau",
}
Expand Down
1 change: 1 addition & 0 deletions src/transformation/visitors/break-continue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const transformContinueStatement: FunctionVisitor<ts.ContinueStatement> =
[LuaTarget.Lua52]: LoopContinued.WithGoto,
[LuaTarget.Lua53]: LoopContinued.WithGoto,
[LuaTarget.Lua54]: LoopContinued.WithGoto,
[LuaTarget.Lua55]: LoopContinued.WithGoto,
[LuaTarget.LuaJIT]: LoopContinued.WithGoto,
[LuaTarget.Luau]: LoopContinued.WithContinue,
}[context.luaTarget];
Expand Down
1 change: 1 addition & 0 deletions test/cli/parse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ describe("tsconfig", () => {
["luaTarget", "5.2", { luaTarget: tstl.LuaTarget.Lua52 }],
["luaTarget", "5.3", { luaTarget: tstl.LuaTarget.Lua53 }],
["luaTarget", "5.4", { luaTarget: tstl.LuaTarget.Lua54 }],
["luaTarget", "5.5", { luaTarget: tstl.LuaTarget.Lua55 }],
["luaTarget", "jit", { luaTarget: tstl.LuaTarget.LuaJIT }],
["luaTarget", "luau", { luaTarget: tstl.LuaTarget.Luau }],

Expand Down
71 changes: 71 additions & 0 deletions test/unit/__snapshots__/expressions.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,77 @@ ____exports.__result = a | b
return ____exports"
`;

exports[`Bitop [5.5] ("~a") 1`] = `
"local ____exports = {}
____exports.__result = ~a
return ____exports"
`;

exports[`Bitop [5.5] ("a&=b") 1`] = `
"local ____exports = {}
a = a & b
____exports.__result = a
return ____exports"
`;

exports[`Bitop [5.5] ("a&b") 1`] = `
"local ____exports = {}
____exports.__result = a & b
return ____exports"
`;

exports[`Bitop [5.5] ("a<<=b") 1`] = `
"local ____exports = {}
a = a << b
____exports.__result = a
return ____exports"
`;

exports[`Bitop [5.5] ("a<<b") 1`] = `
"local ____exports = {}
____exports.__result = a << b
return ____exports"
`;

exports[`Bitop [5.5] ("a>>>=b") 1`] = `
"local ____exports = {}
a = a >> b
____exports.__result = a
return ____exports"
`;

exports[`Bitop [5.5] ("a>>>b") 1`] = `
"local ____exports = {}
____exports.__result = a >> b
return ____exports"
`;

exports[`Bitop [5.5] ("a^=b") 1`] = `
"local ____exports = {}
a = a ~ b
____exports.__result = a
return ____exports"
`;

exports[`Bitop [5.5] ("a^b") 1`] = `
"local ____exports = {}
____exports.__result = a ~ b
return ____exports"
`;

exports[`Bitop [5.5] ("a|=b") 1`] = `
"local ____exports = {}
a = a | b
____exports.__result = a
return ____exports"
`;

exports[`Bitop [5.5] ("a|b") 1`] = `
"local ____exports = {}
____exports.__result = a | b
return ____exports"
`;

exports[`Bitop [JIT] ("~a") 1`] = `
"local ____exports = {}
____exports.__result = bit.bnot(a)
Expand Down
1 change: 1 addition & 0 deletions test/unit/builtins/math.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ util.testEachVersion("Math.atan2", () => util.testExpression`Math.atan2(4, 5)`,
[tstl.LuaTarget.Lua52]: builder => builder.tap(expectMathAtan2),
[tstl.LuaTarget.Lua53]: builder => builder.tap(expectMathAtan),
[tstl.LuaTarget.Lua54]: builder => builder.tap(expectMathAtan2),
[tstl.LuaTarget.Lua55]: builder => builder.tap(expectMathAtan2),
[tstl.LuaTarget.Luau]: builder => builder.tap(expectMathAtan2),
});

Expand Down
7 changes: 7 additions & 0 deletions test/unit/expressions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ test.each(supportedInAll)("Bitop [5.4] (%p)", input => {
.expectLuaToMatchSnapshot();
});

test.each(supportedInAll)("Bitop [5.5] (%p)", input => {
util.testExpression(input)
.setOptions({ luaTarget: tstl.LuaTarget.Lua55, luaLibImport: tstl.LuaLibImportKind.None })
.disableSemanticCheck()
.expectLuaToMatchSnapshot();
});

test.each(unsupportedIn53And54)("Unsupported bitop 5.3 (%p)", input => {
util.testExpression(input)
.setOptions({ luaTarget: tstl.LuaTarget.Lua53, luaLibImport: tstl.LuaLibImportKind.None })
Expand Down
1 change: 1 addition & 0 deletions test/unit/loops.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ for (const testCase of [
[tstl.LuaTarget.Lua52]: expectContinueGotoLabel,
[tstl.LuaTarget.Lua53]: expectContinueGotoLabel,
[tstl.LuaTarget.Lua54]: expectContinueGotoLabel,
[tstl.LuaTarget.Lua55]: expectContinueGotoLabel,
[tstl.LuaTarget.LuaJIT]: expectContinueGotoLabel,
[tstl.LuaTarget.Luau]: () => expectContinueStatement,
});
Expand Down
2 changes: 2 additions & 0 deletions test/unit/spread.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ describe("in function call", () => {
[tstl.LuaTarget.Lua52]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(),
[tstl.LuaTarget.Lua53]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(),
[tstl.LuaTarget.Lua54]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(),
[tstl.LuaTarget.Lua55]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(),
[tstl.LuaTarget.Luau]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(),
}
);
Expand All @@ -95,6 +96,7 @@ describe("in array literal", () => {
[tstl.LuaTarget.Lua52]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(),
[tstl.LuaTarget.Lua53]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(),
[tstl.LuaTarget.Lua54]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(),
[tstl.LuaTarget.Lua55]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(),
[tstl.LuaTarget.Luau]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(),
});

Expand Down
5 changes: 3 additions & 2 deletions test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export function expectEachVersionExceptJit<T>(
[tstl.LuaTarget.Lua52]: expectation,
[tstl.LuaTarget.Lua53]: expectation,
[tstl.LuaTarget.Lua54]: expectation,
[tstl.LuaTarget.Lua55]: expectation,
[tstl.LuaTarget.LuaJIT]: false, // Exclude JIT
[tstl.LuaTarget.Luau]: false,
};
Expand Down Expand Up @@ -157,7 +158,7 @@ export abstract class TestBuilder {
}

protected options: tstl.CompilerOptions = {
luaTarget: tstl.LuaTarget.Lua54,
luaTarget: tstl.LuaTarget.Lua55,
noHeader: true,
skipLibCheck: true,
target: ts.ScriptTarget.ES2017,
Expand Down Expand Up @@ -444,7 +445,7 @@ export abstract class TestBuilder {
// Main file
const mainFile = this.getMainLuaCodeChunk();

const luaTarget = this.options.luaTarget ?? tstl.LuaTarget.Lua54;
const luaTarget = this.options.luaTarget ?? tstl.LuaTarget.Lua55;
const { lauxlib, lua, lualib } = getLuaBindingsForVersion(luaTarget);

const L = lauxlib.luaL_newstate();
Expand Down
2 changes: 1 addition & 1 deletion tsconfig-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"description": "Specifies the Lua version you want to generate code for.",
"type": "string",
"default": "universal",
"enum": ["5.0", "universal", "5.1", "5.2", "5.3", "5.4", "JIT", "Luau"]
"enum": ["5.0", "universal", "5.1", "5.2", "5.3", "5.4", "5.5", "JIT", "Luau"]
},
"noImplicitGlobalVariables": {
"description": "Always declare all root-level variables as local, even if the file is not a module and they would be global in TypeScript.",
Expand Down
Loading