Add test for converting a string literal to UAST

This commit is contained in:
Dmitry Jemerov
2017-02-08 11:29:13 +01:00
parent 5dc178460e
commit 00003684e8
2 changed files with 19 additions and 1 deletions
+3
View File
@@ -0,0 +1,3 @@
class Demo {
val foo = X.bar("lorem")
}
+16 -1
View File
@@ -1,8 +1,13 @@
package org.jetbrains.uast.test.kotlin
import org.jetbrains.kotlin.psi.KtLiteralStringTemplateEntry
import org.jetbrains.uast.UAnnotation
import org.jetbrains.uast.UFile
import org.jetbrains.uast.ULiteralExpression
import org.jetbrains.uast.psi.PsiElementBacked
import org.jetbrains.uast.test.env.findElementByText
import org.jetbrains.uast.toUElement
import org.junit.Assert
import org.junit.Test
@@ -17,5 +22,15 @@ class KotlinUastApiTest : AbstractKotlinUastTest() {
assertEquals(annotation.findAttributeValue("to")?.expression?.evaluate(), 0)
}
}
}
@Test fun testConvertStringTemplate() {
doTest("StringTemplateInClass") { name, file ->
val literalExpression = file.findElementByText<ULiteralExpression>("lorem")
val psi = (literalExpression as PsiElementBacked).psi!!
Assert.assertTrue(psi is KtLiteralStringTemplateEntry)
val literalExpressionAgain = psi.toUElement()
Assert.assertTrue(literalExpressionAgain is ULiteralExpression)
}
}
}