Skip to content

Commit 542a93a

Browse files
committed
Add expected diagnostics to snapshot assertions
1 parent 0473f45 commit 542a93a

25 files changed

+571
-539
lines changed

src/transformation/utils/diagnostics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export const unsupportedAccessorInObjectLiteral = createDiagnosticFactory(
111111
export const unsupportedNullishCoalescing = createDiagnosticFactory("Nullish coalescing is not supported.");
112112

113113
export const unsupportedRightShiftOperator = createDiagnosticFactory(
114-
"Right shift operator is not supported. Use `>>>` instead."
114+
"Right shift operator is not supported for target Lua 5.3. Use `>>>` instead."
115115
);
116116

117117
const getLuaTargetName = (version: LuaTarget) => (version === LuaTarget.LuaJIT ? "LuaJIT" : `Lua ${version}`);

src/transformation/visitors/lua-table.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function validateLuaTableCall(
1717
for (const argument of callArguments) {
1818
if (ts.isSpreadElement(argument)) {
1919
context.diagnostics.push(luaTableForbiddenUsage(argument, "Arguments cannot be spread"));
20+
return;
2021
}
2122
}
2223

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,12 +534,12 @@ end)()
534534
return ____exports"
535535
`;
536536
537-
exports[`Unsupported bitop 5.3 ("a>>=b"): diagnostics 1`] = `"main.ts(1,25): error TSTL: Right shift operator is not supported. Use \`>>>\` instead."`;
537+
exports[`Unsupported bitop 5.3 ("a>>=b"): diagnostics 1`] = `"main.ts(1,25): error TSTL: Right shift operator is not supported for target Lua 5.3. Use \`>>>\` instead."`;
538538
539539
exports[`Unsupported bitop 5.3 ("a>>b"): code 1`] = `
540540
"local ____exports = {}
541541
____exports.__result = a >> b
542542
return ____exports"
543543
`;
544544
545-
exports[`Unsupported bitop 5.3 ("a>>b"): diagnostics 1`] = `"main.ts(1,25): error TSTL: Right shift operator is not supported. Use \`>>>\` instead."`;
545+
exports[`Unsupported bitop 5.3 ("a>>b"): diagnostics 1`] = `"main.ts(1,25): error TSTL: Right shift operator is not supported for target Lua 5.3. Use \`>>>\` instead."`;

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,6 @@ exports[`ambient identifier must be a valid lua identifier (object literal short
128128

129129
exports[`ambient identifier must be a valid lua identifier (object literal shorthand) ("ɥɣɎɌͼƛಠ"): diagnostics 1`] = `"main.ts(3,27): error TSTL: Invalid ambient identifier name 'ɥɣɎɌͼƛಠ'. Ambient identifiers must be valid lua identifiers."`;
130130

131-
exports[`missing expression ("({})[]"): code 1`] = `"local ____ = ({})[____]"`;
132-
133-
exports[`missing expression ("({})[]"): diagnostics 1`] = `"main.ts(1,6): error TS1011: An element access expression should take an argument."`;
134-
135-
exports[`missing expression ("const x = ;"): code 1`] = `"x = ____"`;
136-
137-
exports[`missing expression ("const x = ;"): diagnostics 1`] = `"main.ts(1,11): error TS1109: Expression expected."`;
138-
139131
exports[`undeclared identifier must be a valid lua identifier ("$$"): code 1`] = `"foo = _____24_24_24"`;
140132

141133
exports[`undeclared identifier must be a valid lua identifier ("$$"): diagnostics 1`] = `"main.ts(2,21): error TSTL: Invalid ambient identifier name '$$$'. Ambient identifiers must be valid lua identifiers."`;

test/unit/annotations/__snapshots__/luaTable.spec.ts.snap

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ exports[`Cannot isolate LuaTable method ("get"): code 1`] = `"property = tbl.get
2929

3030
exports[`Cannot isolate LuaTable method ("get"): code 2`] = `"property = tbl.get"`;
3131

32-
exports[`Cannot isolate LuaTable method ("get"): diagnostics 1`] = `"main.ts(11,17): error TSTL: LuaTable.get is unsupported."`;
32+
exports[`Cannot isolate LuaTable method ("get"): diagnostics 1`] = `"main.ts(11,21): error TSTL: LuaTable.get is unsupported."`;
3333

34-
exports[`Cannot isolate LuaTable method ("get"): diagnostics 2`] = `"main.ts(11,17): error TSTL: LuaTable.get is unsupported."`;
34+
exports[`Cannot isolate LuaTable method ("get"): diagnostics 2`] = `"main.ts(11,21): error TSTL: LuaTable.get is unsupported."`;
3535

3636
exports[`Cannot isolate LuaTable method ("set"): code 1`] = `"property = tbl.set"`;
3737

3838
exports[`Cannot isolate LuaTable method ("set"): code 2`] = `"property = tbl.set"`;
3939

40-
exports[`Cannot isolate LuaTable method ("set"): diagnostics 1`] = `"main.ts(11,17): error TSTL: LuaTable.set is unsupported."`;
40+
exports[`Cannot isolate LuaTable method ("set"): diagnostics 1`] = `"main.ts(11,21): error TSTL: LuaTable.set is unsupported."`;
4141

42-
exports[`Cannot isolate LuaTable method ("set"): diagnostics 2`] = `"main.ts(11,17): error TSTL: LuaTable.set is unsupported."`;
42+
exports[`Cannot isolate LuaTable method ("set"): diagnostics 2`] = `"main.ts(11,21): error TSTL: LuaTable.set is unsupported."`;
4343

4444
exports[`Cannot set LuaTable length: code 1`] = `"tbl.length = 2"`;
4545

@@ -108,15 +108,9 @@ exports[`Forbidden LuaTable use ("tbl.set(...([\\"field\\", 0] as const))"): cod
108108

109109
exports[`Forbidden LuaTable use ("tbl.set(...([\\"field\\", 0] as const))"): code 2`] = `"tbl[table.unpack({\\"field\\", 0})] = nil"`;
110110

111-
exports[`Forbidden LuaTable use ("tbl.set(...([\\"field\\", 0] as const))"): diagnostics 1`] = `
112-
"main.ts(11,1): error TSTL: Invalid @luaTable usage: Expected 2 arguments, but got 1.
113-
main.ts(11,9): error TSTL: Invalid @luaTable usage: Arguments cannot be spread."
114-
`;
111+
exports[`Forbidden LuaTable use ("tbl.set(...([\\"field\\", 0] as const))"): diagnostics 1`] = `"main.ts(11,9): error TSTL: Invalid @luaTable usage: Arguments cannot be spread."`;
115112

116-
exports[`Forbidden LuaTable use ("tbl.set(...([\\"field\\", 0] as const))"): diagnostics 2`] = `
117-
"main.ts(11,1): error TSTL: Invalid @luaTable usage: Expected 2 arguments, but got 1.
118-
main.ts(11,9): error TSTL: Invalid @luaTable usage: Arguments cannot be spread."
119-
`;
113+
exports[`Forbidden LuaTable use ("tbl.set(...([\\"field\\", 0] as const))"): diagnostics 2`] = `"main.ts(11,9): error TSTL: Invalid @luaTable usage: Arguments cannot be spread."`;
120114

121115
exports[`Forbidden LuaTable use ("tbl.set(\\"field\\")"): code 1`] = `"tbl.field = nil"`;
122116

@@ -138,15 +132,9 @@ exports[`Forbidden LuaTable use ("tbl.set(\\"field\\", 0, 1)"): code 1`] = `"tbl
138132

139133
exports[`Forbidden LuaTable use ("tbl.set(\\"field\\", 0, 1)"): code 2`] = `"tbl.field = 0"`;
140134

141-
exports[`Forbidden LuaTable use ("tbl.set(\\"field\\", 0, 1)"): diagnostics 1`] = `
142-
"main.ts(11,1): error TSTL: Invalid @luaTable usage: Expected 2 arguments, but got 3.
143-
main.ts(11,21): error TS2554: Expected 0-2 arguments, but got 3."
144-
`;
135+
exports[`Forbidden LuaTable use ("tbl.set(\\"field\\", 0, 1)"): diagnostics 1`] = `"main.ts(11,1): error TSTL: Invalid @luaTable usage: Expected 2 arguments, but got 3."`;
145136

146-
exports[`Forbidden LuaTable use ("tbl.set(\\"field\\", 0, 1)"): diagnostics 2`] = `
147-
"main.ts(11,1): error TSTL: Invalid @luaTable usage: Expected 2 arguments, but got 3.
148-
main.ts(11,21): error TS2554: Expected 0-2 arguments, but got 3."
149-
`;
137+
exports[`Forbidden LuaTable use ("tbl.set(\\"field\\", 0, 1)"): diagnostics 2`] = `"main.ts(11,1): error TSTL: Invalid @luaTable usage: Expected 2 arguments, but got 3."`;
150138

151139
exports[`LuaTable classes must be ambient ("/** @luaTable */ class Table {}"): code 1`] = `
152140
"require(\\"lualib_bundle\\");
@@ -188,9 +176,9 @@ exports[`LuaTable set() cannot be used in a LuaTable call expression: code 1`] =
188176

189177
exports[`LuaTable set() cannot be used in a LuaTable call expression: code 2`] = `"exp = tbl:set(\\"value\\", 5)"`;
190178

191-
exports[`LuaTable set() cannot be used in a LuaTable call expression: diagnostics 1`] = `"main.ts(11,13): error TSTL: LuaTable.set is unsupported."`;
179+
exports[`LuaTable set() cannot be used in a LuaTable call expression: diagnostics 1`] = `"main.ts(11,17): error TSTL: LuaTable.set is unsupported."`;
192180

193-
exports[`LuaTable set() cannot be used in a LuaTable call expression: diagnostics 2`] = `"main.ts(11,13): error TSTL: LuaTable.set is unsupported."`;
181+
exports[`LuaTable set() cannot be used in a LuaTable call expression: diagnostics 2`] = `"main.ts(11,17): error TSTL: LuaTable.set is unsupported."`;
194182

195183
exports[`LuaTables cannot be constructed with arguments: code 1`] = `"____table = {}"`;
196184

@@ -204,10 +192,10 @@ exports[`LuaTables cannot have other members: code 3`] = `"x = tbl:other()"`;
204192

205193
exports[`LuaTables cannot have other members: code 4`] = `"x = tbl:other()"`;
206194

207-
exports[`LuaTables cannot have other members: diagnostics 1`] = `"main.ts(11,1): error TSTL: LuaTable.other is unsupported."`;
195+
exports[`LuaTables cannot have other members: diagnostics 1`] = `"main.ts(11,5): error TSTL: LuaTable.other is unsupported."`;
208196

209-
exports[`LuaTables cannot have other members: diagnostics 2`] = `"main.ts(11,1): error TSTL: LuaTable.other is unsupported."`;
197+
exports[`LuaTables cannot have other members: diagnostics 2`] = `"main.ts(11,5): error TSTL: LuaTable.other is unsupported."`;
210198

211-
exports[`LuaTables cannot have other members: diagnostics 3`] = `"main.ts(11,9): error TSTL: LuaTable.other is unsupported."`;
199+
exports[`LuaTables cannot have other members: diagnostics 3`] = `"main.ts(11,13): error TSTL: LuaTable.other is unsupported."`;
212200

213-
exports[`LuaTables cannot have other members: diagnostics 4`] = `"main.ts(11,9): error TSTL: LuaTable.other is unsupported."`;
201+
exports[`LuaTables cannot have other members: diagnostics 4`] = `"main.ts(11,13): error TSTL: LuaTable.other is unsupported."`;

test/unit/annotations/customConstructor.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { annotationInvalidArgumentCount } from "../../../src/transformation/utils/diagnostics";
12
import * as util from "../../util";
23

34
test("CustomCreate", () => {
@@ -29,5 +30,5 @@ test("IncorrectUsage", () => {
2930
class Point2D {}
3031
3132
new Point2D();
32-
`.expectDiagnosticsToMatchSnapshot();
33+
`.expectDiagnosticsToMatchSnapshot([annotationInvalidArgumentCount.code]);
3334
});

test/unit/annotations/extension.spec.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import {
2+
extensionCannotConstruct,
3+
extensionCannotExtend,
4+
extensionInvalidInstanceOf,
5+
} from "../../../src/transformation/utils/diagnostics";
16
import * as util from "../../util";
27

38
test.each(["extension", "metaExtension"])("Class extends extension (%p)", extensionType => {
@@ -6,7 +11,7 @@ test.each(["extension", "metaExtension"])("Class extends extension (%p)", extens
611
/** @${extensionType} **/
712
class B extends A {}
813
class C extends B {}
9-
`.expectDiagnosticsToMatchSnapshot();
14+
`.expectDiagnosticsToMatchSnapshot([extensionCannotExtend.code]);
1015
});
1116

1217
test.each(["extension", "metaExtension"])("Class construct extension (%p)", extensionType => {
@@ -15,7 +20,7 @@ test.each(["extension", "metaExtension"])("Class construct extension (%p)", exte
1520
/** @${extensionType} **/
1621
class B extends A {}
1722
const b = new B();
18-
`.expectDiagnosticsToMatchSnapshot();
23+
`.expectDiagnosticsToMatchSnapshot([extensionCannotConstruct.code]);
1924
});
2025

2126
test.each(["extension", "metaExtension"])("instanceof extension (%p)", extensionType => {
@@ -25,5 +30,5 @@ test.each(["extension", "metaExtension"])("instanceof extension (%p)", extension
2530
class B extends A {}
2631
declare const foo: any;
2732
const result = foo instanceof B;
28-
`.expectDiagnosticsToMatchSnapshot();
33+
`.expectDiagnosticsToMatchSnapshot([extensionInvalidInstanceOf.code]);
2934
});

test/unit/annotations/forRange.spec.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { invalidForRangeCall } from "../../../src/transformation/utils/diagnostics";
12
import * as util from "../../util";
23

34
const createForRangeDeclaration = (args = "i: number, j: number, k?: number", returns = "number[]") => `
@@ -28,43 +29,43 @@ describe("invalid usage", () => {
2829
util.testModule`
2930
/** @forRange */
3031
function luaRange() {}
31-
`.expectDiagnosticsToMatchSnapshot();
32+
`.expectDiagnosticsToMatchSnapshot([invalidForRangeCall.code]);
3233
});
3334

3435
test.each<[number[]]>([[[]], [[1]], [[1, 2, 3, 4]]])("argument count (%p)", args => {
3536
util.testModule`
3637
${createForRangeDeclaration("...args: number[]")}
3738
for (const i of luaRange(${args})) {}
38-
`.expectDiagnosticsToMatchSnapshot();
39+
`.expectDiagnosticsToMatchSnapshot([invalidForRangeCall.code]);
3940
});
4041

4142
test("non-declared loop variable", () => {
4243
util.testModule`
4344
${createForRangeDeclaration()}
4445
let i: number;
4546
for (i of luaRange(1, 10, 2)) {}
46-
`.expectDiagnosticsToMatchSnapshot();
47+
`.expectDiagnosticsToMatchSnapshot([invalidForRangeCall.code]);
4748
});
4849

4950
test("argument types", () => {
5051
util.testModule`
5152
${createForRangeDeclaration("i: string, j: number")}
5253
for (const i of luaRange("foo", 2)) {}
53-
`.expectDiagnosticsToMatchSnapshot();
54+
`.expectDiagnosticsToMatchSnapshot([invalidForRangeCall.code]);
5455
});
5556

5657
test("variable destructuring", () => {
5758
util.testModule`
5859
${createForRangeDeclaration(undefined, "number[][]")}
5960
for (const [i] of luaRange(1, 10, 2)) {}
60-
`.expectDiagnosticsToMatchSnapshot();
61+
`.expectDiagnosticsToMatchSnapshot([invalidForRangeCall.code]);
6162
});
6263

6364
test("return type", () => {
6465
util.testModule`
6566
${createForRangeDeclaration(undefined, "string[]")}
6667
for (const i of luaRange(1, 10)) {}
67-
`.expectDiagnosticsToMatchSnapshot();
68+
`.expectDiagnosticsToMatchSnapshot([invalidForRangeCall.code]);
6869
});
6970

7071
test.each([
@@ -77,6 +78,6 @@ describe("invalid usage", () => {
7778
util.testModule`
7879
${createForRangeDeclaration()}
7980
${statement}
80-
`.expectDiagnosticsToMatchSnapshot();
81+
`.expectDiagnosticsToMatchSnapshot([invalidForRangeCall.code]);
8182
});
8283
});

test/unit/annotations/luaIterator.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as util from "../../util";
2+
import { luaIteratorForbiddenUsage } from "../../../src/transformation/utils/diagnostics";
23

34
test("forof lua iterator", () => {
45
const code = `
@@ -143,7 +144,7 @@ test("forof lua iterator tuple-return single variable", () => {
143144
interface Iter extends Iterable<[string, string]> {}
144145
declare function luaIter(): Iter;
145146
for (let x of luaIter()) {}
146-
`.expectDiagnosticsToMatchSnapshot();
147+
`.expectDiagnosticsToMatchSnapshot([luaIteratorForbiddenUsage.code]);
147148
});
148149

149150
test("forof lua iterator tuple-return single existing variable", () => {
@@ -156,7 +157,7 @@ test("forof lua iterator tuple-return single existing variable", () => {
156157
declare function luaIter(): Iter;
157158
let x: [string, string];
158159
for (x of luaIter()) {}
159-
`.expectDiagnosticsToMatchSnapshot();
160+
`.expectDiagnosticsToMatchSnapshot([luaIteratorForbiddenUsage.code]);
160161
});
161162

162163
test("forof forwarded lua iterator", () => {

test/unit/annotations/luaTable.spec.ts

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1+
import {
2+
luaTableCannotBeAccessedDynamically,
3+
luaTableCannotBeExtended,
4+
luaTableForbiddenUsage,
5+
luaTableMustBeAmbient,
6+
unsupportedProperty,
7+
luaTableInvalidInstanceOf,
8+
} from "../../../src/transformation/utils/diagnostics";
19
import * as util from "../../util";
210

311
const tableLibClass = `
412
/** @luaTable */
513
declare class Table<K extends {} = {}, V = any> {
614
length: number;
7-
constructor(notAllowed?: boolean);
8-
set(key?: K, value?: V): void;
9-
get(key?: K, notAllowed?: K): V;
15+
constructor(notAllowed?: any);
16+
set(key?: K, value?: V, notAllowed?: any): void;
17+
get(key?: K, notAllowed?: any): V;
1018
other(): void;
1119
}
1220
declare let tbl: Table;
@@ -17,31 +25,35 @@ const tableLibInterface = `
1725
/** @luaTable */
1826
declare interface Table<K extends {} = {}, V = any> {
1927
length: number;
20-
constructor(notAllowed?: boolean);
21-
set(key?: K, value?: V): void;
22-
get(key?: K, notAllowed?: K): V;
28+
constructor(notAllowed?: any);
29+
set(key?: K, value?: V, notAllowed?: any): void;
30+
get(key?: K, notAllowed?: any): V;
2331
other(): void;
2432
}
2533
declare let tbl: Table;
2634
`;
2735

2836
test.each([tableLibClass])("LuaTables cannot be constructed with arguments", tableLib => {
29-
util.testModule(tableLib + `const table = new Table(true);`).expectDiagnosticsToMatchSnapshot();
37+
util.testModule(tableLib + `const table = new Table(true);`).expectDiagnosticsToMatchSnapshot([
38+
luaTableForbiddenUsage.code,
39+
]);
3040
});
3141

3242
test.each([tableLibClass, tableLibInterface])(
3343
"LuaTable set() cannot be used in a LuaTable call expression",
3444
tableLib => {
35-
util.testModule(tableLib + `const exp = tbl.set("value", 5)`).expectDiagnosticsToMatchSnapshot();
45+
util.testModule(tableLib + `const exp = tbl.set("value", 5)`).expectDiagnosticsToMatchSnapshot([
46+
unsupportedProperty.code,
47+
]);
3648
}
3749
);
3850

3951
test.each([tableLibClass, tableLibInterface])("LuaTables cannot have other members", tableLib => {
40-
util.testModule(tableLib + `tbl.other()`).expectDiagnosticsToMatchSnapshot();
52+
util.testModule(tableLib + `tbl.other()`).expectDiagnosticsToMatchSnapshot([unsupportedProperty.code]);
4153
});
4254

4355
test.each([tableLibClass, tableLibInterface])("LuaTables cannot have other members", tableLib => {
44-
util.testModule(tableLib + `let x = tbl.other()`).expectDiagnosticsToMatchSnapshot();
56+
util.testModule(tableLib + `let x = tbl.other()`).expectDiagnosticsToMatchSnapshot([unsupportedProperty.code]);
4557
});
4658

4759
test.each([tableLibClass])("LuaTable new", tableLib => {
@@ -56,7 +68,7 @@ test.each([tableLibClass])("LuaTable length", tableLib => {
5668
});
5769

5870
test.each([tableLibClass, tableLibInterface])("Cannot set LuaTable length", tableLib => {
59-
util.testModule(tableLib + `tbl.length = 2;`).expectDiagnosticsToMatchSnapshot();
71+
util.testModule(tableLib + `tbl.length = 2;`).expectDiagnosticsToMatchSnapshot([luaTableForbiddenUsage.code]);
6072
});
6173

6274
test.each([tableLibClass, tableLibInterface])("Forbidden LuaTable use", tableLib => {
@@ -69,15 +81,15 @@ test.each([tableLibClass, tableLibInterface])("Forbidden LuaTable use", tableLib
6981
'tbl.set(...(["field", 0] as const))',
7082
'tbl.set("field", ...([0] as const))',
7183
])("Forbidden LuaTable use (%p)", invalidCode => {
72-
util.testModule(tableLib + invalidCode).expectDiagnosticsToMatchSnapshot();
84+
util.testModule(tableLib + invalidCode).expectDiagnosticsToMatchSnapshot([luaTableForbiddenUsage.code]);
7385
});
7486
});
7587

7688
test.each([tableLibClass])("Cannot extend LuaTable class", tableLib => {
7789
test.each([`class Ext extends Table {}`, `const c = class Ext extends Table {}`])(
7890
"Cannot extend LuaTable class (%p)",
7991
code => {
80-
util.testModule(tableLib + code).expectDiagnosticsToMatchSnapshot();
92+
util.testModule(tableLib + code).expectDiagnosticsToMatchSnapshot([luaTableCannotBeExtended.code]);
8193
}
8294
);
8395
});
@@ -87,27 +99,31 @@ test.each([
8799
`/** @luaTable */ export class Table {}`,
88100
`/** @luaTable */ const c = class Table {}`,
89101
])("LuaTable classes must be ambient (%p)", code => {
90-
util.testModule(code).expectDiagnosticsToMatchSnapshot();
102+
util.testModule(code).expectDiagnosticsToMatchSnapshot([luaTableMustBeAmbient.code]);
91103
});
92104

93105
test.each([tableLibClass])("Cannot extend LuaTable class", tableLib => {
94106
test.each([`tbl instanceof Table`])("Cannot use instanceof on a LuaTable class (%p)", code => {
95-
util.testModule(tableLib + code).expectDiagnosticsToMatchSnapshot();
107+
util.testModule(tableLib + code).expectDiagnosticsToMatchSnapshot([luaTableInvalidInstanceOf.code]);
96108
});
97109
});
98110

99111
test.each([tableLibClass, tableLibInterface])("Cannot use ElementAccessExpression on a LuaTable", tableLib => {
100112
test.each([`tbl["get"]("field")`, `tbl["set"]("field")`, `tbl["length"]`])(
101113
"Cannot use ElementAccessExpression on a LuaTable (%p)",
102114
code => {
103-
util.testModule(tableLib + code).expectDiagnosticsToMatchSnapshot();
115+
util.testModule(tableLib + code).expectDiagnosticsToMatchSnapshot([
116+
luaTableCannotBeAccessedDynamically.code,
117+
]);
104118
}
105119
);
106120
});
107121

108122
test.each([tableLibClass, tableLibInterface])("Cannot isolate LuaTable methods", tableLib => {
109123
test.each([`set`, `get`])("Cannot isolate LuaTable method (%p)", propertyName => {
110-
util.testModule(`${tableLib} let property = tbl.${propertyName}`).expectDiagnosticsToMatchSnapshot();
124+
util.testModule(`${tableLib} let property = tbl.${propertyName}`).expectDiagnosticsToMatchSnapshot([
125+
unsupportedProperty.code,
126+
]);
111127
});
112128
});
113129

0 commit comments

Comments
 (0)