Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit 5e5083e

Browse files
committed
Prepare for release 0.2.0
1 parent 2547e49 commit 5e5083e

File tree

5 files changed

+47
-9
lines changed

5 files changed

+47
-9
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Change Log
22
==========
33

4+
## Version 0.2.0
5+
6+
_2020-02-12_
7+
8+
* Support configuring of which functions are transformed (eg, assert, require,
9+
check, assertTrue). This works for any function which takes a Boolean and a
10+
String.
11+
* Support Boolean expressions which are split onto multiple lines.
12+
413
## Version 0.1.0
514

615
_2020-02-10_

README.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,51 @@ assert(hello.length == "World".substring(1, 4).length)
5151
at <stacktrace>
5252
```
5353

54+
Complex, multi-line, boolean expression are also supported:
55+
56+
```text
57+
Assertion failed
58+
assert(
59+
(text != null && text.toLowerCase() == text) ||
60+
| |
61+
| false
62+
null
63+
text == "Hello"
64+
| |
65+
| false
66+
null
67+
)
68+
```
69+
5470
## Gradle Plugin
5571

5672
Builds of the Gradle plugin are available through the
5773
[Gradle Plugin Portal][kotlin-power-assert-gradle].
5874

59-
```groovy
75+
```kotlin
6076
plugins {
61-
id "com.bnorm.power.kotlin-power-assert" version "0.1.0"
77+
id("com.bnorm.power.kotlin-power-assert") version "0.2.0"
6278
}
6379
```
6480

81+
The plugin by default will transform `assert` function call but can also
82+
transform other functions like `require`, `check`, and/or `assertTrue`. The
83+
function needs to validate the Boolean expression evaluates to `true` and has a
84+
form which also takes a String or String producing lambda.
85+
86+
```kotlin
87+
configure<com.bnorm.power.PowerAssertGradleExtension> {
88+
functions = listOf("kotlin.test.AssertionsKt.assertTrue", "kotlin.PreconditionsKt.require")
89+
}
90+
```
91+
6592
## Kotlin IR
6693

6794
Using this compiler plugin only works if the code is compiled using IR. This can
6895
be enabled only when compiling the test SourceSet if desired. As Kotlin IR is
6996
still experimental, mileage may vary.
7097

71-
```groovy
98+
```kotlin
7299
compileTestKotlin {
73100
kotlinOptions {
74101
useIR = true

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66

77
allprojects {
88
group = "com.bnorm.power"
9-
version = "0.2.0-SNAPSHOT"
9+
version = "0.2.0"
1010
}
1111

1212
subprojects {

kotlin-power-assert-gradle/src/main/kotlin/com/bnorm/power/PowerAssertGradleSubplugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class PowerAssertGradleSubplugin : KotlinGradleSubplugin<AbstractCompile> {
3737
override fun getPluginArtifact(): SubpluginArtifact = SubpluginArtifact(
3838
groupId = "com.bnorm.power",
3939
artifactId = "kotlin-power-assert",
40-
version = "0.2.0-SNAPSHOT"
40+
version = "0.2.0"
4141
)
4242

4343
override fun apply(

kotlin-power-assert/src/test/kotlin/com/bnorm/power/test.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,12 @@ assert(text == null || (text.length == 5 && text.toLowerCase() == text))
228228
@Test
229229
fun booleanMixOrLast() {
230230
assertMessage(
231-
"""
232-
fun main() {
233-
val text = "Hello"
234-
assert((text.length == 5 && text.toLowerCase() == text) || text.length == 1)
231+
"""fun main() {
232+
val text: String? = null
233+
assert(
234+
(text != null && text.toLowerCase() == text) ||
235+
text == "Hello"
236+
)
235237
}""",
236238
"""
237239
Assertion failed

0 commit comments

Comments
 (0)