Skip to content

Commit

Permalink
Add custom expression function test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kingcom committed Dec 29, 2021
1 parent c97c5ad commit 524e343
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Tests/Core/CustomExpressionFunctions/CustomExpressionFunctions.asm
@@ -0,0 +1,30 @@
.gba
.create "output.bin",0

.macro check,exp,value
.if (exp) != value
.error "Error: " + °(exp) + " = " + (exp) + " != " + value
.endif
.endmacro

; simple function with multiple parameters
.expfunc lerp(a, b, t), a + t*(b-a)

check lerp(1, 5, 0.75), 4

; resursive function
.expfunc fib(n), n <= 0 ? 0 : n <= 2 ? 1 : fib(n-1)+fib(n-2)

check fib(0), 0
check fib(2), 1
check fib(8), 21

; function that depends on architecture specific functions. Change the architecture afterwards to check
; if it has any influence
.expfunc isArmWrapper(), isArm()

check isArmWrapper(), 0

.psp

.close
1 change: 1 addition & 0 deletions Tests/Core/CustomExpressionFunctions/expected.txt
@@ -0,0 +1 @@


0 comments on commit 524e343

Please sign in to comment.