This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new b66693d GROOVY-5103: add test case
b66693d is described below
commit b66693d1a923a5626dce41a7ba2a7151034db3e7
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()
+ '''
}
}