@@ -27,6 +27,50 @@ describe('libGD.js - GDJS Code Generation integration tests', function () {
27
27
gd = await initializeGDevelopJs ( ) ;
28
28
} ) ;
29
29
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
+
30
74
it ( 'does not generate anything for a disabled event and its sub events' , function ( ) {
31
75
const serializerElement = gd . Serializer . fromJSObject ( [
32
76
{
@@ -885,8 +929,11 @@ describe('libGD.js - GDJS Code Generation integration tests', function () {
885
929
) . toBe ( 2 ) ;
886
930
887
931
// 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
+ ) ;
890
937
runHotReloadedCompiledEvents (
891
938
gdjs ,
892
939
runtimeScene /*, Don't pass arguments to not run the function. */
0 commit comments