Test for local variables in LQ

This commit is contained in:
Matthias Koefferlein 2019-07-28 01:38:37 +02:00
parent 49c1bacb98
commit 3514fad64a
1 changed files with 5 additions and 1 deletions

View File

@ -77,6 +77,7 @@ class DBLayoutQuery_TestClass < TestBase
ctx = RBA::ExpressionContext::new
ctx.var("suffix", "!")
ctx.var("all", [])
ctx.var("nonmod", "")
q = RBA::LayoutQuery::new("select cell.name + suffix from *")
res = []
@ -88,10 +89,13 @@ class DBLayoutQuery_TestClass < TestBase
assert_equal(res[0], "[\"TOPTOP!\"]")
assert_equal(res[1], "[\"TOP!\"]")
q = RBA::LayoutQuery::new("with * do all.push(cell.name)")
q = RBA::LayoutQuery::new("with * do var nonmod = cell.name; all.push(nonmod)")
q.execute(ly, ctx)
assert_equal(ctx.eval("all").join(","), "TOPTOP,TOP")
# not modified, because we used "var nonmod" in the query which
# creates a local variable:
assert_equal(ctx.eval("nonmod"), "")
end