Prepare for release 0.2.0

This commit is contained in:
Brian Norman
2020-02-12 22:23:28 -06:00
parent 2547e49160
commit 5e5083ef1c
5 changed files with 47 additions and 9 deletions
+9
View File
@@ -1,6 +1,15 @@
Change Log Change Log
========== ==========
## Version 0.2.0
_2020-02-12_
* Support configuring of which functions are transformed (eg, assert, require,
check, assertTrue). This works for any function which takes a Boolean and a
String.
* Support Boolean expressions which are split onto multiple lines.
## Version 0.1.0 ## Version 0.1.0
_2020-02-10_ _2020-02-10_
+30 -3
View File
@@ -51,24 +51,51 @@ assert(hello.length == "World".substring(1, 4).length)
at <stacktrace> at <stacktrace>
``` ```
Complex, multi-line, boolean expression are also supported:
```text
Assertion failed
assert(
(text != null && text.toLowerCase() == text) ||
| |
| false
null
text == "Hello"
| |
| false
null
)
```
## Gradle Plugin ## Gradle Plugin
Builds of the Gradle plugin are available through the Builds of the Gradle plugin are available through the
[Gradle Plugin Portal][kotlin-power-assert-gradle]. [Gradle Plugin Portal][kotlin-power-assert-gradle].
```groovy ```kotlin
plugins { plugins {
id "com.bnorm.power.kotlin-power-assert" version "0.1.0" id("com.bnorm.power.kotlin-power-assert") version "0.2.0"
} }
``` ```
The plugin by default will transform `assert` function call but can also
transform other functions like `require`, `check`, and/or `assertTrue`. The
function needs to validate the Boolean expression evaluates to `true` and has a
form which also takes a String or String producing lambda.
```kotlin
configure<com.bnorm.power.PowerAssertGradleExtension> {
functions = listOf("kotlin.test.AssertionsKt.assertTrue", "kotlin.PreconditionsKt.require")
}
```
## Kotlin IR ## Kotlin IR
Using this compiler plugin only works if the code is compiled using IR. This can Using this compiler plugin only works if the code is compiled using IR. This can
be enabled only when compiling the test SourceSet if desired. As Kotlin IR is be enabled only when compiling the test SourceSet if desired. As Kotlin IR is
still experimental, mileage may vary. still experimental, mileage may vary.
```groovy ```kotlin
compileTestKotlin { compileTestKotlin {
kotlinOptions { kotlinOptions {
useIR = true useIR = true
+1 -1
View File
@@ -6,7 +6,7 @@ plugins {
allprojects { allprojects {
group = "com.bnorm.power" group = "com.bnorm.power"
version = "0.2.0-SNAPSHOT" version = "0.2.0"
} }
subprojects { subprojects {
@@ -37,7 +37,7 @@ class PowerAssertGradleSubplugin : KotlinGradleSubplugin<AbstractCompile> {
override fun getPluginArtifact(): SubpluginArtifact = SubpluginArtifact( override fun getPluginArtifact(): SubpluginArtifact = SubpluginArtifact(
groupId = "com.bnorm.power", groupId = "com.bnorm.power",
artifactId = "kotlin-power-assert", artifactId = "kotlin-power-assert",
version = "0.2.0-SNAPSHOT" version = "0.2.0"
) )
override fun apply( override fun apply(
@@ -228,10 +228,12 @@ assert(text == null || (text.length == 5 && text.toLowerCase() == text))
@Test @Test
fun booleanMixOrLast() { fun booleanMixOrLast() {
assertMessage( assertMessage(
""" """fun main() {
fun main() { val text: String? = null
val text = "Hello" assert(
assert((text.length == 5 && text.toLowerCase() == text) || text.length == 1) (text != null && text.toLowerCase() == text) ||
text == "Hello"
)
}""", }""",
""" """
Assertion failed Assertion failed