test apply with method

This commit is contained in:
2020-12-04 11:45:46 -07:00
parent 8329c867a5
commit 473e882606
2 changed files with 21 additions and 1 deletions

View File

@@ -225,4 +225,21 @@ class BasicTestCase extends Test {
function testApply() {
_testApply();
}
function testApplyWithMethod() {
Assert.equals(30, applyWithMethod(new BasicObject(5)));
Assert.equals(18, applyWithMethod(new BasicObject(3)));
}
}
class BasicObject {
var val:Int;
public function new(val:Int) {
this.val = val;
}
public function multiply(otherVal:Int) {
return val * otherVal;
}
}

View File

@@ -302,4 +302,7 @@
(assert ![]))
(defun _testApply []
(Assert.equals 6 (apply + [1 2 3])))
(Assert.equals 6 (apply + [1 2 3])))
(defun applyWithMethod [obj]
(apply .multiply obj [6]))