Add tests
This commit is contained in:
Clément Fournier
committed by
Andreas Dangel
parent
8ce91fc3e4
commit
4f9c8f7f60
@ -2025,12 +2025,12 @@ void ClassOrInterfaceType() #void:
|
||||
}
|
||||
|
||||
/*
|
||||
Now if there are other segments, either the previous type specified formal parameters,
|
||||
Now if there are other segments, either the previous type specified type arguments,
|
||||
or the next has an annotation.
|
||||
|
||||
Each of the following segments is its own ClassOrInterfaceType which encloses the
|
||||
previous one. The resulting structure appears left-recursive, but the parser just
|
||||
executes a loop. That scheme preserves the position of type params and annotations.
|
||||
executes a loop. That scheme preserves the position of type arguments and annotations.
|
||||
See #1150.
|
||||
|
||||
FIXME this doesn't account for annotated AND qualified types
|
||||
@ -2068,6 +2068,10 @@ void TypeArguments():
|
||||
"<" {checkForBadDiamondUsage();} ">"
|
||||
}
|
||||
|
||||
/**
|
||||
* We could make this #void and instead have a node WildcardType extending ReferenceType.
|
||||
* This would remove this level of nesting, which is unnecessary.
|
||||
*/
|
||||
void TypeArgument():
|
||||
{}
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ import io.kotlintest.specs.FunSpec
|
||||
class ASTClassOrInterfaceTypeTest : FunSpec({
|
||||
|
||||
|
||||
testGroup("Test non-recursive ClassOrInterfaceTypes") {
|
||||
testGroup("Test non-recursive COITs") {
|
||||
|
||||
"java.util.List" should matchType<ASTClassOrInterfaceType> {
|
||||
it.typeImage shouldBe "java.util.List"
|
||||
@ -29,5 +29,76 @@ class ASTClassOrInterfaceTypeTest : FunSpec({
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("Test recursive COITs") {
|
||||
|
||||
"java.util.Map.@Foo Entry<K, V>" should matchType<ASTClassOrInterfaceType> {
|
||||
it.typeImage shouldBe "java.util.Map.Entry"
|
||||
it.image shouldBe "Entry"
|
||||
|
||||
it.leftHandSide shouldBePresent child {
|
||||
it.typeImage shouldBe "java.util.Map"
|
||||
}
|
||||
|
||||
child<ASTAnnotation> {
|
||||
it.annotationName shouldBe "Foo"
|
||||
|
||||
child<ASTMarkerAnnotation> {
|
||||
child<ASTName> { }
|
||||
}
|
||||
}
|
||||
|
||||
child<ASTTypeArguments> {
|
||||
child<ASTTypeArgument> {
|
||||
child<ASTClassOrInterfaceType> {
|
||||
it.typeImage shouldBe "K"
|
||||
}
|
||||
}
|
||||
|
||||
child<ASTTypeArgument> {
|
||||
child<ASTClassOrInterfaceType> {
|
||||
it.typeImage shouldBe "V"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"Foo<K>.@A Bar.Brew<V>" should matchType<ASTClassOrInterfaceType> {
|
||||
|
||||
it.typeImage shouldBe "Foo.Bar.Brew"
|
||||
|
||||
it.leftHandSide shouldBePresent child {
|
||||
it.typeImage shouldBe "Foo.Bar"
|
||||
|
||||
it.leftHandSide shouldBePresent child {
|
||||
it.typeImage shouldBe "Foo"
|
||||
|
||||
child<ASTTypeArguments> {
|
||||
child<ASTTypeArgument> {
|
||||
child<ASTClassOrInterfaceType> {
|
||||
it.typeImage shouldBe "K"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
child<ASTAnnotation> {
|
||||
it.annotationName shouldBe "A"
|
||||
|
||||
child<ASTMarkerAnnotation> {
|
||||
child<ASTName> { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
child<ASTTypeArguments> {
|
||||
child<ASTTypeArgument> {
|
||||
child<ASTClassOrInterfaceType> {
|
||||
it.typeImage shouldBe "V"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
})
|
Reference in New Issue
Block a user