eval stringmap expressions
Some checks failed
CI / test-core (14, ubuntu-latest, 3.x, cpp) (push) Failing after 0s
CI / test-core (14, ubuntu-latest, 3.x, js) (push) Failing after 1s
CI / test-core (14, ubuntu-latest, 3.x, nodejs) (push) Failing after 3s
CI / test-core (14, ubuntu-latest, 3.x, py) (push) Failing after 11m5s
CI / test-core (14, ubuntu-latest, 3.x, interp) (push) Failing after 11m33s

This commit is contained in:
2025-09-24 17:57:44 -05:00
parent 9b6f4713bc
commit 870c19519f
3 changed files with 28 additions and 4 deletions

View File

@@ -110,11 +110,24 @@
// String literal
((StrExp str)
(cc str))
// Key value exp
((KeyValueExp keyExp valExp)
(evalCC keyExp ->key (evalCC valExp ->value (cc (objectWith key value)))))
// Array expression
((ListExp elements)
// TODO check for KeyValueExp (map expression)
(_evalAllCC elements ->values
(cc values)))
(case (first elements)
// Key value exps: it's a map
((object def (KeyValueExp _ _))
(_evalAllCC elements ->values
(let [m (new Map<String,Dynamic>)]
(doFor kvp values
(let [:String key kvp.key
:Dynamic value kvp.value]
(dictSet m key value)))
(cc m))))
// It's a list
(otherwise (_evalAllCC elements ->values
(cc values)))))
// Symbol
((Symbol ident)
// Check for numbers

View File

@@ -25,7 +25,10 @@ class KissInterp2TestCase extends Test {
function testCallMethod() {
_testCallMethod();
}
function testPrint() {
function testPrint() {
_testPrint();
}
function testMapExpression() {
_testMapExpression();
}
}

View File

@@ -27,3 +27,11 @@
(function _testPrint []
(let [interp (new Interp)]
(assertEval "testing" "(print \"testing\")")))
(function _testMapExpression []
(let [interp (new Interp)]
(interp.evalCC #"[=>"4" 5 =>"6" 7]"# ->[:Map<String,Dynamic> mapVal] {
(Assert.equals 5 (dictGet mapVal "4"))
(Assert.equals 7 (dictGet mapVal "6"))
})))