[groovy] extract CategorySupportTest

This commit is contained in:
Daniil Ovchinnikov
2019-03-20 19:03:17 +03:00
parent e0f4d03f1f
commit ad10821513
4 changed files with 45 additions and 28 deletions
@@ -0,0 +1,45 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.groovy.lang.resolve
import com.intellij.psi.PsiModifier
import groovy.transform.CompileStatic
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrGdkMethod
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrReflectedMethod
import org.jetbrains.plugins.groovy.util.GroovyLatestTest
import org.jetbrains.plugins.groovy.util.ResolveTest
import org.junit.Test
@CompileStatic
class CategorySupportTest extends GroovyLatestTest implements ResolveTest {
@Test
void 'static category method outside of category'() {
def resolved = resolveTest '''\
@Category(String) class C { def foo() {} }
C.<caret>foo("")
''', GrReflectedMethod
assert resolved.modifierList.hasModifierProperty(PsiModifier.STATIC)
}
@Test
void 'category method within category'() {
resolveTest '''\
@Category(String)
class C {
def foo() {}
def usage() { <caret>foo() }
}
''', GrGdkMethod
}
@Test
void 'explicit category method within category'() {
resolveTest '''\
@Category(String)
class C {
static def foo(String s) {}
def usage() { <caret>foo() }
}
''', GrGdkMethod
}
}
@@ -722,15 +722,6 @@ class Foo {
assertNotNull(resolve('a.groovy'))
}
void testCategoryClassMethod() {
def resolved = resolve('a.groovy', GrReflectedMethod)
assertTrue(resolved.modifierList.hasModifierProperty(PsiModifier.STATIC))
}
void testCategoryMethodWithinCategory() {
assertNotNull resolve('a.groovy')
}
void testMixinAndCategory() {
def ref = configureByText("""
@Category(B)
@@ -1,8 +0,0 @@
@Category(A)
class B {
def foo(){}
}
class A{}
B.f<ref>oo(new A())
@@ -1,11 +0,0 @@
class A {}
@Category(A)
class B {
def foo() {
ba<ref>r()
}
def bar() {}
}