power_assert 1.1.0 → 1.1.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.
- checksums.yaml +4 -4
- data/README.rdoc +48 -0
- data/lib/power_assert/context.rb +7 -1
- data/lib/power_assert/parser.rb +5 -2
- data/lib/power_assert/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94700e701d6e70078cff18ec8db5689ebcb69fc1
|
4
|
+
data.tar.gz: cf854f8bb406169ccf8b22869d77b8320191a07c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52ee0c7f1fb5ea27e42f64c99160e71d54ab3ca8787f703d173a340c98bccb0a0f5fc322c96c97ec99c0f04f6cabd664e4cae1085653c47e34a25c1de71a49db
|
7
|
+
data.tar.gz: def9341626a182f990d568a67fb8970d004644dfe0d48d89daef2671fa87e18c6f48099594c237130da74e4d762a9f38c9af723f86fd443ebdea19e189505509
|
data/README.rdoc
CHANGED
@@ -23,4 +23,52 @@ Use following test frameworks or extensions instead.
|
|
23
23
|
== Reference
|
24
24
|
* {Power Assert in Ruby (at RubyKaigi 2014) // Speaker Deck}[https://speakerdeck.com/k_tsj/power-assert-in-ruby]
|
25
25
|
|
26
|
+
== Known Limitations
|
27
|
+
* Expressions must be put in one line. Expressions with folded long lines produce nothing report, e.g.:
|
28
|
+
assert do
|
29
|
+
# reported
|
30
|
+
func(foo: 0123456789, bar: "abcdefg")
|
31
|
+
end
|
32
|
+
|
33
|
+
assert do
|
34
|
+
# won't be reported
|
35
|
+
func(foo: 0123456789,
|
36
|
+
bar: "abcdefg")
|
37
|
+
end
|
38
|
+
* Expressions must have one or more method call. Expressions with no method call produce nothing report, e.g.:
|
39
|
+
val = false
|
40
|
+
assert do
|
41
|
+
# reported
|
42
|
+
val == true
|
43
|
+
end
|
44
|
+
|
45
|
+
assert do
|
46
|
+
# won't be reported
|
47
|
+
val
|
48
|
+
end
|
49
|
+
* Returned values from accessor methods, method missing, or "super" produce nothing report, e.g:
|
50
|
+
class Foo
|
51
|
+
attr_accessor :val
|
52
|
+
end
|
53
|
+
foo = Foo.new
|
54
|
+
foo.val = false
|
55
|
+
|
56
|
+
assert do
|
57
|
+
# reported (only the value of "foo" and the literal "true")
|
58
|
+
foo.val == true
|
59
|
+
end
|
60
|
+
|
61
|
+
assert do
|
62
|
+
# won't be reported
|
63
|
+
foo.val
|
64
|
+
end
|
65
|
+
* Expressions should not have conditional branches. Expressions with such conditional codes may produce nothing report, e.g.:
|
66
|
+
condition = true
|
67
|
+
expected = false
|
68
|
+
actual = true
|
69
|
+
assert do
|
70
|
+
# this will fail but nothing reported
|
71
|
+
condition ? expected == actual : expected == actual
|
72
|
+
end
|
73
|
+
|
26
74
|
== Travis Build Status {<img src="https://secure.travis-ci.org/k-tsj/power_assert.png?branch=master"/>}[http://travis-ci.org/k-tsj/power_assert]
|
data/lib/power_assert/context.rb
CHANGED
@@ -76,7 +76,13 @@ module PowerAssert
|
|
76
76
|
vals = (return_values + ref_values).find_all(&:column).sort_by(&:column).reverse
|
77
77
|
return line if vals.empty?
|
78
78
|
|
79
|
-
fmt = (0..vals[0].column).map
|
79
|
+
fmt = (0..vals[0].column).map do |i|
|
80
|
+
if vals.find {|v| v.column == i }
|
81
|
+
"%<#{i}>s"
|
82
|
+
else
|
83
|
+
line[i] == "\t" ? "\t" : ' '
|
84
|
+
end
|
85
|
+
end.join
|
80
86
|
lines = []
|
81
87
|
lines << line.chomp
|
82
88
|
lines << sprintf(fmt, vals.each_with_object({}) {|v, h| h[v.column.to_s.to_sym] = '|' }).chomp
|
data/lib/power_assert/parser.rb
CHANGED
@@ -139,12 +139,15 @@ module PowerAssert
|
|
139
139
|
(tag3 == :@ident or tag3 == :@const) and mname == @assertion_method_name and (tag4 == :brace_block or tag4 == :do_block)
|
140
140
|
ss.flat_map {|s| extract_idents(s) }
|
141
141
|
else
|
142
|
-
_, (
|
143
|
-
extract_idents(
|
142
|
+
_, (s0, *) = sexp
|
143
|
+
extract_idents(s0)
|
144
144
|
end
|
145
145
|
when :ifop
|
146
146
|
_, s0, s1, s2 = sexp
|
147
147
|
[*extract_idents(s0), Branch[extract_idents(s1), extract_idents(s2)]]
|
148
|
+
when :if, :unless
|
149
|
+
_, s0, ss0, (_, ss1) = sexp
|
150
|
+
[*extract_idents(s0), Branch[ss0.flat_map {|s| extract_idents(s) }, ss1 ? ss1.flat_map {|s| extract_idents(s) } : []]]
|
148
151
|
when :if_mod, :unless_mod
|
149
152
|
_, s0, s1 = sexp
|
150
153
|
[*extract_idents(s0), Branch[extract_idents(s1), []]]
|
data/lib/power_assert/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: power_assert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuki Tsujimoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-unit
|