Closed Olipro closed 1 year ago
I may have more information: It does seem that globals such as include_lib
are also injected into locals
- which is not the case in GreyHack. Could this be the cause of the problem?
That might be a bug then. I'll take a look as soon as I have time. Thanks for reporting.
Also just a side note the interpreter which is used by greybel is not actually the same as the MiniScript interpreter therefore there might some discrepancies compared to how MiniScript/GreyScript works. But since this is supposed to emulate the original behavior I'll try to fix those issues. So if you find any more discrepancies in the future feel free to create more issues. Anyway just a heads up ;)
Alright I found the culprit. I have a PR ready which going to be merged soonish https://github.com/ayecue/greybel-js/pull/109
Do you have an example code with your mock library where you mock a function? Just for testing.
I imagine that most of the discrepancies will be that it's a superior implementation of MiniMock. Hopefully one day the game will update to the 2023 release too.
I have a release here: https://www.greyrepo.xyz/posts/unit-testing-mocking-library
The example is a bit fatty but you should be able to extract what you need - if not, let me know and I should be able to give you a minimum sample sometime tomorrow.
Alright the PR got merged. It worked for me while testing. I'll close this ticket as soon as you can confirm that it works for you as well.
Replacement of globals also working fine now!
I use mocking for my unit tests (code here if you're interested) and in certain tests, I override global functions.
For example, if I want to override
include_lib
then I instantiate a new Mock class, tell it to define the key/value pair and then assign the funcRef intoglobals.include_lib
. After the test is completed, I remove the key fromglobals
to restore the environment state to normalcy.This works absolutely fine when I run my tests inside GreyHack. However, when using the debugger bundled with the VSCode extension, the class under test (which is in a different, included file) does not see the new global.