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
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:
@@ -110,11 +110,24 @@
|
|||||||
// String literal
|
// String literal
|
||||||
((StrExp str)
|
((StrExp str)
|
||||||
(cc str))
|
(cc str))
|
||||||
|
// Key value exp
|
||||||
|
((KeyValueExp keyExp valExp)
|
||||||
|
(evalCC keyExp ->key (evalCC valExp ->value (cc (objectWith key value)))))
|
||||||
// Array expression
|
// Array expression
|
||||||
((ListExp elements)
|
((ListExp elements)
|
||||||
// TODO check for KeyValueExp (map expression)
|
(case (first elements)
|
||||||
|
// Key value exps: it's a map
|
||||||
|
((object def (KeyValueExp _ _))
|
||||||
(_evalAllCC elements ->values
|
(_evalAllCC elements ->values
|
||||||
(cc 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
|
||||||
((Symbol ident)
|
((Symbol ident)
|
||||||
// Check for numbers
|
// Check for numbers
|
||||||
|
@@ -28,4 +28,7 @@ class KissInterp2TestCase extends Test {
|
|||||||
function testPrint() {
|
function testPrint() {
|
||||||
_testPrint();
|
_testPrint();
|
||||||
}
|
}
|
||||||
|
function testMapExpression() {
|
||||||
|
_testMapExpression();
|
||||||
|
}
|
||||||
}
|
}
|
@@ -27,3 +27,11 @@
|
|||||||
(function _testPrint []
|
(function _testPrint []
|
||||||
(let [interp (new Interp)]
|
(let [interp (new Interp)]
|
||||||
(assertEval "testing" "(print \"testing\")")))
|
(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"))
|
||||||
|
})))
|
||||||
|
Reference in New Issue
Block a user