mirror of https://github.com/KLayout/klayout.git
Preparing tests for GSI class properties
This commit is contained in:
parent
05ba1743d7
commit
063040695a
|
|
@ -375,6 +375,18 @@ A *A::a20_get ()
|
|||
return a_inst.get ();
|
||||
}
|
||||
|
||||
static int s_sp = 0;
|
||||
|
||||
int A::sp_i_get ()
|
||||
{
|
||||
return s_sp;
|
||||
}
|
||||
|
||||
void A::sp_i_set (int v)
|
||||
{
|
||||
s_sp = v + 1;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// Implementation of B
|
||||
|
||||
|
|
@ -1253,6 +1265,8 @@ static gsi::Class<A> decl_a ("", "A",
|
|||
gsi::method ("a9b", &A::a9b) +
|
||||
gsi::method ("a20", &A::a20) +
|
||||
gsi::method ("a20_get", &A::a20_get) +
|
||||
gsi::method ("sp_i", &A::sp_i_get) +
|
||||
gsi::method ("sp_i=", &A::sp_i_set) +
|
||||
gsi::method ("to_s", &A::to_s) +
|
||||
gsi::iterator ("a6", &A::a6b, &A::a6e) +
|
||||
gsi::iterator ("a7", &A::a7b, &A::a7e) +
|
||||
|
|
|
|||
|
|
@ -415,6 +415,10 @@ struct A
|
|||
|
||||
std::string to_s () const;
|
||||
|
||||
// static (class) properties
|
||||
static int sp_i_get ();
|
||||
static void sp_i_set (int v);
|
||||
|
||||
// members
|
||||
std::vector<double> m_d;
|
||||
int n;
|
||||
|
|
|
|||
|
|
@ -149,6 +149,15 @@ class BasicTest(unittest.TestCase):
|
|||
|
||||
def test_00(self):
|
||||
|
||||
# does not work with all Python versions
|
||||
# (debugging shows that Python calls the setter on the metaclass,
|
||||
# not on the class itself at least on 3.12)
|
||||
# # static (class) properties
|
||||
# pya.A.sp_i = 17
|
||||
# self.assertEqual(pya.A.sp_i, 18)
|
||||
# pya.A.sp_i = -1
|
||||
# self.assertEqual(pya.A.sp_i, 0)
|
||||
|
||||
# all references of PA are released now:
|
||||
ic0 = pya.A.instance_count()
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,12 @@ class Basic_TestClass < TestBase
|
|||
# for testing the ut logger:
|
||||
puts "Special chars: <&>"
|
||||
|
||||
# static (class) properties
|
||||
RBA::A.sp_i = 17
|
||||
assert_equal( RBA::A.sp_i, 18 )
|
||||
RBA::A.sp_i = -1
|
||||
assert_equal( RBA::A.sp_i, 0 )
|
||||
|
||||
GC.start
|
||||
|
||||
# all references of A are released now:
|
||||
|
|
|
|||
Loading…
Reference in New Issue