-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rearrange tests and fix dependency submission
- Loading branch information
1 parent
587cc38
commit ecc1f00
Showing
13 changed files
with
1,071 additions
and
1,004 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,10 +41,10 @@ jobs: | |
uses: mikepenz/[email protected] | ||
with: | ||
gradle-build-module: |- | ||
:annotations | ||
:runtime | ||
:compile | ||
:groovy | ||
:javac | ||
:opensesame-annotations | ||
:opensesame-runtime | ||
:opensesame-compile | ||
:opensesame-groovy | ||
:opensesame-javac | ||
gradle-build-configuration: |- | ||
compileClasspath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,10 +53,10 @@ jobs: | |
uses: mikepenz/[email protected] | ||
with: | ||
gradle-build-module: |- | ||
:annotations | ||
:runtime | ||
:compile | ||
:groovy | ||
:javac | ||
:opensesame-annotations | ||
:opensesame-runtime | ||
:opensesame-compile | ||
:opensesame-groovy | ||
:opensesame-javac | ||
gradle-build-configuration: |- | ||
compileClasspath |
142 changes: 142 additions & 0 deletions
142
groovy/src/test/groovy/dev/lukebemish/opensesame/test/groovy/Open/TestInstance.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
package dev.lukebemish.opensesame.test.groovy.Open | ||
|
||
import dev.lukebemish.opensesame.annotations.Open | ||
import dev.lukebemish.opensesame.test.target.Public | ||
import groovy.transform.CompileStatic | ||
import org.junit.jupiter.api.Test | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals | ||
|
||
@CompileStatic | ||
class TestInstance { | ||
@Open( | ||
name = 'privateInstance', | ||
targetClass = Public, | ||
type = Open.Type.VIRTUAL | ||
) | ||
private static String publicPrivateInstance(Public instance) { | ||
throw new RuntimeException() | ||
} | ||
|
||
@Test | ||
void testPrivateInstance() { | ||
assertEquals("privateInstance", publicPrivateInstance(new Public())) | ||
} | ||
|
||
@Open( | ||
name = 'protectedInstance', | ||
targetClass = Public, | ||
type = Open.Type.VIRTUAL | ||
) | ||
private static String publicProtectedInstance(Public instance) { | ||
throw new RuntimeException() | ||
} | ||
|
||
@Test | ||
void testProtectedInstance() { | ||
assertEquals("protectedInstance", publicProtectedInstance(new Public())) | ||
} | ||
|
||
@Open( | ||
name = 'packagePrivateInstance', | ||
targetClass = Public, | ||
type = Open.Type.VIRTUAL | ||
) | ||
private static String publicPackagePrivateInstance(Public instance) { | ||
throw new RuntimeException() | ||
} | ||
|
||
@Test | ||
void testPackagePrivateInstance() { | ||
assertEquals("packagePrivateInstance", publicPackagePrivateInstance(new Public())) | ||
} | ||
|
||
@Open( | ||
name = 'privateInstanceField', | ||
targetClass = Public, | ||
type = Open.Type.GET_INSTANCE | ||
) | ||
private static String publicPrivateInstanceField(Public instance) { | ||
throw new RuntimeException() | ||
} | ||
|
||
@Open( | ||
name = 'privateInstanceField', | ||
targetClass = Public, | ||
type = Open.Type.SET_INSTANCE | ||
) | ||
private static void publicPrivateInstanceField(Public instance, String value) { | ||
throw new RuntimeException() | ||
} | ||
|
||
@Test | ||
void testPrivateInstanceField() { | ||
var instance = new Public() | ||
publicPrivateInstanceField(instance, "test") | ||
assertEquals("test", publicPrivateInstanceField(instance)) | ||
} | ||
|
||
@Open( | ||
name = 'protectedInstanceField', | ||
targetClass = Public, | ||
type = Open.Type.GET_INSTANCE | ||
) | ||
private static String publicProtectedInstanceField(Public instance) { | ||
throw new RuntimeException() | ||
} | ||
|
||
@Open( | ||
name = 'protectedInstanceField', | ||
targetClass = Public, | ||
type = Open.Type.SET_INSTANCE | ||
) | ||
private static void publicProtectedInstanceField(Public instance, String value) { | ||
throw new RuntimeException() | ||
} | ||
|
||
@Test | ||
void testProtectedInstanceField() { | ||
var instance = new Public() | ||
publicProtectedInstanceField(instance, "test") | ||
assertEquals("test", publicProtectedInstanceField(instance)) | ||
} | ||
|
||
@Open( | ||
name = 'packagePrivateInstanceField', | ||
targetClass = Public, | ||
type = Open.Type.GET_INSTANCE | ||
) | ||
private static String publicPackagePrivateInstanceField(Public instance) { | ||
throw new RuntimeException() | ||
} | ||
|
||
@Open( | ||
name = 'packagePrivateInstanceField', | ||
targetClass = Public, | ||
type = Open.Type.SET_INSTANCE | ||
) | ||
private static void publicPackagePrivateInstanceField(Public instance, String value) { | ||
throw new RuntimeException() | ||
} | ||
|
||
@Test | ||
void testPackagePrivateInstanceField() { | ||
var instance = new Public() | ||
publicPackagePrivateInstanceField(instance, "test") | ||
assertEquals("test", publicPackagePrivateInstanceField(instance)) | ||
} | ||
|
||
@Open( | ||
name = 'privateFinalInstanceField', | ||
targetClass = Public, | ||
type = Open.Type.GET_INSTANCE | ||
) | ||
private static String publicPrivateFinalInstanceField(Public instance) { | ||
throw new RuntimeException() | ||
} | ||
|
||
@Test | ||
void testPrivateFinalInstanceField() { | ||
assertEquals("privateFinalInstanceField", publicPrivateFinalInstanceField(new Public())) | ||
} | ||
} |
141 changes: 141 additions & 0 deletions
141
groovy/src/test/groovy/dev/lukebemish/opensesame/test/groovy/Open/TestMisc.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
package dev.lukebemish.opensesame.test.groovy.Open | ||
|
||
|
||
import dev.lukebemish.opensesame.annotations.Open | ||
import dev.lukebemish.opensesame.test.target.Public | ||
import groovy.transform.CompileStatic | ||
import groovy.transform.PackageScope | ||
import org.junit.jupiter.api.Test | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals | ||
import static org.junit.jupiter.api.Assertions.assertThrows | ||
|
||
@CompileStatic | ||
class TestMisc { | ||
@Open( | ||
name = 'privateInstanceOverloaded', | ||
targetClass = Public, | ||
type = Open.Type.VIRTUAL | ||
) | ||
private static String publicPrivateInstanceOverloaded(Public instance) { | ||
throw new RuntimeException() | ||
} | ||
|
||
@Test | ||
void testPrivateInstanceOverloaded() { | ||
assertEquals("privateInstanceOverloaded", publicPrivateInstanceOverloaded(new Public())) | ||
assertEquals("privateInstanceOverloaded", publicPrivateInstanceOverloaded(new Public.PublicSubclass())) | ||
} | ||
|
||
@Open( | ||
targetName = 'dev.lukebemish.opensesame.test.target.Public$Private', | ||
type = Open.Type.CONSTRUCT | ||
) | ||
@PackageScope | ||
static Object privatePrivateConstructor() { | ||
throw new RuntimeException() | ||
} | ||
|
||
@Open( | ||
name = 'privateInstance', | ||
targetName = 'dev.lukebemish.opensesame.test.target.Public$Private', | ||
type = Open.Type.VIRTUAL | ||
) | ||
private static String privatePrivateInstance(Object instance) { | ||
throw new RuntimeException() | ||
} | ||
|
||
@Test | ||
void testPrivateClass() { | ||
Object instance = privatePrivateConstructor() | ||
assertEquals("Private", instance.toString()) | ||
assertEquals("privateInstance", privatePrivateInstance(instance)) | ||
} | ||
|
||
@Open( | ||
targetName = 'dev.lukebemish.opensesame.test.target.Public$PrivateCtor', | ||
type = Open.Type.CONSTRUCT | ||
) | ||
private static Public.PrivateCtor privateConstructor() { | ||
throw new RuntimeException() | ||
} | ||
|
||
@Test | ||
void testPrivateConstructor() { | ||
Public.PrivateCtor instance = privateConstructor() | ||
assertEquals("PrivateCtor", instance.toString()) | ||
} | ||
|
||
@Open( | ||
targetName = 'dev.lukebemish.opensesame.test.target.PackagePrivate', | ||
type = Open.Type.CONSTRUCT | ||
) | ||
private static Object packagePrivateConstructor() { | ||
throw new RuntimeException() | ||
} | ||
|
||
@Open( | ||
name = 'privateInstance', | ||
targetName = 'dev.lukebemish.opensesame.test.target.PackagePrivate', | ||
type = Open.Type.VIRTUAL | ||
) | ||
private static String packagePrivateInstance(Object instance) { | ||
throw new RuntimeException() | ||
} | ||
|
||
@Test | ||
void testPackagePrivateClass() { | ||
Object instance = packagePrivateConstructor() | ||
assertEquals("PackagePrivate", instance.toString()) | ||
assertEquals("privateInstance", packagePrivateInstance(instance)) | ||
} | ||
|
||
@Open( | ||
name = 'hiddenByModules', | ||
targetName = 'dev.lukebemish.opensesame.test.target.hidden.Hidden', | ||
type = Open.Type.STATIC, | ||
unsafe = true | ||
) | ||
private static String hiddenByModules() { | ||
throw new RuntimeException() | ||
} | ||
|
||
@Open( | ||
name = 'hiddenByModulesPrivate', | ||
targetName = 'dev.lukebemish.opensesame.test.target.hidden.Hidden', | ||
type = Open.Type.STATIC, | ||
unsafe = true | ||
) | ||
private static String hiddenByModulesPrivate() { | ||
throw new RuntimeException() | ||
} | ||
|
||
@Test | ||
void testModuleBreaking() { | ||
assertEquals('hiddenByModules', hiddenByModules()) | ||
assertEquals('hiddenByModulesPrivate', hiddenByModulesPrivate()) | ||
assertThrows(IllegalAccessException, { | ||
Class<?> hidden = Class.forName("dev.lukebemish.opensesame.test.target.hidden.Hidden") | ||
hidden.getDeclaredMethod("hiddenByModules").invoke(null) | ||
}) | ||
} | ||
|
||
@Open( | ||
targetName = 'dev.lukebemish.opensesame.test.target.Public$Private', | ||
type = Open.Type.ARRAY | ||
) | ||
private static Object[] privateArrayConstructor(int i) { | ||
throw new RuntimeException() | ||
} | ||
|
||
@Test | ||
void testPrivateArrayConstructor() { | ||
Object[] array = privateArrayConstructor(2) | ||
assertEquals(2, array.length) | ||
array[0] = privatePrivateConstructor() | ||
assertEquals("Private", array[0].toString()) | ||
assertThrows(ArrayStoreException, { | ||
array[1] = "stuff" | ||
}) | ||
} | ||
} |
Oops, something went wrong.