Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
maximiliankaul committed Aug 14, 2024
1 parent 0635d77 commit 50fdaed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class MultiValueEvaluator : ValueEvaluator() {

override fun evaluate(node: Any?): Any? {
val result = evaluateInternal(node as? Node, 0)
return if (result is Collection<*> && result.all { r -> r is Number })
ConcreteNumberSet(result.map { r -> (r as Number).toLong() }.toMutableSet())
return if (result is Collection<*> && result.filterNotNull().all { r -> r is Number })
ConcreteNumberSet(result.mapNotNull { r -> (r as? Number)?.toLong() }.toMutableSet())
else result
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class ValueEvaluationTests {
ref("a") assign literal(2, t("int"))
call("println") { ref("a") }

// c = 5 - 2
declare {
variable("c", t("int")) {
literal(5, t("int")) - literal(2, t("int"))
Expand All @@ -186,6 +187,8 @@ class ValueEvaluationTests {
}
}

// g = -c
// g = -3
declare { variable("g", t("int")) { -ref("c") } }

call("println") {
Expand Down

0 comments on commit 50fdaed

Please sign in to comment.