Skip to content

Commit

Permalink
Implement proof of concept for power assert
Browse files Browse the repository at this point in the history
  • Loading branch information
kishikawakatsumi committed Nov 11, 2022
1 parent 3b7d3ad commit dc96212
Show file tree
Hide file tree
Showing 5 changed files with 752 additions and 0 deletions.
36 changes: 36 additions & 0 deletions PowerAssert.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Proof of Concept for Power Assert for Swift

Power assertions (a.k.a. diagrammed assertions) augment your assertion failures with information about values produced during the evaluation of a condition, and presents them in an easily digestible form.
Power assertions are a popular feature of [Spock](https://github.com/spockframework/spock) (and later the whole [Groovy](https://github.com/apache/groovy) language independently of Spock),
[ScalaTest](http://www.scalatest.org/), and [Expecty](https://github.com/pniederw/expecty).

Power assertions provide descriptive assertion messages for your tests, like this.

```
#powerAssert(max(a, b) == c)
| | | | |
7 4 7 | 12
false
#powerAssert(xs.contains(4))
| | |
| false 4
[1, 2, 3]
#powerAssert("hello".hasPrefix("h") && "goodbye".hasSuffix("y"))
| | | | | | |
"hello" true "h" | "goodbye" false "y"
false
```


Getting Started
---------------------------------------

#### Run Example

You can run the example with the following command:

```shell
swift build && .build/debug/swift-parser-cli expand-macros PowerAssertTests.swift | swiftc - ./PowerAssert.swift && ./main && rm ./main
```

0 comments on commit dc96212

Please sign in to comment.