-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_forward_decl.py
43 lines (33 loc) · 1020 Bytes
/
test_forward_decl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from forward_decl import *
import unittest
# Define class to test the program
class TestBasicFunctionality(unittest.TestCase):
def test_local_fwref(self):
var2 = FwDecl()
var1 = OpaqueFwRef("var2")
var2 = "Hello"
self.assertIsNotNone(
var1.get_ref(),
"get_ref doesn't find the assigned object"
)
self.assertIs(
var1.get_ref(),
var2,
"get_ref doesn't find the correct object"
)
def test_class_fwref(self):
MyClass = FwDecl()
class MyClass:
clsReference = OpaqueFwRef("MyClass")
clsVar = "Hello"
self.assertIsNotNone(
MyClass.clsReference.get_ref(),
"get_ref doesn't find the assigned object"
)
self.assertIs(
MyClass.clsReference.get_ref().clsVar,
MyClass.clsVar,
"get_ref doesn't find the correct object"
)
if __name__ == '__main__':
unittest.main()