Test modelica text
This commit is contained in:
@ -9,6 +9,8 @@ import io.kotlintest.shouldBe
|
|||||||
import io.kotlintest.specs.FunSpec
|
import io.kotlintest.specs.FunSpec
|
||||||
import net.sourceforge.pmd.lang.LanguageRegistry
|
import net.sourceforge.pmd.lang.LanguageRegistry
|
||||||
import net.sourceforge.pmd.lang.ast.Node
|
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.matchNode
|
||||||
import net.sourceforge.pmd.lang.ast.test.shouldBe
|
import net.sourceforge.pmd.lang.ast.test.shouldBe
|
||||||
import java.io.StringReader
|
import java.io.StringReader
|
||||||
@ -25,71 +27,111 @@ package TestPackage
|
|||||||
end TestPackage;
|
end TestPackage;
|
||||||
""".trim().parseModelica() should matchNode<ASTStoredDefinition> {
|
""".trim().parseModelica() should matchNode<ASTStoredDefinition> {
|
||||||
|
|
||||||
|
it::getText shouldBe """package TestPackage
|
||||||
|
package EmptyPackage
|
||||||
|
end EmptyPackage;
|
||||||
|
end TestPackage;"""
|
||||||
|
|
||||||
it.assertBounds(1, 1, 4, 17)
|
it.assertBounds(1, 1, 4, 17)
|
||||||
|
|
||||||
child<ASTClassDefinition> {
|
child<ASTClassDefinition> {
|
||||||
|
it::getText shouldBe """package TestPackage
|
||||||
|
package EmptyPackage
|
||||||
|
end EmptyPackage;
|
||||||
|
end TestPackage"""
|
||||||
it.assertBounds(1, 1, 4, 16)
|
it.assertBounds(1, 1, 4, 16)
|
||||||
|
|
||||||
child<ASTClassPrefixes> {
|
child<ASTClassPrefixes> {
|
||||||
|
it::getText shouldBe "package"
|
||||||
it.assertBounds(1, 1, 1, 8)
|
it.assertBounds(1, 1, 1, 8)
|
||||||
|
|
||||||
child<ASTPackageClause> {
|
child<ASTPackageClause> {
|
||||||
|
it::getText shouldBe "package"
|
||||||
it.assertBounds(1, 1, 1, 8)
|
it.assertBounds(1, 1, 1, 8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
child<ASTClassSpecifier> {
|
child<ASTClassSpecifier> {
|
||||||
|
it::getText shouldBe """TestPackage
|
||||||
|
package EmptyPackage
|
||||||
|
end EmptyPackage;
|
||||||
|
end TestPackage"""
|
||||||
it.assertBounds(1, 9, 4, 16)
|
it.assertBounds(1, 9, 4, 16)
|
||||||
|
|
||||||
child<ASTSimpleLongClassSpecifier> {
|
child<ASTSimpleLongClassSpecifier> {
|
||||||
|
it::getText shouldBe """TestPackage
|
||||||
|
package EmptyPackage
|
||||||
|
end EmptyPackage;
|
||||||
|
end TestPackage"""
|
||||||
|
|
||||||
it.assertBounds(1, 9, 4, 16)
|
it.assertBounds(1, 9, 4, 16)
|
||||||
|
|
||||||
child<ASTSimpleName> {
|
child<ASTSimpleName> {
|
||||||
|
it::getText shouldBe "TestPackage"
|
||||||
it.assertBounds(1, 9, 1, 20)
|
it.assertBounds(1, 9, 1, 20)
|
||||||
}
|
}
|
||||||
child<ASTComposition> {
|
child<ASTComposition> {
|
||||||
|
it::getText shouldBe """package EmptyPackage
|
||||||
|
end EmptyPackage;"""
|
||||||
it.assertBounds(2, 3, 3, 20)
|
it.assertBounds(2, 3, 3, 20)
|
||||||
|
|
||||||
child<ASTElementList> {
|
child<ASTElementList> {
|
||||||
|
it::getText shouldBe """package EmptyPackage
|
||||||
|
end EmptyPackage;"""
|
||||||
it.assertBounds(2, 3, 3, 20)
|
it.assertBounds(2, 3, 3, 20)
|
||||||
|
|
||||||
child<ASTRegularElement> {
|
child<ASTRegularElement> {
|
||||||
|
it::getText shouldBe """package EmptyPackage
|
||||||
|
end EmptyPackage"""
|
||||||
it.assertBounds(2, 3, 3, 19)
|
it.assertBounds(2, 3, 3, 19)
|
||||||
|
|
||||||
child<ASTClassDefinition> {
|
child<ASTClassDefinition> {
|
||||||
|
it::getText shouldBe """package EmptyPackage
|
||||||
|
end EmptyPackage"""
|
||||||
it.assertBounds(2, 3, 3, 19)
|
it.assertBounds(2, 3, 3, 19)
|
||||||
it.isPartial shouldBe false
|
it.isPartial shouldBe false
|
||||||
|
|
||||||
child<ASTClassPrefixes> {
|
child<ASTClassPrefixes> {
|
||||||
|
it::getText shouldBe "package"
|
||||||
it.assertBounds(2, 3, 2, 10)
|
it.assertBounds(2, 3, 2, 10)
|
||||||
|
|
||||||
child<ASTPackageClause> {
|
child<ASTPackageClause> {
|
||||||
|
it::getText shouldBe "package"
|
||||||
it.assertBounds(2, 3, 2, 10)
|
it.assertBounds(2, 3, 2, 10)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
child<ASTClassSpecifier> {
|
child<ASTClassSpecifier> {
|
||||||
|
it::getText shouldBe """EmptyPackage
|
||||||
|
end EmptyPackage"""
|
||||||
it.assertBounds(2, 11, 3, 19)
|
it.assertBounds(2, 11, 3, 19)
|
||||||
|
|
||||||
child<ASTSimpleLongClassSpecifier> {
|
child<ASTSimpleLongClassSpecifier> {
|
||||||
|
it::getText shouldBe """EmptyPackage
|
||||||
|
end EmptyPackage"""
|
||||||
it.assertBounds(2, 11, 3, 19)
|
it.assertBounds(2, 11, 3, 19)
|
||||||
it.simpleClassName shouldBe "EmptyPackage"
|
it.simpleClassName shouldBe "EmptyPackage"
|
||||||
|
|
||||||
child<ASTSimpleName> {
|
child<ASTSimpleName> {
|
||||||
|
it::getText shouldBe "EmptyPackage"
|
||||||
it.assertBounds(2, 11, 2, 23)
|
it.assertBounds(2, 11, 2, 23)
|
||||||
|
|
||||||
}
|
}
|
||||||
child<ASTComposition> {
|
child<ASTComposition> {
|
||||||
|
it::getText shouldBe ""
|
||||||
|
it.firstToken::isImplicit shouldBe true
|
||||||
|
it.lastToken shouldBe it.firstToken
|
||||||
|
|
||||||
it.assertBounds(3, 3, 3, 3)
|
it.assertBounds(3, 3, 3, 3)
|
||||||
|
|
||||||
child<ASTElementList> {
|
child<ASTElementList> {
|
||||||
/*
|
it::getText shouldBe ""
|
||||||
This ElementList is empty and has no explicit token.
|
it.firstToken::isImplicit shouldBe true
|
||||||
*/
|
it.lastToken shouldBe it.firstToken
|
||||||
|
|
||||||
it.assertBounds(3, 3, 3, 3)
|
it.assertBounds(3, 3, 3, 3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
child<ASTSimpleName> {
|
child<ASTSimpleName> {
|
||||||
|
it::getText shouldBe "EmptyPackage"
|
||||||
it::getImage shouldBe "EmptyPackage"
|
it::getImage shouldBe "EmptyPackage"
|
||||||
it.assertBounds(3, 7, 3, 19)
|
it.assertBounds(3, 7, 3, 19)
|
||||||
}
|
}
|
||||||
@ -100,6 +142,7 @@ end TestPackage;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
child<ASTSimpleName> {
|
child<ASTSimpleName> {
|
||||||
|
it::getText shouldBe "TestPackage"
|
||||||
it.assertBounds(4, 5, 4, 16)
|
it.assertBounds(4, 5, 4, 16)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user