mirror of
https://github.com/KLayout/klayout.git
synced 2026-08-29 01:14:35 +02:00
Merge branch 'wip' into wip2
This commit is contained in:
Vendored
+502
@@ -0,0 +1,502 @@
|
||||
# KLayout Layout Viewer
|
||||
# Copyright (C) 2006-2023 Matthias Koefferlein
|
||||
#
|
||||
# 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
|
||||
|
||||
|
||||
import klayout.db
|
||||
import unittest
|
||||
import sys
|
||||
|
||||
class BoxPCell(klayout.db.PCellDeclaration):
|
||||
|
||||
def display_text(self, parameters):
|
||||
# provide a descriptive text for the cell
|
||||
return "Box(L=" + str(parameters[0]) + ",W=" + ('%.3f' % parameters[1]) + ",H=" + ('%.3f' % parameters[2]) + ")"
|
||||
|
||||
def get_parameters(self):
|
||||
|
||||
# prepare a set of parameter declarations
|
||||
param = []
|
||||
|
||||
param.append(klayout.db.PCellParameterDeclaration("l", klayout.db.PCellParameterDeclaration.TypeLayer, "Layer", klayout.db.LayerInfo(0, 0)))
|
||||
param.append(klayout.db.PCellParameterDeclaration("w", klayout.db.PCellParameterDeclaration.TypeDouble, "Width", 1.0))
|
||||
param.append(klayout.db.PCellParameterDeclaration("h", klayout.db.PCellParameterDeclaration.TypeDouble, "Height", 1.0))
|
||||
|
||||
return param
|
||||
|
||||
|
||||
def get_layers(self, parameters):
|
||||
return [ parameters[0] ]
|
||||
|
||||
def produce(self, layout, layers, parameters, cell):
|
||||
|
||||
dbu = layout.dbu
|
||||
|
||||
# fetch the parameters
|
||||
l = parameters[0]
|
||||
w = parameters[1] / layout.dbu
|
||||
h = parameters[2] / layout.dbu
|
||||
|
||||
# create the shape
|
||||
cell.shapes(layers[0]).insert(klayout.db.Box(-w / 2, -h / 2, w / 2, h / 2))
|
||||
|
||||
def can_create_from_shape(self, layout, shape, layer):
|
||||
return shape.is_box()
|
||||
|
||||
def transformation_from_shape(self, layout, shape, layer):
|
||||
return klayout.db.Trans(shape.box.center() - klayout.db.Point())
|
||||
|
||||
def parameters_from_shape(self, layout, shape, layer):
|
||||
return [ layout.get_info(layer), shape.box.width() * layout.dbu, shape.box.height() * layout.dbu ]
|
||||
|
||||
class PCellTestLib(klayout.db.Library):
|
||||
|
||||
def __init__(self):
|
||||
|
||||
# set the description
|
||||
self.description = "PCell test lib"
|
||||
|
||||
# create the PCell declarations
|
||||
self.layout().register_pcell("Box", BoxPCell())
|
||||
|
||||
sb_index = self.layout().add_cell("StaticBox")
|
||||
l10 = self.layout().insert_layer(klayout.db.LayerInfo(10, 0))
|
||||
sb_cell = self.layout().cell(sb_index)
|
||||
sb_cell.shapes(l10).insert(klayout.db.Box(0, 0, 100, 200))
|
||||
|
||||
# register us with the name "MyLib"
|
||||
self.register("PCellTestLib")
|
||||
|
||||
|
||||
# A PCell based on the declaration helper
|
||||
|
||||
class BoxPCell2(klayout.db.PCellDeclarationHelper):
|
||||
|
||||
def __init__(self):
|
||||
|
||||
super(BoxPCell2, self).__init__()
|
||||
|
||||
self.param("layer", self.TypeLayer, "Layer", default = klayout.db.LayerInfo(0, 0))
|
||||
self.param("width", self.TypeDouble, "Width", default = 1.0)
|
||||
self.param("height", self.TypeDouble, "Height", default = 1.0)
|
||||
|
||||
def display_text_impl(self):
|
||||
# provide a descriptive text for the cell
|
||||
return "Box2(L=" + str(self.layer) + ",W=" + ('%.3f' % self.width) + ",H=" + ('%.3f' % self.height) + ")"
|
||||
|
||||
def wants_lazy_evaluation(self):
|
||||
return True
|
||||
|
||||
def produce_impl(self):
|
||||
|
||||
dbu = self.layout.dbu
|
||||
|
||||
# fetch the parameters
|
||||
l = self.layer_layer
|
||||
w = self.width / self.layout.dbu
|
||||
h = self.height / self.layout.dbu
|
||||
|
||||
# create the shape
|
||||
self.cell.shapes(l).insert(klayout.db.Box(-w / 2, -h / 2, w / 2, h / 2))
|
||||
|
||||
def can_create_from_shape_impl(self):
|
||||
return self.shape.is_box()
|
||||
|
||||
def transformation_from_shape_impl(self):
|
||||
return klayout.db.Trans(self.shape.box.center() - klayout.db.Point())
|
||||
|
||||
def parameters_from_shape_impl(self):
|
||||
self.layer = self.layout.get_info(self.layer)
|
||||
self.width = self.shape.box.width() * self.layout.dbu
|
||||
self.height = self.shape.box.height() * self.layout.dbu
|
||||
|
||||
class PCellTestLib2(klayout.db.Library):
|
||||
|
||||
def __init__(self):
|
||||
|
||||
# set the description
|
||||
self.description = "PCell test lib2"
|
||||
|
||||
# create the PCell declarations
|
||||
self.layout().register_pcell("Box2", BoxPCell2())
|
||||
|
||||
# register us with the name "MyLib"
|
||||
self.register("PCellTestLib2")
|
||||
|
||||
|
||||
def inspect_LayerInfo(self):
|
||||
return "<" + str(self) + ">"
|
||||
|
||||
klayout.db.LayerInfo.__repr__ = inspect_LayerInfo
|
||||
|
||||
def find_layer(ly, lp):
|
||||
|
||||
for li in ly.layer_indices():
|
||||
if str(ly.get_info(li)) == lp:
|
||||
return li
|
||||
return None
|
||||
|
||||
|
||||
def nh(h):
|
||||
"""
|
||||
Returns a normalized hash representation
|
||||
"""
|
||||
v = []
|
||||
for k in sorted(h):
|
||||
v.append(repr(k) + ": " + repr(h[k]))
|
||||
return "{" + (", ".join(v)) + "}"
|
||||
|
||||
class DBPCellTests(unittest.TestCase):
|
||||
|
||||
def test_1(self):
|
||||
|
||||
# instantiate and register the library
|
||||
tl = PCellTestLib()
|
||||
|
||||
ly = klayout.db.Layout(True)
|
||||
ly.dbu = 0.01
|
||||
|
||||
li1 = find_layer(ly, "1/0")
|
||||
self.assertEqual(li1 == None, True)
|
||||
|
||||
ci1 = ly.add_cell("c1")
|
||||
c1 = ly.cell(ci1)
|
||||
|
||||
lib = klayout.db.Library.library_by_name("NoLib")
|
||||
self.assertEqual(lib == None, True)
|
||||
lib = klayout.db.Library.library_by_name("PCellTestLib")
|
||||
self.assertEqual(lib != None, True)
|
||||
pcell_decl = lib.layout().pcell_declaration("x")
|
||||
self.assertEqual(pcell_decl == None, True)
|
||||
pcell_decl = lib.layout().pcell_declaration("Box")
|
||||
self.assertEqual(pcell_decl != None, True)
|
||||
pcell_decl_id = lib.layout().pcell_id("Box")
|
||||
self.assertEqual(pcell_decl.id(), pcell_decl_id)
|
||||
self.assertEqual(":".join(lib.layout().pcell_names()), "Box")
|
||||
self.assertEqual(lib.layout().pcell_ids(), [ pcell_decl_id ])
|
||||
self.assertEqual(lib.layout().pcell_declaration(pcell_decl_id).id(), pcell_decl_id)
|
||||
|
||||
param = [ klayout.db.LayerInfo(1, 0) ] # rest is filled with defaults
|
||||
pcell_var_id = ly.add_pcell_variant(lib, pcell_decl_id, param)
|
||||
pcell_var = ly.cell(pcell_var_id)
|
||||
pcell_inst = c1.insert(klayout.db.CellInstArray(pcell_var_id, klayout.db.Trans()))
|
||||
self.assertEqual(pcell_var.layout().__repr__(), ly.__repr__())
|
||||
self.assertEqual(pcell_var.library().__repr__(), lib.__repr__())
|
||||
self.assertEqual(pcell_var.is_pcell_variant(), True)
|
||||
self.assertEqual(pcell_var.display_title(), "PCellTestLib.Box(L=1/0,W=1.000,H=1.000)")
|
||||
self.assertEqual(pcell_var.basic_name(), "Box")
|
||||
self.assertEqual(pcell_var.pcell_declaration().wants_lazy_evaluation(), False)
|
||||
self.assertEqual(c1.is_pcell_variant(), False)
|
||||
self.assertEqual(c1.is_pcell_variant(pcell_inst), True)
|
||||
self.assertEqual(pcell_var.pcell_id(), pcell_decl_id)
|
||||
self.assertEqual(pcell_var.pcell_library().__repr__(), lib.__repr__())
|
||||
self.assertEqual(pcell_var.pcell_parameters().__repr__(), "[<1/0>, 1.0, 1.0]")
|
||||
self.assertEqual(nh(pcell_var.pcell_parameters_by_name()), "{'h': 1.0, 'l': <1/0>, 'w': 1.0}")
|
||||
self.assertEqual(pcell_var.pcell_parameter("h").__repr__(), "1.0")
|
||||
self.assertEqual(c1.pcell_parameters(pcell_inst).__repr__(), "[<1/0>, 1.0, 1.0]")
|
||||
self.assertEqual(nh(c1.pcell_parameters_by_name(pcell_inst)), "{'h': 1.0, 'l': <1/0>, 'w': 1.0}")
|
||||
self.assertEqual(c1.pcell_parameter(pcell_inst, "h").__repr__(), "1.0")
|
||||
self.assertEqual(nh(pcell_inst.pcell_parameters_by_name()), "{'h': 1.0, 'l': <1/0>, 'w': 1.0}")
|
||||
self.assertEqual(pcell_inst["h"].__repr__(), "1.0")
|
||||
self.assertEqual(pcell_inst["i"].__repr__(), "None")
|
||||
self.assertEqual(pcell_inst.pcell_parameter("h").__repr__(), "1.0")
|
||||
self.assertEqual(pcell_var.pcell_declaration().__repr__(), pcell_decl.__repr__())
|
||||
self.assertEqual(c1.pcell_declaration(pcell_inst).__repr__(), pcell_decl.__repr__())
|
||||
self.assertEqual(pcell_inst.pcell_declaration().__repr__(), pcell_decl.__repr__())
|
||||
|
||||
pcell_inst.change_pcell_parameter("h", 2.0)
|
||||
self.assertEqual(nh(pcell_inst.pcell_parameters_by_name()), "{'h': 2.0, 'l': <1/0>, 'w': 1.0}")
|
||||
pcell_inst.set_property("abc", "a property")
|
||||
self.assertEqual(pcell_inst.property("abc").__repr__(), "'a property'")
|
||||
|
||||
c1.clear()
|
||||
|
||||
param = [ klayout.db.LayerInfo(1, 0), 5.0, 10.0 ]
|
||||
pcell_var_id = ly.add_pcell_variant(lib, pcell_decl_id, param)
|
||||
pcell_var = ly.cell(pcell_var_id)
|
||||
pcell_inst = c1.insert(klayout.db.CellInstArray(pcell_var_id, klayout.db.Trans()))
|
||||
self.assertEqual(pcell_var.layout().__repr__(), ly.__repr__())
|
||||
self.assertEqual(pcell_var.library().__repr__(), lib.__repr__())
|
||||
self.assertEqual(pcell_var.is_pcell_variant(), True)
|
||||
self.assertEqual(pcell_var.display_title(), "PCellTestLib.Box(L=1/0,W=5.000,H=10.000)")
|
||||
self.assertEqual(pcell_var.basic_name(), "Box")
|
||||
self.assertEqual(c1.is_pcell_variant(), False)
|
||||
self.assertEqual(c1.is_pcell_variant(pcell_inst), True)
|
||||
self.assertEqual(pcell_var.pcell_id(), pcell_decl_id)
|
||||
self.assertEqual(pcell_var.pcell_library().__repr__(), lib.__repr__())
|
||||
self.assertEqual(pcell_var.pcell_parameters().__repr__(), "[<1/0>, 5.0, 10.0]")
|
||||
self.assertEqual(c1.pcell_parameters(pcell_inst).__repr__(), "[<1/0>, 5.0, 10.0]")
|
||||
self.assertEqual(pcell_inst.pcell_parameters().__repr__(), "[<1/0>, 5.0, 10.0]")
|
||||
self.assertEqual(pcell_var.pcell_declaration().__repr__(), pcell_decl.__repr__())
|
||||
self.assertEqual(c1.pcell_declaration(pcell_inst).__repr__(), pcell_decl.__repr__())
|
||||
|
||||
li1 = find_layer(ly, "1/0")
|
||||
self.assertEqual(li1 != None, True)
|
||||
self.assertEqual(ly.is_valid_layer(li1), True)
|
||||
self.assertEqual(str(ly.get_info(li1)), "1/0")
|
||||
|
||||
lib_proxy_id = ly.add_lib_cell(lib, lib.layout().cell_by_name("StaticBox"))
|
||||
lib_proxy = ly.cell(lib_proxy_id)
|
||||
self.assertEqual(lib_proxy.display_title(), "PCellTestLib.StaticBox")
|
||||
self.assertEqual(lib_proxy.basic_name(), "StaticBox")
|
||||
self.assertEqual(lib_proxy.layout().__repr__(), ly.__repr__())
|
||||
self.assertEqual(lib_proxy.library().__repr__(), lib.__repr__())
|
||||
self.assertEqual(lib_proxy.is_pcell_variant(), False)
|
||||
self.assertEqual(lib.layout().cell(lib.layout().cell_by_name("StaticBox")).library().__repr__(), "None")
|
||||
|
||||
li2 = find_layer(ly, "10/0")
|
||||
self.assertEqual(li2 != None, True)
|
||||
|
||||
self.assertEqual(ly.begin_shapes(c1.cell_index(), li1).shape().__str__(), "box (-250,-500;250,500)")
|
||||
self.assertEqual(ly.begin_shapes(lib_proxy.cell_index(), li2).shape().__str__(), "box (0,0;10,20)")
|
||||
|
||||
param = { "w": 1, "h": 2 }
|
||||
c1.change_pcell_parameters(pcell_inst, param)
|
||||
self.assertEqual(ly.begin_shapes(c1.cell_index(), li1).shape().__str__(), "box (-50,-100;50,100)")
|
||||
|
||||
param = [ klayout.db.LayerInfo(1, 0), 5.0, 5.0 ]
|
||||
c1.change_pcell_parameters(pcell_inst, param)
|
||||
self.assertEqual(ly.begin_shapes(c1.cell_index(), li1).shape().__str__(), "box (-250,-250;250,250)")
|
||||
|
||||
pcell_inst.change_pcell_parameters({ "w": 2.0, "h": 10.0 })
|
||||
self.assertEqual(ly.begin_shapes(c1.cell_index(), li1).shape().__str__(), "box (-100,-500;100,500)")
|
||||
|
||||
pcell_inst.change_pcell_parameters([ klayout.db.LayerInfo(1, 0), 5.0, 5.0 ])
|
||||
self.assertEqual(ly.begin_shapes(c1.cell_index(), li1).shape().__str__(), "box (-250,-250;250,250)")
|
||||
|
||||
pcell_inst.change_pcell_parameter("w", 5.0)
|
||||
pcell_inst.change_pcell_parameter("h", 1.0)
|
||||
self.assertEqual(ly.begin_shapes(c1.cell_index(), li1).shape().__str__(), "box (-250,-50;250,50)")
|
||||
|
||||
c1.change_pcell_parameter(pcell_inst, "w", 10.0)
|
||||
c1.change_pcell_parameter(pcell_inst, "h", 2.0)
|
||||
self.assertEqual(ly.begin_shapes(c1.cell_index(), li1).shape().__str__(), "box (-500,-100;500,100)")
|
||||
|
||||
self.assertEqual(ly.cell(pcell_inst.cell_index).is_pcell_variant(), True)
|
||||
self.assertEqual(pcell_inst.is_pcell(), True)
|
||||
new_id = ly.convert_cell_to_static(pcell_inst.cell_index)
|
||||
self.assertEqual(new_id == pcell_inst.cell_index, False)
|
||||
self.assertEqual(ly.cell(new_id).is_pcell_variant(), False)
|
||||
param = [ klayout.db.LayerInfo(1, 0), 5.0, 5.0 ]
|
||||
c1.change_pcell_parameters(pcell_inst, param)
|
||||
self.assertEqual(ly.begin_shapes(c1.cell_index(), li1).shape().__str__(), "box (-250,-250;250,250)")
|
||||
pcell_inst.cell_index = new_id
|
||||
self.assertEqual(ly.begin_shapes(c1.cell_index(), li1).shape().__str__(), "box (-500,-100;500,100)")
|
||||
|
||||
l10 = ly.layer(10, 0)
|
||||
c1.shapes(l10).insert(klayout.db.Box(0, 10, 100, 210))
|
||||
l11 = ly.layer(11, 0)
|
||||
c1.shapes(l11).insert(klayout.db.Text("hello", klayout.db.Trans()))
|
||||
self.assertEqual(pcell_decl.can_create_from_shape(ly, ly.begin_shapes(c1.cell_index(), l11).shape(), l10), False)
|
||||
self.assertEqual(pcell_decl.can_create_from_shape(ly, ly.begin_shapes(c1.cell_index(), l10).shape(), l10), True)
|
||||
self.assertEqual(repr(pcell_decl.parameters_from_shape(ly, ly.begin_shapes(c1.cell_index(), l10).shape(), l10)), "[<10/0>, 1.0, 2.0]")
|
||||
self.assertEqual(str(pcell_decl.transformation_from_shape(ly, ly.begin_shapes(c1.cell_index(), l10).shape(), l10)), "r0 50,110")
|
||||
|
||||
|
||||
def test_1a(self):
|
||||
|
||||
if not "PCellDeclarationHelper" in klayout.db.__dict__:
|
||||
return
|
||||
|
||||
# instantiate and register the library
|
||||
tl = PCellTestLib2()
|
||||
|
||||
ly = klayout.db.Layout(True)
|
||||
ly.dbu = 0.01
|
||||
|
||||
li1 = find_layer(ly, "1/0")
|
||||
self.assertEqual(li1 == None, True)
|
||||
|
||||
ci1 = ly.add_cell("c1")
|
||||
c1 = ly.cell(ci1)
|
||||
|
||||
lib = klayout.db.Library.library_by_name("PCellTestLib2")
|
||||
self.assertEqual(lib != None, True)
|
||||
pcell_decl = lib.layout().pcell_declaration("Box2")
|
||||
|
||||
param = [ klayout.db.LayerInfo(1, 0) ] # rest is filled with defaults
|
||||
pcell_var_id = ly.add_pcell_variant(lib, pcell_decl.id(), param)
|
||||
pcell_var = ly.cell(pcell_var_id)
|
||||
pcell_inst = c1.insert(klayout.db.CellInstArray(pcell_var_id, klayout.db.Trans()))
|
||||
self.assertEqual(pcell_var.basic_name(), "Box2")
|
||||
self.assertEqual(pcell_var.pcell_parameters().__repr__(), "[<1/0>, 1.0, 1.0]")
|
||||
self.assertEqual(pcell_var.display_title(), "PCellTestLib2.Box2(L=1/0,W=1.000,H=1.000)")
|
||||
self.assertEqual(nh(pcell_var.pcell_parameters_by_name()), "{'height': 1.0, 'layer': <1/0>, 'width': 1.0}")
|
||||
self.assertEqual(pcell_var.pcell_parameter("height").__repr__(), "1.0")
|
||||
self.assertEqual(c1.pcell_parameters(pcell_inst).__repr__(), "[<1/0>, 1.0, 1.0]")
|
||||
self.assertEqual(nh(c1.pcell_parameters_by_name(pcell_inst)), "{'height': 1.0, 'layer': <1/0>, 'width': 1.0}")
|
||||
self.assertEqual(c1.pcell_parameter(pcell_inst, "height").__repr__(), "1.0")
|
||||
self.assertEqual(nh(pcell_inst.pcell_parameters_by_name()), "{'height': 1.0, 'layer': <1/0>, 'width': 1.0}")
|
||||
self.assertEqual(pcell_inst["height"].__repr__(), "1.0")
|
||||
self.assertEqual(pcell_inst.pcell_parameter("height").__repr__(), "1.0")
|
||||
self.assertEqual(pcell_var.pcell_declaration().__repr__(), pcell_decl.__repr__())
|
||||
self.assertEqual(c1.pcell_declaration(pcell_inst).__repr__(), pcell_decl.__repr__())
|
||||
self.assertEqual(pcell_inst.pcell_declaration().__repr__(), pcell_decl.__repr__())
|
||||
self.assertEqual(pcell_decl.wants_lazy_evaluation(), True)
|
||||
|
||||
li1 = find_layer(ly, "1/0")
|
||||
self.assertEqual(li1 == None, False)
|
||||
pcell_inst.change_pcell_parameter("height", 2.0)
|
||||
self.assertEqual(nh(pcell_inst.pcell_parameters_by_name()), "{'height': 2.0, 'layer': <1/0>, 'width': 1.0}")
|
||||
|
||||
self.assertEqual(ly.begin_shapes(c1.cell_index(), li1).shape().__str__(), "box (-50,-100;50,100)")
|
||||
|
||||
param = { "layer": klayout.db.LayerInfo(2, 0), "width": 2, "height": 1 }
|
||||
li2 = ly.layer(2, 0)
|
||||
c1.change_pcell_parameters(pcell_inst, param)
|
||||
self.assertEqual(ly.begin_shapes(c1.cell_index(), li2).shape().__str__(), "box (-100,-50;100,50)")
|
||||
|
||||
l10 = ly.layer(10, 0)
|
||||
c1.shapes(l10).insert(klayout.db.Box(0, 10, 100, 210))
|
||||
l11 = ly.layer(11, 0)
|
||||
c1.shapes(l11).insert(klayout.db.Text("hello", klayout.db.Trans()))
|
||||
self.assertEqual(pcell_decl.can_create_from_shape(ly, ly.begin_shapes(c1.cell_index(), l11).shape(), l10), False)
|
||||
self.assertEqual(pcell_decl.can_create_from_shape(ly, ly.begin_shapes(c1.cell_index(), l10).shape(), l10), True)
|
||||
self.assertEqual(repr(pcell_decl.parameters_from_shape(ly, ly.begin_shapes(c1.cell_index(), l10).shape(), l10)), "[<10/0>, 1.0, 2.0]")
|
||||
self.assertEqual(str(pcell_decl.transformation_from_shape(ly, ly.begin_shapes(c1.cell_index(), l10).shape(), l10)), "r0 50,110")
|
||||
|
||||
|
||||
def test_2(self):
|
||||
|
||||
# instantiate and register the library
|
||||
tl = PCellTestLib()
|
||||
|
||||
ly = klayout.db.Layout(True)
|
||||
ly.dbu = 0.01
|
||||
|
||||
ci1 = ly.add_cell("c1")
|
||||
c1 = ly.cell(ci1)
|
||||
|
||||
lib = klayout.db.Library.library_by_name("PCellTestLib")
|
||||
pcell_decl_id = lib.layout().pcell_id("Box")
|
||||
|
||||
param = [ klayout.db.LayerInfo(1, 0), 10.0, 2.0 ]
|
||||
pcell_var_id = ly.add_pcell_variant(lib, pcell_decl_id, param)
|
||||
pcell_var = ly.cell(pcell_var_id)
|
||||
pcell_inst = c1.insert(klayout.db.CellInstArray(pcell_var_id, klayout.db.Trans()))
|
||||
|
||||
li1 = find_layer(ly, "1/0")
|
||||
self.assertEqual(li1 != None, True)
|
||||
self.assertEqual(ly.is_valid_layer(li1), True)
|
||||
self.assertEqual(str(ly.get_info(li1)), "1/0")
|
||||
|
||||
self.assertEqual(pcell_inst.is_pcell(), True)
|
||||
|
||||
self.assertEqual(ly.begin_shapes(pcell_inst.cell_index, li1).shape().__str__(), "box (-500,-100;500,100)")
|
||||
pcell_inst.convert_to_static()
|
||||
self.assertEqual(pcell_inst.is_pcell(), False)
|
||||
self.assertEqual(ly.begin_shapes(pcell_inst.cell_index, li1).shape().__str__(), "box (-500,-100;500,100)")
|
||||
pcell_inst.convert_to_static()
|
||||
self.assertEqual(pcell_inst.is_pcell(), False)
|
||||
self.assertEqual(ly.begin_shapes(pcell_inst.cell_index, li1).shape().__str__(), "box (-500,-100;500,100)")
|
||||
|
||||
def test_3(self):
|
||||
|
||||
# instantiate and register the library
|
||||
tl = PCellTestLib()
|
||||
|
||||
ly = klayout.db.Layout(True)
|
||||
ly.dbu = 0.01
|
||||
|
||||
c1 = ly.create_cell("c1")
|
||||
|
||||
lib = klayout.db.Library.library_by_name("PCellTestLib")
|
||||
pcell_decl_id = lib.layout().pcell_id("Box")
|
||||
|
||||
param = { "w": 4.0, "h": 8.0, "l": klayout.db.LayerInfo(1, 0) }
|
||||
pcell_var_id = ly.add_pcell_variant(lib, pcell_decl_id, param)
|
||||
pcell_var = ly.cell(pcell_var_id)
|
||||
pcell_inst = c1.insert(klayout.db.CellInstArray(pcell_var_id, klayout.db.Trans()))
|
||||
|
||||
self.assertEqual(ly.begin_shapes(c1.cell_index(), ly.layer(1, 0)).shape().__str__(), "box (-200,-400;200,400)")
|
||||
|
||||
def test_4(self):
|
||||
|
||||
# instantiate and register the library
|
||||
tl = PCellTestLib()
|
||||
|
||||
lib = klayout.db.Library.library_by_name("PCellTestLib")
|
||||
pcell_decl_id = lib.layout().pcell_id("Box")
|
||||
|
||||
param = { "w": 4.0, "h": 8.0, "l": klayout.db.LayerInfo(1, 0) }
|
||||
pcell_var_id = lib.layout().add_pcell_variant(pcell_decl_id, param)
|
||||
|
||||
self.assertEqual(lib.layout().begin_shapes(pcell_var_id, lib.layout().layer(1, 0)).shape().__str__(), "box (-2000,-4000;2000,4000)")
|
||||
|
||||
def test_5(self):
|
||||
|
||||
# instantiate and register the library
|
||||
tl = PCellTestLib()
|
||||
|
||||
lib = klayout.db.Library.library_by_name("PCellTestLib")
|
||||
pcell_decl_id = lib.layout().pcell_id("Box")
|
||||
|
||||
param = { "w": 3.0, "h": 7.0, "l": klayout.db.LayerInfo(2, 0) }
|
||||
pcell_var_id = lib.layout().add_pcell_variant(pcell_decl_id, param)
|
||||
|
||||
self.assertEqual(lib.layout().begin_shapes(pcell_var_id, lib.layout().layer(2, 0)).shape().__str__(), "box (-1500,-3500;1500,3500)")
|
||||
|
||||
|
||||
def test_6(self):
|
||||
|
||||
# instantiate and register the library
|
||||
tl = PCellTestLib()
|
||||
|
||||
lib = klayout.db.Library.library_by_name("PCellTestLib")
|
||||
|
||||
param = { "w": 3.0, "h": 8.0, "l": klayout.db.LayerInfo(3, 0) }
|
||||
pcell_var = lib.layout().create_cell("Box", param)
|
||||
|
||||
self.assertEqual(lib.layout().begin_shapes(pcell_var.cell_index(), lib.layout().layer(3, 0)).shape().__str__(), "box (-1500,-4000;1500,4000)")
|
||||
|
||||
|
||||
def test_7(self):
|
||||
|
||||
# instantiate and register the library
|
||||
tl = PCellTestLib()
|
||||
|
||||
ly = klayout.db.Layout(True)
|
||||
ly.dbu = 0.01
|
||||
|
||||
param = { "w": 4.0, "h": 8.0, "l": klayout.db.LayerInfo(4, 0) }
|
||||
cell = ly.create_cell("Box", "PCellTestLib", param)
|
||||
|
||||
self.assertEqual(ly.begin_shapes(cell, ly.layer(4, 0)).shape().__str__(), "box (-200,-400;200,400)")
|
||||
|
||||
def test_8(self):
|
||||
|
||||
# instantiate and register the library
|
||||
tl = PCellTestLib()
|
||||
|
||||
lib = klayout.db.Library.library_by_name("PCellTestLib")
|
||||
ly = klayout.db.Layout(True)
|
||||
ly.dbu = 0.01
|
||||
|
||||
param = { "w": 2.0, "h": 6.0, "l": klayout.db.LayerInfo(5, 0) }
|
||||
pcell_var = lib.layout().create_cell("Box", param)
|
||||
pcell_var.name = "BOXVAR"
|
||||
|
||||
cell = ly.create_cell("BOXVAR", "PCellTestLib")
|
||||
|
||||
self.assertEqual(cell.begin_shapes_rec(ly.layer(5, 0)).shape().__str__(), "box (-100,-300;100,300)")
|
||||
|
||||
# run unit tests
|
||||
if __name__ == '__main__':
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(DBPCellTests)
|
||||
|
||||
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
|
||||
sys.exit(1)
|
||||
|
||||
Vendored
+48
-3
@@ -1400,10 +1400,55 @@ class BasicTest(unittest.TestCase):
|
||||
def f4():
|
||||
n[0] = n[0] + 2
|
||||
|
||||
n[0] = 0
|
||||
e.e0(f4)
|
||||
e.s1()
|
||||
self.assertEqual( 4, n[0] )
|
||||
self.assertEqual( 2, n[0] )
|
||||
|
||||
# remove event handler -> no events triggered anymore
|
||||
n[0] = 0
|
||||
e.e0 -= f4
|
||||
e.s1()
|
||||
self.assertEqual( 0, n[0] )
|
||||
|
||||
# adding again will re-activate it
|
||||
e.e0 += f4
|
||||
n[0] = 0
|
||||
e.s1()
|
||||
self.assertEqual( 2, n[0] )
|
||||
|
||||
# two events at once
|
||||
def f5():
|
||||
n[0] = n[0] + 10
|
||||
n[0] = 0
|
||||
e.e0 += f5
|
||||
e.s1()
|
||||
self.assertEqual( 12, n[0] )
|
||||
|
||||
# clearing events
|
||||
e.e0.clear()
|
||||
e.s1()
|
||||
n[0] = 0
|
||||
self.assertEqual( 0, n[0] )
|
||||
|
||||
# synonyms: add, connect
|
||||
e.e0.add(f4)
|
||||
e.e0.connect(f5)
|
||||
n[0] = 0
|
||||
e.s1()
|
||||
self.assertEqual( 12, n[0] )
|
||||
|
||||
# synonyms: remove, disconnect
|
||||
e.e0.disconnect(f4)
|
||||
n[0] = 0
|
||||
e.s1()
|
||||
self.assertEqual( 10, n[0] )
|
||||
n[0] = 0
|
||||
e.e0.remove(f5)
|
||||
e.s1()
|
||||
self.assertEqual( 0, n[0] )
|
||||
|
||||
# another signal
|
||||
e.s2()
|
||||
self.assertEqual( 100, n[1] )
|
||||
e.m = 1
|
||||
@@ -1975,11 +2020,11 @@ class BasicTest(unittest.TestCase):
|
||||
# Hint: QApplication creates some leaks (FT, GTK). Hence it must not be used in the leak_check case ..
|
||||
if not leak_check:
|
||||
a = pya.QCoreApplication.instance()
|
||||
self.assertEqual("<class 'pya.Application'>", str(type(a)))
|
||||
self.assertEqual("<class 'klayout.pyacore.Application'>", str(type(a)))
|
||||
qd = pya.QDialog()
|
||||
pya.QApplication.setActiveWindow(qd)
|
||||
self.assertEqual(repr(pya.QApplication.activeWindow), repr(qd))
|
||||
self.assertEqual("<class 'pya.QDialog'>", str(type(pya.QApplication.activeWindow)))
|
||||
self.assertEqual("<class 'klayout.pyacore.QDialog'>", str(type(pya.QApplication.activeWindow)))
|
||||
qd._destroy()
|
||||
self.assertEqual(repr(pya.QApplication.activeWindow), "None")
|
||||
|
||||
|
||||
Vendored
+54
@@ -0,0 +1,54 @@
|
||||
# KLayout Layout Viewer
|
||||
# Copyright (C) 2006-2023 Matthias Koefferlein
|
||||
#
|
||||
# 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
|
||||
|
||||
|
||||
import pya
|
||||
import unittest
|
||||
|
||||
class LAYObjectsTests(unittest.TestCase):
|
||||
|
||||
def test_1(self):
|
||||
|
||||
class MyBrowserSource(pya.BrowserSource):
|
||||
def get(self, url):
|
||||
next_url = "int:" + str(int(url.split(":")[1]) + 1)
|
||||
return f"This is {url}. <a href='{next_url}'>Goto next ({next_url})</a>"
|
||||
|
||||
dialog = pya.BrowserDialog()
|
||||
dialog.home = "int:0"
|
||||
dialog.source = MyBrowserSource()
|
||||
|
||||
dialog = pya.BrowserDialog()
|
||||
dialog.home = "int:0"
|
||||
dialog.source = MyBrowserSource()
|
||||
|
||||
self.assertEqual(True, True)
|
||||
|
||||
|
||||
# run unit tests
|
||||
if __name__ == '__main__':
|
||||
suite = unittest.TestSuite()
|
||||
# NOTE: Use this instead of loadTestsfromTestCase to select a specific test:
|
||||
# suite.addTest(BasicTest("test_26"))
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(LAYObjectsTests)
|
||||
|
||||
# Only runs with Application available
|
||||
if "Application" in pya.__all__ and not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
||||
Vendored
+75
@@ -649,6 +649,81 @@ class QtBindingTest(unittest.TestCase):
|
||||
self.assertEqual(item.background(0).color.green, 255)
|
||||
self.assertEqual(item.background(0).color.blue, 0)
|
||||
|
||||
def test_55(self):
|
||||
|
||||
# addWidget to QHBoxLayout keeps object managed
|
||||
window = pya.QDialog()
|
||||
layout = pya.QHBoxLayout(window)
|
||||
|
||||
w = pya.QPushButton()
|
||||
oid = str(w)
|
||||
layout.addWidget(w)
|
||||
self.assertEqual(str(layout.itemAt(0).widget()), oid)
|
||||
|
||||
# try to kill the object
|
||||
w = None
|
||||
|
||||
# still there
|
||||
w = layout.itemAt(0).widget()
|
||||
self.assertEqual(w._destroyed(), False)
|
||||
self.assertEqual(str(w), oid)
|
||||
|
||||
# killing the window kills the layout kills the widget
|
||||
window._destroy()
|
||||
self.assertEqual(window._destroyed(), True)
|
||||
self.assertEqual(layout._destroyed(), True)
|
||||
self.assertEqual(w._destroyed(), True)
|
||||
|
||||
def test_56(self):
|
||||
|
||||
# Creating QImage from binary data
|
||||
|
||||
bstr = b'\x01\x02\x03\x04\x11\x12\x13\x14\x21\x22\x33\x34' + b'\x31\x32\x33\x34\x41\x42\x43\x44\x51\x52\x53\x54' + b'\x61\x62\x63\x64\x71\x72\x73\x74\x81\x82\x83\x84' + b'\x91\x92\x93\x94\xa1\xa2\xa3\xa4\xb1\xb2\xb3\xb4'
|
||||
|
||||
image = pya.QImage(bstr, 3, 4, pya.QImage.Format_ARGB32)
|
||||
self.assertEqual("%08x" % image.pixel(0, 0), "04030201")
|
||||
self.assertEqual("%08x" % image.pixel(1, 0), "14131211")
|
||||
self.assertEqual("%08x" % image.pixel(0, 2), "64636261")
|
||||
|
||||
def test_57(self):
|
||||
|
||||
# QColor with string parameter (suppressing QLatin1String)
|
||||
|
||||
color = pya.QColor("blue")
|
||||
self.assertEqual(color.name(), "#0000ff")
|
||||
|
||||
def test_58(self):
|
||||
|
||||
# The various ways to refer to enums
|
||||
|
||||
self.assertEqual(pya.Qt.MouseButton(4).to_i(), 4)
|
||||
self.assertEqual(pya.Qt_MouseButton(4).to_i(), 4)
|
||||
self.assertEqual(pya.Qt_MouseButton(4).__int__(), 4)
|
||||
self.assertEqual(pya.Qt_MouseButton(4).__hash__(), 4)
|
||||
self.assertEqual(int(pya.Qt_MouseButton(4)), 4)
|
||||
self.assertEqual(str(pya.Qt_MouseButton(1)), "LeftButton")
|
||||
self.assertEqual(pya.Qt.MouseButton.LeftButton.to_i(), 1)
|
||||
self.assertEqual(pya.Qt_MouseButton.LeftButton.to_i(), 1)
|
||||
self.assertEqual(pya.Qt.LeftButton.to_i(), 1)
|
||||
self.assertEqual((pya.Qt_MouseButton.LeftButton | pya.Qt_MouseButton.RightButton).to_i(), 3)
|
||||
self.assertEqual(type(pya.Qt_MouseButton.LeftButton | pya.Qt_MouseButton.RightButton).__name__, "Qt_QFlags_MouseButton")
|
||||
self.assertEqual((pya.Qt.MouseButton.LeftButton | pya.Qt.MouseButton.RightButton).to_i(), 3)
|
||||
self.assertEqual(type(pya.Qt.MouseButton.LeftButton | pya.Qt.MouseButton.RightButton).__name__, "Qt_QFlags_MouseButton")
|
||||
self.assertEqual((pya.Qt.LeftButton | pya.Qt.RightButton).to_i(), 3)
|
||||
self.assertEqual(type(pya.Qt.LeftButton | pya.Qt.RightButton).__name__, "Qt_QFlags_MouseButton")
|
||||
|
||||
def test_59(self):
|
||||
|
||||
# Enums can act as hash keys
|
||||
|
||||
h = {}
|
||||
h[pya.Qt.MouseButton.LeftButton] = "left"
|
||||
h[pya.Qt.MouseButton.RightButton] = "right"
|
||||
self.assertEqual(pya.Qt.MouseButton.LeftButton in h, True)
|
||||
self.assertEqual(h[pya.Qt.MouseButton.LeftButton], "left")
|
||||
self.assertEqual(h[pya.Qt.MouseButton.RightButton], "right")
|
||||
self.assertEqual(pya.Qt.MouseButton.NoButton in h, False)
|
||||
|
||||
# run unit tests
|
||||
if __name__ == '__main__':
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(QtBindingTest)
|
||||
|
||||
Vendored
+45
-1
@@ -1325,11 +1325,55 @@ class Basic_TestClass < TestBase
|
||||
assert_equal( 2, n0 )
|
||||
|
||||
# using lambda
|
||||
n0 = 0
|
||||
p = lambda { n0 += 2 }
|
||||
e.e0(&p)
|
||||
e.s1
|
||||
assert_equal( 4, n0 )
|
||||
assert_equal( 2, n0 )
|
||||
|
||||
# remove event handler -> no events triggered anymore
|
||||
n0 = 0
|
||||
e.e0 -= p
|
||||
e.s1
|
||||
assert_equal( 0, n0 )
|
||||
|
||||
# adding again will re-activate it
|
||||
e.e0 += p
|
||||
n0 = 0
|
||||
e.s1
|
||||
assert_equal( 2, n0 )
|
||||
|
||||
# two events at once
|
||||
pp = lambda { n0 += 10 }
|
||||
n0 = 0
|
||||
e.e0 += pp
|
||||
e.s1
|
||||
assert_equal( 12, n0 )
|
||||
|
||||
# clearing events
|
||||
e.e0.clear
|
||||
e.s1
|
||||
n0 = 0
|
||||
assert_equal( 0, n0 )
|
||||
|
||||
# synonyms: add, connect
|
||||
e.e0.add(p)
|
||||
e.e0.connect(pp)
|
||||
n0 = 0
|
||||
e.s1
|
||||
assert_equal( 12, n0 )
|
||||
|
||||
# synonyms: remove, disconnect
|
||||
e.e0.disconnect(p)
|
||||
n0 = 0
|
||||
e.s1
|
||||
assert_equal( 10, n0 )
|
||||
n0 = 0
|
||||
e.e0.remove(pp)
|
||||
e.s1
|
||||
assert_equal( 0, n0 )
|
||||
|
||||
# another signal
|
||||
e.s2
|
||||
assert_equal( 100, n1 )
|
||||
e.m = 1
|
||||
|
||||
Vendored
+3
-2
@@ -183,8 +183,9 @@ class LAYLayoutView_TestClass < TestBase
|
||||
assert_equal(view.has_selection?, false)
|
||||
assert_equal(view.selection_size, 0)
|
||||
|
||||
view.set_config("search-range-box", "5")
|
||||
view.select_from(RBA::DBox::new(-1.0, -1.0, 1.0, 1.0))
|
||||
view.set_config("search-range-box", "0") # so the selection becomes independent from resolution and size
|
||||
view.set_config("search-range", "0")
|
||||
view.select_from(RBA::DBox::new(-2.5, -2.5, 2.5, 2.5))
|
||||
assert_equal(selection_changed, 1)
|
||||
assert_equal(view.selection_size, 2)
|
||||
assert_equal(view.has_selection?, true)
|
||||
|
||||
Vendored
+89
-4
@@ -272,21 +272,21 @@ class QtBinding_TestClass < TestBase
|
||||
label = RBA::QLabel::new(dialog)
|
||||
layout = RBA::QHBoxLayout::new(dialog)
|
||||
layout.addWidget(label)
|
||||
label.destroy
|
||||
label._destroy
|
||||
GC.start
|
||||
|
||||
dialog = RBA::QDialog::new(mw)
|
||||
label = RBA::QLabel::new(dialog)
|
||||
layout = RBA::QHBoxLayout::new(dialog)
|
||||
layout.addWidget(label)
|
||||
layout.destroy
|
||||
layout._destroy
|
||||
GC.start
|
||||
|
||||
dialog = RBA::QDialog::new(mw)
|
||||
label = RBA::QLabel::new(dialog)
|
||||
layout = RBA::QHBoxLayout::new(dialog)
|
||||
layout.addWidget(label)
|
||||
dialog.destroy
|
||||
dialog._destroy
|
||||
GC.start
|
||||
|
||||
dialog = RBA::QDialog::new(mw)
|
||||
@@ -740,7 +740,7 @@ class QtBinding_TestClass < TestBase
|
||||
img.save(buf, "PNG")
|
||||
|
||||
assert_equal(buf.data.size > 100, true)
|
||||
assert_equal(buf.data[0..7].inspect, "\"\\x89PNG\\r\\n\\x1A\\n\"")
|
||||
assert_equal(buf.data[0..7].unpack("C*"), [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a])
|
||||
|
||||
end
|
||||
|
||||
@@ -767,6 +767,91 @@ class QtBinding_TestClass < TestBase
|
||||
|
||||
end
|
||||
|
||||
def test_55
|
||||
|
||||
# addWidget to QHBoxLayout keeps object managed
|
||||
window = RBA::QDialog::new
|
||||
layout = RBA::QHBoxLayout::new(window)
|
||||
|
||||
w = RBA::QPushButton::new
|
||||
oid = w.object_id
|
||||
layout.addWidget(w)
|
||||
assert_equal(layout.itemAt(0).widget.object_id, oid)
|
||||
|
||||
# try to kill the object
|
||||
w = nil
|
||||
GC.start
|
||||
|
||||
# still there
|
||||
w = layout.itemAt(0).widget
|
||||
assert_equal(w._destroyed?, false)
|
||||
assert_equal(w.object_id, oid)
|
||||
|
||||
# killing the window kills the layout kills the widget
|
||||
window._destroy
|
||||
assert_equal(window._destroyed?, true)
|
||||
assert_equal(layout._destroyed?, true)
|
||||
assert_equal(w._destroyed?, true)
|
||||
|
||||
end
|
||||
|
||||
def test_56
|
||||
|
||||
# Creating QImage from binary data
|
||||
|
||||
bytes = [ 0x01, 0x02, 0x03, 0x04, 0x11, 0x12, 0x13, 0x14, 0x21, 0x22, 0x33, 0x34,
|
||||
0x31, 0x32, 0x33, 0x34, 0x41, 0x42, 0x43, 0x44, 0x51, 0x52, 0x53, 0x54,
|
||||
0x61, 0x62, 0x63, 0x64, 0x71, 0x72, 0x73, 0x74, 0x81, 0x82, 0x83, 0x84,
|
||||
0x91, 0x92, 0x93, 0x94, 0xa1, 0xa2, 0xa3, 0xa4, 0xb1, 0xb2, 0xb3, 0xb4 ].pack("C*")
|
||||
|
||||
image = RBA::QImage::new(bytes, 3, 4, RBA::QImage::Format_ARGB32)
|
||||
assert_equal("%08x" % image.pixel(0, 0), "04030201")
|
||||
assert_equal("%08x" % image.pixel(1, 0), "14131211")
|
||||
assert_equal("%08x" % image.pixel(0, 2), "64636261")
|
||||
|
||||
end
|
||||
|
||||
def test_57
|
||||
|
||||
# QColor with string parameter (suppressing QLatin1String)
|
||||
|
||||
color = RBA::QColor::new("blue")
|
||||
assert_equal(color.name(), "#0000ff")
|
||||
|
||||
end
|
||||
|
||||
def test_58
|
||||
|
||||
# The various ways to refer to enums
|
||||
|
||||
assert_equal(RBA::Qt::MouseButton::new(4).to_i, 4)
|
||||
assert_equal(RBA::Qt_MouseButton::new(4).to_i, 4)
|
||||
assert_equal(RBA::Qt_MouseButton::new(4).hash, 4)
|
||||
assert_equal(RBA::Qt_MouseButton::new(1).to_s, "LeftButton")
|
||||
assert_equal(RBA::Qt_MouseButton::LeftButton.to_i, 1)
|
||||
assert_equal(RBA::Qt::LeftButton.to_i, 1)
|
||||
assert_equal((RBA::Qt_MouseButton::LeftButton | RBA::Qt_MouseButton::RightButton).to_i, 3)
|
||||
assert_equal((RBA::Qt_MouseButton::LeftButton | RBA::Qt_MouseButton::RightButton).class.to_s, "RBA::Qt_QFlags_MouseButton")
|
||||
assert_equal((RBA::Qt::MouseButton::LeftButton | RBA::Qt::MouseButton::RightButton).to_i, 3)
|
||||
assert_equal((RBA::Qt::MouseButton::LeftButton | RBA::Qt::MouseButton::RightButton).class.to_s, "RBA::Qt_QFlags_MouseButton")
|
||||
assert_equal((RBA::Qt::LeftButton | RBA::Qt::RightButton).to_i, 3)
|
||||
assert_equal((RBA::Qt::LeftButton | RBA::Qt::RightButton).class.to_s, "RBA::Qt_QFlags_MouseButton")
|
||||
|
||||
end
|
||||
|
||||
def test_59
|
||||
|
||||
# Enums can act as hash keys
|
||||
|
||||
h = {}
|
||||
h[RBA::Qt::MouseButton::LeftButton] = "left"
|
||||
h[RBA::Qt::MouseButton::RightButton] = "right"
|
||||
assert_equal(h[RBA::Qt::MouseButton::LeftButton], "left")
|
||||
assert_equal(h[RBA::Qt::MouseButton::RightButton], "right")
|
||||
assert_equal(h[RBA::Qt::MouseButton::NoButton], nil)
|
||||
|
||||
end
|
||||
|
||||
def test_60
|
||||
|
||||
# findChild, findChildren
|
||||
|
||||
Reference in New Issue
Block a user