Skip to content

Commit b34e802

Browse files
authored
Add a test with diagnostics that used to crash the app
Don't show in changelog
1 parent 31dac9c commit b34e802

File tree

1 file changed

+49
-2
lines changed

1 file changed

+49
-2
lines changed

GDevelop.js/__tests__/GDJSBasicCodeGenerationIntegrationTests.js

+49-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,50 @@ describe('libGD.js - GDJS Code Generation integration tests', function () {
2727
gd = await initializeGDevelopJs();
2828
});
2929

30+
it('does not crash when generating code with diagnostics', function () {
31+
const serializerElement = gd.Serializer.fromJSObject([
32+
{
33+
type: 'BuiltinCommonInstructions::Standard',
34+
conditions: [],
35+
actions: [
36+
{
37+
type: { value: 'ModVarScene' },
38+
parameters: [
39+
'Counter',
40+
'+',
41+
'1 + VariableThatDoesNotExist.Test.Test2',
42+
],
43+
},
44+
{
45+
type: { value: 'SetNumberObjectVariable' },
46+
parameters: [
47+
'NonExistingObject',
48+
'NonExistingVariable',
49+
'=',
50+
'123',
51+
],
52+
},
53+
{
54+
type: { value: 'ModVarScene' },
55+
parameters: ['Counter', '+', '3'],
56+
},
57+
],
58+
events: [],
59+
},
60+
]);
61+
62+
const runCompiledEvents = generateCompiledEventsFromSerializedEvents(
63+
gd,
64+
serializerElement
65+
);
66+
67+
const { gdjs, runtimeScene } = makeMinimalGDJSMock();
68+
runCompiledEvents(gdjs, runtimeScene, []);
69+
70+
expect(runtimeScene.getVariables().has('Counter')).toBe(true);
71+
expect(runtimeScene.getVariables().get('Counter').getAsNumber()).toBe(3);
72+
});
73+
3074
it('does not generate anything for a disabled event and its sub events', function () {
3175
const serializerElement = gd.Serializer.fromJSObject([
3276
{
@@ -885,8 +929,11 @@ describe('libGD.js - GDJS Code Generation integration tests', function () {
885929
).toBe(2);
886930

887931
// Simulate a hot reloading by recompiling the function and running it again.
888-
const runHotReloadedCompiledEvents =
889-
generateCompiledEventsForEventsFunction(gd, project, eventsFunction);
932+
const runHotReloadedCompiledEvents = generateCompiledEventsForEventsFunction(
933+
gd,
934+
project,
935+
eventsFunction
936+
);
890937
runHotReloadedCompiledEvents(
891938
gdjs,
892939
runtimeScene /*, Don't pass arguments to not run the function. */

0 commit comments

Comments
 (0)