Skip to content

Commit e6883bf

Browse files
committed
Revert "Use inline snapshots for simple tests"
This reverts commit 9312a0c.
1 parent 9312a0c commit e6883bf

20 files changed

Lines changed: 53 additions & 112 deletions

test/unit/__snapshots__/conditionals.spec.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ function ____exports.__main(self)
99
end
1010
return ____exports"
1111
`;
12+
13+
exports[`switch not allowed in 5.1: diagnostics 1`] = `"main.ts(2,9): error TSTL: Switch statements is/are not supported for target Lua 5.1."`;

test/unit/__snapshots__/loops.spec.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ end
1010
return ____exports"
1111
`;
1212

13+
exports[`forin[Array]: diagnostics 1`] = `"main.ts(3,9): error TSTL: Iterating over arrays with 'for ... in' is not allowed."`;
14+
1315
exports[`forof object destructuring ({"initializer": "{a, b}", "vars": "let a: string, b: string;"}): code 1`] = `
1416
"local a
1517
local b

test/unit/builtins/__snapshots__/loading.spec.ts.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ ____exports.__result = Math.unknownProperty
66
return ____exports"
77
`;
88

9+
exports[`Unknown builtin property access: diagnostics 1`] = `"main.ts(1,25): error TSTL: Math.unknownProperty is unsupported."`;
10+
911
exports[`Unknown builtin property function call: code 1`] = `
1012
"local ____exports = {}
1113
____exports.__result = ({}):unknownFunction()
1214
return ____exports"
1315
`;
16+
17+
exports[`Unknown builtin property function call: diagnostics 1`] = `"main.ts(1,25): error TSTL: array.unknownFunction is unsupported."`;

test/unit/builtins/loading.spec.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,10 @@ test("lualib should not include tstl header", () => {
3939

4040
describe("Unknown builtin property", () => {
4141
test("access", () => {
42-
util.testExpression`Math.unknownProperty`
43-
.disableSemanticCheck()
44-
.expectDiagnostics(m =>
45-
m.toMatchInlineSnapshot(`"main.ts(1,25): error TSTL: Math.unknownProperty is unsupported."`)
46-
);
42+
util.testExpression`Math.unknownProperty`.disableSemanticCheck().expectDiagnosticsToMatchSnapshot();
4743
});
4844

4945
test("function call", () => {
50-
util.testExpression`[].unknownFunction()`
51-
.disableSemanticCheck()
52-
.expectDiagnostics(m =>
53-
m.toMatchInlineSnapshot(`"main.ts(1,25): error TSTL: array.unknownFunction is unsupported."`)
54-
);
46+
util.testExpression`[].unknownFunction()`.disableSemanticCheck().expectDiagnosticsToMatchSnapshot();
5547
});
5648
});

test/unit/bundle.spec.ts

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,7 @@ test("LuaLibImportKind.Inline generates a warning", () => {
9090
result.push(3);
9191
`
9292
.setOptions({ luaLibImport: LuaLibImportKind.Inline })
93-
.expectDiagnostics(
94-
m =>
95-
m.toMatchInlineSnapshot(
96-
`"warning TSTL: Using 'luaBundle' with 'luaLibImport: \\"inline\\"' might generate duplicate code. It is recommended to use 'luaLibImport: \\"require\\"'"`
97-
),
98-
true
99-
)
93+
.expectDiagnosticsToMatchSnapshot(true)
10094
.expectToEqual({ result: [1, 2, 3] });
10195
});
10296

@@ -119,22 +113,9 @@ test("cyclic imports", () => {
119113
});
120114

121115
test("no entry point", () => {
122-
util.testBundle``
123-
.setOptions({ luaBundleEntry: undefined })
124-
.expectDiagnostics(
125-
m => m.toMatchInlineSnapshot(`"error TSTL: 'luaBundleEntry' is required when 'luaBundle' is enabled."`),
126-
true
127-
);
116+
util.testBundle``.setOptions({ luaBundleEntry: undefined }).expectDiagnosticsToMatchSnapshot(true);
128117
});
129118

130119
test("luaEntry doesn't exist", () => {
131-
util.testBundle``
132-
.setEntryPoint("entry.ts")
133-
.expectDiagnostics(
134-
m =>
135-
m.toMatchInlineSnapshot(
136-
`"error TSTL: Could not find bundle entry point 'entry.ts'. It should be a file in the project."`
137-
),
138-
true
139-
);
120+
util.testBundle``.setEntryPoint("entry.ts").expectDiagnosticsToMatchSnapshot(true);
140121
});

test/unit/classes/__snapshots__/classes.spec.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ exports[`super without class: code 1`] = `
55
____exports.__result = ____.____constructor(self)
66
return ____exports"
77
`;
8+
9+
exports[`super without class: diagnostics 1`] = `"main.ts(1,25): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors."`;

test/unit/classes/__snapshots__/decorators.spec.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ function ____exports.__main(self)
1414
end
1515
return ____exports"
1616
`;
17+
18+
exports[`Throws error if decorator function has void context: diagnostics 1`] = `"main.ts(4,9): error TSTL: Decorator function cannot have 'this: void'."`;

test/unit/classes/classes.spec.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,7 @@ test("Subclass constructor across merged namespace", () => {
237237
});
238238

239239
test("super without class", () => {
240-
util.testExpression`super()`.expectDiagnostics(m =>
241-
m.toMatchInlineSnapshot(
242-
`"main.ts(1,25): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors."`
243-
)
244-
);
240+
util.testExpression`super()`.expectDiagnosticsToMatchSnapshot();
245241
});
246242

247243
test("super in unnamed class", () => {

test/unit/classes/decorators.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ test("Throws error if decorator function has void context", () => {
108108
109109
@decorator
110110
class TestClass {}
111-
`.expectDiagnostics(m =>
112-
m.toMatchInlineSnapshot(`"main.ts(4,9): error TSTL: Decorator function cannot have 'this: void'."`)
113-
);
111+
`.expectDiagnosticsToMatchSnapshot();
114112
});
115113

116114
test("Exported class decorator", () => {

test/unit/conditionals.spec.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,7 @@ test("switch not allowed in 5.1", () => {
315315
switch ("abc") {}
316316
`
317317
.setOptions({ luaTarget: tstl.LuaTarget.Lua51 })
318-
.expectDiagnostics(m =>
319-
m.toMatchInlineSnapshot(
320-
`"main.ts(2,9): error TSTL: Switch statements is/are not supported for target Lua 5.1."`
321-
)
322-
);
318+
.expectDiagnosticsToMatchSnapshot();
323319
});
324320

325321
test.each([

0 commit comments

Comments
 (0)