forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_testlib.lcb
More file actions
52 lines (36 loc) · 1.62 KB
/
_testlib.lcb
File metadata and controls
52 lines (36 loc) · 1.62 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
module com.livecode.__INTERNAL._testlib
use com.livecode.foreign
----------------------------------------------------------------
-- **EXPERIMENTAL** Helper functions for testing error states
----------------------------------------------------------------
public handler type Thunk() returns optional any
public handler MCUnitTestHandlerThrows(in pHandler as any, in pDescription as String) returns nothing
MCUnitTestHandlerThrowsImpl(pHandler, pDescription, false, "")
end handler
public handler MCUnitTestHandlerThrowsBroken(in pHandler as any, in pDescription as String, in pReason as String) returns nothing
MCUnitTestHandlerThrowsImpl(pHandler, pDescription, true, pReason)
end handler
----------------------------------------------------------------
foreign handler MCHandlerTryToInvokeWithList(in Handler as any, inout Arguments as optional List, out Result as optional any) returns optional any binds to "<builtin>"
handler MCUnitTestHandlerThrowsImpl(in pHandler as any, in pDescription as String, in pBroken as Boolean, in pReason as String) returns nothing
variable tHandler as Thunk
put pHandler into tHandler
variable tArgList as optional List
variable tResult as optional any
variable tMaybeError as optional any
put [] into tArgList
unsafe
put MCHandlerTryToInvokeWithList(tHandler, tArgList, tResult) into tMaybeError
end unsafe
variable tHasError as Boolean
put tMaybeError is not nothing into tHasError
if tHasError then
test diagnostic tMaybeError
end if
if pBroken then
broken test pDescription when tHasError because pReason
else
test pDescription when tHasError
end if
end handler
end module