[groovy] add tests for 'for' variables

This commit is contained in:
Daniil Ovchinnikov
2018-07-02 14:28:14 +03:00
parent 6b52f53638
commit bdb8e7ce0f
4 changed files with 34 additions and 23 deletions
@@ -52,4 +52,38 @@ class ResolveLocalTest implements ResolveTest {
void 'parameter from resource initializer'() {
resolveTest 'def foo(param) { try (def a = <caret>param) {} }', GrParameter
}
@Test
void 'for variable from for block'() {
resolveTest 'for (def e;;){ <caret>e }', GrVariable
}
@Test
void 'for variable from for condition'() {
resolveTest 'for (def e;<caret>e;){}', GrVariable
}
@Test
void 'for variable from for update'() {
resolveTest 'for (def e;;<caret>e){}', GrVariable
}
@Test
void 'for variable from for-each expression'() {
resolveTest 'for (e : <caret>e) {}', null
resolveTest 'for (e in <caret>e) {}', null
}
@Test
void 'for variable from for-each block'() {
resolveTest 'for (e : b) { <caret>e }', GrVariable
resolveTest 'for (e in b) { <caret>e }', GrVariable
}
@Test
void 'for variable after for'() {
resolveTest 'for (def e;;) {}; <caret>e', null
resolveTest 'for (e : b) {}; <caret>e', null
resolveTest 'for (e in b) {}; <caret>e', null
}
}
@@ -58,11 +58,6 @@ class ResolvePropertyTest extends GroovyResolveTestCase {
doTest("field2/A.groovy")
}
void testForVariable1() throws Exception {
disableTransformations testRootDisposable
resolve "ForVariable.groovy", GrParameter
}
void testArrayLength() throws Exception {
doTest("arrayLength/A.groovy")
}
@@ -87,10 +82,6 @@ class ResolvePropertyTest extends GroovyResolveTestCase {
assertTrue(ref.resolve() instanceof GrAccessorMethod)
}
void _testForVariable2() throws Exception {
doTest("forVariable2/ForVariable.groovy")
}
void testCatchParameter() throws Exception {
disableTransformations testRootDisposable
resolve "CatchParameter.groovy", GrParameter
@@ -1,7 +0,0 @@
class ForVariable {
def foo = {
for (i in is) {
def e = <ref>i
}
}
}
@@ -1,7 +0,0 @@
class ForVariable {
def foo = {
for (def i = 0, j = 0;;) {
def e = <ref>j
}
}
}