This is taken from D1844 with an extra update of the JS int limits, and some whitespace. It mainly tests features that are useful for modding.
Check that tests pass.
No, this should be in before, so that SM45 is shown to not break those (it doesn't).
Sure I'll change that.
What do you mean by hardcoded? This is not supposed to be moddable or anything, this is just the engine testing that it can run some specific JS code and yield the expected results from it.
Well as elexis said here https://wildfiregames.com/forum/index.php?/topic/25393-moving-components-schemas-to-xml-files/, having two languages in the same file is an anti pattern, and since you seemed to be loading scripts in Component manager I was wondering why you didn't do it as well.
In binaries/data/mods we have, _test.dae, _test.sim etc we could have _test.scriptinterface, and there you could just tweak the js code without having to recompile. Just an idea.
No, this is a test file for the script interface, which parses and executes JS code in the C++ engine, so having the two languages in the file is perfectly natural. In the component manager, I'm testing the ability to load scripts and overload them when modding/hotloading. If I moved this code to a JS file, I would be testing the loading from the file and the snippet I actually want to test, which would make the test non-unitary (i.e. if it fails you don't know what failed).
We could have a _test.scriptinterface mod indeed, but we would use it for different things like tests for globalscripts hotloading when we have that, testing the fix for #5376 when we have it, etc.
This should have been changed in a previous SM upgrade, yes. I don't know which one bumped jsval limits to the current values, but the new cassert will allow us to not miss future changes.
Note that this is valid because the old value is now completely irrelevant and is a i32 value like any other.
Ah, it could be used for the first argument yes indeed, and would remove the need for the cassert and all those comments. I basically kept things as they were, and it's quite readable this way, but doing what you suggest is probably better.