File tree Expand file tree Collapse file tree 1 file changed +25
-10
lines changed Expand file tree Collapse file tree 1 file changed +25
-10
lines changed Original file line number Diff line number Diff line change @@ -31,37 +31,37 @@ To colorize output messages, add <code>require "power_assert/colorize"</code> to
3131(It requires irb 1.3.1+)
3232
3333## Known Limitations
34- * Expressions must be put in one line. Expressions with folded long lines produce nothing report, e.g.:
34+ * Expressions must be on a single line. Splitting an assertion across multiple lines prevents any report from being generated , e.g.:
3535
3636``` ruby
3737assert do
38- # reported
38+ # Reported
3939 func(foo: 0123456789 , bar: " abcdefg" )
4040end
4141
4242assert do
43- # won't be reported
43+ # Not reported
4444 func(foo: 0123456789 ,
4545 bar: " abcdefg" )
4646end
4747```
4848
49- * Expressions must have one or more method call. Expressions with no method call produce nothing report, e.g.:
49+ * Expressions must include at least one method call. Assertions without method calls generate no report, e.g.:
5050
5151``` ruby
5252val = false
5353assert do
54- # reported
54+ # Reported
5555 val == true
5656end
5757
5858assert do
59- # won't be reported
59+ # Not reported
6060 val
6161end
6262```
6363
64- * Returned values from method missing, or " super" produce nothing report, e.g:
64+ * Return values from ` method_missing ` or ` super ` generate no report, e.g. :
6565
6666``` ruby
6767class Foo
7272foo = Foo .new
7373
7474assert do
75- # won't be reported
75+ # Not reported
7676 foo.foo
7777end
7878```
7979
80- * Expressions should not have conditional branches. Expressions with such conditional codes may produce nothing report, e.g.:
80+ * Avoid conditional branches inside assertions. Conditional logic may prevent a report from being generated , e.g.:
8181
8282``` ruby
8383condition = true
8484expected = false
8585actual = true
8686assert do
87- # this will fail but nothing reported
87+ # This fails, but nothing is reported
8888 condition ? expected == actual : expected == actual
8989end
9090```
9191
92+ * (CRuby 4.0+) ` <Struct subclass>.new ` generates no report. Use ` <Struct subclass>.[] ` instead, e.g.:
93+
94+ ``` ruby
95+ s = Struct .new (:a )
96+ assert do
97+ # Not reported
98+ s.new (0 )
99+ end
100+
101+ assert do
102+ # Reported
103+ s[0 ]
104+ end
105+ ```
106+
92107## Reference
93108* [ Power Assert in Ruby (at RubyKaigi 2014) // Speaker Deck] ( https://speakerdeck.com/k_tsj/power-assert-in-ruby )
You can’t perform that action at this time.
0 commit comments