-
Notifications
You must be signed in to change notification settings - Fork 5
/
pmlassert.pmlobj
176 lines (80 loc) · 3.19 KB
/
pmlassert.pmlobj
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
-- Copyright (c) 2019 Florian Zimmermann.
-- Licensed under the MIT License: https://opensource.org/licenses/MIT
define object PmlAssert
endobject
define method .equal(!left is Any, !right is Any)
!this.equal(!left, !right, 'Equality check failed.')
endmethod
define method .equal(!left is Any, !right is Any, !message is String)
!this.isTrue(!left eq !right, !message)
endmethod
define method .notEqual(!left is Any, !right is Any)
!this.notEqual(!left, !right, 'Inequality check failed.')
endmethod
define method .notEqual(!left is Any, !right is Any, !message is String)
!this.isTrue(!left ne !right, !message)
endmethod
define method .lessThan(!left is Any, !right is Any)
!this.lessThan(!left, !right, 'Less than check failed.')
endmethod
define method .lessThan(!left is Any, !right is Any, !message is String)
!this.isTrue(!left lt !right, !message)
endmethod
define method .lessThanOrEqual(!left is Any, !right is Any)
!this.lessThanOrEqual(!left, !right, 'Less than or equal check failed.')
endmethod
define method .lessThanOrEqual(!left is Any, !right is Any, !message is String)
!this.isTrue(!left le !right, !message)
endmethod
define method .greaterThanOrEqual(!left is Any, !right is Any)
!this.greaterThanOrEqual(!left, !right, 'Greater than or equal check failed.')
endmethod
define method .greaterThanOrEqual(!left is Any, !right is Any, !message is String)
!this.isTrue(!left ge !right, !message)
endmethod
define method .greaterThan(!left is Any, !right is Any)
!this.greaterThan(!left, !right, 'Greater than check failed.')
endmethod
define method .greaterThan(!left is Any, !right is Any, !message is String)
!this.isTrue(!left gt !right, !message)
endmethod
define method .isSet(!value is Any)
!this.isSet(!value, 'Value is not set.')
endmethod
define method .isSet(!value is Any, !message is String)
!this.isTrue(!value.set(), !message)
endmethod
define method .isUnset(!value is Any)
!this.isUnset(!value, 'Value is set.')
endmethod
define method .isUnset(!value is Any, !message is String)
!this.isTrue(!value.unset(), !message)
endmethod
define method .isTrue(!value is Boolean)
!this.isTrue(!value, 'Value is not true.')
endmethod
define method .isTrue(!value is Boolean, !message is String)
if (!value.unset() or not !value) then
!this.fail(!message)
endif
endmethod
define method .isFalse(!value is Boolean)
!this.isFalse(!value, 'Value is not false.')
endmethod
define method .isFalse(!value is Boolean, !message is String)
if (!value.unset() or !value) then
!this.fail(!message)
endif
endmethod
define method .instanceOf(!object is Any, !objectType is String)
!this.instanceOf(!object, !objectType, 'Expected object to be of type <$!<objectType>> but it is of type <' & !object.objectType() & '> instead.')
endmethod
define method .instanceOf(!object is Any, !objectType is String, !message is String)
!this.equal(!object.objectType(), !objectType, !message)
endmethod
define method .fail()
!this.fail('Test Failed.')
endmethod
define method .fail(!message is String)
!!messageFile.error(196, 1, !message)
endmethod