Skip to content

Commit 9c50d52

Browse files
committed
Update README.md
1 parent e0ff20a commit 9c50d52

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

README.md

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff 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
3737
assert do
38-
# reported
38+
# Reported
3939
func(foo: 0123456789, bar: "abcdefg")
4040
end
4141

4242
assert do
43-
# won't be reported
43+
# Not reported
4444
func(foo: 0123456789,
4545
bar: "abcdefg")
4646
end
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
5252
val = false
5353
assert do
54-
# reported
54+
# Reported
5555
val == true
5656
end
5757

5858
assert do
59-
# won't be reported
59+
# Not reported
6060
val
6161
end
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
6767
class Foo
@@ -72,22 +72,37 @@ end
7272
foo = Foo.new
7373

7474
assert do
75-
# won't be reported
75+
# Not reported
7676
foo.foo
7777
end
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
8383
condition = true
8484
expected = false
8585
actual = true
8686
assert do
87-
# this will fail but nothing reported
87+
# This fails, but nothing is reported
8888
condition ? expected == actual : expected == actual
8989
end
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)

0 commit comments

Comments
 (0)