You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2021/10/07 15:33:11 UTC
[groovy] branch master updated: Tweak test `SealedTest` further
This is an automated email from the ASF dual-hosted git repository.
sunlan 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 7230c05 Tweak test `SealedTest` further
7230c05 is described below
commit 7230c053a2d24179094e8ced2aeb295d99216e19
Author: Daniel Sun <su...@apache.org>
AuthorDate: Thu Oct 7 23:32:49 2021 +0800
Tweak test `SealedTest` further
---
.../org/codehaus/groovy/classgen/SealedTest.groovy | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/test/groovy/org/codehaus/groovy/classgen/SealedTest.groovy b/src/test/groovy/org/codehaus/groovy/classgen/SealedTest.groovy
index b5cc556..f3b07502 100644
--- a/src/test/groovy/org/codehaus/groovy/classgen/SealedTest.groovy
+++ b/src/test/groovy/org/codehaus/groovy/classgen/SealedTest.groovy
@@ -22,6 +22,7 @@ import groovy.transform.CompileStatic
import org.codehaus.groovy.control.CompilerConfiguration
import org.junit.Test
+import static groovy.test.GroovyAssert.assertScript
import static groovy.test.GroovyAssert.isAtLeastJdk
import static org.junit.Assume.assumeTrue
@@ -30,27 +31,26 @@ class SealedTest {
@Test
void testInferredPermittedNestedClasses() {
assumeTrue(isAtLeastJdk('17.0'))
- List<Class> classes = (List<Class>) new GroovyShell().evaluate('''
+ assertScript '''
sealed class Shape {
final class Triangle extends Shape { }
final class Polygon extends Shape { }
}
- Shape.getPermittedSubclasses()
- ''')
- assert classes*.name == ['Shape$Triangle', 'Shape$Polygon']
+ List<Class> classes = Shape.getPermittedSubclasses()
+ assert classes*.name == ['Shape$Triangle', 'Shape$Polygon']
+ '''
}
@Test
void testInferredPermittedNestedClassesWithNativeDisabled() {
assumeTrue(isAtLeastJdk('17.0'))
- def config = new CompilerConfiguration(sealedNative: false)
- def classes = new GroovyShell(config).evaluate('''
+ assertScript(new GroovyShell(new CompilerConfiguration(sealedNative: false)), '''
sealed class Shape {
final class Triangle extends Shape { }
final class Polygon extends Shape { }
}
- Shape.getPermittedSubclasses()
+ List<Class> classes = Shape.getPermittedSubclasses()
+ assert !classes
''')
- assert !classes
}
}