Uast: Update tests, make the tests a bit more readable (provide toString() methods for Uast kinds)
This commit is contained in:
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user