BasicTestCase

This commit is contained in:
2020-11-13 12:28:32 -07:00
parent 69df6a9e20
commit 2070fdf6a7
3 changed files with 34 additions and 5 deletions

View File

@@ -1,6 +1,2 @@
(defvar message "Hello, world!")
(defvar math #|5 + 6 * 3|#) // inject raw haxe
(defun floor [num] (Math.floor num))
(defun main []
(trace message)
(trace (floor 7.5)))
(trace "Hello, world!"))

View File

@@ -0,0 +1,23 @@
package test.cases;
import utest.Test;
import utest.Assert;
@:build(kiss.Kiss.build("src/test/cases/BasicTestCase.kiss"))
class BasicTestCase extends Test {
function testStaticVar() {
Assert.equals("Howdy", BasicTestCase.message);
}
function testHaxeInsertion() {
Assert.equals(23, BasicTestCase.mathResult);
}
function testStaticFunction() {
Assert.equals(6, BasicTestCase.myFloor(6.5));
}
function testFuncall() {
Assert.equals(7, BasicTestCase.funResult);
}
}

View File

@@ -0,0 +1,10 @@
// (defvar) declares static variables
(defvar message "Howdy")
// #| ... |# parses and injects raw Haxe code
(defvar mathResult #|5 + 6 * 3|#) // Order of operations will apply
// (defun) declares static functions
(defun myFloor [num]
// funcalls can use dot access
(Math.floor num))
// functions are resolved in the macro context
(defvar funResult (myFloor 7.5))