-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
docparverbatimmarkupparser_ut__define.pro
93 lines (73 loc) · 2.42 KB
/
docparverbatimmarkupparser_ut__define.pro
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
;+
; Test a simple three lines of text.
;
; :Returns: 1 for pass, 0 for fail
;-
function docparverbatimmarkupparser_ut::test_simple
compile_opt strictarr
code = ['This is a comment', 'Another comment', 'Last comment']
tree = self.parser->parse(code)
tree->getProperty, n_children=nChildren
assert, obj_isa(tree, 'MGtmTag'), 'wrong class for tree'
assert, nChildren eq 6, 'wrong number of children'
child = tree->getChild(0)
assert, obj_isa(child, 'MGtmText'), 'wrong class for child 0'
child->getProperty, text=text
assert, text eq code[0], 'wrong text for child 0'
child = tree->getChild(1)
assert, obj_isa(child, 'MGtmTag'), 'wrong class for child 1'
child->getProperty, type=type
assert, type eq 'newline', 'wrong type for child 1'
child = tree->getChild(2)
assert, obj_isa(child, 'MGtmText'), 'wrong class for child 2'
child->getProperty, text=text
assert, text eq code[1], 'wrong text for child 2'
child = tree->getChild(3)
assert, obj_isa(child, 'MGtmTag'), 'wrong class for child 3'
child->getProperty, type=type
assert, type eq 'newline', 'wrong type for child 3'
child = tree->getChild(4)
assert, obj_isa(child, 'MGtmText'), 'wrong class for child 4'
child->getProperty, text=text
assert, text eq code[2], 'wrong text for child 4'
child = tree->getChild(5)
assert, obj_isa(child, 'MGtmTag'), 'wrong class for child 5'
child->getProperty, type=type
assert, type eq 'newline', 'wrong type for child 5'
obj_destroy, tree
return, 1
end
;+
; Setup parser.
;-
pro docparverbatimmarkupparser_ut::setup
compile_opt strictarr
root = filepath('', $
subdir=['unit_tests', 'examples'], $
root=self.root)
output = filepath('', $
subdir=['unit_tests', 'examples-docs'], $
root=self.root)
self.system = obj_new('DOC_System', root=root, output=output, /silent)
self.parser = obj_new('DOCparVerbatimMarkupParser', system=self.system)
end
;+
; Free parser.
;-
pro docparverbatimmarkupparser_ut::teardown
compile_opt strictarr
obj_destroy, [self.system, self.parser]
end
;+
; Define instance variables.
;
; :Fields:
; `parser` verbatim parser to test
;-
pro docparverbatimmarkupparser_ut__define
compile_opt strictarr
define = { DOCparVerbatimMarkupParser_ut, inherits DOCutTestCase, $
system: obj_new(), $
parser: obj_new() $
}
end