Feature Overriding ASH library functions for testing

Jeparo

New member
tl;dr: It would be nice if defining int item_amount(item it) { /* something */ } didn't yield a Function 'item_amount( item )' overrides a library function error, but if it's difficult then I'll just write a bunch of wrapper functions.

Some folks in the scripting community are maintaining some pretty big scripts, and testing this stuff properly can get really difficult. For example, sl_ascend has Dark Gyffte-only consumption code, and it's tough to test this without having an account that's in Dark Gyffte. If we could mock out builtin functions for these tests, we could override item_amount(), eat(), and drink(), and call it a day. The alternative to doing this at the Mafia layer would be manually implementing a wrapper layer around every Mafia builtin (which wouldn't be compatible with imported scripts). I'm not super familiar with the internals of Mafia, so I don't know how much work this would be - I find it believable that it would be a ton of work and not worth doing. But if it's not too difficult, allowing scripts to override library functions (and showing a warning) would make testing a lot easier.

(You could also guard it behind a preference signalling "is it OK to run unsafe code that overrides library functions"?)
 
Top