diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-10-26 23:57:25 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-10-26 23:57:25 -0700 |
commit | 20cca772b85661b607af760d0b77ef603b5ce222 (patch) | |
tree | 1ae6e2a78b3979d7d24a0875a9dd10779a8e852f /tutorial/task11-solution.mu | |
parent | a3f73278b198d0366c590ec8bd7fb8cad5c2931d (diff) | |
download | mu-20cca772b85661b607af760d0b77ef603b5ce222.tar.gz |
task: conditional execution
Diffstat (limited to 'tutorial/task11-solution.mu')
-rw-r--r-- | tutorial/task11-solution.mu | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tutorial/task11-solution.mu b/tutorial/task11-solution.mu new file mode 100644 index 00000000..85140470 --- /dev/null +++ b/tutorial/task11-solution.mu @@ -0,0 +1,22 @@ +fn difference a: int, b: int -> _/eax: int { + var result/eax: int <- copy a + result <- subtract b + compare result, 0 + { + break-if->= + result <- negate + } + return result +} + +fn test-difference { + var result/eax: int <- difference 5, 3 + check-ints-equal result, 2, "F - difference works" + result <- difference 3, 5 + check-ints-equal result, 2, "F - difference is always positive" + result <- difference 6, 6 + check-ints-equal result, 0, "F - difference can be 0" +} + +fn main screen: (addr screen) { +} |