Uast: Update tests, make the tests a bit more readable (provide toString() methods for Uast kinds)

This commit is contained in:
Yan Zhulanow
2016-03-24 17:11:28 +03:00
parent 109c76c87d
commit 3484f92d10
29 changed files with 454 additions and 105 deletions
@@ -127,4 +127,8 @@ open class UastBinaryOperator(override val text: String): UastOperator {
@JvmField
val UNSIGNED_SHIFT_RIGHT_ASSIGN = AssignOperator(">>>=")
}
override fun toString(): String{
return "UastBinaryOperator(text='$text')"
}
}
@@ -23,4 +23,8 @@ class UastCallKind(val name: String) {
@JvmField
val CONSTRUCTOR_CALL = UastCallKind("constructor_call")
}
override fun toString(): String{
return "UastCallKind(name='$name')"
}
}
@@ -35,4 +35,8 @@ open class UastClassKind(val text: String) {
@JvmField
val OBJECT = UastClassKind("object")
}
override fun toString(): String{
return "UastClassKind(text='$text')"
}
}
@@ -25,4 +25,8 @@ open class UastFunctionKind(val text: String) {
@JvmField
val CONSTRUCTOR = UastFunctionKind("CONSTRUCTOR")
}
override fun toString(): String{
return "UastFunctionKind(text='$text')"
}
}
@@ -25,4 +25,8 @@ class UastImportKind(val text: String) {
@JvmField
val MEMBER = UastImportKind("member")
}
override fun toString(): String{
return "UastImportKind(text='$text')"
}
}
@@ -28,4 +28,8 @@ class UastModifier(val name: String) {
@JvmField
val OVERRIDE = UastModifier("override")
}
override fun toString(): String{
return "UastModifier(name='$name')"
}
}
@@ -28,4 +28,8 @@ class UastPostfixOperator(override val text: String): UastOperator {
@JvmField
val UNKNOWN = UastPostfixOperator("<unknown>")
}
override fun toString(): String{
return "UastPostfixOperator(text='$text')"
}
}
@@ -40,4 +40,8 @@ class UastPrefixOperator(override val text: String): UastOperator {
@JvmField
val UNKNOWN = UastPrefixOperator("<unknown>")
}
override fun toString(): String{
return "UastPrefixOperator(text='$text')"
}
}
@@ -20,4 +20,8 @@ class UastQualifiedExpressionAccessType(val name: String) {
@JvmField
val SIMPLE = UastQualifiedExpressionAccessType(".")
}
override fun toString(): String{
return "UastQualifiedExpressionAccessType(name='$name')"
}
}
@@ -29,4 +29,8 @@ class UastSpecialExpressionKind(val name: String) {
@JvmField
val CONTINUE = UastSpecialExpressionKind("continue")
}
override fun toString(): String{
return "UastSpecialExpressionKind(name='$name')"
}
}
@@ -26,4 +26,8 @@ class UastVariableKind(val name: String) {
@JvmField
val VALUE_PARAMETER = UastVariableKind("parameter")
}
override fun toString(): String{
return "UastVariableKind(name='$name')"
}
}
@@ -28,4 +28,8 @@ class UastVisibility(val name: String) {
}
fun isPublic() = this == PUBLIC
override fun toString(): String {
return "UastVisibility(name='$name')"
}
}
@@ -24,7 +24,7 @@ import java.io.File
open class AbstractStructureTest : LightCodeInsightTestCase() {
fun test(name: String) {
val testDir = File("testData")
val testDir = testDataPath
val javaFile = File(testDir, "$name.java")
val logFile = File(File(testDir, "log"), "$name.txt")
val renderFile = File(File(testDir, "render"), "$name.txt")
@@ -61,4 +61,6 @@ open class AbstractStructureTest : LightCodeInsightTestCase() {
}
private class NoTestFileException(file: File) : RuntimeException("Test file was generated: $file")
override fun getTestDataPath() = "plugins/uast-java/testData"
}
+7 -7
View File
@@ -1,6 +1,6 @@
UFile (package = null)
UClass (_Dummy_, enum = false, interface = false, object = false)
UClass (ControlStructures, enum = false, interface = false, object = false)
UClass (_Dummy_, kind = class)
UClass (ControlStructures, kind = class)
UFunction (main, kind = function, paramCount = 1)
UBlockExpression
UIfExpression
@@ -11,7 +11,7 @@ UFile (package = null)
ULiteralExpression (0)
UBlockExpression
USpecialExpressionList (return)
EmptyExpression
UDeclarationsExpression
UVariable (mode, kind = local)
@@ -30,7 +30,7 @@ UFile (package = null)
UQualifiedExpression
USimpleReferenceExpression (System)
USimpleReferenceExpression (out)
UFunctionCallExpression (FUNCTION_CALL, argCount = 1)
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (println)
USimpleReferenceExpression (arg)
UForExpression
@@ -49,7 +49,7 @@ UFile (package = null)
UQualifiedExpression
USimpleReferenceExpression (System)
USimpleReferenceExpression (out)
UFunctionCallExpression (FUNCTION_CALL, argCount = 1)
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (println)
UBinaryExpression (+)
UBinaryExpression (+)
@@ -72,7 +72,7 @@ UFile (package = null)
UQualifiedExpression
USimpleReferenceExpression (System)
USimpleReferenceExpression (out)
UFunctionCallExpression (FUNCTION_CALL, argCount = 1)
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (println)
UBinaryExpression (+)
ULiteralExpression ("Index ")
@@ -93,7 +93,7 @@ UFile (package = null)
UQualifiedExpression
USimpleReferenceExpression (System)
USimpleReferenceExpression (out)
UFunctionCallExpression (FUNCTION_CALL, argCount = 1)
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (println)
USimpleReferenceExpression (i)
UAssignmentExpression (+=)
+6 -6
View File
@@ -1,9 +1,9 @@
UFile (package = null)
UClass (_Dummy_, enum = false, interface = false, object = false)
UClass (Lambda, enum = false, interface = false, object = false)
UClass (_Dummy_, kind = class)
UClass (Lambda, kind = class)
UFunction (example, kind = function, paramCount = 0)
UBlockExpression
UFunctionCallExpression (FUNCTION_CALL, argCount = 2)
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 2)
USimpleReferenceExpression (doJob)
ULambdaExpression
UVariable (arg, kind = parameter)
@@ -18,13 +18,13 @@ UFile (package = null)
UQualifiedExpression
USimpleReferenceExpression (System)
USimpleReferenceExpression (out)
UFunctionCallExpression (FUNCTION_CALL, argCount = 1)
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (println)
UQualifiedExpression
USimpleReferenceExpression (job)
UFunctionCallExpression (FUNCTION_CALL, argCount = 1)
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (doJob)
USimpleReferenceExpression (arg)
UClass (Job, enum = false, interface = true, object = false)
UClass (Job, kind = interface)
UFunction (doJob, kind = function, paramCount = 1)
EmptyExpression
+6 -7
View File
@@ -1,11 +1,10 @@
UFile (package = null)
UClass (_Dummy_, enum = false, interface = false, object = false)
UClass (NestedClasses, enum = false, interface = false, object = false)
UClass (Nested, enum = false, interface = false, object = false)
UClass (_Dummy_, kind = class)
UClass (NestedClasses, kind = class)
UClass (Nested, kind = class)
UFunction (func1, kind = function, paramCount = 0)
UBlockExpression
UClass (Inner, enum = false, interface = false, object = false)
UClass (Inner, kind = class)
UFunction (func2, kind = function, paramCount = 0)
UBlockExpression
UBlockExpression
+3 -3
View File
@@ -1,9 +1,9 @@
UFile (package = null)
UClass (_Dummy_, enum = false, interface = false, object = false)
UClass (Simple, enum = false, interface = false, object = false)
UClass (_Dummy_, kind = class)
UClass (Simple, kind = class)
UVariable (name, kind = member)
EmptyExpression
UFunction (Simple, kind = function, paramCount = 1)
UFunction (<init>, kind = CONSTRUCTOR, paramCount = 1)
UBlockExpression
UAssignmentExpression (=)
UQualifiedExpression
+14 -14
View File
@@ -1,6 +1,6 @@
UFile (package = null)
UClass (_Dummy_, enum = false, interface = false, object = false)
UClass (SpecialExpressions, enum = false, interface = false, object = false)
UClass (_Dummy_, kind = class)
UClass (SpecialExpressions, kind = class)
UFunction (test, kind = function, paramCount = 0)
UBlockExpression
USpecialExpressionList (assert)
@@ -20,7 +20,7 @@ UFile (package = null)
UQualifiedExpression
USimpleReferenceExpression (System)
USimpleReferenceExpression (out)
UFunctionCallExpression (FUNCTION_CALL, argCount = 1)
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (println)
ULiteralExpression ("A")
UDeclarationsExpression
@@ -41,7 +41,7 @@ UFile (package = null)
ULiteralExpression (3)
UBlockExpression
USpecialExpressionList (break)
EmptyExpression
UIfExpression
UBinaryExpression (===)
@@ -51,20 +51,20 @@ UFile (package = null)
ULiteralExpression (0)
UBlockExpression
USpecialExpressionList (continue)
EmptyExpression
UPostfixExpression (--)
USimpleReferenceExpression (a)
UQualifiedExpression
UThisExpression
UFunctionCallExpression (FUNCTION_CALL, argCount = 0)
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 0)
USimpleReferenceExpression (test)
UQualifiedExpression
USuperExpression
UFunctionCallExpression (FUNCTION_CALL, argCount = 0)
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 0)
USimpleReferenceExpression (hashCode)
UDeclarationsExpression
UVariable (x, kind = local)
EmptyExpression
@@ -78,7 +78,7 @@ UFile (package = null)
USimpleReferenceExpression (x)
ULiteralExpression ("1")
USpecialExpressionList (break)
UExpressionSwitchClauseExpression
ULiteralExpression (3)
UAssignmentExpression (=)
@@ -97,16 +97,16 @@ UFile (package = null)
UQualifiedExpression
UQualifiedExpression
USimpleReferenceExpression (System)
UFunctionCallExpression (FUNCTION_CALL, argCount = 2)
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 2)
USimpleReferenceExpression (getProperty)
ULiteralExpression ("abc")
ULiteralExpression ("")
UFunctionCallExpression (FUNCTION_CALL, argCount = 1)
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (equals)
ULiteralExpression ("1")
UBlockExpression
USpecialExpressionList (throw)
UFunctionCallExpression (CONSTRUCTOR_CALL, argCount = 1)
UFunctionCallExpression (UastCallKind(name='constructor_call'), argCount = 1)
<no element>
ULiteralExpression ("Err")
EmptyExpression
@@ -114,7 +114,7 @@ UFile (package = null)
UBlockExpression
UQualifiedExpression
USimpleReferenceExpression (Thread)
UFunctionCallExpression (FUNCTION_CALL, argCount = 1)
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (sleep)
ULiteralExpression (1000) UCatchClause
UBlockExpression
+10 -10
View File
@@ -1,33 +1,33 @@
default class _Dummy_ {
default inner class ControlStructures {
public fun main(args: java.lang.String[]): void {
default class ControlStructures {
public fun main(args: String[]): void {
if (args.length === 0) {
return
return
}
var mode: String = (args.length === 1) ? ("singleArg") : ("multiArgs")
for (arg : args) {
System.out.println(arg)
}
for (var i: int = 0; i < args.length; ++i) {
System.out.println(i + ": " + args[i])
}
var i: int = 0
while (i < args.length) {
System.out.println("Index " + i)
i++
}
i = 0
do {
System.out.println(i)
i += 1
}
while (i < args.length)
}
}
}
}
+2 -2
View File
@@ -1,5 +1,5 @@
default class _Dummy_ {
default inner class Lambda {
default class Lambda {
default fun example(): void {
doJob({ arg: String ->
arg + arg
@@ -11,7 +11,7 @@ default class _Dummy_ {
}
}
default abstract interface Job {
default abstract static interface Job {
public fun doJob(arg: String): String = EmptyExpression
}
}
+6 -6
View File
@@ -1,14 +1,14 @@
default class _Dummy_ {
default inner class NestedClasses {
public class Nested {
default class NestedClasses {
public static class Nested {
default fun func1(): void {
}
}
public inner class Inner {
public class Inner {
default fun func2(): void {
}
}
}
}
}
+7 -7
View File
@@ -1,18 +1,18 @@
default class _Dummy_ {
default inner class Simple {
default class Simple {
var name: String
public fun Simple(name: String) {
public fun <init>(name: String) {
this.name = name
}
public fun getName(): String {
return name
}
public fun setName(name: String): void {
this.name = name
}
}
}
}
+23 -23
View File
@@ -1,68 +1,68 @@
default class _Dummy_ {
default inner class SpecialExpressions {
default class SpecialExpressions {
default fun test(): boolean {
assert 5 > 3 : EmptyExpression
assert 5 > 3 : "Message"
synchronized this : {
System.out.println("A")
}
var a: int = 5
var b: int = 7
var c: int
while (a > 0) {
if (a === 3) {
break
break
}
if (a % 5 === 0) {
continue
continue
}
a--
}
this.test()
super.hashCode()
var x: String
switch (a)
{
case 1:
1 ->
{
x = "1"
break
break
}
case 3:
3 ->
x = "3"
case 4:
4 ->
x = "4"
else:
else ->
x = ""
}
if (System.getProperty("abc", "").equals("1")) {
throw <noref>("Err")
throw AssertionError("Err")
}
try {
Thread.sleep(1000)
}
catch (e) {
}
finally {
a = 3
}
{
a = 5
}
return true
}
}
}
}
+196 -5
View File
@@ -1,11 +1,202 @@
UFile (package = null)
UClass (ControlStructures, enum = false, interface = false, object = false)
UClass (ControlStructures, kind = class)
UFunction (<init>, kind = CONSTRUCTOR, paramCount = 0)
EmptyExpression
UFunction (test, kind = function, paramCount = 0)
UBlockExpression
UIfExpression
UBinaryExpression (>)
ULiteralExpression (5)
ULiteralExpression (3)
UBlockExpression
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (println)
ULiteralExpression ("5 > 3")
<no element>
UForEachExpression (c)
ULiteralExpression ("ABC")
UBlockExpression
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (println)
USimpleReferenceExpression (c)
UForEachExpression (c)
ULiteralExpression ("DEF")
UBlockExpression
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (println)
UQualifiedExpression
USimpleReferenceExpression (c)
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 0)
USimpleReferenceExpression (toByte)
UDeclarationsExpression
UVariable (i, kind = local)
ULiteralExpression (5)
UWhileExpression
UBinaryExpression (>)
USimpleReferenceExpression (i)
ULiteralExpression (0)
UBlockExpression
UPostfixExpression (--)
USimpleReferenceExpression (i)
UIfExpression
UBinaryExpression (==)
USimpleReferenceExpression (i)
ULiteralExpression (3)
USpecialExpressionList (break)
<no element>
UIfExpression
UBinaryExpression (==)
USimpleReferenceExpression (i)
ULiteralExpression (2)
UBlockExpression
USpecialExpressionList (continue)
<no element>
UBinaryExpression (=)
USimpleReferenceExpression (i)
ULiteralExpression (5)
UDoWhileExpression
UBinaryExpression (>)
USimpleReferenceExpression (i)
ULiteralExpression (0)
UBlockExpression
UBinaryExpression (-=)
USimpleReferenceExpression (i)
ULiteralExpression (1)
UQualifiedExpression
ULiteralExpression ("ABC")
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (forEach)
ULambdaExpression
UBlockExpression
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (println)
UArrayAccessExpression
UQualifiedExpression
USimpleReferenceExpression (it)
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 0)
USimpleReferenceExpression (toString)
ULiteralExpression (0)
UQualifiedExpression
UQualifiedExpression
ULiteralExpression ("ABC")
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (zip)
ULiteralExpression ("DEF")
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (forEach)
ULambdaExpression
UBlockExpression
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (println)
UBinaryExpression (+)
UBinaryExpression (+)
UQualifiedExpression
USimpleReferenceExpression (it)
USimpleReferenceExpression (first)
ULiteralExpression (" ")
UQualifiedExpression
USimpleReferenceExpression (it)
USimpleReferenceExpression (second)
UDeclarationsExpression
UVariable (var1496943053, kind = local)
UQualifiedExpression
ULiteralExpression ("ABC")
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (zip)
ULiteralExpression ("DEF")
UVariable (a, kind = local)
UQualifiedExpression
USimpleReferenceExpression (var1496943053)
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 0)
USimpleReferenceExpression (component1)
UVariable (b, kind = local)
UQualifiedExpression
USimpleReferenceExpression (var1496943053)
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 0)
USimpleReferenceExpression (component2)
UDeclarationsExpression
UVariable (value, kind = local)
UIfExpression
UBinaryExpression (>)
ULiteralExpression (5)
ULiteralExpression (3)
ULiteralExpression ("a")
ULiteralExpression ("b")
UDeclarationsExpression
UVariable (list, kind = local)
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (listOf)
ULiteralExpression ("A")
UDeclarationsExpression
UVariable (list2, kind = local)
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (listOf)
ULiteralExpression ("A")
UDeclarationsExpression
UVariable (type, kind = local)
USwitchExpression
USimpleReferenceExpression (value)
USpecialExpressionList (when)
KotlinUSwitchEntry
USpecialExpressionList (when_entry)
ULiteralExpression ("inlist")
USpecialExpressionList (break)
KotlinUSwitchEntry
USpecialExpressionList (when_entry)
ULiteralExpression ("notinlist2")
USpecialExpressionList (break)
KotlinUSwitchEntry
USpecialExpressionList (when_entry)
ULiteralExpression ("string")
USpecialExpressionList (break)
KotlinUSwitchEntry
USpecialExpressionList (when_entry)
ULiteralExpression ("cs")
USpecialExpressionList (break)
KotlinUSwitchEntry
USpecialExpressionList (when_entry)
ULiteralExpression ("unknown")
USpecialExpressionList (break)
UDeclarationsExpression
UVariable (x, kind = local)
UFunctionCallExpression (FUNCTION_CALL, argCount = 1)
USimpleReferenceExpression (listOf)
ULiteralExpression ("ABC")
USwitchExpression
<no element>
USpecialExpressionList (when)
KotlinUSwitchEntry
USpecialExpressionList (when_entry)
ULiteralExpression ("B")
USpecialExpressionList (break)
KotlinUSwitchEntry
USpecialExpressionList (when_entry)
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (println)
ULiteralExpression ("A")
ULiteralExpression ("Q")
USpecialExpressionList (break)
KotlinUSwitchEntry
USpecialExpressionList (when_entry)
ULiteralExpression ("!")
USpecialExpressionList (break)
KotlinUSwitchEntry
USpecialExpressionList (when_entry)
ULiteralExpression ("A")
USpecialExpressionList (break)
USpecialExpressionList (return)
ULiteralExpression (false)
ULiteralExpression (false)
+10 -4
View File
@@ -1,11 +1,17 @@
UFile (package = null)
UClass (Declarations, enum = false, interface = false, object = false)
UClass (Declarations, kind = class)
UFunction (<init>, kind = CONSTRUCTOR, paramCount = 0)
EmptyExpression
UVariable (a, kind = member)
ULiteralExpression ("a")
UClass (NestedClass, enum = false, interface = false, object = false)
UClass (NestedClass, kind = class)
UFunction (<init>, kind = CONSTRUCTOR, paramCount = 0)
EmptyExpression
UVariable (b, kind = member)
ULiteralExpression ("b")
UClass (InnerClass, enum = false, interface = false, object = false)
UClass (InnerClass, kind = class)
UFunction (<init>, kind = CONSTRUCTOR, paramCount = 0)
EmptyExpression
UVariable (c, kind = member)
USimpleReferenceExpression (a)
UFunction (func, kind = function, paramCount = 2)
@@ -18,4 +24,4 @@ UFile (package = null)
ULiteralExpression (1)
UQualifiedExpression
USimpleReferenceExpression (b)
USimpleReferenceExpression (length)
USimpleReferenceExpression (length)
+9 -3
View File
@@ -1,19 +1,25 @@
UFile (package = null)
UClass (Simple, enum = false, interface = false, object = false)
UClass (Simple, kind = class)
UFunction (<init>, kind = CONSTRUCTOR, paramCount = 0)
EmptyExpression
UVariable (a, kind = member)
UBinaryExpression (+)
UBinaryExpression (+)
ULiteralExpression ("text")
ULiteralExpression ("other")
ULiteralExpression ("text")
UVariable (b, kind = member)
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (listOf)
ULiteralExpression ("A")
UFunction (test, kind = function, paramCount = 0)
UBlockExpression
UQualifiedExpression
UQualifiedExpression
USimpleReferenceExpression (System)
USimpleReferenceExpression (out)
UFunctionCallExpression (FUNCTION_CALL, argCount = 1)
UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1)
USimpleReferenceExpression (println)
UBinaryExpression (/)
ULiteralExpression (5.0f)
ULiteralExpression (2)
ULiteralExpression (2)
+94 -2
View File
@@ -1,6 +1,98 @@
public class ControlStructures {
public static class ControlStructures {
public fun <init>() = EmptyExpression
public fun test(): Boolean {
var x: List = listOf("ABC")
if (5 > 3) {
println("5 > 3")
}
for (c : "ABC") {
println(c)
}
for (c : "DEF") {
println(c.toByte())
}
var i: Int = 5
while (i > 0) {
i--
if (i == 3) break
if (i == 2) {
continue
}
}
i = 5
do {
i -= 1
}
while (i > 0)
"ABC".forEach({
println(it.toString()[0])
})
"ABC".zip("DEF").forEach({
println(it.first + " " + it.second)
})
var var1496943053: <error> = "ABC".zip("DEF")
var a: Pair<Char, Char> = var1496943053.component1()
var b: Pair<Char, Char> = var1496943053.component2()
var value: String = if (5 > 3) "a" else "b"
var list: List<String> = listOf("A")
var list2: List<String> = listOf("A")
var type: String = switch (value) {
it in list -> {
"inlist"
break
}
it in list2 -> {
"notinlist2"
break
}
(it) is null -> {
"string"
break
}
(it) is null -> {
"cs"
break
}
else -> {
"unknown"
break
}
}
var x: String = switch {
value == "b" -> {
"B"
break
}
5 % 2 == 0 -> {
println("A")
"Q"
break
}
false -> {
"!"
break
}
else -> {
"A"
break
}
}
return false
}
+6 -3
View File
@@ -1,11 +1,14 @@
public class Declarations {
public static class Declarations {
public fun <init>() = EmptyExpression
var a: String = "a"
public class NestedClass {
public static class NestedClass {
public fun <init>() = EmptyExpression
var b: String = "b"
}
public inner class InnerClass {
public class InnerClass {
public fun <init>() = EmptyExpression
var c: CharSequence = a
}
+4 -2
View File
@@ -1,6 +1,8 @@
public class Simple {
public static class Simple {
public fun <init>() = EmptyExpression
var a: String = "text" + "other" + "text"
val b = listOf("A")
var b: List<String> = listOf("A")
public fun test(): Unit {
System.out.println(5.0f / 2)