Skip to content

Commit

Permalink
Merge pull request #3899 from maxonfjvipon/bug/#3815/xmir-object-test
Browse files Browse the repository at this point in the history
bug(#3815): fixed `XmirObjectTest`
  • Loading branch information
yegor256 authored Feb 9, 2025
2 parents b4151e7 + 8a54d1c commit e6d7329
Showing 1 changed file with 14 additions and 29 deletions.
43 changes: 14 additions & 29 deletions eo-runtime/src/test/java/org/eolang/XmirObjectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,52 +29,37 @@
import com.google.common.reflect.ClassPath;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.util.Set;
import java.util.stream.Collectors;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

/**
* Test case for {@link XmirObject}.
*
* @since 0.38
* @todo #3481:30min Enable the test. The test was disabled because it's became a bit
* irrelevant when we got rid of @ref attributes and "abstract-float-up.xsl" transformation.
* We got a much less amount of generated classes after translation to java. So we need to
* refactor the test and enable it.
*/
final class XmirObjectTest {

@Test
@Disabled
void annotatesOnlyPublicClasses() throws IOException {
final Set<Class<?>> clazzes = ClassPath.from(ClassLoader.getSystemClassLoader())
.getAllClasses()
.stream()
.filter(clazz -> "EOorg.EOeolang".equals(clazz.getPackageName()))
.map(ClassPath.ClassInfo::load)
.filter(
clazz -> clazz.getSimpleName().startsWith("EO")
&& Phi.class.isAssignableFrom(clazz)
)
.collect(Collectors.toSet());
assert !clazzes.isEmpty();
MatcherAssert.assertThat(
"Some EOxx classes are found",
clazzes.stream()
.filter(clazz -> !Modifier.isPublic(clazz.getModifiers()))
.collect(Collectors.toList()),
Matchers.empty()
);
MatcherAssert.assertThat(
"All EOxx classes are public",
clazzes.stream()
.filter(clazz -> !Modifier.isPublic(clazz.getModifiers()))
"All top-level EOxx classes must be public",
ClassPath.from(ClassLoader.getSystemClassLoader())
.getAllClasses()
.stream()
.filter(
clazz -> "EOorg.EOeolang".equals(clazz.getPackageName())
&& clazz.getSimpleName().startsWith("EO")
)
.map(ClassPath.ClassInfo::load)
.filter(
clazz -> !Modifier.isPublic(clazz.getModifiers())
&& !(clazz.isMemberClass() || clazz.isLocalClass())
&& Phi.class.isAssignableFrom(clazz)
)
.collect(Collectors.toList()),
Matchers.empty()
);
}

}

1 comment on commit e6d7329

@0pdd
Copy link

@0pdd 0pdd commented on e6d7329 Feb 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 3481-e9fa64ec disappeared from eo-runtime/src/test/java/org/eolang/XmirObjectTest.java), that's why I closed #3815. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

Please sign in to comment.