Skip to content

Commit

Permalink
bug(#3757): param
Browse files Browse the repository at this point in the history
  • Loading branch information
maxonfjvipon committed Dec 25, 2024
1 parent 94c9b68 commit 8b0478f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
7 changes: 6 additions & 1 deletion eo-maven-plugin/src/main/java/org/eolang/maven/PhiMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public final class PhiMojo extends SafeMojo {
)
private File phiOutputDir;

/**
* Print all the braces in sweet notation.
*/
private boolean conservative = true;

/**
* Convert to PHI without syntax sugar.
* @checkstyle MemberNameCheck (10 lines)
Expand Down Expand Up @@ -167,7 +172,7 @@ private String translated(final XML xml) throws ImpossibleToPhiTranslationExcept
if (this.phiNoSugar) {
phi = xmir.toSaltyPhi();
} else {
phi = xmir.toPhi(true);
phi = xmir.toPhi(this.conservative);
}
} catch (final IndexOutOfBoundsException exception) {
throw new ImpossibleToPhiTranslationException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ public <T extends AbstractMojo> FakeMaven execute(final Class<T> mojo) throws IO
this.params.putIfAbsent("offline", false);
this.params.putIfAbsent("phiNoSugar", false);
this.params.putIfAbsent("phiSkipFailed", false);
this.params.putIfAbsent("conservative", false);
this.params.putIfAbsent(
"phiInputDir",
this.workspace.absolute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,13 @@ void checksPhiPacksWithSugar(final String pack, @Mktmp final Path temp) throws E
new TextOf(
new FakeMaven(temp)
.withProgram(xtory.map().get("input").toString())
.with("conservative", xtory.map().get("conservative") != null)
.with("phiNoSugar", false)
.execute(new FakeMaven.Phi())
.result()
.get("target/phi/foo/x/main.phi")
).asString(),
Matchers.equalTo(xtory.map().get("with-sugar").toString())
Matchers.equalTo(xtory.map().get("sweet").toString())
);
}

Expand All @@ -219,7 +220,7 @@ void checksPhiPacksNoSugar(final String pack, @Mktmp final Path temp) throws Exc
.result()
.get("target/phi/foo/x/main.phi")
).asString(),
Matchers.equalTo(xtory.map().get("no-sugar").toString())
Matchers.equalTo(xtory.map().get("salty").toString())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void checksUnphiPacks(final String pack, @Mktmp final Path temp) throws Exceptio
void convertsToXmirAndBack(final String pack, @Mktmp final Path temp) throws Exception {
final Xtory xtory = new XtSticky(new XtYaml(pack));
Assumptions.assumeTrue(xtory.map().get("skip") == null);
final String phi = xtory.map().get("with-sugar").toString();
final String phi = xtory.map().get("sweet").toString();
final String main = "target/phi/main.phi";
final Path path = Paths.get(main);
new HmBase(temp).save(phi, path);
Expand All @@ -244,6 +244,7 @@ void convertsToXmirAndBack(final String pack, @Mktmp final Path temp) throws Exc
final Path xmir = temp.resolve(String.format("target/%s/main.xmir", ParseMojo.DIR));
maven.foreignTojos().add("name").withXmir(xmir);
final Path result = maven
.with("conservative", xtory.map().get("conservative") != null)
.execute(OptimizeMojo.class)
.execute(PhiMojo.class)
.result()
Expand Down

0 comments on commit 8b0478f

Please sign in to comment.