-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTypeTest.bb
More file actions
76 lines (61 loc) · 2.16 KB
/
Copy pathTypeTest.bb
File metadata and controls
76 lines (61 loc) · 2.16 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Strict
EnableGC
Type TestType
Field testVar$
Method create.TestType()
self\testVar = "test"
return self
End Method
End Type
Type SecondType.TestType
Field secondTestVar$
End Type
Type ConstructType
Field setField$
Method create.ConstructType(fieldToSet$)
self\setField = fieldToSet
return self
End Method
End Type
Test testTestVar()
Local testType1.TestType = new TestType()
Assert(testType1\testVar = "test")
End Test
Test testClassName()
Local testType1.TestType = new TestType()
Assert(testType1\className = "TestType")
Assert(testType1\className = TestType::className())
; If you call new TestType without () it will not be constructed and you will have to set className manually
End Test
Test testClassNameIntegrity()
Local testType1.SecondType = new SecondType()
Assert(testType1\className = "SecondType")
Local testType2.TestType = testType1
Assert(testType2\className = SecondType::className())
End Test
Test testRecastChecking()
Local testType1.SecondType = new SecondType()
Local testType2.TestType = testType1
If (NOT testType2\className = SecondType::className())
RuntimeError("Cannot cast to " + SecondType::className())
End If
Local testType3.SecondType = Recast.SecondType(testType2)
Assert(testType3\className = SecondType::className())
End Test
Test testConstructorArgs()
Local testType1.ConstructType = new ConstructType("testValue")
Assert(testType1\setField = "testValue")
; You can still call new ConstructType without () to skip construction and set the Type up the old way
End Test
Test testFindingClassName()
Local testType1.SecondType = new SecondType()
testType1\secondTestVar = "testValue"
Local typePointer@ = Ptr(testType1)
Assert(ObjectType(typePointer) = "SecondType")
Local castedType.TestType = Object.TestType(typePointer)
Local wrongType.ConstructType = Object.ConstructType(typePointer)
Assert(wrongType = Null)
Assert(castedType\className = "SecondType")
Local recastedType.SecondType = Recast.SecondType(castedType)
Assert(recastedType\secondTestVar = "testValue")
End Test