forked from apple/swift-syntax
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement proof of concept for power assert
- Loading branch information
1 parent
3b7d3ad
commit dc96212
Showing
5 changed files
with
752 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
Oops, something went wrong.