(continue), (break)
This commit is contained in:
@@ -182,6 +182,16 @@ class SpecialForms {
|
||||
EReturn(k.convert(args[0])).withMacroPosOf(wholeExp);
|
||||
};
|
||||
|
||||
map["break"] = (wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState) -> {
|
||||
wholeExp.checkNumArgs(0, 0, "(break)");
|
||||
EBreak.withMacroPosOf(wholeExp);
|
||||
};
|
||||
|
||||
map["continue"] = (wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState) -> {
|
||||
wholeExp.checkNumArgs(0, 0, "(continue)");
|
||||
EContinue.withMacroPosOf(wholeExp);
|
||||
};
|
||||
|
||||
// TODO (case... ) for switch
|
||||
|
||||
// Type check syntax:
|
||||
|
@@ -232,4 +232,8 @@ class BasicTestCase extends Test {
|
||||
function testFieldExps() {
|
||||
_testFieldExps();
|
||||
}
|
||||
|
||||
function testBreakContinue() {
|
||||
_testBreakContinue();
|
||||
}
|
||||
}
|
||||
|
@@ -262,4 +262,16 @@
|
||||
|
||||
(defun _testFieldExps []
|
||||
(Assert.equals "hey" (.trim " hey "))
|
||||
(Assert.equals "e" (.charAt (.trim " hey ") 1)))
|
||||
(Assert.equals "e" (.charAt (.trim " hey ") 1)))
|
||||
|
||||
(defun _testBreakContinue []
|
||||
(let [[a b c]
|
||||
(for val [1 2 3 4 5 6 7 8]
|
||||
(if (> val 6)
|
||||
(break)
|
||||
(if (% val 2)
|
||||
(continue)
|
||||
val)))]
|
||||
(Assert.equals 2 a)
|
||||
(Assert.equals 4 b)
|
||||
(Assert.equals 6 c)))
|
Reference in New Issue
Block a user