aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2022-08-17 14:35:31 +0200
committerGitHub <noreply@github.com>2022-08-17 14:35:31 +0200
commitd755694746b877b0051b886e4ac05bd428bee429 (patch)
treea411c896ce741165faf4ee0f943b950f86c6d252 /plugins/base/src/test
parenta7c3113b2249a0fa1631dbc0e4bb85d75a12b25a (diff)
downloaddokka-d755694746b877b0051b886e4ac05bd428bee429.tar.gz
dokka-d755694746b877b0051b886e4ac05bd428bee429.tar.bz2
dokka-d755694746b877b0051b886e4ac05bd428bee429.zip
Display values of java constants (#2609)
Fixes #2524
Diffstat (limited to 'plugins/base/src/test')
-rw-r--r--plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt45
1 files changed, 45 insertions, 0 deletions
diff --git a/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt b/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt
index 3f34f020..97d85548 100644
--- a/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt
+++ b/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt
@@ -199,6 +199,51 @@ class DefaultPsiToDocumentableTranslatorTest : BaseAbstractTest() {
}
@Test
+ fun `should add default value to constant properties`() {
+ testInline(
+ """
+ |/src/main/java/test/JavaConstants.java
+ |package test;
+ |
+ |public class JavaConstants {
+ | public static final byte BYTE = 1;
+ | public static final short SHORT = 2;
+ | public static final int INT = 3;
+ | public static final long LONG = 4L;
+ | public static final float FLOAT = 5.0f;
+ | public static final double DOUBLE = 6.0d;
+ | public static final String STRING = "Seven";
+ | public static final char CHAR = 'E';
+ | public static final boolean BOOLEAN = true;
+ |}
+ """.trimIndent(),
+ configuration
+ ) {
+ documentablesMergingStage = { module ->
+ val testedClass = module.packages.single().classlikes.single { it.name == "JavaConstants" }
+
+ val constants = testedClass.properties
+ assertEquals(9, constants.size)
+
+ val constantsByName = constants.associateBy { it.name }
+ fun getConstantExpression(name: String): Expression? {
+ return constantsByName.getValue(name).extra[DefaultValue]?.expression?.values?.first()
+ }
+
+ assertEquals(IntegerConstant(1), getConstantExpression("BYTE"))
+ assertEquals(IntegerConstant(2), getConstantExpression("SHORT"))
+ assertEquals(IntegerConstant(3), getConstantExpression("INT"))
+ assertEquals(IntegerConstant(4), getConstantExpression("LONG"))
+ assertEquals(FloatConstant(5.0f), getConstantExpression("FLOAT"))
+ assertEquals(DoubleConstant(6.0), getConstantExpression("DOUBLE"))
+ assertEquals(StringConstant("Seven"), getConstantExpression("STRING"))
+ assertEquals(StringConstant("E"), getConstantExpression("CHAR"))
+ assertEquals(BooleanConstant(true), getConstantExpression("BOOLEAN"))
+ }
+ }
+ }
+
+ @Test
fun `should resolve static imports used as annotation param values as literal values`() {
testInline(
"""