diff --git a/src/gsi/unit_tests/gsiExpression.cc b/src/gsi/unit_tests/gsiExpression.cc index b2c42ba25..960c30c1a 100644 --- a/src/gsi/unit_tests/gsiExpression.cc +++ b/src/gsi/unit_tests/gsiExpression.cc @@ -157,6 +157,7 @@ TEST(1) v = e.parse ("var a=A.new; a.push_ev(Enum.a); a.push_ev(Enum.new); a.push_ev(Enum.b); a.ev").execute (); EXPECT_EQ (v.to_string (), std::string ("a,#0,b")); +#if defined(HAVE_QT) v = e.parse ("var a=A.new; a.get_ef").execute (); EXPECT_EQ (v.to_string (), std::string ("")); v = e.parse ("var a=A.new; a.set_ef(Enum.a); a.get_ef").execute (); @@ -204,6 +205,8 @@ TEST(1) v = e.parse ("var a=A.new; var ef=Enums.new(); a.mod_efref(ef, Enum.b); a.mod_efptr(ef, Enum.a); ef").execute (); EXPECT_EQ (v.to_string (), std::string ("a|b")); #endif +#endif + } TEST(2) diff --git a/src/pymod/unit_tests/pymod_tests.cc b/src/pymod/unit_tests/pymod_tests.cc index f816e4f3b..c456dfeb3 100644 --- a/src/pymod/unit_tests/pymod_tests.cc +++ b/src/pymod/unit_tests/pymod_tests.cc @@ -87,7 +87,7 @@ PYMODTEST (import_QtXmlPatterns, "import_QtXmlPatterns.py") #endif -#else +#elif defined(HAVE_QT) PYMODTEST (import_lay, "import_lay_noqt.py") diff --git a/testdata/python/basic.py b/testdata/python/basic.py index e458959e0..1fca4191e 100644 --- a/testdata/python/basic.py +++ b/testdata/python/basic.py @@ -184,15 +184,16 @@ class BasicTest(unittest.TestCase): self.assertEqual( a.a3("a"), 1 ) self.assertEqual( a.a3("ab"), 2 ) self.assertEqual( a.a3("µ"), 2 ) # two UTF8 bytes - self.assertEqual( a.a3_qstr("a"), 1 ) - self.assertEqual( a.a3_qstr("ab"), 2 ) - self.assertEqual( a.a3_qstr("µ"), 1 ) # one UTF character - self.assertEqual( a.a3_qstrref("a"), 1 ) - self.assertEqual( a.a3_qstrref("ab"), 2 ) - self.assertEqual( a.a3_qstrref("µ"), 1 ) # one UTF character - self.assertEqual( a.a3_qba("a"), 1 ) - self.assertEqual( a.a3_qba("ab"), 2 ) - self.assertEqual( a.a3_qba("µ"), 2 ) # two UTF8 bytes + if "a3_qstr" in a.__dict__: + self.assertEqual( a.a3_qstr("a"), 1 ) + self.assertEqual( a.a3_qstr("ab"), 2 ) + self.assertEqual( a.a3_qstr("µ"), 1 ) # one UTF character + self.assertEqual( a.a3_qstrref("a"), 1 ) + self.assertEqual( a.a3_qstrref("ab"), 2 ) + self.assertEqual( a.a3_qstrref("µ"), 1 ) # one UTF character + self.assertEqual( a.a3_qba("a"), 1 ) + self.assertEqual( a.a3_qba("ab"), 2 ) + self.assertEqual( a.a3_qba("µ"), 2 ) # two UTF8 bytes self.assertEqual( a.a3(""), 0 ) self.assertEqual( a.a4([1]), 1.0 ) @@ -303,84 +304,86 @@ class BasicTest(unittest.TestCase): self.assertEqual( eb < eb, False ) self.assertEqual( ea < eb, True ) - eea = pya.Enums() - eei = pya.Enums(3) - eeb = pya.Enums(eb) - self.assertEqual( str(eea), "" ) - self.assertEqual( repr(eea), " (0)" ) - self.assertEqual( repr(pya.Enums(str(eea))), " (0)" ) - self.assertEqual( repr(eei), "a|b (3)" ) - self.assertEqual( repr(pya.Enums(str(eei))), "a|b (3)" ) - self.assertEqual( repr(eeb), "b (2)" ) - self.assertEqual( repr(pya.Enums(str(eeb))), "b (2)" ) - eeab1 = ea | eb - eeab2 = ea | pya.Enums(eb) - eeab3 = pya.Enums(ea) | eb - eeab4 = pya.Enums(ea) | pya.Enums(eb) - self.assertEqual( repr(eeab1), "a|b (3)" ) - self.assertEqual( repr(eeab2), "a|b (3)" ) - self.assertEqual( repr(eeab3), "a|b (3)" ) - self.assertEqual( repr(eeab4), "a|b (3)" ) - # Note: unsigned enum's will produce the long int, signed enums will produce the short one - self.assertEqual( repr(~eeab4) == " (-4)" or repr(~eeab4) == " (4294967292)", True ) - self.assertEqual( repr(eeab4 & ea), "a (1)" ) - self.assertEqual( repr(eeab4 & eeb), "b (2)" ) - self.assertEqual( repr(eeab4 ^ eeb), "a (1)" ) - self.assertEqual( repr(eeab4 ^ eb), "a (1)" ) - self.assertEqual( repr(eeab4), "a|b (3)" ) - eeab4 ^= ea - self.assertEqual( repr(eeab4), "b (2)" ) + if "Enums" in pya.__dict__: - ee = pya.Enum() - self.assertEqual( str(ee), "#0" ) - a.mod_eref( ee, pya.Enum.c ) - self.assertEqual( str(ee), "c" ) - a.mod_eptr( ee, pya.Enum.a ) - self.assertEqual( str(ee), "a" ) + eea = pya.Enums() + eei = pya.Enums(3) + eeb = pya.Enums(eb) + self.assertEqual( str(eea), "" ) + self.assertEqual( repr(eea), " (0)" ) + self.assertEqual( repr(pya.Enums(str(eea))), " (0)" ) + self.assertEqual( repr(eei), "a|b (3)" ) + self.assertEqual( repr(pya.Enums(str(eei))), "a|b (3)" ) + self.assertEqual( repr(eeb), "b (2)" ) + self.assertEqual( repr(pya.Enums(str(eeb))), "b (2)" ) + eeab1 = ea | eb + eeab2 = ea | pya.Enums(eb) + eeab3 = pya.Enums(ea) | eb + eeab4 = pya.Enums(ea) | pya.Enums(eb) + self.assertEqual( repr(eeab1), "a|b (3)" ) + self.assertEqual( repr(eeab2), "a|b (3)" ) + self.assertEqual( repr(eeab3), "a|b (3)" ) + self.assertEqual( repr(eeab4), "a|b (3)" ) + # Note: unsigned enum's will produce the long int, signed enums will produce the short one + self.assertEqual( repr(~eeab4) == " (-4)" or repr(~eeab4) == " (4294967292)", True ) + self.assertEqual( repr(eeab4 & ea), "a (1)" ) + self.assertEqual( repr(eeab4 & eeb), "b (2)" ) + self.assertEqual( repr(eeab4 ^ eeb), "a (1)" ) + self.assertEqual( repr(eeab4 ^ eb), "a (1)" ) + self.assertEqual( repr(eeab4), "a|b (3)" ) + eeab4 ^= ea + self.assertEqual( repr(eeab4), "b (2)" ) - self.assertEqual( repr(a.ev()), "[]" ) - a.push_ev( pya.Enum.a ) - a.push_ev( pya.Enum() ) - a.push_ev( pya.Enum.b ) - self.assertEqual( repr(a.ev()), "[a (1), (not a valid enum value), b (2)]" ) + ee = pya.Enum() + self.assertEqual( str(ee), "#0" ) + a.mod_eref( ee, pya.Enum.c ) + self.assertEqual( str(ee), "c" ) + a.mod_eptr( ee, pya.Enum.a ) + self.assertEqual( str(ee), "a" ) - self.assertEqual( repr(a.get_ef()), " (0)" ) - a.set_ef( pya.Enum.a ) - self.assertEqual( str(a.get_ef()), "a" ) - a.set_ef( pya.Enums(pya.Enum.b) ) - self.assertEqual( str(a.get_ef()), "b" ) - a.set_efptr( None ) - self.assertEqual( repr(a.get_ef()), " (0)" ) - a.set_efptr( pya.Enums(pya.Enum.c) ) - self.assertEqual( str(a.get_ef()), "a|b|c" ) - a.set_efcptr( None ) - self.assertEqual( repr(a.get_ef()), " (0)" ) - a.set_efcptr( pya.Enums(pya.Enum.b) ) - self.assertEqual( str(a.get_ef()), "b" ) - a.set_efcptr( pya.Enum.c ) - self.assertEqual( str(a.get_ef()), "a|b|c" ) - a.set_efcref( pya.Enum.b ) - self.assertEqual( str(a.get_ef()), "b" ) - a.set_efcref( pya.Enums(pya.Enum.a) ) - self.assertEqual( str(a.get_ef()), "a" ) - a.set_efref( pya.Enums(pya.Enum.c) ) - self.assertEqual( str(a.get_ef()), "a|b|c" ) - self.assertEqual( str(a.get_efptr()), "a|b|c" ) - self.assertEqual( str(a.get_efref()), "a|b|c" ) - self.assertEqual( str(a.get_efcptr()), "a|b|c" ) - self.assertEqual( str(a.get_efcref()), "a|b|c" ) - a.set_efcptr( None ) - self.assertEqual( a.get_efcptr(), None ) - self.assertEqual( repr(a.get_efcref()), " (0)" ) - self.assertEqual( a.get_efptr(), None ) - self.assertEqual( repr(a.get_efref()), " (0)" ) + self.assertEqual( repr(a.ev()), "[]" ) + a.push_ev( pya.Enum.a ) + a.push_ev( pya.Enum() ) + a.push_ev( pya.Enum.b ) + self.assertEqual( repr(a.ev()), "[a (1), (not a valid enum value), b (2)]" ) - ee = pya.Enums() - self.assertEqual( repr(ee), " (0)" ) - a.mod_efref( ee, pya.Enum.b ) - self.assertEqual( str(ee), "b" ) - a.mod_efptr( ee, pya.Enum.a ) - self.assertEqual( str(ee), "a|b" ) + self.assertEqual( repr(a.get_ef()), " (0)" ) + a.set_ef( pya.Enum.a ) + self.assertEqual( str(a.get_ef()), "a" ) + a.set_ef( pya.Enums(pya.Enum.b) ) + self.assertEqual( str(a.get_ef()), "b" ) + a.set_efptr( None ) + self.assertEqual( repr(a.get_ef()), " (0)" ) + a.set_efptr( pya.Enums(pya.Enum.c) ) + self.assertEqual( str(a.get_ef()), "a|b|c" ) + a.set_efcptr( None ) + self.assertEqual( repr(a.get_ef()), " (0)" ) + a.set_efcptr( pya.Enums(pya.Enum.b) ) + self.assertEqual( str(a.get_ef()), "b" ) + a.set_efcptr( pya.Enum.c ) + self.assertEqual( str(a.get_ef()), "a|b|c" ) + a.set_efcref( pya.Enum.b ) + self.assertEqual( str(a.get_ef()), "b" ) + a.set_efcref( pya.Enums(pya.Enum.a) ) + self.assertEqual( str(a.get_ef()), "a" ) + a.set_efref( pya.Enums(pya.Enum.c) ) + self.assertEqual( str(a.get_ef()), "a|b|c" ) + self.assertEqual( str(a.get_efptr()), "a|b|c" ) + self.assertEqual( str(a.get_efref()), "a|b|c" ) + self.assertEqual( str(a.get_efcptr()), "a|b|c" ) + self.assertEqual( str(a.get_efcref()), "a|b|c" ) + a.set_efcptr( None ) + self.assertEqual( a.get_efcptr(), None ) + self.assertEqual( repr(a.get_efcref()), " (0)" ) + self.assertEqual( a.get_efptr(), None ) + self.assertEqual( repr(a.get_efref()), " (0)" ) + + ee = pya.Enums() + self.assertEqual( repr(ee), " (0)" ) + a.mod_efref( ee, pya.Enum.b ) + self.assertEqual( str(ee), "b" ) + a.mod_efptr( ee, pya.Enum.a ) + self.assertEqual( str(ee), "a|b" ) def test_12(self): @@ -401,9 +404,10 @@ class BasicTest(unittest.TestCase): self.assertEqual( a3.a1(), -11 ) self.assertEqual( a1.a10_d(5.2), "5.2" ) - self.assertEqual( a1.a10_d_qstr(5.25), "5.25" ) - self.assertEqual( a1.a10_d_qstrref(5.2), "5.2" ) - self.assertEqual( a1.a10_d_qba(5.1), "5.1" ) + if "a10_d_qstr" in a1.__dict__: + self.assertEqual( a1.a10_d_qstr(5.25), "5.25" ) + self.assertEqual( a1.a10_d_qstrref(5.2), "5.2" ) + self.assertEqual( a1.a10_d_qba(5.1), "5.1" ) self.assertEqual( a1.a10_f(5.7), "5.7" ) x = pya.Value(1.5) self.assertEqual( str(x.value), "1.5" ) @@ -2313,63 +2317,65 @@ class BasicTest(unittest.TestCase): b.set_ss([]) self.assertEqual(b.ss(), []) - v = [ "a", "b" ] - pya.B.push_qls(v, "x") - self.assertEqual(v, [ "a", "b", "x" ]) - b.set_qls([ "1" ]) - self.assertEqual(b.qls(), [ "1" ]) - b.set_qls([]) - self.assertEqual(b.qls(), []) + if "set_qls" in b.__dict__: - v = [ "a", 1 ] - pya.B.push_qlv(v, 2.5) - self.assertEqual(v, [ "a", 1, 2.5 ]) - b.set_qlv([ 17, "1" ]) - self.assertEqual(b.qlv(), [ 17, "1" ]) - b.set_qlv([]) - self.assertEqual(b.qlv(), []) + v = [ "a", "b" ] + pya.B.push_qls(v, "x") + self.assertEqual(v, [ "a", "b", "x" ]) + b.set_qls([ "1" ]) + self.assertEqual(b.qls(), [ "1" ]) + b.set_qls([]) + self.assertEqual(b.qls(), []) - v = [ "a", "b" ] - pya.B.push_qsl(v, "x") - self.assertEqual(v, [ "a", "b", "x" ]) - b.set_qsl([ "1" ]) - self.assertEqual(b.qsl(), [ "1" ]) - b.set_qsl([]) - self.assertEqual(b.qsl(), []) + v = [ "a", 1 ] + pya.B.push_qlv(v, 2.5) + self.assertEqual(v, [ "a", 1, 2.5 ]) + b.set_qlv([ 17, "1" ]) + self.assertEqual(b.qlv(), [ 17, "1" ]) + b.set_qlv([]) + self.assertEqual(b.qlv(), []) - v = [ "a", "b" ] - pya.B.push_qvs(v, "x") - self.assertEqual(v, [ "a", "b", "x" ]) - b.set_qvs([ "1" ]) - self.assertEqual(b.qvs(), [ "1" ]) - b.set_qvs([]) - self.assertEqual(b.qvs(), []) + v = [ "a", "b" ] + pya.B.push_qsl(v, "x") + self.assertEqual(v, [ "a", "b", "x" ]) + b.set_qsl([ "1" ]) + self.assertEqual(b.qsl(), [ "1" ]) + b.set_qsl([]) + self.assertEqual(b.qsl(), []) - v = [ "a", "b" ] - pya.B.push_qss(v, "x") - v_sorted = v - v_sorted.sort() - self.assertEqual(v_sorted, [ "a", "b", "x" ]) - b.set_qss([ "1" ]) - self.assertEqual(b.qss(), [ "1" ]) - b.set_qss([]) - self.assertEqual(b.qss(), []) + v = [ "a", "b" ] + pya.B.push_qvs(v, "x") + self.assertEqual(v, [ "a", "b", "x" ]) + b.set_qvs([ "1" ]) + self.assertEqual(b.qvs(), [ "1" ]) + b.set_qvs([]) + self.assertEqual(b.qvs(), []) - v = { 1: "a", 17: "b" } - pya.B.insert_qmap_is(v, 2, "x") - self.assertEqual(v, { 1: "a", 17: "b", 2: "x" }) - b.set_qmap_is({ 1: "t", 17: "b" }) - self.assertEqual(b.qmap_is(), { 1: "t", 17: "b" }) - b.set_qmap_is({}) - self.assertEqual(b.qmap_is(), {}) + v = [ "a", "b" ] + pya.B.push_qss(v, "x") + v_sorted = v + v_sorted.sort() + self.assertEqual(v_sorted, [ "a", "b", "x" ]) + b.set_qss([ "1" ]) + self.assertEqual(b.qss(), [ "1" ]) + b.set_qss([]) + self.assertEqual(b.qss(), []) - v = { 1: "a", 17: "b" } - pya.B.insert_qhash_is(v, 2, "x") - self.assertEqual(v, { 1: "a", 17: "b", 2: "x" }) - b.set_qhash_is({ 1: "t", 17: "b" }) - self.assertEqual(b.qhash_is(), { 1: "t", 17: "b" }) - b.set_qhash_is({}) - self.assertEqual(b.qhash_is(), {}) + v = { 1: "a", 17: "b" } + pya.B.insert_qmap_is(v, 2, "x") + self.assertEqual(v, { 1: "a", 17: "b", 2: "x" }) + b.set_qmap_is({ 1: "t", 17: "b" }) + self.assertEqual(b.qmap_is(), { 1: "t", 17: "b" }) + b.set_qmap_is({}) + self.assertEqual(b.qmap_is(), {}) + + v = { 1: "a", 17: "b" } + pya.B.insert_qhash_is(v, 2, "x") + self.assertEqual(v, { 1: "a", 17: "b", 2: "x" }) + b.set_qhash_is({ 1: "t", 17: "b" }) + self.assertEqual(b.qhash_is(), { 1: "t", 17: "b" }) + b.set_qhash_is({}) + self.assertEqual(b.qhash_is(), {}) def test_51(self): @@ -2390,6 +2396,9 @@ class BasicTest(unittest.TestCase): def test_60(self): + if not "SQ" in pya.__dict__: + return + class SignalCollector(object): got_s0 = False @@ -2483,6 +2492,9 @@ class BasicTest(unittest.TestCase): def test_61(self): + if not "SQ" in pya.__dict__: + return + class SignalCollector(object): got_s0a = 0 diff --git a/testdata/python/dbLayoutTest.py b/testdata/python/dbLayoutTest.py index 4377479f8..b31cefef1 100644 --- a/testdata/python/dbLayoutTest.py +++ b/testdata/python/dbLayoutTest.py @@ -310,7 +310,7 @@ class DBLayoutTest(unittest.TestCase): self.assertEqual( inst.nb, 20 ) self.assertEqual( inst.cell_index, c1.cell_index() ) - if( pya.Application.instance().is_editable() ): + if ly.is_editable(): for inst in c2.each_inst(): c2.erase( inst ) self.assertEqual( c2.bbox().to_s(), "()" ) @@ -566,7 +566,7 @@ class DBLayoutTest(unittest.TestCase): self.assertEqual( inst.nb, 20 ) self.assertEqual( inst.cell_index, c1.cell_index() ) - if( pya.Application.instance().is_editable() ): + if ly.is_editable(): for inst in c2.each_inst(): c2.erase( inst ) self.assertEqual( c2.bbox().to_s(), "()" ) @@ -727,9 +727,9 @@ class DBLayoutTest(unittest.TestCase): # Instances and bboxes (editable mode) def test_6_Layout_new(self): - if pya.Application.instance().is_editable(): + ly = pya.Layout() + if ly.is_editable(): - ly = pya.Layout() pv = { 17: "a", "b": [ 1, 5, 7 ] } pid1 = ly.properties_id( pv ) pv = { 100: "x" } @@ -831,11 +831,12 @@ class DBLayoutTest(unittest.TestCase): # Copy/move between cells def test_7_cells_copy_move(self): + ly1 = pya.Layout() + # because of set_property ... - if not pya.Application.instance().is_editable(): + if not ly1.is_editable(): return - ly1 = pya.Layout() la1 = ly1.insert_layer(pya.LayerInfo(1, 0)) lb1 = ly1.insert_layer(pya.LayerInfo(2, 0)) ly1.dbu = 0.001 @@ -1001,7 +1002,7 @@ class DBLayoutTest(unittest.TestCase): sv.append(i.to_s(True)) self.assertEqual(";".join(sv), "") - if pya.Application.instance().is_editable(): + if ly.is_editable(): i1.cell_index = ci3 diff --git a/testdata/python/dbPCells.py b/testdata/python/dbPCells.py index 27a80057b..26d2a31e7 100644 --- a/testdata/python/dbPCells.py +++ b/testdata/python/dbPCells.py @@ -81,57 +81,59 @@ class PCellTestLib(pya.Library): self.register("PCellTestLib") -# A PCell based on the declaration helper +if "PCellDeclarationHelper" in pya.__dict__: -class BoxPCell2(pya.PCellDeclarationHelper): + # A PCell based on the declaration helper - def __init__(self): + class BoxPCell2(pya.PCellDeclarationHelper): - super(BoxPCell2, self).__init__() - - self.param("layer", self.TypeLayer, "Layer", default = pya.LayerInfo(0, 0)) - self.param("width", self.TypeDouble, "Width", default = 1.0) - self.param("height", self.TypeDouble, "Height", default = 1.0) + def __init__(self): + + super(BoxPCell2, self).__init__() - 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 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 + self.param("layer", self.TypeLayer, "Layer", default = pya.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) + ")" - # create the shape - self.cell.shapes(l).insert(pya.Box(-w / 2, -h / 2, w / 2, h / 2)) + def produce_impl(self): - def can_create_from_shape_impl(self): - return self.shape.is_box() + dbu = self.layout.dbu - def transformation_from_shape_impl(self): - return pya.Trans(self.shape.box.center() - pya.Point()) + # 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(pya.Box(-w / 2, -h / 2, w / 2, h / 2)) + + def can_create_from_shape_impl(self): + return self.shape.is_box() - 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 + def transformation_from_shape_impl(self): + return pya.Trans(self.shape.box.center() - pya.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(pya.Library): + + def __init__(self): -class PCellTestLib2(pya.Library): + # set the description + self.description = "PCell test lib2" + + # create the PCell declarations + self.layout().register_pcell("Box2", BoxPCell2()) - 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") + # register us with the name "MyLib" + self.register("PCellTestLib2") def inspect_LayerInfo(self): @@ -304,6 +306,9 @@ class DBPCellTests(unittest.TestCase): def test_1a(self): + if not "PCellDeclarationHelper" in pya.__dict__: + return + # instantiate and register the library tl = PCellTestLib2() diff --git a/testdata/ruby/antTest.rb b/testdata/ruby/antTest.rb index 7e3901d44..17b8dd21a 100644 --- a/testdata/ruby/antTest.rb +++ b/testdata/ruby/antTest.rb @@ -155,6 +155,10 @@ class Ant_TestClass < TestBase # Annotation object def test_1 + if !RBA.constants.member?(:Application) + return + end + a = RBA::Annotation::new assert_equal( a.to_s, "p1=0,0, p2=0,0, fmt=$D, fmt_x=$X, fmt_y=$Y, style=ruler, outline=diag, snap=true, ac=global" ) @@ -387,6 +391,10 @@ class Ant_TestClass < TestBase # Test LayoutView integration def test_2 + if !RBA.constants.member?(:Application) + return + end + mw = RBA::Application::instance.main_window mw.close_all mw.create_layout( 0 ) @@ -459,6 +467,10 @@ class Ant_TestClass < TestBase # Test LayoutView integration with live updates def test_3 + if !RBA.constants.member?(:Application) + return + end + mw = RBA::Application::instance.main_window mw.close_all mw.create_layout( 0 ) diff --git a/testdata/ruby/basic_testcore.rb b/testdata/ruby/basic_testcore.rb index d671e5299..059d92e79 100644 --- a/testdata/ruby/basic_testcore.rb +++ b/testdata/ruby/basic_testcore.rb @@ -86,15 +86,17 @@ class Basic_TestClass < TestBase assert_equal( a.a3("a"), 1 ) assert_equal( a.a3("ab"), 2 ) assert_equal( a.a3("µ"), 2 ) # two UTF8 bytes - assert_equal( a.a3_qstr("a"), 1 ) - assert_equal( a.a3_qstr("ab"), 2 ) - assert_equal( a.a3_qstr("µ"), 1 ) # one UTF8 character - assert_equal( a.a3_qstrref("a"), 1 ) - assert_equal( a.a3_qstrref("ab"), 2 ) - assert_equal( a.a3_qstrref("µ"), 1 ) # one UTF8 character - assert_equal( a.a3_qba("a"), 1 ) - assert_equal( a.a3_qba("ab"), 2 ) - assert_equal( a.a3_qba("µ"), 2 ) # two UTF8 bytes + if a.respond_to?(:a3_qstr) + assert_equal( a.a3_qstr("a"), 1 ) + assert_equal( a.a3_qstr("ab"), 2 ) + assert_equal( a.a3_qstr("µ"), 1 ) # one UTF8 character + assert_equal( a.a3_qstrref("a"), 1 ) + assert_equal( a.a3_qstrref("ab"), 2 ) + assert_equal( a.a3_qstrref("µ"), 1 ) # one UTF8 character + assert_equal( a.a3_qba("a"), 1 ) + assert_equal( a.a3_qba("ab"), 2 ) + assert_equal( a.a3_qba("µ"), 2 ) # two UTF8 bytes + end assert_equal( a.a3(""), 0 ) assert_equal( a.a4([1]), 1.0 ) @@ -176,111 +178,115 @@ class Basic_TestClass < TestBase assert_equal( eb < eb, false ) assert_equal( ea < eb, true ) - eea = RBA::Enums::new - eei = RBA::Enums::new(3) - eeb = RBA::Enums::new(eb) - assert_equal( eea.to_s, "" ) - assert_equal( eea.inspect, " (0)" ) - assert_equal( RBA::Enums::new(eea.to_s).inspect, " (0)" ) - assert_equal( eei.inspect, "a|b (3)" ) - assert_equal( RBA::Enums::new(eei.to_s).inspect, "a|b (3)" ) - assert_equal( eeb.inspect, "b (2)" ) - assert_equal( RBA::Enums::new(eeb.to_s).inspect, "b (2)" ) - eeab1 = ea | eb - eeab2 = ea | RBA::Enums::new(eb) - eeab3 = RBA::Enums::new(ea) | eb - eeab4 = RBA::Enums::new(ea) | RBA::Enums::new(eb) - assert_equal( eeab1.inspect, "a|b (3)" ) - assert_equal( eeab2.inspect, "a|b (3)" ) - assert_equal( eeab3.inspect, "a|b (3)" ) - assert_equal( eeab4.inspect, "a|b (3)" ) - # Note: unsigned enum's will produce the long int, signed enums will produce the short one - assert_equal( (~eeab4).inspect == " (-4)" || (~eeab4).inspect == " (4294967292)", true ) - assert_equal( (eeab4 & ea).inspect, "a (1)" ) - assert_equal( (eeab4 & eeb).inspect, "b (2)" ) - assert_equal( (eeab4 ^ eeb).inspect, "a (1)" ) - assert_equal( (eeab4 ^ eb).inspect, "a (1)" ) - assert_equal( eeab4.inspect, "a|b (3)" ) - eeab4 ^= ea - assert_equal( eeab4.inspect, "b (2)" ) + if RBA.constants.member?(:Enums) - assert_equal( a.get_e.to_s, "#0" ) - a.set_e( RBA::Enum::a ) - assert_equal( a.get_e.to_s, "a" ) - a.set_e( RBA::Enum::b ) - assert_equal( a.get_e.to_s, "b" ) - a.set_eptr( nil ) - assert_equal( a.get_e.to_s, "#0" ) - a.set_eptr( RBA::Enum::c ) - assert_equal( a.get_e.to_s, "c" ) - a.set_ecptr( nil ) - assert_equal( a.get_e.to_s, "#0" ) - a.set_ecptr( RBA::Enum::b ) - assert_equal( a.get_e.to_s, "b" ) - a.set_ecref( RBA::Enum::a ) - assert_equal( a.get_e.to_s, "a" ) - a.set_eref( RBA::Enum::c ) - assert_equal( a.get_e.to_s, "c" ) - assert_equal( a.get_eptr.to_s, "c" ) - assert_equal( a.get_eref.to_s, "c" ) - assert_equal( a.get_ecptr.to_s, "c" ) - assert_equal( a.get_ecref.to_s, "c" ) - a.set_ecptr( nil ) - assert_equal( a.get_ecptr, nil ) - assert_equal( a.get_ecref.to_s, "#0" ) - assert_equal( a.get_eptr, nil ) - assert_equal( a.get_eref.to_s, "#0" ) + eea = RBA::Enums::new + eei = RBA::Enums::new(3) + eeb = RBA::Enums::new(eb) + assert_equal( eea.to_s, "" ) + assert_equal( eea.inspect, " (0)" ) + assert_equal( RBA::Enums::new(eea.to_s).inspect, " (0)" ) + assert_equal( eei.inspect, "a|b (3)" ) + assert_equal( RBA::Enums::new(eei.to_s).inspect, "a|b (3)" ) + assert_equal( eeb.inspect, "b (2)" ) + assert_equal( RBA::Enums::new(eeb.to_s).inspect, "b (2)" ) + eeab1 = ea | eb + eeab2 = ea | RBA::Enums::new(eb) + eeab3 = RBA::Enums::new(ea) | eb + eeab4 = RBA::Enums::new(ea) | RBA::Enums::new(eb) + assert_equal( eeab1.inspect, "a|b (3)" ) + assert_equal( eeab2.inspect, "a|b (3)" ) + assert_equal( eeab3.inspect, "a|b (3)" ) + assert_equal( eeab4.inspect, "a|b (3)" ) + # Note: unsigned enum's will produce the long int, signed enums will produce the short one + assert_equal( (~eeab4).inspect == " (-4)" || (~eeab4).inspect == " (4294967292)", true ) + assert_equal( (eeab4 & ea).inspect, "a (1)" ) + assert_equal( (eeab4 & eeb).inspect, "b (2)" ) + assert_equal( (eeab4 ^ eeb).inspect, "a (1)" ) + assert_equal( (eeab4 ^ eb).inspect, "a (1)" ) + assert_equal( eeab4.inspect, "a|b (3)" ) + eeab4 ^= ea + assert_equal( eeab4.inspect, "b (2)" ) - ee = RBA::Enum::new - assert_equal( ee.to_s, "#0" ) - a.mod_eref( ee, RBA::Enum::c ) - assert_equal( ee.to_s, "c" ) - a.mod_eptr( ee, RBA::Enum::a ) - assert_equal( ee.to_s, "a" ) + assert_equal( a.get_e.to_s, "#0" ) + a.set_e( RBA::Enum::a ) + assert_equal( a.get_e.to_s, "a" ) + a.set_e( RBA::Enum::b ) + assert_equal( a.get_e.to_s, "b" ) + a.set_eptr( nil ) + assert_equal( a.get_e.to_s, "#0" ) + a.set_eptr( RBA::Enum::c ) + assert_equal( a.get_e.to_s, "c" ) + a.set_ecptr( nil ) + assert_equal( a.get_e.to_s, "#0" ) + a.set_ecptr( RBA::Enum::b ) + assert_equal( a.get_e.to_s, "b" ) + a.set_ecref( RBA::Enum::a ) + assert_equal( a.get_e.to_s, "a" ) + a.set_eref( RBA::Enum::c ) + assert_equal( a.get_e.to_s, "c" ) + assert_equal( a.get_eptr.to_s, "c" ) + assert_equal( a.get_eref.to_s, "c" ) + assert_equal( a.get_ecptr.to_s, "c" ) + assert_equal( a.get_ecref.to_s, "c" ) + a.set_ecptr( nil ) + assert_equal( a.get_ecptr, nil ) + assert_equal( a.get_ecref.to_s, "#0" ) + assert_equal( a.get_eptr, nil ) + assert_equal( a.get_eref.to_s, "#0" ) - assert_equal( a.ev.inspect, "[]" ) - a.push_ev( RBA::Enum::a ) - a.push_ev( RBA::Enum::new ) - a.push_ev( RBA::Enum::b ) - assert_equal( a.ev.inspect, "[a (1), (not a valid enum value), b (2)]" ) + ee = RBA::Enum::new + assert_equal( ee.to_s, "#0" ) + a.mod_eref( ee, RBA::Enum::c ) + assert_equal( ee.to_s, "c" ) + a.mod_eptr( ee, RBA::Enum::a ) + assert_equal( ee.to_s, "a" ) - assert_equal( a.get_ef.inspect, " (0)" ) - a.set_ef( RBA::Enum::a ) - assert_equal( a.get_ef.to_s, "a" ) - a.set_ef( RBA::Enums::new(RBA::Enum::b) ) - assert_equal( a.get_ef.to_s, "b" ) - a.set_efptr( nil ) - assert_equal( a.get_ef.inspect, " (0)" ) - a.set_efptr( RBA::Enums::new(RBA::Enum::c) ) - assert_equal( a.get_ef.to_s, "a|b|c" ) - a.set_efcptr( nil ) - assert_equal( a.get_ef.inspect, " (0)" ) - a.set_efcptr( RBA::Enums::new(RBA::Enum::b) ) - assert_equal( a.get_ef.to_s, "b" ) - a.set_efcptr( RBA::Enum::c ) - assert_equal( a.get_ef.to_s, "a|b|c" ) - a.set_efcref( RBA::Enum::b ) - assert_equal( a.get_ef.to_s, "b" ) - a.set_efcref( RBA::Enums::new(RBA::Enum::a) ) - assert_equal( a.get_ef.to_s, "a" ) - a.set_efref( RBA::Enums::new(RBA::Enum::c) ) - assert_equal( a.get_ef.to_s, "a|b|c" ) - assert_equal( a.get_efptr.to_s, "a|b|c" ) - assert_equal( a.get_efref.to_s, "a|b|c" ) - assert_equal( a.get_efcptr.to_s, "a|b|c" ) - assert_equal( a.get_efcref.to_s, "a|b|c" ) - a.set_efcptr( nil ) - assert_equal( a.get_efcptr, nil ) - assert_equal( a.get_efcref.inspect, " (0)" ) - assert_equal( a.get_efptr, nil ) - assert_equal( a.get_efref.inspect, " (0)" ) + assert_equal( a.ev.inspect, "[]" ) + a.push_ev( RBA::Enum::a ) + a.push_ev( RBA::Enum::new ) + a.push_ev( RBA::Enum::b ) + assert_equal( a.ev.inspect, "[a (1), (not a valid enum value), b (2)]" ) - ee = RBA::Enums::new - assert_equal( ee.inspect, " (0)" ) - a.mod_efref( ee, RBA::Enum::b ) - assert_equal( ee.to_s, "b" ) - a.mod_efptr( ee, RBA::Enum::a ) - assert_equal( ee.to_s, "a|b" ) + assert_equal( a.get_ef.inspect, " (0)" ) + a.set_ef( RBA::Enum::a ) + assert_equal( a.get_ef.to_s, "a" ) + a.set_ef( RBA::Enums::new(RBA::Enum::b) ) + assert_equal( a.get_ef.to_s, "b" ) + a.set_efptr( nil ) + assert_equal( a.get_ef.inspect, " (0)" ) + a.set_efptr( RBA::Enums::new(RBA::Enum::c) ) + assert_equal( a.get_ef.to_s, "a|b|c" ) + a.set_efcptr( nil ) + assert_equal( a.get_ef.inspect, " (0)" ) + a.set_efcptr( RBA::Enums::new(RBA::Enum::b) ) + assert_equal( a.get_ef.to_s, "b" ) + a.set_efcptr( RBA::Enum::c ) + assert_equal( a.get_ef.to_s, "a|b|c" ) + a.set_efcref( RBA::Enum::b ) + assert_equal( a.get_ef.to_s, "b" ) + a.set_efcref( RBA::Enums::new(RBA::Enum::a) ) + assert_equal( a.get_ef.to_s, "a" ) + a.set_efref( RBA::Enums::new(RBA::Enum::c) ) + assert_equal( a.get_ef.to_s, "a|b|c" ) + assert_equal( a.get_efptr.to_s, "a|b|c" ) + assert_equal( a.get_efref.to_s, "a|b|c" ) + assert_equal( a.get_efcptr.to_s, "a|b|c" ) + assert_equal( a.get_efcref.to_s, "a|b|c" ) + a.set_efcptr( nil ) + assert_equal( a.get_efcptr, nil ) + assert_equal( a.get_efcref.inspect, " (0)" ) + assert_equal( a.get_efptr, nil ) + assert_equal( a.get_efref.inspect, " (0)" ) + + ee = RBA::Enums::new + assert_equal( ee.inspect, " (0)" ) + a.mod_efref( ee, RBA::Enum::b ) + assert_equal( ee.to_s, "b" ) + a.mod_efptr( ee, RBA::Enum::a ) + assert_equal( ee.to_s, "a|b" ) + + end end @@ -303,9 +309,11 @@ class Basic_TestClass < TestBase assert_equal( a3.a1, -11 ) assert_equal( a1.a10_d(5.2), "5.2" ) - assert_equal( a1.a10_d_qstr(5.25), "5.25" ) - assert_equal( a1.a10_d_qstrref(5.2), "5.2" ) - assert_equal( a1.a10_d_qba(5.1), "5.1" ) + if a1.respond_to?(:a10_d_qstr) + assert_equal( a1.a10_d_qstr(5.25), "5.25" ) + assert_equal( a1.a10_d_qstrref(5.2), "5.2" ) + assert_equal( a1.a10_d_qba(5.1), "5.1" ) + end assert_equal( a1.a10_f(5.7), "5.7" ) x = RBA::Value.new(1.5) assert_equal( x.value.to_s, "1.5" ) @@ -2212,61 +2220,65 @@ class Basic_TestClass < TestBase b.set_ss([]) assert_equal(b.ss, []) - v = [ "a", "b" ] - RBA::B::push_qls(v, "x") - assert_equal(v, [ "a", "b", "x" ]) - b.set_qls([ "1" ]) - assert_equal(b.qls, [ "1" ]) - b.set_qls([]) - assert_equal(b.qls, []) + if b.respond_to?(:set_qls) - v = [ "a", 1 ] - RBA::B::push_qlv(v, 2.5) - assert_equal(v, [ "a", 1, 2.5 ]) - b.set_qlv([ 17, "1" ]) - assert_equal(b.qlv, [ 17, "1" ]) - b.set_qlv([]) - assert_equal(b.qlv, []) + v = [ "a", "b" ] + RBA::B::push_qls(v, "x") + assert_equal(v, [ "a", "b", "x" ]) + b.set_qls([ "1" ]) + assert_equal(b.qls, [ "1" ]) + b.set_qls([]) + assert_equal(b.qls, []) - v = [ "a", "b" ] - RBA::B::push_qsl(v, "x") - assert_equal(v, [ "a", "b", "x" ]) - b.set_qsl([ "1" ]) - assert_equal(b.qsl, [ "1" ]) - b.set_qsl([]) - assert_equal(b.qsl, []) + v = [ "a", 1 ] + RBA::B::push_qlv(v, 2.5) + assert_equal(v, [ "a", 1, 2.5 ]) + b.set_qlv([ 17, "1" ]) + assert_equal(b.qlv, [ 17, "1" ]) + b.set_qlv([]) + assert_equal(b.qlv, []) - v = [ "a", "b" ] - RBA::B::push_qvs(v, "x") - assert_equal(v, [ "a", "b", "x" ]) - b.set_qvs([ "1" ]) - assert_equal(b.qvs, [ "1" ]) - b.set_qvs([]) - assert_equal(b.qvs, []) + v = [ "a", "b" ] + RBA::B::push_qsl(v, "x") + assert_equal(v, [ "a", "b", "x" ]) + b.set_qsl([ "1" ]) + assert_equal(b.qsl, [ "1" ]) + b.set_qsl([]) + assert_equal(b.qsl, []) - v = [ "a", "b" ] - RBA::B::push_qss(v, "x") - assert_equal(v.sort, [ "a", "b", "x" ]) - b.set_qss([ "1" ]) - assert_equal(b.qss, [ "1" ]) - b.set_qss([]) - assert_equal(b.qss, []) + v = [ "a", "b" ] + RBA::B::push_qvs(v, "x") + assert_equal(v, [ "a", "b", "x" ]) + b.set_qvs([ "1" ]) + assert_equal(b.qvs, [ "1" ]) + b.set_qvs([]) + assert_equal(b.qvs, []) - v = { 1 => "a", 17 => "b" } - RBA::B::insert_qmap_is(v, 2, "x") - assert_equal(v, { 1 => "a", 17 => "b", 2 => "x" }) - b.set_qmap_is({ 1 => "t", 17 => "b" }) - assert_equal(b.qmap_is, { 1 => "t", 17 => "b" }) - b.set_qmap_is({}) - assert_equal(b.qmap_is, {}) + v = [ "a", "b" ] + RBA::B::push_qss(v, "x") + assert_equal(v.sort, [ "a", "b", "x" ]) + b.set_qss([ "1" ]) + assert_equal(b.qss, [ "1" ]) + b.set_qss([]) + assert_equal(b.qss, []) - v = { 1 => "a", 17 => "b" } - RBA::B::insert_qhash_is(v, 2, "x") - assert_equal(v, { 1 => "a", 17 => "b", 2 => "x" }) - b.set_qhash_is({ 1 => "t", 17 => "b" }) - assert_equal(b.qhash_is, { 1 => "t", 17 => "b" }) - b.set_qhash_is({}) - assert_equal(b.qhash_is, {}) + v = { 1 => "a", 17 => "b" } + RBA::B::insert_qmap_is(v, 2, "x") + assert_equal(v, { 1 => "a", 17 => "b", 2 => "x" }) + b.set_qmap_is({ 1 => "t", 17 => "b" }) + assert_equal(b.qmap_is, { 1 => "t", 17 => "b" }) + b.set_qmap_is({}) + assert_equal(b.qmap_is, {}) + + v = { 1 => "a", 17 => "b" } + RBA::B::insert_qhash_is(v, 2, "x") + assert_equal(v, { 1 => "a", 17 => "b", 2 => "x" }) + b.set_qhash_is({ 1 => "t", 17 => "b" }) + assert_equal(b.qhash_is, { 1 => "t", 17 => "b" }) + b.set_qhash_is({}) + assert_equal(b.qhash_is, {}) + + end end @@ -2290,6 +2302,10 @@ class Basic_TestClass < TestBase end def test_60 + + if !RBA.constants.member?(:SQ) + return + end sq = RBA::SQ::new @@ -2353,6 +2369,10 @@ class Basic_TestClass < TestBase def test_61 + if !RBA.constants.member?(:SQ) + return + end + sq = RBA::SQ::new got_s0a = 0 diff --git a/testdata/ruby/dbGlyphs.rb b/testdata/ruby/dbGlyphs.rb index 2b389386a..429405073 100644 --- a/testdata/ruby/dbGlyphs.rb +++ b/testdata/ruby/dbGlyphs.rb @@ -29,6 +29,10 @@ class DBGlyph_TestClass < TestBase def test_1_Glyph tg = RBA::TextGenerator.default_generator + + # TODO: no default generator in non-Qt mode (no resources) + tg || return + assert_equal(tg.name, "std_font") assert_equal(tg.description, "Non-manhattan (0.6 x 0.8 um cell)") assert_equal(tg.width.to_s, "600") diff --git a/testdata/ruby/dbInstanceTest.rb b/testdata/ruby/dbInstanceTest.rb index 91a288597..33a771409 100644 --- a/testdata/ruby/dbInstanceTest.rb +++ b/testdata/ruby/dbInstanceTest.rb @@ -29,11 +29,7 @@ class DBInstance_TestClass < TestBase def test_1_InstEdit # this only works in editable mode - if ! RBA::Application::instance.is_editable? - return - end - - ly = RBA::Layout::new + ly = RBA::Layout::new(true) ci1 = ly.add_cell( "c1" ) ci2 = ly.add_cell( "c2" ) @@ -224,11 +220,7 @@ class DBInstance_TestClass < TestBase def test_2_InstEdit # this only works in editable mode - if ! RBA::Application::instance.is_editable? - return - end - - ly = RBA::Layout::new + ly = RBA::Layout::new(true) ci1 = ly.add_cell( "c1" ) ci2 = ly.add_cell( "c2" ) @@ -435,11 +427,7 @@ class DBInstance_TestClass < TestBase def test_4_InstFlatten # this only works in editable mode - if ! RBA::Application::instance.is_editable? - return - end - - ly = RBA::Layout::new + ly = RBA::Layout::new(true) ci1 = ly.add_cell( "c1" ) ci2 = ly.add_cell( "c2" ) @@ -502,11 +490,7 @@ class DBInstance_TestClass < TestBase def test_5_InstEdit_Double # this only works in editable mode - if ! RBA::Application::instance.is_editable? - return - end - - ly = RBA::Layout::new + ly = RBA::Layout::new(true) ci1 = ly.add_cell( "c1" ) ci2 = ly.add_cell( "c2" ) @@ -697,11 +681,7 @@ class DBInstance_TestClass < TestBase def test_6_InstEdit_Double # this only works in editable mode - if ! RBA::Application::instance.is_editable? - return - end - - ly = RBA::Layout::new + ly = RBA::Layout::new(true) ci1 = ly.add_cell( "c1" ) ci2 = ly.add_cell( "c2" ) diff --git a/testdata/ruby/dbLayout.rb b/testdata/ruby/dbLayout.rb index 902c0e4fa..9b100d8ba 100644 --- a/testdata/ruby/dbLayout.rb +++ b/testdata/ruby/dbLayout.rb @@ -1044,7 +1044,7 @@ END assert_equal(dump_layer(lll, 1, "c0"), "(0,100;1000,1200); (100,0;1100,1100)") # TODO: undo tests crashes in non-editable mode! Should be checked properly. - if RBA::Application::instance.is_editable? + if lll.is_editable? assert_equal(m.has_undo?, true) assert_equal(m.has_redo?, false) diff --git a/testdata/ruby/dbPCells.rb b/testdata/ruby/dbPCells.rb index 1f3e30950..124217264 100644 --- a/testdata/ruby/dbPCells.rb +++ b/testdata/ruby/dbPCells.rb @@ -97,67 +97,71 @@ class PCellTestLib < RBA::Library end -# A PCell based on the declaration helper +if RBA.constants.member?(:PCellDeclarationHelper) -class BoxPCell2 < RBA::PCellDeclarationHelper + # A PCell based on the declaration helper - def initialize + class BoxPCell2 < RBA::PCellDeclarationHelper - super() + def initialize - param("layer", BoxPCell2::TypeLayer, "Layer", :default => RBA::LayerInfo::new(0, 0)) - param("width", BoxPCell2::TypeDouble, "Width", :default => 1.0) - param("height", BoxPCell2::TypeDouble, "Height", :default => 1.0) + super() - end + param("layer", BoxPCell2::TypeLayer, "Layer", :default => RBA::LayerInfo::new(0, 0)) + param("width", BoxPCell2::TypeDouble, "Width", :default => 1.0) + param("height", BoxPCell2::TypeDouble, "Height", :default => 1.0) + + end + + def display_text_impl + # provide a descriptive text for the cell + return "Box2(L=" + layer.to_s + ",W=" + ('%.3f' % width) + ",H=" + ('%.3f' % height) + ")" + end - def display_text_impl - # provide a descriptive text for the cell - return "Box2(L=" + layer.to_s + ",W=" + ('%.3f' % width) + ",H=" + ('%.3f' % height) + ")" - end - - def produce_impl - - # fetch the parameters - l = layer_layer - w = width / layout.dbu - h = height / layout.dbu + def produce_impl - # create the shape - cell.shapes(l).insert(RBA::Box::new(-w / 2, -h / 2, w / 2, h / 2)) + # fetch the parameters + l = layer_layer + w = width / layout.dbu + h = height / layout.dbu + + # create the shape + cell.shapes(l).insert(RBA::Box::new(-w / 2, -h / 2, w / 2, h / 2)) + end + + def can_create_from_shape_impl + return self.shape.is_box? + end + + def transformation_from_shape_impl + return RBA::Trans::new(shape.box.center - RBA::Point::new) + end + + def parameters_from_shape_impl + # NOTE: because there is one parameter called "layer" already, we need to use + # the "_layer" fallback to access the argument to this method + set_layer(_layout.get_info(_layer)) + set_width(shape.box.width * _layout.dbu) + set_height(shape.box.height * _layout.dbu) + end + end + + class PCellTestLib2 < RBA::Library + + def initialize - def can_create_from_shape_impl - return self.shape.is_box? - end + # set the description + description = "PCell test lib2" + + # create the PCell declarations + layout.register_pcell("Box2", BoxPCell2::new) - def transformation_from_shape_impl - return RBA::Trans::new(shape.box.center - RBA::Point::new) - end + # register us with the name "MyLib" + self.register("PCellTestLib2") - def parameters_from_shape_impl - # NOTE: because there is one parameter called "layer" already, we need to use - # the "_layer" fallback to access the argument to this method - set_layer(_layout.get_info(_layer)) - set_width(shape.box.width * _layout.dbu) - set_height(shape.box.height * _layout.dbu) - end - -end - -class PCellTestLib2 < RBA::Library - - def initialize - - # set the description - description = "PCell test lib2" - - # create the PCell declarations - layout.register_pcell("Box2", BoxPCell2::new) - - # register us with the name "MyLib" - self.register("PCellTestLib2") + end end @@ -337,6 +341,10 @@ class DBPCell_TestClass < TestBase def test_1a + if !RBA.constants.member?(:PCellDeclarationHelper) + return + end + # instantiate and register the library tl = PCellTestLib2::new diff --git a/testdata/ruby/dbShapesTest.rb b/testdata/ruby/dbShapesTest.rb index d4eee02fd..9e8e77d92 100644 --- a/testdata/ruby/dbShapesTest.rb +++ b/testdata/ruby/dbShapesTest.rb @@ -592,11 +592,7 @@ class DBShapes_TestClass < TestBase # Shapes (edit) def test_7_LayoutEdit - if ! RBA::Application::instance.is_editable? - return - end - - ly = RBA::Layout::new + ly = RBA::Layout::new(true) ci1 = ly.add_cell( "c1" ) ci2 = ly.add_cell( "c2" ) @@ -741,11 +737,7 @@ class DBShapes_TestClass < TestBase # Shapes (edit, new methods) def test_7_LayoutEdit2 - if ! RBA::Application::instance.is_editable? - return - end - - ly = RBA::Layout::new + ly = RBA::Layout::new(true) ci1 = ly.add_cell( "c1" ) ci2 = ly.add_cell( "c2" ) @@ -951,11 +943,7 @@ class DBShapes_TestClass < TestBase # Shapes (edit, new methods) def test_7_DLayoutEdit2 - if ! RBA::Application::instance.is_editable? - return - end - - ly = RBA::Layout::new + ly = RBA::Layout::new(true) ci1 = ly.add_cell( "c1" ) ci2 = ly.add_cell( "c2" ) @@ -1161,11 +1149,7 @@ class DBShapes_TestClass < TestBase # Shapes (edit, new methods) def test_7_LayoutEdit3 - if ! RBA::Application::instance.is_editable? - return - end - - ly = RBA::Layout::new + ly = RBA::Layout::new(true) ci1 = ly.add_cell( "c1" ) ci2 = ly.add_cell( "c2" ) diff --git a/testdata/ruby/dbTilingProcessorTest.rb b/testdata/ruby/dbTilingProcessorTest.rb index 0ae4431a8..9f389d508 100644 --- a/testdata/ruby/dbTilingProcessorTest.rb +++ b/testdata/ruby/dbTilingProcessorTest.rb @@ -252,6 +252,10 @@ END def test_7 + if !RBA.constants.member?(:Image) + return + end + rin = RBA::Region::new rin.insert(RBA::Box::new(0, 0, 100, 200)) rin.insert(RBA::Box::new(9900, 9800, 10000, 10000)) diff --git a/testdata/ruby/edtTest.rb b/testdata/ruby/edtTest.rb index f36103d22..70a77f333 100644 --- a/testdata/ruby/edtTest.rb +++ b/testdata/ruby/edtTest.rb @@ -28,6 +28,10 @@ class EDT_TestClass < TestBase # ObjectInstPath def test_1 + if !RBA.constants.member?(:ObjectInstPath) + return + end + ly = RBA::Layout::new li = ly.insert_layer(RBA::LayerInfo::new(1, 0)) tc = ly.create_cell("TOP") @@ -110,6 +114,10 @@ class EDT_TestClass < TestBase # Selection def test_2 + if !RBA.constants.member?(:Application) + return + end + mw = RBA::Application::instance.main_window mw.close_all mw.create_layout( 0 ) diff --git a/testdata/ruby/imgObject.rb b/testdata/ruby/imgObject.rb index 70ce95292..d44f58eaa 100644 --- a/testdata/ruby/imgObject.rb +++ b/testdata/ruby/imgObject.rb @@ -27,6 +27,10 @@ class IMG_TestClass < TestBase def test_1 + if !RBA.constants.member?(:ImageDataMapping) + return + end + dm = RBA::ImageDataMapping.new dm.gamma = 0.5 assert_equal(dm.gamma, 0.5) @@ -62,6 +66,10 @@ class IMG_TestClass < TestBase def test_2 + if !RBA.constants.member?(:Image) + return + end + image = RBA::Image.new assert_equal(image.to_s, "empty:") assert_equal(image.is_empty?, true) @@ -181,6 +189,10 @@ class IMG_TestClass < TestBase def test_3 + if !RBA.constants.member?(:Image) + return + end + # compatibility with 0.21 d = [] 20000.times { d.push(0.0) } @@ -197,6 +209,10 @@ class IMG_TestClass < TestBase def test_4 + if !RBA.constants.member?(:Application) + return + end + mw = RBA::Application.instance.main_window mw.close_all mw.create_layout(0) diff --git a/testdata/ruby/layLayers.rb b/testdata/ruby/layLayers.rb index a623a6bcd..805a960a5 100644 --- a/testdata/ruby/layLayers.rb +++ b/testdata/ruby/layLayers.rb @@ -61,6 +61,10 @@ class LAYLayers_TestClass < TestBase def test_1 + if !RBA.constants.member?(:Application) + return + end + app = RBA::Application.instance mw = app.main_window mw.close_all @@ -213,6 +217,10 @@ class LAYLayers_TestClass < TestBase def test_1a + if !RBA.constants.member?(:Application) + return + end + app = RBA::Application.instance mw = app.main_window mw.close_all @@ -424,6 +432,10 @@ class LAYLayers_TestClass < TestBase def test_2 + if !RBA.constants.member?(:Application) + return + end + p = RBA::LayerPropertiesNode::new assert_equal( p.source( false ), "*/*@*" ) @@ -667,6 +679,10 @@ class LAYLayers_TestClass < TestBase # direct replacement of objects and attributes def test_3 + if !RBA.constants.member?(:Application) + return + end + app = RBA::Application.instance mw = app.main_window mw.close_all @@ -749,6 +765,10 @@ class LAYLayers_TestClass < TestBase # propagation of "real" attributes through the hierarchy def test_4 + if !RBA.constants.member?(:Application) + return + end + app = RBA::Application.instance mw = app.main_window mw.close_all @@ -786,6 +806,10 @@ class LAYLayers_TestClass < TestBase # delete method of iterator def test_5 + if !RBA.constants.member?(:Application) + return + end + app = RBA::Application.instance mw = app.main_window mw.close_all @@ -830,6 +854,10 @@ class LAYLayers_TestClass < TestBase # custom stipples and line styles def test_6 + if !RBA.constants.member?(:Application) + return + end + app = RBA::Application.instance mw = app.main_window mw.close_all diff --git a/testdata/ruby/layLayoutView.rb b/testdata/ruby/layLayoutView.rb index 206f77861..e06269044 100644 --- a/testdata/ruby/layLayoutView.rb +++ b/testdata/ruby/layLayoutView.rb @@ -39,6 +39,10 @@ class LAYLayoutView_TestClass < TestBase # Basic view creation and MainWindow events def test_1 + if !RBA.constants.member?(:Application) + return + end + app = RBA::Application.instance mw = app.main_window mw.close_all @@ -122,6 +126,10 @@ class LAYLayoutView_TestClass < TestBase def test_2 + if !RBA.constants.member?(:Application) + return + end + app = RBA::Application.instance mw = app.main_window mw.close_all diff --git a/testdata/ruby/layMarkers.rb b/testdata/ruby/layMarkers.rb index 115422df8..3ac7ec549 100644 --- a/testdata/ruby/layMarkers.rb +++ b/testdata/ruby/layMarkers.rb @@ -27,6 +27,10 @@ class LAYMarkers_TestClass < TestBase def test_1 + if !RBA.constants.member?(:Application) + return + end + app = RBA::Application.instance mw = app.main_window mw.create_layout(0) diff --git a/testdata/ruby/layMenuTest.rb b/testdata/ruby/layMenuTest.rb index e21592bf1..d504c981e 100644 --- a/testdata/ruby/layMenuTest.rb +++ b/testdata/ruby/layMenuTest.rb @@ -27,6 +27,10 @@ class LAYMenuTest_TestClass < TestBase def test_0 + if !RBA.constants.member?(:Action) + return + end + a = RBA::Action::new b = a.dup @@ -94,6 +98,10 @@ class LAYMenuTest_TestClass < TestBase def test_1 + if !RBA.constants.member?(:Application) + return + end + app = RBA::Application.instance mw = app.main_window menu = mw.menu @@ -261,21 +269,29 @@ RESULT end - class MenuHandler < RBA::Action - def initialize( t, k, &action ) - self.title = t - self.shortcut = k - @action = action + if RBA.constants.member?(:Action) + + class MenuHandler < RBA::Action + def initialize( t, k, &action ) + self.title = t + self.shortcut = k + @action = action + end + def triggered + @action.call( self ) + end + private + @action end - def triggered - @action.call( self ) - end - private - @action + end def test_2 + if !RBA.constants.member?(:Application) + return + end + app = RBA::Application.instance mw = app.main_window menu = mw.menu diff --git a/testdata/ruby/laySession.rb b/testdata/ruby/laySession.rb index 053bd016f..7a5e95ccd 100644 --- a/testdata/ruby/laySession.rb +++ b/testdata/ruby/laySession.rb @@ -45,6 +45,10 @@ class LAYSession_TestClass < TestBase def test_1 + if !RBA.constants.member?(:Application) + return + end + app = RBA::Application.instance mw = app.main_window mw.close_all diff --git a/testdata/ruby/rdbTest.rb b/testdata/ruby/rdbTest.rb index 72ebc74ca..f03238f10 100644 --- a/testdata/ruby/rdbTest.rb +++ b/testdata/ruby/rdbTest.rb @@ -422,10 +422,12 @@ class RDB_TestClass < TestBase assert_equal(item.has_tag?(db.tag_id("x1")), false) assert_equal(item.tags_str, "") - is="iVBORw0KGgoAAAANSUhEUgAAACoAAAA0CAIAAABzfT3nAAAAA3NCSVQICAjb4U/gAAAACXBIWXMAAA0SAAANOgHo3ZneAAAA3UlEQVRYhe2WwQ3DIAxFoco8XaGZIaeO43FyYgZYgYXcQ6SWuDGgBhWq/qccIvGCEd9SbAwAAPSGaW2lFR2rfWDpXrPpSe2SP10fvnn/PZHZH9IwbKFVZZ/Z6wMtZcjW02Bn2FVpZYdWdkr2nvh23S2FyDNJuVITpwmRjTGbNr0v20U5byNtJuuJt/fO2f93+UlbEJl5UjVPr3Y71EQ/PoPPlU+lDJtWlCt3GwCMG33BuJGAcWMEMG6c1jBudCyf/nzV8nbZPRohclFLHdGbZ8eNSjN1fmf0AACA1jwA4hKxu4C6P7EAAAAASUVORK5CYII=" - item.image_str=is - # Only the first 30 bytes count ... the remaining part is too different for different versions of Qt - assert_equal(item.image_str[0..30], is[0..30]) + if item.respond_to?(:image_str) + is="iVBORw0KGgoAAAANSUhEUgAAACoAAAA0CAIAAABzfT3nAAAAA3NCSVQICAjb4U/gAAAACXBIWXMAAA0SAAANOgHo3ZneAAAA3UlEQVRYhe2WwQ3DIAxFoco8XaGZIaeO43FyYgZYgYXcQ6SWuDGgBhWq/qccIvGCEd9SbAwAAPSGaW2lFR2rfWDpXrPpSe2SP10fvnn/PZHZH9IwbKFVZZ/Z6wMtZcjW02Bn2FVpZYdWdkr2nvh23S2FyDNJuVITpwmRjTGbNr0v20U5byNtJuuJt/fO2f93+UlbEJl5UjVPr3Y71EQ/PoPPlU+lDJtWlCt3GwCMG33BuJGAcWMEMG6c1jBudCyf/nzV8nbZPRohclFLHdGbZ8eNSjN1fmf0AACA1jwA4hKxu4C6P7EAAAAASUVORK5CYII=" + item.image_str=is + # Only the first 30 bytes count ... the remaining part is too different for different versions of Qt + assert_equal(item.image_str[0..30], is[0..30]) + end vs = RBA::RdbItemValue.new("a string") vs2 = RBA::RdbItemValue.new("a string (ii)") @@ -599,7 +601,9 @@ class RDB_TestClass < TestBase item.add_tag(db.tag_id("x1")) item.add_tag(db.user_tag_id("x2")) is="iVBORw0KGgoAAAANSUhEUgAAACoAAAA0CAIAAABzfT3nAAAAA3NCSVQICAjb4U/gAAAACXBIWXMAAA0SAAANOgHo3ZneAAAA3UlEQVRYhe2WwQ3DIAxFoco8XaGZIaeO43FyYgZYgYXcQ6SWuDGgBhWq/qccIvGCEd9SbAwAAPSGaW2lFR2rfWDpXrPpSe2SP10fvnn/PZHZH9IwbKFVZZ/Z6wMtZcjW02Bn2FVpZYdWdkr2nvh23S2FyDNJuVITpwmRjTGbNr0v20U5byNtJuuJt/fO2f93+UlbEJl5UjVPr3Y71EQ/PoPPlU+lDJtWlCt3GwCMG33BuJGAcWMEMG6c1jBudCyf/nzV8nbZPRohclFLHdGbZ8eNSjN1fmf0AACA1jwA4hKxu4C6P7EAAAAASUVORK5CYII=" - item.image_str=is + if item.respond_to?(:image_str) + item.image_str=is + end tmp = File::join($ut_testtmp, "tmp.lyrdb") @@ -635,7 +639,9 @@ class RDB_TestClass < TestBase assert_equal(ii[0].has_tag?(db2.tag_id("x1")), true) assert_equal(ii[0].has_tag?(db2.tag_id("x")), false) # Only the first 30 bytes count ... the remaining part is too different for different versions of Qt - assert_equal(ii[0].image_str[0..30], is[0..30]) + if ii[0].respond_to?(:image_str) + assert_equal(ii[0].image_str[0..30], is[0..30]) + end assert_equal(db2.cell_by_id(ii[0].cell_id).qname, "cell_name") assert_equal(db2.category_by_id(ii[0].category_id).path, "cat") vs = "" @@ -656,6 +662,10 @@ class RDB_TestClass < TestBase # LayoutView def test_10 + if !RBA.constants.member?(:Application) + return + end + mw = RBA::Application.instance.main_window mw.create_layout(1) view = mw.current_view