-
Notifications
You must be signed in to change notification settings - Fork 1
/
UnitTest.ipf
executable file
·115 lines (91 loc) · 2.64 KB
/
UnitTest.ipf
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
#pragma rtGlobals=1 // Use modern global access method.
// UnitTest -- a component of IgorUnit
// This data type represents a single unit test
#ifndef IGORUNIT_UNITTEST
#define IGORUNIT_UNITTEST
Structure UnitTest
String groupname
String testname
String funcname
Variable index
String docstring
EndStructure
Function UnitTest_persist(test, to_dfref)
STRUCT UnitTest &test
DFREF to_dfref
Variable/G to_dfref:index = test.index
String/G to_dfref:groupname = test.groupname
String/G to_dfref:testname = test.testname
String/G to_dfref:funcname = test.funcname
String/G to_dfref:docstring = test.docstring
End
Function UnitTest_load(test, from_dfref)
STRUCT UnitTest &test
DFREF from_dfref
SVAR groupname = from_dfref:groupname
SVAR testname = from_dfref:testname
SVAR funcname = from_dfref:funcname
NVAR index = from_dfref:index
SVAR docstring = from_dfref:docstring
UnitTest_set(test, groupname, testname, funcname)
UnitTest_setIndex(test, index)
UnitTest_setDocString(test, docstring)
End
Function UnitTest_init(test, groupname, testname, funcname)
STRUCT UnitTest &test
String groupname, testname, funcname
UnitTest_set(test, groupname, testname, funcname)
test.docstring = ""
End
Function UnitTest_set(test, groupname, testname, funcname)
STRUCT UnitTest &test
String groupname, testname, funcname
test.groupname = groupname
test.testname = testname
test.funcname = funcname
End
Function UnitTest_setIndex(test, index)
STRUCT UnitTest &test
Variable index
test.index = index
End
Function UnitTest_setDocString(test, doc_str)
STRUCT UnitTest &test
String doc_str
test.docstring = doc_str
End
Function UnitTest_autosetDocString(test)
STRUCT UnitTest &test
String first_re = "^\\s*//[\\t ]*([^\\r]*)\\r?"
String doc_str = Func_getPostDocString(test.funcname)
test.docstring = String_getRegexMatch(doc_str, first_re)
End
Function UnitTest_getIndex(test)
STRUCT UnitTest &test
return test.index
End
Function/S UnitTest_getTestname(test)
STRUCT UnitTest &test
return test.testname
End
Function/S UnitTest_getGroupname(test)
STRUCT UnitTest &test
return test.groupname
End
Function/S UnitTest_getFuncname(test)
STRUCT UnitTest &test
return test.funcname
End
Function/S UnitTest_getDocString(test)
STRUCT UnitTest &test
return test.docstring
End
Function/S UnitTest_getFilename(test)
STRUCT UnitTest &test
return Func_getFilename(test.funcname)
End
Function UnitTest_getLineNumber(test)
STRUCT UnitTest &test
return Func_getLineNumber(test.funcname)
End
#endif