21.10.2015, 17:52
You don't want a global var for various reasons, mainly because the code will be created even if the variable suggests no test.
Here is an idea:
Assume our include does md5 computation. We call the include md5.include.ab3. Now, we create another file called md5.unittest.ab3.
For now this is just a regular ab3 program that does this:
[ab3]XINCLUDE "unittest.include.ab3" ; here come the Macros from...
XINCLUDE "md5.include.ab3" ; this is what we want to test
NPrint "Unit test for md5.include:"
!TEST_EQ{md5{"Hello World!"}, "1B42C4473A0E264F12FF"}
NPrint "Successfully passed."
End[/ab3]
Now we can add a menu entry "Run Unit Tests", next to "Create Executable".
Assume you are writing a program using md5 include. If you hit "Run Unit Tests" it would scan for the used includes and compile&run, if any, their unit tests and report failure/success, just like a compiling error.
This would be fairly easy to add to AIDE at least, since it scans the Includes anyway, and no modification needs to be done to the compiler.
*Note: Amiblitz3 Development is typically not on a professional level. Nobody really writes unit tests so far to safe time (I know this doesnt pay off in the long run).
If we introduce a new concept this might be difficult for AB3 users. Making this really simple and replacing the Includes Demo with a unit test might be sufficient.
What do people think?
Unit tests are also a good way to give usage examples, pretty much like the internal demos do already, just more comprehensive.
Here is an idea:
Assume our include does md5 computation. We call the include md5.include.ab3. Now, we create another file called md5.unittest.ab3.
For now this is just a regular ab3 program that does this:
[ab3]XINCLUDE "unittest.include.ab3" ; here come the Macros from...
XINCLUDE "md5.include.ab3" ; this is what we want to test
NPrint "Unit test for md5.include:"
!TEST_EQ{md5{"Hello World!"}, "1B42C4473A0E264F12FF"}
NPrint "Successfully passed."
End[/ab3]
Now we can add a menu entry "Run Unit Tests", next to "Create Executable".
Assume you are writing a program using md5 include. If you hit "Run Unit Tests" it would scan for the used includes and compile&run, if any, their unit tests and report failure/success, just like a compiling error.
This would be fairly easy to add to AIDE at least, since it scans the Includes anyway, and no modification needs to be done to the compiler.
*Note: Amiblitz3 Development is typically not on a professional level. Nobody really writes unit tests so far to safe time (I know this doesnt pay off in the long run).
If we introduce a new concept this might be difficult for AB3 users. Making this really simple and replacing the Includes Demo with a unit test might be sufficient.
What do people think?
Unit tests are also a good way to give usage examples, pretty much like the internal demos do already, just more comprehensive.