Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions eo-runtime/src/main/java/org/eolang/Dataized.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ public byte[] take() {
raw.addAll(ex.messages());
Collections.reverse(raw);
final Phi enc = ex.enclosure();
if ("go.to.token.jump".equals(enc.forma())) {
if (Dataized.isGoToTokenJump(enc)) {
throw new EOerror.ExError(enc);
}
if (String.format("%s.string", PhPackage.GLOBAL).equals(enc.forma())) {
if (Dataized.isString(enc)) {
raw.add(
String.format(
"\"%s\"",
Expand Down Expand Up @@ -185,4 +185,22 @@ public Boolean asBool() {
public Bytes asBytes() {
return new BytesOf(this.take());
}

/**
* Check if object is go.to.token.jump.
* @param phi The object
* @return True if it is go.to.token.jump
*/
private static boolean isGoToTokenJump(final Phi phi) {
return phi.forma().endsWith(".go.to.token.jump");
}

/**
* Check if object is string.
* @param phi The object
* @return True if it is string
*/
private static boolean isString(final Phi phi) {
return phi.forma().endsWith(".string");
}
}
24 changes: 15 additions & 9 deletions eo-runtime/src/main/java/org/eolang/PhDefault.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* @since 0.1
* @checkstyle DesignForExtensionCheck (500 lines)
*/
@SuppressWarnings("PMD.TooManyMethods")
@SuppressWarnings({"PMD.GodClass", "PMD.TooManyMethods"})
public class PhDefault implements Phi, Cloneable {
/**
* Logger.
Expand Down Expand Up @@ -210,14 +210,20 @@ public String forma() {
if (PhDefault.class.getSimpleName().equals(name)) {
form = "[]";
} else {
form = String.join(
".",
PhPackage.GLOBAL,
PhDefault.TO_FORMA.matcher(
this.getClass().getPackageName()
).replaceAll("$1"),
name
);
final String pkg = this.getClass().getPackageName();
final String simplified;
if ("org.eolang".equals(pkg)) {
simplified = "";
} else {
simplified = PhDefault.TO_FORMA.matcher(pkg).replaceAll("$1");
}
final String prefix;
if (simplified.isEmpty()) {
prefix = PhPackage.GLOBAL;
} else {
prefix = String.join(".", PhPackage.GLOBAL, simplified);
}
form = String.join(".", prefix, name);
}
return form;
}
Expand Down
4 changes: 2 additions & 2 deletions eo-runtime/src/main/java/org/eolang/PhSafe.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ public String locator() {
public String forma() {
return String.join(
".",
this.getClass().getPackageName(),
this.oname
PhPackage.GLOBAL,
this.oname
);
}

Expand Down
13 changes: 0 additions & 13 deletions eo-runtime/src/test/java/org/eolang/DataizedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
Expand All @@ -22,20 +21,9 @@
* Test case for {@link Dataized}.
*
* @since 0.22
* @todo #4538:30min Enable the test {@link DataizedTest#doesNotLogGoToTokenJump}.
* The test was disabled because we've moved EO objects from default package 'org.eolang'
* to Q, but java classes are placed in 'org.eolang' java package. That's why the method
* {@link PhDefault#forma()} and {@link PhSafe#forma()} started to work incorrectly and
* show 'org.eolang'. Need to fix these methods, make sure they work as expected and enable
* the test.
* @todo #4538:30min Enable the test {@link DataizedTest#logsAllLocationsWithPhSafe()}.
* The test was disabled because we've moved EO objects from default package 'org.eolang'
* to Q. This somehow affected {@link PhSafe} and {@link PhDefault} classes.
* Need to fix it and enable the test
*/
@Execution(ExecutionMode.SAME_THREAD)
final class DataizedTest {
@Disabled
@Test
@SuppressWarnings({"PMD.UnitTestContainsTooManyAsserts", "PMD.UnnecessaryLocalRule"})
void logsAllLocationsWithPhSafe() {
Expand Down Expand Up @@ -92,7 +80,6 @@ void failsWhenError() {
);
}

@Disabled
@Test
@SuppressWarnings({"PMD.UnitTestContainsTooManyAsserts", "PMD.UnnecessaryLocalRule"})
void doesNotLogGoToTokenJump() {
Expand Down
Loading