This is an automated email from the ASF dual-hosted git repository. paulk pushed a commit to branch GROOVY_3_0_X in repository https://gitbox.apache.org/repos/asf/groovy.git
commit c2e3b6a1af4e5a5eec041c4621397a50d6e84e37 Author: Eric Milles <[email protected]> AuthorDate: Sat Jul 18 12:26:30 2020 -0500 GROOVY-5103: add test case --- src/test/groovy/ImportTest.groovy | 53 ++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/src/test/groovy/ImportTest.groovy b/src/test/groovy/ImportTest.groovy index bece387..8031f61 100644 --- a/src/test/groovy/ImportTest.groovy +++ b/src/test/groovy/ImportTest.groovy @@ -18,28 +18,45 @@ */ package groovy -import groovy.test.GroovyTestCase +import org.junit.Test -class ImportTest extends GroovyTestCase { +import static groovy.test.GroovyAssert.assertScript +import static groovy.test.GroovyAssert.shouldFail +final class ImportTest { + + @Test void testImportAll() { - def file = new File("foo.txt") - assert file instanceof File - assert file.getClass().name == "java.io.File" + assertScript ''' + def file = new File('foo') + assert file instanceof File + ''' } - + + @Test void testImportByName() { - def x = [:] - assert x instanceof Map - /** - * For maps, map.getClass() should be used instead of map.class, - * when map has no member, named as "class" - */ - assert x.getClass() != null - assert x.getClass().name.startsWith("java.util.") - - def y = [1, 2, 3] - assert y instanceof List - assert y.getClass().name.startsWith("java.util.") + assertScript ''' + def map = [foo:'bar'] + assert map instanceof Map + ''' + + assertScript ''' + def list = [1, 2, 3] + assert list instanceof List + ''' + } + + @Test + void testImportStaticInnerClass() { + assertScript ''' + import java.util.Map.Entry + Entry entry = [foo:'bar'].entrySet().first() + ''' + + // GROOVY-5103 + shouldFail ''' + import java.util.Map.* + Entry entry = [foo:'bar'].entrySet().first() + ''' } }
