[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[golo-dev] Using unions in Java code?
|
Hello,
I could not think of a way to write unit tests in Golo, so for my Scrobbler
project, so I've chosen to write them in Java and JUnit. Had lots of troubles
with setting up an Eclipse IDE project, but I found a workaround.
I've now hit a brick wall, that I cannot seem to fix.
I have the following module in my Golo code:
module audiostreamerscrobbler.states.detector.MainTypes
union DetectorStateTypes = {
PlayerNotFound
PlayerFound = { Player }
}
In my Java unit test code I need to check whether a functions returns an
instance of DetectorStateTypes.PlayerNotFound, so I added following import statement:
import audiostreamerscrobbler.states.detector.MainTypes.types.DetectorStateTypes.PlayerNotFound;
In Eclipse IDE, there's a red line from audiostreamerscrobbler to types.
It reports the following error:
"audiostreamerscrobbler.states.detector.DetectorStateTypes.types cannot be
resolved". Gradle reports the following error:
"xxx\BluOsPlayerDetectorTests.java:6: error: cannot find symbol, where the ^
carrot is under the "t" of types.
Can unions be used in Java at all?
I have the impression that this is caused by the Golo compiler, which compiles
a (in this particular case seemingly unneccessary) MainTypes.class file in the
build\classes\audiostreamerscrobbler\states\detector directory and Java,
unlike Golo, apparently does not like having a class name that matches with
a part of the package name.
Is there any clean solution, did I misunderstood things, or do I need to resort
to reflections to check a union return value in Java unit tests?
Best regards,
Vincent