Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(engine): list projection with variable #385

Merged
merged 1 commit into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -978,17 +978,9 @@ class FeelInterpreter {
names match {
case Nil => x
case n :: ns =>
withContext(
x, {
case ctx: ValContext =>
EvalContext
.wrap(ctx.context)(context.valueMapper)
.variable(n) match {
case e: ValError => e
case x: Val => ref(x, ns)
}
case e => error(e, s"context contains no entry with key '$n'")
}
withVal(
path(x, n),
value => ref(value, ns)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,17 @@ class InterpreterContextExpressionTest
eval("{ a: { b:1 } }.a.b") should be(ValNumber(1))
}

it should "be accessed in a list" in {
it should "be accessed in a list (literal)" in {

eval("[ {a:1, b:2}, {a:3, b:4} ].a") should be(
ValList(List(ValNumber(1), ValNumber(3))))
}

it should "be accessed in a list (variable)" in {
eval("a.b", Map("a" -> List(Map("b" -> 1), Map("b" -> 2)))) should be(
ValList(List(ValNumber(1), ValNumber(2))))
}

it should "be accessed in same context" in {

eval("{ a:1, b:(a+1), c:(b+1)}.c") should be(ValNumber(3))
Expand Down