File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,6 +11,12 @@ impl EmptyClass {
1111 fn new ( ) -> Self {
1212 EmptyClass { }
1313 }
14+
15+ fn method ( & self ) { }
16+
17+ fn __len__ ( & self ) -> usize {
18+ 0
19+ }
1420}
1521
1622/// This is for demonstrating how to return a value from __next__
Original file line number Diff line number Diff line change @@ -8,14 +8,38 @@ def test_empty_class_init(benchmark):
88 benchmark (pyclasses .EmptyClass )
99
1010
11+ def test_method_call (benchmark ):
12+ obj = pyclasses .EmptyClass ()
13+ assert benchmark (obj .method ) is None
14+
15+
16+ def test_proto_call (benchmark ):
17+ obj = pyclasses .EmptyClass ()
18+ assert benchmark (len , obj ) == 0
19+
20+
1121class EmptyClassPy :
12- pass
22+ def method (self ):
23+ pass
24+
25+ def __len__ (self ) -> int :
26+ return 0
1327
1428
1529def test_empty_class_init_py (benchmark ):
1630 benchmark (EmptyClassPy )
1731
1832
33+ def test_method_call_py (benchmark ):
34+ obj = EmptyClassPy ()
35+ assert benchmark (obj .method ) == pyclasses .EmptyClass ().method ()
36+
37+
38+ def test_proto_call_py (benchmark ):
39+ obj = EmptyClassPy ()
40+ assert benchmark (len , obj ) == len (pyclasses .EmptyClass ())
41+
42+
1943def test_iter ():
2044 i = pyclasses .PyClassIter ()
2145 assert next (i ) == 1
You can’t perform that action at this time.
0 commit comments