Skip to content

Commit

Permalink
feat(objectionary#946): fix some small bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Jan 13, 2025
1 parent 37f0172 commit 11b3592
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private XmirRepresentation(final XmlDoc xml, final String source) {
public String name() {
final XmlNode root = this.xml.root();
return new ClassName(
root.xpath("/program/metas/meta/tail/text()").get(0),
root.xpath("/program/metas/meta[head[text()]='package']/tail/text()").get(0),
root.xpath("/program/@name").get(0)
).full();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ public DirectivesMetas(final ClassName classname) {
@Override
public Iterator<Directive> iterator() {
final Directives result = new Directives().add("metas");
result.append(this.version());
if (!this.name.pckg().isEmpty()) {
result.append(this.pckg());
}
result.append(this.unlint());
result.append(this.version());
return result.up().iterator();
}

Expand All @@ -75,18 +76,13 @@ ClassName className() {
*/
private Directives pckg() {
final Directives result;
final String original = this.name.pckg();
// if (original.isEmpty()) {
// result = new Directives();
// } else {
final String prefixed = new PrefixedName(original).encode();
result = new Directives()
.add("meta")
.add("head").set("package").up()
.add("tail").set(prefixed).up()
.add("part").set(prefixed).up()
.up();
// }
final String prefixed = new PrefixedName(this.name.pckg()).encode();
result = new Directives()
.add("meta")
.add("head").set("package").up()
.add("tail").set(prefixed).up()
.add("part").set(prefixed).up()
.up();
return result;
}

Expand All @@ -101,4 +97,16 @@ private Directives version() {
.add("tail").set(Manifests.read("JEO-Version")).up()
.up();
}

/**
* Ignored XMIR checks.
* @return Directives for ignored checks.
*/
private Directives unlint() {
return new Directives()
.add("meta")
.add("head").set("unlint").up()
.add("tail").set("mandatory-package").up()
.up();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import com.jcabi.log.Logger;
import com.jcabi.matchers.XhtmlMatchers;
import com.jcabi.xml.XML;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
Expand Down Expand Up @@ -61,11 +62,13 @@ final class XmirRepresentationTest {
void retrievesName() {
final String name = "Math";
final String expected = "j$org/j$eolang/j$foo/j$Math";
final XML xml = new BytecodeProgram(
"org/eolang/foo",
new BytecodeClass(name)
).xml();
System.out.println(xml);
final String actual = new XmirRepresentation(
new BytecodeProgram(
"org/eolang/foo",
new BytecodeClass(name)
).xml()
xml
).name();
MatcherAssert.assertThat(
String.format(
Expand Down

0 comments on commit 11b3592

Please sign in to comment.