smeup / jariko

a JAva virtual machine Rpg Interpreter written in KOtlin
Apache License 2.0
65 stars 11 forks source link

Bugfix/ErrorEvent with unknown sourceid #577

Closed lanarimarco closed 3 months ago

lanarimarco commented 3 months ago

Description

Fix Issue

When a syntax error occurred after the /API directive, the ErrorEvent.sourceReference.sourceId was UNKNOWN.

Regression due to #573.

The reason for this regression is that the loading and usage of the API must follow a well-defined pattern, which the author of the fix in #573 could not know. This pattern was implemented only in the CompilationUnit.includeApi function. To avoid misuse of API, I have added the new ApiId.loadAndUse function, which ensures the safe loading and usage of the API.

Refactor Test Functions

In the context of this implementation, these useful test functions:

were moved from JarikoCallbackTest to AbstractTest. Consequently, two test units, written specifically for Smeup, were moved from JarikoCallbackTest to SmeupInterpreterTest.

In addition, I have added a validation in both functions where if ErrorEvent.sourceReference.sourceId is UNKNOWN, an error is thrown.

Overall, this implementation improves the handling of RPG programs with the /API directive.

Checklist: