From 83e86c20c5c90ca1118148dd4e2d1fbdf28eb94f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Mon, 13 Jan 2020 01:13:46 +0100 Subject: [PATCH] Test modelica text --- .../lang/modelica/ast/ModelicaCoordsTest.kt | 49 +++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/pmd-modelica/src/test/kotlin/net/sourceforge/pmd/lang/modelica/ast/ModelicaCoordsTest.kt b/pmd-modelica/src/test/kotlin/net/sourceforge/pmd/lang/modelica/ast/ModelicaCoordsTest.kt index b595fe65d8..425a357281 100644 --- a/pmd-modelica/src/test/kotlin/net/sourceforge/pmd/lang/modelica/ast/ModelicaCoordsTest.kt +++ b/pmd-modelica/src/test/kotlin/net/sourceforge/pmd/lang/modelica/ast/ModelicaCoordsTest.kt @@ -9,6 +9,8 @@ import io.kotlintest.shouldBe import io.kotlintest.specs.FunSpec import net.sourceforge.pmd.lang.LanguageRegistry import net.sourceforge.pmd.lang.ast.Node +import net.sourceforge.pmd.lang.ast.test.firstToken +import net.sourceforge.pmd.lang.ast.test.lastToken import net.sourceforge.pmd.lang.ast.test.matchNode import net.sourceforge.pmd.lang.ast.test.shouldBe import java.io.StringReader @@ -25,71 +27,111 @@ package TestPackage end TestPackage; """.trim().parseModelica() should matchNode { + it::getText shouldBe """package TestPackage + package EmptyPackage + end EmptyPackage; +end TestPackage;""" + it.assertBounds(1, 1, 4, 17) child { + it::getText shouldBe """package TestPackage + package EmptyPackage + end EmptyPackage; +end TestPackage""" it.assertBounds(1, 1, 4, 16) child { + it::getText shouldBe "package" it.assertBounds(1, 1, 1, 8) child { + it::getText shouldBe "package" it.assertBounds(1, 1, 1, 8) } } child { + it::getText shouldBe """TestPackage + package EmptyPackage + end EmptyPackage; +end TestPackage""" it.assertBounds(1, 9, 4, 16) child { + it::getText shouldBe """TestPackage + package EmptyPackage + end EmptyPackage; +end TestPackage""" + it.assertBounds(1, 9, 4, 16) child { + it::getText shouldBe "TestPackage" it.assertBounds(1, 9, 1, 20) } child { + it::getText shouldBe """package EmptyPackage + end EmptyPackage;""" it.assertBounds(2, 3, 3, 20) child { + it::getText shouldBe """package EmptyPackage + end EmptyPackage;""" it.assertBounds(2, 3, 3, 20) child { + it::getText shouldBe """package EmptyPackage + end EmptyPackage""" it.assertBounds(2, 3, 3, 19) child { + it::getText shouldBe """package EmptyPackage + end EmptyPackage""" it.assertBounds(2, 3, 3, 19) it.isPartial shouldBe false child { + it::getText shouldBe "package" it.assertBounds(2, 3, 2, 10) child { + it::getText shouldBe "package" it.assertBounds(2, 3, 2, 10) } } child { + it::getText shouldBe """EmptyPackage + end EmptyPackage""" it.assertBounds(2, 11, 3, 19) child { + it::getText shouldBe """EmptyPackage + end EmptyPackage""" it.assertBounds(2, 11, 3, 19) it.simpleClassName shouldBe "EmptyPackage" child { + it::getText shouldBe "EmptyPackage" it.assertBounds(2, 11, 2, 23) } child { + it::getText shouldBe "" + it.firstToken::isImplicit shouldBe true + it.lastToken shouldBe it.firstToken it.assertBounds(3, 3, 3, 3) child { - /* - This ElementList is empty and has no explicit token. - */ + it::getText shouldBe "" + it.firstToken::isImplicit shouldBe true + it.lastToken shouldBe it.firstToken it.assertBounds(3, 3, 3, 3) } } child { + it::getText shouldBe "EmptyPackage" it::getImage shouldBe "EmptyPackage" it.assertBounds(3, 7, 3, 19) } @@ -100,6 +142,7 @@ end TestPackage; } } child { + it::getText shouldBe "TestPackage" it.assertBounds(4, 5, 4, 16) } }