2017-07-23 23:03:21 +02:00
|
|
|
# encoding: UTF-8
|
|
|
|
|
|
|
|
|
|
# KLayout Layout Viewer
|
2024-01-01 17:06:23 +01:00
|
|
|
# Copyright (C) 2006-2024 Matthias Koefferlein
|
2017-07-23 23:03:21 +02:00
|
|
|
#
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
|
|
|
if !$:.member?(File::dirname($0))
|
|
|
|
|
$:.push(File::dirname($0))
|
|
|
|
|
end
|
2017-02-12 13:21:08 +01:00
|
|
|
|
|
|
|
|
load("test_prologue.rb")
|
|
|
|
|
|
|
|
|
|
class DBLayoutQuery_TestClass < TestBase
|
|
|
|
|
|
|
|
|
|
def test_1
|
|
|
|
|
|
|
|
|
|
ly = RBA::Layout::new
|
|
|
|
|
ly.read(ENV["TESTSRC"] + "/testdata/gds/t11.gds")
|
|
|
|
|
|
|
|
|
|
q = RBA::LayoutQuery::new("select cell.name, cell.bbox from *")
|
|
|
|
|
res = []
|
|
|
|
|
q.each(ly) do |iter|
|
2020-03-28 22:31:19 +01:00
|
|
|
res << iter.data.map(&:to_s).join(", ")
|
2017-02-12 13:21:08 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
assert_equal(res.size, 2)
|
2020-03-28 22:31:19 +01:00
|
|
|
assert_equal(res[0], "TOPTOP, (0,0;32800,12800)")
|
|
|
|
|
assert_equal(res[1], "TOP, (0,0;900,900)")
|
2017-02-12 13:21:08 +01:00
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def test_2
|
|
|
|
|
|
|
|
|
|
ly = RBA::Layout::new
|
|
|
|
|
ly.read(ENV["TESTSRC"] + "/testdata/gds/t11.gds")
|
|
|
|
|
|
|
|
|
|
q = RBA::LayoutQuery::new("delete TOP")
|
|
|
|
|
q.execute(ly)
|
|
|
|
|
|
|
|
|
|
q = RBA::LayoutQuery::new("select cell.name, cell.bbox from *")
|
|
|
|
|
res = []
|
|
|
|
|
q.each(ly) do |iter|
|
2020-03-28 22:31:19 +01:00
|
|
|
res << iter.data.map(&:to_s).join(", ")
|
2017-02-12 13:21:08 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
assert_equal(res.size, 1)
|
2020-03-28 22:31:19 +01:00
|
|
|
assert_equal(res[0], "TOPTOP, ()")
|
2017-02-12 13:21:08 +01:00
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def test_3
|
|
|
|
|
|
|
|
|
|
q = RBA::LayoutQuery::new("delete TOP")
|
2022-02-11 19:12:57 +01:00
|
|
|
assert_equal(q.property_names.sort.join(","), "bbox,cell,cell_bbox,cell_dbbox,cell_index,cell_name,dbbox,hier_levels,initial_cell,initial_cell_index,initial_cell_name,inst,instances,path,path_dtrans,path_names,path_trans,references,shape,tot_weight,weight")
|
2017-02-12 13:21:08 +01:00
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
2019-07-28 01:33:30 +02:00
|
|
|
# variables
|
|
|
|
|
def test_4
|
|
|
|
|
|
|
|
|
|
ly = RBA::Layout::new
|
|
|
|
|
ly.read(ENV["TESTSRC"] + "/testdata/gds/t11.gds")
|
|
|
|
|
|
|
|
|
|
ctx = RBA::ExpressionContext::new
|
|
|
|
|
ctx.var("suffix", "!")
|
|
|
|
|
ctx.var("all", [])
|
2019-07-28 01:38:37 +02:00
|
|
|
ctx.var("nonmod", "")
|
2019-07-28 01:33:30 +02:00
|
|
|
|
|
|
|
|
q = RBA::LayoutQuery::new("select cell.name + suffix from *")
|
|
|
|
|
res = []
|
|
|
|
|
q.each(ly, ctx) do |iter|
|
|
|
|
|
res << iter.data.inspect
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
assert_equal(res.size, 2)
|
|
|
|
|
assert_equal(res[0], "[\"TOPTOP!\"]")
|
|
|
|
|
assert_equal(res[1], "[\"TOP!\"]")
|
|
|
|
|
|
2019-07-28 01:38:37 +02:00
|
|
|
q = RBA::LayoutQuery::new("with * do var nonmod = cell.name; all.push(nonmod)")
|
2019-07-28 01:33:30 +02:00
|
|
|
q.execute(ly, ctx)
|
|
|
|
|
|
|
|
|
|
assert_equal(ctx.eval("all").join(","), "TOPTOP,TOP")
|
2019-07-28 01:38:37 +02:00
|
|
|
# not modified, because we used "var nonmod" in the query which
|
|
|
|
|
# creates a local variable:
|
|
|
|
|
assert_equal(ctx.eval("nonmod"), "")
|
2019-07-28 01:33:30 +02:00
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
2017-02-12 13:21:08 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
load("test_epilogue.rb")
|
|
|
|
|
|