Simplify message expression from lambda argument when converting assert to if.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package a
|
||||
|
||||
fun foo() {
|
||||
<caret>assert(true, "text")
|
||||
<caret>assert(true, { "text" })
|
||||
}
|
||||
|
||||
class AssertionError
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo() {
|
||||
<caret>assert(true && false, "text")
|
||||
<caret>assert(true && false, { "text" })
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo() {
|
||||
<caret>assert(1 > 0, "text")
|
||||
<caret>assert(1 > 0) { "text" }
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo() {
|
||||
<caret>assert(0 != 1, "text")
|
||||
<caret>assert(0 != 1) { "text" }
|
||||
}
|
||||
+1
-1
@@ -2,5 +2,5 @@
|
||||
fun foo() {
|
||||
val x = true
|
||||
val y = false
|
||||
<caret>assert(x || y, "text")
|
||||
<caret>assert(x || y) { "text" }
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fun main(args: Array<String>) {
|
||||
asse<caret>rt(false, "mess" as kotlin.String)
|
||||
asse<caret>rt(false) { "mess" as kotlin.String }
|
||||
}
|
||||
|
||||
// WITH_RUNTIME
|
||||
@@ -1,4 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo() {
|
||||
kotlin.<caret>assert(true, "text")
|
||||
kotlin.<caret>assert(true) {"text"}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo() {
|
||||
<caret>assert(bar(), "text")
|
||||
<caret>assert(bar()) { "text" }
|
||||
}
|
||||
|
||||
fun bar(): Boolean = true
|
||||
+3
-1
@@ -1,4 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo() {
|
||||
<caret>assert(true, { "text" })
|
||||
<caret>assert(true, {
|
||||
if (true) "text" else return
|
||||
})
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo() {
|
||||
if (!true) {
|
||||
throw AssertionError({ "text" }())
|
||||
throw AssertionError(if (true) "text" else return)
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -1,4 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo() {
|
||||
<caret>assert(true) { "text" }
|
||||
<caret>assert(true) {
|
||||
return
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -1,6 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo() {
|
||||
if (!true) {
|
||||
throw AssertionError({ "text" }())
|
||||
throw AssertionError({
|
||||
return
|
||||
}())
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo() {
|
||||
<caret>assert(true, {
|
||||
val value = 1
|
||||
"text and $value"
|
||||
})
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo() {
|
||||
if (!true) {
|
||||
throw AssertionError({
|
||||
val value = 1
|
||||
"text and $value"
|
||||
}())
|
||||
}
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo() {
|
||||
<caret>assert(true) {
|
||||
if (false) return
|
||||
"text"
|
||||
}
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo() {
|
||||
if (!true) {
|
||||
throw AssertionError({
|
||||
if (false) return
|
||||
"text"
|
||||
}())
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo() {
|
||||
<caret>assert((true && false), "text")
|
||||
<caret>assert((true && false)) { "text" }
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo() {
|
||||
<caret>assert(true, "text")
|
||||
<caret>assert(true) { "text" }
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo() {
|
||||
val f = "text"
|
||||
<caret>assert(true, f)
|
||||
<caret>assert(true) { f }
|
||||
}
|
||||
Reference in New Issue
Block a user