test apply with method
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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]))
|
Reference in New Issue
Block a user