Prepare for release 0.2.0
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
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
|
||||
|
||||
_2020-02-10_
|
||||
|
||||
@@ -51,24 +51,51 @@ assert(hello.length == "World".substring(1, 4).length)
|
||||
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
|
||||
|
||||
Builds of the Gradle plugin are available through the
|
||||
[Gradle Plugin Portal][kotlin-power-assert-gradle].
|
||||
|
||||
```groovy
|
||||
```kotlin
|
||||
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
|
||||
|
||||
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
|
||||
still experimental, mileage may vary.
|
||||
|
||||
```groovy
|
||||
```kotlin
|
||||
compileTestKotlin {
|
||||
kotlinOptions {
|
||||
useIR = true
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ plugins {
|
||||
|
||||
allprojects {
|
||||
group = "com.bnorm.power"
|
||||
version = "0.2.0-SNAPSHOT"
|
||||
version = "0.2.0"
|
||||
}
|
||||
|
||||
subprojects {
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ class PowerAssertGradleSubplugin : KotlinGradleSubplugin<AbstractCompile> {
|
||||
override fun getPluginArtifact(): SubpluginArtifact = SubpluginArtifact(
|
||||
groupId = "com.bnorm.power",
|
||||
artifactId = "kotlin-power-assert",
|
||||
version = "0.2.0-SNAPSHOT"
|
||||
version = "0.2.0"
|
||||
)
|
||||
|
||||
override fun apply(
|
||||
|
||||
@@ -228,10 +228,12 @@ assert(text == null || (text.length == 5 && text.toLowerCase() == text))
|
||||
@Test
|
||||
fun booleanMixOrLast() {
|
||||
assertMessage(
|
||||
"""
|
||||
fun main() {
|
||||
val text = "Hello"
|
||||
assert((text.length == 5 && text.toLowerCase() == text) || text.length == 1)
|
||||
"""fun main() {
|
||||
val text: String? = null
|
||||
assert(
|
||||
(text != null && text.toLowerCase() == text) ||
|
||||
text == "Hello"
|
||||
)
|
||||
}""",
|
||||
"""
|
||||
Assertion failed
|
||||
|
||||
Reference in New Issue
Block a user