-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
129 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
UNIT TEST DEMO | ||
============== | ||
|
||
This shows how to do simple unit tests with a function in a header file. | ||
So with something like this you can write safer code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// multiply-test.l1com | ||
// | ||
// | ||
#include <intr.l1h> | ||
#include <bool.l1h> | ||
(main func) | ||
(set int64 1 zero 0) | ||
(set int64 1 one 1) | ||
(set int64 1 x1 5) | ||
(set int64 1 y1 3) | ||
(set int64 1 ret1 15) | ||
(set int64 1 x2 -5) | ||
(set int64 1 y2 3) | ||
(set int64 1 ret2 -15) | ||
(set int64 1 ret 0) | ||
(set bool 1 Btest_ok 1) | ||
(set int64 1 f 0) | ||
(set int64 1 retcode 0) | ||
(set string s test_passstr "tests passed: all ok!") | ||
(set string s test_failstr "tests failed!") | ||
// run tests | ||
|
||
// test 1 | ||
(x1 y1 :multiply !) | ||
(ret stpop) | ||
|
||
print_i (ret) | ||
print_n | ||
|
||
(((ret ret1 !=) f =) f if) | ||
(false Btest_ok =) | ||
(endif) | ||
|
||
// test 2 | ||
(x2 y2 :multiply !) | ||
(ret stpop) | ||
|
||
print_i (ret) | ||
print_n | ||
|
||
(((ret ret2 !=) f =) f if) | ||
(false Btest_ok =) | ||
(endif) | ||
|
||
// check | ||
(((Btest_ok false ==) f =) f if+) | ||
print_s (test_failstr) | ||
(one retcode =) | ||
(else) | ||
print_s (test_passstr) | ||
(zero retcode =) | ||
(endif) | ||
print_n | ||
exit (retcode) | ||
(funcend) | ||
#include <multiply.l1h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// multiply.l1com | ||
// | ||
// | ||
#include <intr.l1h> | ||
(main func) | ||
(set int64 1 zero 0) | ||
(set int64 1 x 5) | ||
(set int64 1 y 3) | ||
(set int64 1 ret 0) | ||
(x y :multiply !) | ||
(ret stpop) | ||
print_i (ret) | ||
print_n | ||
exit (zero) | ||
(funcend) | ||
#include <multiply.l1h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(multiply func) | ||
#var ~ multiply | ||
|
||
(set int64 1 x~ 0) | ||
(set int64 1 y~ 0) | ||
(set int64 1 ret~ 0) | ||
(y~ x~ stpop) | ||
{ret~ = (x~ * y~)} | ||
(ret~ stpush) | ||
(funcend) |