qed 2.6.3 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.ruby +4 -3
- data/.yardopts +3 -0
- data/HISTORY.rdoc +71 -35
- data/README.rdoc +9 -10
- data/bin/qed +1 -1
- data/bin/qedoc +2 -1
- data/lib/qed.rb +2 -5
- data/lib/qed.yml +4 -3
- data/lib/qed/applique.rb +57 -24
- data/lib/qed/cli.rb +8 -0
- data/lib/qed/cli/qed.rb +124 -0
- data/lib/qed/demo.rb +35 -39
- data/lib/qed/document.rb +5 -3
- data/lib/qed/document/template.rhtml +1 -0
- data/lib/qed/evaluator.rb +227 -199
- data/lib/qed/parser.rb +60 -282
- data/lib/qed/reporter/abstract.rb +54 -58
- data/lib/qed/reporter/dotprogress.rb +6 -4
- data/lib/qed/reporter/html.rb +112 -31
- data/lib/qed/reporter/tapy.rb +95 -125
- data/lib/qed/reporter/verbatim.rb +80 -38
- data/lib/qed/scope.rb +35 -48
- data/lib/qed/session.rb +35 -140
- data/lib/qed/settings.rb +104 -67
- data/lib/qed/step.rb +237 -0
- data/{spec → qed}/01_demos.rdoc +0 -0
- data/{spec → qed}/02_advice.rdoc +18 -7
- data/qed/03_helpers.rdoc +44 -0
- data/{spec → qed}/04_samples.rdoc +4 -4
- data/{spec → qed}/05_quote.rdoc +3 -3
- data/{spec → qed}/07_toplevel.rdoc +0 -0
- data/{spec → qed}/08_cross_script.rdoc +0 -0
- data/{spec → qed}/09_cross_script.rdoc +0 -0
- data/{spec → qed}/10_constant_lookup.rdoc +2 -2
- data/qed/11_embedded_rules.rdoc +46 -0
- data/{test/integration/topcode.rdoc → qed/99_issues/02_topcode.rdoc} +0 -0
- data/{spec → qed}/applique/constant.rb +0 -0
- data/{spec → qed}/applique/env.rb +0 -0
- data/{spec → qed}/applique/fileutils.rb +0 -0
- data/{spec → qed}/applique/markup.rb +0 -0
- data/{spec → qed}/applique/toplevel.rb +0 -0
- data/{spec → qed}/helpers/advice.rb +6 -7
- data/{spec → qed}/helpers/toplevel.rb +0 -0
- data/{spec → qed}/samples/data.txt +0 -0
- data/{spec → qed}/samples/table.yml +0 -0
- metadata +44 -39
- data/LICENSE.rdoc +0 -31
- data/SPECSHEET.rdoc +0 -456
- data/lib/qed/advice.rb +0 -158
- data/lib/qed/reporter/bullet.rb +0 -91
- data/lib/qed/reporter/dtrace.rb +0 -67
- data/lib/yard-qed.rb +0 -1
- data/spec/03_helpers.rdoc +0 -43
- data/spec/applique/quote.rb +0 -4
- data/spec/helpers/sample.rb +0 -4
data/lib/qed/advice.rb
DELETED
@@ -1,158 +0,0 @@
|
|
1
|
-
raise "no needed any more"
|
2
|
-
|
3
|
-
require 'qed/core_ext'
|
4
|
-
|
5
|
-
module QED
|
6
|
-
|
7
|
-
# = Advice
|
8
|
-
#
|
9
|
-
# This class tracks advice defined by demonstrandum and applique.
|
10
|
-
# Advice are evaluated in Scope, so that they will have access
|
11
|
-
# to the same local binding as the scripts themselves.
|
12
|
-
#
|
13
|
-
# There are two types of advice: *pattern matchers*
|
14
|
-
# and *event signals*.
|
15
|
-
#
|
16
|
-
# == Pattern Matchers (When)
|
17
|
-
#
|
18
|
-
# Matchers are evaluated when they match a description.
|
19
|
-
#
|
20
|
-
# == Event Signals (Before, After)
|
21
|
-
#
|
22
|
-
# Event advice are triggered on symbolic targets which
|
23
|
-
# represent an event in the evaluation process, such as
|
24
|
-
# before an example is run, or after a demo finishes.
|
25
|
-
#
|
26
|
-
class Advice
|
27
|
-
|
28
|
-
#
|
29
|
-
attr :matchers
|
30
|
-
|
31
|
-
#
|
32
|
-
attr :signals
|
33
|
-
|
34
|
-
#
|
35
|
-
def initialize
|
36
|
-
@matchers = []
|
37
|
-
@signals = [{}]
|
38
|
-
end
|
39
|
-
|
40
|
-
#
|
41
|
-
#def initialize_copy(other)
|
42
|
-
# @matchers = other.matchers.dup
|
43
|
-
# @signals = other.signals.dup
|
44
|
-
#end
|
45
|
-
|
46
|
-
#
|
47
|
-
def call(scope, type, *args)
|
48
|
-
case type
|
49
|
-
when :when
|
50
|
-
call_matchers(scope, *args)
|
51
|
-
else
|
52
|
-
call_signals(scope, type, *args)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
#
|
57
|
-
def add_event(type, &procedure)
|
58
|
-
@signals.last[type.to_sym] = procedure
|
59
|
-
end
|
60
|
-
|
61
|
-
#
|
62
|
-
def add_match(patterns, &procedure)
|
63
|
-
@matchers << [patterns, procedure]
|
64
|
-
end
|
65
|
-
|
66
|
-
# React to an event.
|
67
|
-
def call_signals(scope, type, *args)
|
68
|
-
@signals.each do |set|
|
69
|
-
proc = set[type.to_sym]
|
70
|
-
#proc.call(*args) if proc
|
71
|
-
scope.instance_exec(*args, &proc) if proc
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
#
|
76
|
-
def call_matchers(scope, section)
|
77
|
-
match = section.text
|
78
|
-
args = section.arguments
|
79
|
-
matchers.each do |(patterns, proc)|
|
80
|
-
compare = match
|
81
|
-
matched = true
|
82
|
-
params = []
|
83
|
-
patterns.each do |pattern|
|
84
|
-
case pattern
|
85
|
-
when Regexp
|
86
|
-
regex = pattern
|
87
|
-
else
|
88
|
-
regex = match_string_to_regexp(pattern)
|
89
|
-
end
|
90
|
-
if md = regex.match(compare)
|
91
|
-
params.concat(md[1..-1])
|
92
|
-
compare = md.post_match
|
93
|
-
else
|
94
|
-
matched = false
|
95
|
-
break
|
96
|
-
end
|
97
|
-
end
|
98
|
-
if matched
|
99
|
-
params += args
|
100
|
-
#proc.call(*params)
|
101
|
-
scope.instance_exec(*params, &proc)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
# Clear last set of advice.
|
107
|
-
def signals_reset
|
108
|
-
@signals.pop
|
109
|
-
end
|
110
|
-
|
111
|
-
#
|
112
|
-
def signals_setup
|
113
|
-
@signals.push({})
|
114
|
-
end
|
115
|
-
|
116
|
-
# Clear advice.
|
117
|
-
def signals_clear(type=nil)
|
118
|
-
if type
|
119
|
-
@signals.each{ |set| set.delete(type.to_sym) }
|
120
|
-
else
|
121
|
-
@signals = [{}]
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
private
|
126
|
-
|
127
|
-
# Convert matching string into a regular expression. If the string
|
128
|
-
# contains double parenthesis, such as ((.*?)), then the text within
|
129
|
-
# them is treated as in regular expression and kept verbatium.
|
130
|
-
#
|
131
|
-
# TODO: Better way to isolate regexp. Maybe ?:(.*?) or /(.*?)/.
|
132
|
-
#
|
133
|
-
# TODO: Now that we can use multi-patterns, do we still need this?
|
134
|
-
#
|
135
|
-
def match_string_to_regexp(str)
|
136
|
-
str = str.split(/(\(\(.*?\)\))(?!\))/).map{ |x|
|
137
|
-
x =~ /\A\(\((.*)\)\)\Z/ ? $1 : Regexp.escape(x)
|
138
|
-
}.join
|
139
|
-
str = str.gsub(/\\\s+/, '\s+')
|
140
|
-
Regexp.new(str, Regexp::IGNORECASE)
|
141
|
-
|
142
|
-
#rexps = []
|
143
|
-
#str = str.gsub(/\(\((.*?)\)\)/) do |m|
|
144
|
-
# rexps << '(' + $1 + ')'
|
145
|
-
# "\0"
|
146
|
-
#end
|
147
|
-
#str = Regexp.escape(str)
|
148
|
-
#rexps.each do |r|
|
149
|
-
# str = str.sub("\0", r)
|
150
|
-
#end
|
151
|
-
#str = str.gsub(/(\\\ )+/, '\s+')
|
152
|
-
#Regexp.new(str, Regexp::IGNORECASE)
|
153
|
-
end
|
154
|
-
|
155
|
-
end
|
156
|
-
|
157
|
-
end
|
158
|
-
|
data/lib/qed/reporter/bullet.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
module QED
|
2
|
-
module Reporter #:nodoc:
|
3
|
-
|
4
|
-
require 'qed/reporter/abstract'
|
5
|
-
|
6
|
-
# Bullet Point Reporter - similar to the Verbose reporter, but does
|
7
|
-
# not display test code for passing tests.
|
8
|
-
#
|
9
|
-
class BulletPoint < Abstract
|
10
|
-
|
11
|
-
#
|
12
|
-
def head(step)
|
13
|
-
io.print "#{step}".ansi(:bold)
|
14
|
-
end
|
15
|
-
|
16
|
-
def desc(step)
|
17
|
-
txt = step.to_s.strip.tabto(2)
|
18
|
-
txt[0,1] = "*"
|
19
|
-
io.puts txt
|
20
|
-
io.puts
|
21
|
-
end
|
22
|
-
|
23
|
-
def pass(step)
|
24
|
-
#io.puts "#{step}".ansi(:green)
|
25
|
-
end
|
26
|
-
|
27
|
-
def fail(step, assertion)
|
28
|
-
backtrace = sane_backtrace(assertion)
|
29
|
-
|
30
|
-
msg = []
|
31
|
-
msg << " " + "FAIL".ansi(:red)
|
32
|
-
msg << ""
|
33
|
-
msg << assertion.to_s.gsub(/^/, ' ')
|
34
|
-
msg << ""
|
35
|
-
backtrace.each do |bt|
|
36
|
-
msg << " " + relative_file(bt)
|
37
|
-
end
|
38
|
-
io.puts msg.join("\n")
|
39
|
-
io.puts
|
40
|
-
io.print step.text.tabto(4)
|
41
|
-
end
|
42
|
-
|
43
|
-
def error(step, exception)
|
44
|
-
raise exception if $DEBUG
|
45
|
-
|
46
|
-
backtrace = sane_backtrace(exception)
|
47
|
-
|
48
|
-
msg = []
|
49
|
-
msg << " " + "ERROR".ansi(:red)
|
50
|
-
msg << ""
|
51
|
-
msg << " " + exception.to_s
|
52
|
-
msg << ""
|
53
|
-
backtrace.each do |bt|
|
54
|
-
msg << " " + relative_file(bt)
|
55
|
-
end
|
56
|
-
io.puts msg.join("\n")
|
57
|
-
io.puts
|
58
|
-
io.print step.text.tabto(4)
|
59
|
-
end
|
60
|
-
|
61
|
-
#def report(str)
|
62
|
-
# count[-1] += 1 unless count.empty?
|
63
|
-
# str = str.chomp('.') + '.'
|
64
|
-
# str = count.join('.') + ' ' + str
|
65
|
-
# io.puts str.strip
|
66
|
-
#end
|
67
|
-
|
68
|
-
#def report_comment(step)
|
69
|
-
# txt = step.to_s.strip.tabto(2)
|
70
|
-
# txt[0,1] = "*"
|
71
|
-
# io.puts txt
|
72
|
-
# io.puts
|
73
|
-
#end
|
74
|
-
|
75
|
-
#def report_macro(step)
|
76
|
-
# txt = step.to_s.tabto(2)
|
77
|
-
# txt[0,1] = "*"
|
78
|
-
# io.puts txt
|
79
|
-
# #io.puts
|
80
|
-
# #io.puts "#{step}".ansi(:magenta)
|
81
|
-
#end
|
82
|
-
|
83
|
-
def after_session(session)
|
84
|
-
print_time
|
85
|
-
print_tally
|
86
|
-
end
|
87
|
-
|
88
|
-
end #class Summary
|
89
|
-
|
90
|
-
end#module Reporter
|
91
|
-
end#module QED
|
data/lib/qed/reporter/dtrace.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
module QED
|
2
|
-
module Reporter #:nodoc:
|
3
|
-
|
4
|
-
require 'qed/reporter/abstract'
|
5
|
-
|
6
|
-
# Deep trace reporter
|
7
|
-
#
|
8
|
-
class DTrace < Abstract
|
9
|
-
|
10
|
-
#
|
11
|
-
def before_session(session)
|
12
|
-
@start_time = Time.now
|
13
|
-
io.puts "Started"
|
14
|
-
end
|
15
|
-
|
16
|
-
#
|
17
|
-
#def before_step(step)
|
18
|
-
# super(step)
|
19
|
-
# io.print "."
|
20
|
-
# io.flush
|
21
|
-
#end
|
22
|
-
|
23
|
-
def pass(step)
|
24
|
-
super(step)
|
25
|
-
end
|
26
|
-
|
27
|
-
#
|
28
|
-
def fail(step, assertion)
|
29
|
-
super(step, assertion)
|
30
|
-
|
31
|
-
io.puts "#{assertion}".ansi(:red)
|
32
|
-
|
33
|
-
backtrace = sane_backtrace(assertion)
|
34
|
-
backtrace.each do |bt|
|
35
|
-
io.puts bt
|
36
|
-
io.puts code_snippet(bt)
|
37
|
-
end
|
38
|
-
|
39
|
-
io.puts
|
40
|
-
end
|
41
|
-
|
42
|
-
#
|
43
|
-
def error(step, exception)
|
44
|
-
super(step, exception)
|
45
|
-
|
46
|
-
io.puts "#{exception}".ansi(:red)
|
47
|
-
|
48
|
-
backtrace = sane_backtrace(exception)
|
49
|
-
backtrace.each do |bt|
|
50
|
-
io.puts bt
|
51
|
-
io.puts code_snippet(bt)
|
52
|
-
end
|
53
|
-
|
54
|
-
io.puts
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
|
-
#
|
59
|
-
def after_session(session)
|
60
|
-
print_time
|
61
|
-
print_tally
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
end#module Reporter
|
67
|
-
end#module QED
|
data/lib/yard-qed.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# TODO: Create a YARD plugin for QED.
|
data/spec/03_helpers.rdoc
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
= Helpers
|
2
|
-
|
3
|
-
There are two ways to load advice scripts. Either per
|
4
|
-
demonstration or globally. Per demonstration helpers
|
5
|
-
apply only to the current demonstration. Global helpers
|
6
|
-
apply to all demonstrations.
|
7
|
-
|
8
|
-
== Global Helpers
|
9
|
-
|
10
|
-
Global helpers are loaded at the start of a session and
|
11
|
-
apply equally to all demonstrations in a suite. Global
|
12
|
-
helpers are simply Ruby scripts and are placed in an
|
13
|
-
+environment+ subdirectory. For instance this document
|
14
|
-
is used <a href="environment/env.rb">environment/env.rb</a>.
|
15
|
-
|
16
|
-
== Local Helpers
|
17
|
-
|
18
|
-
Helper scripts can be written just like demonstration scripts,
|
19
|
-
or they can be defined as pure Ruby scripts. Either way
|
20
|
-
they are loaded per-demonstration by using specially
|
21
|
-
marked links.
|
22
|
-
|
23
|
-
For example, because this link, Advice[qed://helpers/advice.rb],
|
24
|
-
begins with +qed:+, it will be used to load a global
|
25
|
-
helper. We can see this with the following assertion.
|
26
|
-
|
27
|
-
pudding.assert.include?('load advice.rb')
|
28
|
-
|
29
|
-
No where in the demonstration have we defined +pudding+, but
|
30
|
-
it has been defined for us in the advice.rb helper script.
|
31
|
-
|
32
|
-
We can also see that the generic When clause in our advice
|
33
|
-
helper is keeping count of decriptive paragraphs. Since the
|
34
|
-
helper script was loaded two paragraphs back, the next count
|
35
|
-
will be 3.
|
36
|
-
|
37
|
-
count.assert == 3
|
38
|
-
|
39
|
-
Helpers are vital to building test-demonstration suites for
|
40
|
-
applications. But here again, only use them as necessary.
|
41
|
-
The more helpers you use the more difficult your demos will
|
42
|
-
be to follow.
|
43
|
-
|
data/spec/applique/quote.rb
DELETED
data/spec/helpers/sample.rb
DELETED