Skip to content

Commit

Permalink
Explain why gobco only covers syntactical boolean expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
rillig committed Mar 8, 2024
1 parent 4ed993b commit 227a31d
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ func square(x int) int {
The compiler will see that these conditions are side-effect-free and will thus
optimize them away, so there is no runtime overhead.

Since the above conditions are syntactically recognizable as boolean
expressions, gobco inserts its coverage code around them.

Note that for boolean expressions that don't clearly look like boolean
expressions, you have to write `cond == true` instead of a simple `cond` since
as of March 2021, gobco only analyzes the code at the syntactical level,
without resolving any types.
Gobco only inserts its coverage code around expressions that are syntactically
recognizable as boolean expressions, such as comparisons '&&', '||', '!'.
When a boolean expression is merely passed around, there is no branch
involved, thus nothing to do for branch coverage.

0 comments on commit 227a31d

Please sign in to comment.