Class: TestML::Runtime::Unit
Instance Attribute Summary collapse
#base, #bridge, #compiler, #error, #function, #global, #library, #skip, #testml
Instance Method Summary
collapse
#apply_signature, #compile_testml, #get_label, #get_point, #initialize, #initialize_runtime, #lookup_callable, #read_testml_file, #replace_label, #run_assignment, #run_call, #run_expression, #run_function, #run_statement, #select_blocks
Instance Attribute Details
Returns the value of attribute planned.
14
15
16
|
# File 'lib/testml/runtime/unit.rb', line 14
def planned
@planned
end
|
Returns the value of attribute testcase.
13
14
15
|
# File 'lib/testml/runtime/unit.rb', line 13
def testcase
@testcase
end
|
Instance Method Details
#assert_EQ(got, want) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/testml/runtime/unit.rb', line 60
def assert_EQ(got, want)
got = got.value
want = want.value
if got != want
if want.match /\n/
File.open('/tmp/got', 'w') {|f| f.write got}
File.open('/tmp/want', 'w') {|f| f.write want}
STDERR.write(`diff -u /tmp/want /tmp/got`)
end
end
testcase.assert_equal want, got, get_label
end
|
#assert_HAS(got, has) ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/testml/runtime/unit.rb', line 74
def assert_HAS(got, has)
got = got.value
has = has.value
assertion = got.index(has)
if !assertion
msg = <<"..."
Failed TestML HAS (~~) assertion. This text:
'#{got}'
does not contain this string:
'#{has}'
...
STDERR.write(msg)
end
testcase.assert(assertion, get_label)
end
|
#assert_OK(got) ⇒ Object
90
91
92
|
# File 'lib/testml/runtime/unit.rb', line 90
def assert_OK(got)
testcase.assert(got.bool.value, get_label)
end
|
#check_plan ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/testml/runtime/unit.rb', line 29
def check_plan
if ! @planned
title
plan_begin
@planned = true
end
end
|
#plan_begin ⇒ Object
51
|
# File 'lib/testml/runtime/unit.rb', line 51
def plan_begin;end
|
53
54
55
56
57
58
|
# File 'lib/testml/runtime/unit.rb', line 53
def plan_end
if plan = @function.getvar('Plan')
count = @function.getvar('TestNumber').value
testcase.assert_equal plan.value.to_i, count, 'Tests Planned'
end
end
|
#run(unittest_testcase) ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/testml/runtime/unit.rb', line 16
def run(unittest_testcase)
@testcase = unittest_testcase
@planned = false
super()
check_plan
plan_end
end
|
#run_assertion(*args) ⇒ Object
24
25
26
27
|
# File 'lib/testml/runtime/unit.rb', line 24
def run_assertion(*args)
check_plan
super(*args)
end
|
#skip_test(reason) ⇒ Object
47
48
49
|
# File 'lib/testml/runtime/unit.rb', line 47
def skip_test(reason)
fail "TODO"
end
|
XXX Need to disable by default and provide a simple way to turn on.
38
39
40
41
42
43
44
45
|
# File 'lib/testml/runtime/unit.rb', line 38
def title
if title = @function.getvar('Title')
title = title.value
title = "\n=== #{title} ===\n"
end
end
|