forked from TypeScriptToLua/TypeScriptToLua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloading.spec.ts
More file actions
47 lines (41 loc) · 1.77 KB
/
Copy pathloading.spec.ts
File metadata and controls
47 lines (41 loc) · 1.77 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
41
42
43
44
45
46
47
import * as tstl from "../../../src";
import { unsupportedProperty } from "../../../src/transformation/utils/diagnostics";
import * as util from "../../util";
describe("luaLibImport", () => {
test("inline", () => {
util.testExpression`[0].push(1)`
.setOptions({ luaLibImport: tstl.LuaLibImportKind.Inline })
.tap(builder => expect(builder.getMainLuaCodeChunk()).not.toContain('require("lualib_bundle")'))
.expectToMatchJsResult();
});
test("require", () => {
util.testExpression`[0].push(1)`
.setOptions({ luaLibImport: tstl.LuaLibImportKind.Require })
.tap(builder => expect(builder.getMainLuaCodeChunk()).toContain('require("lualib_bundle")'))
.expectToMatchJsResult();
});
test("always", () => {
util.testModule``
.setOptions({ luaLibImport: tstl.LuaLibImportKind.Always })
.tap(builder => expect(builder.getMainLuaCodeChunk()).toContain('require("lualib_bundle")'))
.expectToEqual(undefined);
});
});
test.each([tstl.LuaLibImportKind.Inline, tstl.LuaLibImportKind.None, tstl.LuaLibImportKind.Require])(
"should not include lualib without code (%p)",
luaLibImport => {
util.testModule``.setOptions({ luaLibImport }).tap(builder => expect(builder.getMainLuaCodeChunk()).toBe(""));
}
);
test("lualib should not include tstl header", () => {
util.testExpression`[0].push(1)`.tap(builder =>
expect(builder.getMainLuaCodeChunk()).not.toContain("Generated with")
);
});
describe("Unknown builtin property", () => {
test("access", () => {
util.testExpression`Math.unknownProperty`
.disableSemanticCheck()
.expectDiagnosticsToMatchSnapshot([unsupportedProperty.code]);
});
});