I noticed haxe.unit has been removed from Haxe 4’s standard library when I was greeted with this message trying to run unit tests:
Test.hx:1: characters 7-24 : Type not found : haxe.unit.TestCase
I understand the logic behind removing it from core, and GitHub - HaxeFoundation/hx3compat: Haxe 3 compatibility lib for Haxe 4 was one way to address compatibility (although you have to know it exists.) I’d like to suggest an alternative way to go about its removal, which hopefully can be used in the future on additional cleanup. I can point to OpenFL’s NMEPreloader deprecation as a great example of handling deprecation carefully. The important difference is that there’s an explicit transition phase, where both ways will work, before we remove one of them.
I’d like to see what people think. If the argument is “we should but we don’t have time”, I volunteer to make the change myself
Either put it in “hx3compat” or create a new “HaxeFoundation/unit” and copy the haxe.unit package there. (It’s possible to split files out of a git repo while maintaining their history.) The package now exists in both places.
If anyone uses
haxe.unit.* from the main repo without including the new split out library, they should be shown a compiler warning; however, their tests should still compile and work. There are a couple ways to do this; OpenFL and HaxePunk have both done it in the past. Clearly deprecate it in the docs as well with the same hint.
The warning should specify exactly how to fix the problem: run “haxelib install hx3compat” and include it when you compile.
If you’re using the external version, it will shadow the std lib package and you won’t see the warning.
When people have had plenty of time to make the switch, you can go ahead and remove the package from core.