assert2 0.3.0 → 0.3.1
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/lib/assert2.rb +32 -0
- data/lib/ruby_reflector.rb +9 -3
- metadata +41 -48
data/lib/assert2.rb
CHANGED
@@ -156,6 +156,38 @@ module Assert_2_0
|
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
159
|
+
# wrap this common idiom:
|
160
|
+
# foo = assemble()
|
161
|
+
# deny{ foo.bar() }
|
162
|
+
# foo.activate()
|
163
|
+
# assert{ foo.bar() }
|
164
|
+
#
|
165
|
+
# that becomes:
|
166
|
+
# foo = assemble()
|
167
|
+
# assert_yin_yang proc{ foo.bar() } do
|
168
|
+
# foo.activate()
|
169
|
+
# end
|
170
|
+
#
|
171
|
+
def assert_yin_yang(prock, diagnostic = nil, &block)
|
172
|
+
source = reflect_source(&block)
|
173
|
+
fuss = [diagnostic, "fault before calling:", source].compact.join("\n")
|
174
|
+
deny fuss, &prock
|
175
|
+
block.call
|
176
|
+
fuss = [diagnostic, "fault after calling:", source].compact.join("\n")
|
177
|
+
assert fuss, &prock
|
178
|
+
end
|
179
|
+
|
180
|
+
# the prock assertion must pass on both sides of the called block
|
181
|
+
#
|
182
|
+
def deny_yin_yang(prock, diagnostic = nil, &block)
|
183
|
+
source = reflect_source(&block)
|
184
|
+
fuss = [diagnostic, "fault before calling:", source].compact.join("\n")
|
185
|
+
assert fuss, &prock
|
186
|
+
block.call
|
187
|
+
fuss = [diagnostic, "fault after calling:", source].compact.join("\n")
|
188
|
+
assert fuss, &prock
|
189
|
+
end
|
190
|
+
|
159
191
|
private
|
160
192
|
def build_message_(diagnostic, reflection)
|
161
193
|
diagnostic = nil if diagnostic == ''
|
data/lib/ruby_reflector.rb
CHANGED
@@ -130,7 +130,7 @@ module RubyNodeReflector
|
|
130
130
|
if e.message.index('syntax error, unexpected \',\'') and expression !~ /\[ /
|
131
131
|
return eval_intermediate_guarded('[ ' + expression + ' ]')
|
132
132
|
end # faint prayer to infinite recursion diety here! (-;
|
133
|
-
|
133
|
+
|
134
134
|
@evaluations << [expression, nil, e.message]
|
135
135
|
rescue => e
|
136
136
|
@evaluations << [expression, nil, e.message]
|
@@ -151,7 +151,7 @@ module RubyNodeReflector
|
|
151
151
|
return prettier
|
152
152
|
end
|
153
153
|
private :short_inspect
|
154
|
-
|
154
|
+
|
155
155
|
# ERGO spew the backrefs (?) any regular expression matchers may emit!
|
156
156
|
# ERGO don't eval the caller of a block without its block!
|
157
157
|
|
@@ -208,6 +208,11 @@ module RubyNodeReflector
|
|
208
208
|
"\nend\n"
|
209
209
|
end
|
210
210
|
|
211
|
+
def _method(node)
|
212
|
+
p node
|
213
|
+
return ''
|
214
|
+
end
|
215
|
+
|
211
216
|
def _class(node); _module(node, 'class'); end
|
212
217
|
def _self(node); 'self'; end
|
213
218
|
def _defn(node); _defs(node); end
|
@@ -265,7 +270,8 @@ module RubyNodeReflector
|
|
265
270
|
@rest = @args[:rest] if @args
|
266
271
|
@opt = @args[:opt] if @args
|
267
272
|
|
268
|
-
@node[:tbl].each_with_index do
|
273
|
+
@node[:tbl].each_with_index do |_n, _index|
|
274
|
+
@n, @index = _n, _index
|
269
275
|
render_argument
|
270
276
|
break if @block_arg
|
271
277
|
end
|
metadata
CHANGED
@@ -1,62 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.4
|
3
|
+
specification_version: 1
|
2
4
|
name: assert2
|
3
5
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
6
|
+
version: 0.3.1
|
7
|
+
date: 2008-04-18 00:00:00 -07:00
|
8
|
+
summary: An assertion that reflects its block, with all intermediate values
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: phlip2005@gmail.com
|
12
|
+
homepage: http://assert2.rubyforge.org/
|
13
|
+
rubyforge_project: assert2
|
14
|
+
description:
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: false
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
5
25
|
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
6
29
|
authors:
|
7
30
|
- Phlip
|
8
|
-
|
9
|
-
|
10
|
-
|
31
|
+
files:
|
32
|
+
- lib/ruby_reflector.rb
|
33
|
+
- lib/assert2.rb
|
34
|
+
test_files: []
|
35
|
+
|
36
|
+
rdoc_options: []
|
37
|
+
|
38
|
+
extra_rdoc_files: []
|
39
|
+
|
40
|
+
executables: []
|
41
|
+
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
requirements: []
|
11
45
|
|
12
|
-
date: 2008-03-08 00:00:00 -08:00
|
13
|
-
default_executable:
|
14
46
|
dependencies:
|
15
47
|
- !ruby/object:Gem::Dependency
|
16
48
|
name: rubynode
|
17
49
|
version_requirement:
|
18
|
-
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
19
51
|
requirements:
|
20
|
-
- - "
|
52
|
+
- - ">"
|
21
53
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
54
|
+
version: 0.0.0
|
23
55
|
version:
|
24
|
-
description:
|
25
|
-
email: phlip2005@gmail.com
|
26
|
-
executables: []
|
27
|
-
|
28
|
-
extensions: []
|
29
|
-
|
30
|
-
extra_rdoc_files: []
|
31
|
-
|
32
|
-
files:
|
33
|
-
- lib/ruby_reflector.rb
|
34
|
-
- lib/assert2.rb
|
35
|
-
has_rdoc: false
|
36
|
-
homepage: http://assert2.rubyforge.org/
|
37
|
-
post_install_message:
|
38
|
-
rdoc_options: []
|
39
|
-
|
40
|
-
require_paths:
|
41
|
-
- lib
|
42
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: "0"
|
47
|
-
version:
|
48
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
-
requirements:
|
50
|
-
- - ">="
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: "0"
|
53
|
-
version:
|
54
|
-
requirements: []
|
55
|
-
|
56
|
-
rubyforge_project: assert2
|
57
|
-
rubygems_version: 1.0.1
|
58
|
-
signing_key:
|
59
|
-
specification_version: 2
|
60
|
-
summary: An assertion that reflects its block, with all intermediate values
|
61
|
-
test_files: []
|
62
|
-
|