Skip to content

Commit

Permalink
fix(#2754): changed program braces in phi
Browse files Browse the repository at this point in the history
  • Loading branch information
maxonfjvipon committed Feb 7, 2024
1 parent 638c611 commit 942e325
Show file tree
Hide file tree
Showing 33 changed files with 252 additions and 169 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,10 @@ SOFTWARE.
<xsl:template match="program">
<phi>
<xsl:text>{</xsl:text>
<xsl:variable name="tabs" select="1"/>
<xsl:value-of select="eo:eol($tabs)"/>
<xsl:variable name="tabs" select="2"/>
<xsl:value-of select="eo:eol(1)"/>
<xsl:value-of select="$lb"/>
<xsl:value-of select="eo:eol(2)"/>
<xsl:variable name="has-package" select="metas/meta/head[text()='package']"/>
<xsl:variable name="package" select="metas/meta[head[text()='package']]/tail[1]"/>
<xsl:variable name="parts" select="tokenize($package,'\.')"/>
Expand Down Expand Up @@ -215,6 +217,8 @@ SOFTWARE.
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="eo:eol(1)"/>
<xsl:value-of select="$rb"/>
<xsl:value-of select="eo:eol(0)"/>
<xsl:text>}</xsl:text>
</phi>
Expand Down
29 changes: 20 additions & 9 deletions eo-maven-plugin/src/test/java/org/eolang/maven/UnphiMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class UnphiMojoTest {
@Test
void createsFile(@TempDir final Path temp) throws Exception {
new HmBase(temp).save(
"{std ↦ Φ.org.eolang.io.stdout, y ↦ Φ.org.eolang.x}",
"{std ↦ Φ.org.eolang.io.stdout, y ↦ Φ.org.eolang.x}",
Paths.get("target/phi/std.phi")
);
MatcherAssert.assertThat(
Expand Down Expand Up @@ -93,14 +93,16 @@ void checksUnphiPacks(final String pack, @TempDir final Path temp) throws Except
new HmBase(temp).save(phi, Paths.get("target/phi/main.phi"));
final List<String> failures = new ListOf<>();
new FakeMaven(temp).execute(UnphiMojo.class);
final XML doc = new XMLDocument(
new TextOf(
temp.resolve(
Paths.get(String.format("target/%s/main.xmir", ParseMojo.DIR))
)
).asString()
);
System.out.println(doc.toString());
for (final String xpath : (Iterable<String>) map.get("tests")) {
final List<XML> nodes = new XMLDocument(
new TextOf(
temp.resolve(
Paths.get(String.format("target/%s/main.xmir", ParseMojo.DIR))
)
).asString()
).nodes(xpath);
final List<XML> nodes = doc.nodes(xpath);
if (nodes.isEmpty()) {
failures.add(xpath);
}
Expand All @@ -125,13 +127,22 @@ void convertsToXmirAndBack(final String pack, @TempDir final Path temp) throws E
);
}
final String phi = map.get("phi").toString();
final String after;
if (map.containsKey("after")) {
after = map.get("after").toString();
} else {
after = phi;
}
final String main = "target/phi/main.phi";
final Path path = Paths.get(main);
new HmBase(temp).save(phi, path);
final long saved = temp.resolve(path).toFile().lastModified();
final FakeMaven maven = new FakeMaven(temp).execute(UnphiMojo.class);
maven.foreignTojos().add("name")
.withXmir(temp.resolve(String.format("target/%s/main.xmir", ParseMojo.DIR)));
System.out.println(
new TextOf(temp.resolve(String.format("target/%s/main.xmir", ParseMojo.DIR))).asString()
);
final Path result = maven
.execute(OptimizeMojo.class)
.execute(PhiMojo.class)
Expand All @@ -144,7 +155,7 @@ void convertsToXmirAndBack(final String pack, @TempDir final Path temp) throws E
);
MatcherAssert.assertThat(
"Origin phi should equal to phi got from \"unphied\" xmir, but it isn't",
phi,
after,
Matchers.equalTo(
new TextOf(result).asString()
)
Expand Down
22 changes: 12 additions & 10 deletions eo-maven-plugin/src/test/resources/org/eolang/maven/phi/as-phi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ eo: |
$.greater-than 0
phi: |
{
prints-itself ↦ ⟦
φ ↦ Φ.org.eolang.assert-that(
α0 ↦ Φ.org.eolang.as-phi(
α0 ↦ ξ
).length,
α1 ↦ ξ.greater-than(
α0 ↦ Φ.org.eolang.int(
α0 ↦ Φ.org.eolang.bytes(
Δ ⤍ 00-00-00-00-00-00-00-00
prints-itself ↦ ⟦
φ ↦ Φ.org.eolang.assert-that(
α0 ↦ Φ.org.eolang.as-phi(
α0 ↦ ξ
).length,
α1 ↦ ξ.greater-than(
α0 ↦ Φ.org.eolang.int(
α0 ↦ Φ.org.eolang.bytes(
Δ ⤍ 00-00-00-00-00-00-00-00
)
)
)
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ eo: |
[] > inner /bytes
phi: |
{
main ↦ ⟦
λ ⤍ Lambda
⟧,
outer ↦ ⟦
inner ↦ ⟦
main ↦ ⟦
λ ⤍ Lambda
⟧,
outer ↦ ⟦
inner ↦ ⟦
λ ⤍ Lambda
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ eo: |
5:five
phi: |
{
xyz ↦ Φ.org.eolang.x(
attr ↦ Φ.org.eolang.y,
abs ↦ ⟦
z ↦ ∅,
φ ↦ Φ.org.eolang.w
⟧,
five ↦ Φ.org.eolang.int(
α0 ↦ Φ.org.eolang.bytes(
Δ ⤍ 00-00-00-00-00-00-00-05
xyz ↦ Φ.org.eolang.x(
attr ↦ Φ.org.eolang.y,
abs ↦ ⟦
z ↦ ∅,
φ ↦ Φ.org.eolang.w
⟧,
five ↦ Φ.org.eolang.int(
α0 ↦ Φ.org.eolang.bytes(
Δ ⤍ 00-00-00-00-00-00-00-05
)
)
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ eo: |
cage' a > y
phi: |
{
obj ↦ ⟦
x ↦ Φ.org.eolang.cage(),
y ↦ Φ.org.eolang.cage()(
α0 ↦ Φ.org.eolang.a
)
obj ↦ ⟦
x ↦ Φ.org.eolang.cage(),
y ↦ Φ.org.eolang.cage()(
α0 ↦ Φ.org.eolang.a
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ eo: |
x y > z
phi: |
{
foo ↦ ⟦
bar ↦ ⟦
main ↦ ⟦
y ↦ ∅,
z ↦ Φ.com.yegor256.x(
α0 ↦ ξ.y
)
foo ↦ ⟦
bar ↦ ⟦
main ↦ ⟦
y ↦ ∅,
z ↦ Φ.com.yegor256.x(
α0 ↦ ξ.y
)
⟧,
λ ⤍ Package
⟧,
λ ⤍ Package
⟧,
λ ⤍ Package
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
eo: -- > empty
phi: |
{
empty ↦ Φ.org.eolang.bytes(
Δ ⤍ --
)
empty ↦ Φ.org.eolang.bytes(
Δ ⤍ --
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ eo: |
seq' > y
phi: |
{
main ↦ ⟦
z ↦ ∅,
x ↦ ⟦⟧,
y ↦ Φ.org.eolang.seq()
main ↦ ⟦
z ↦ ∅,
x ↦ ⟦⟧,
y ↦ Φ.org.eolang.seq()
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,43 @@ eo: |
n.minus 2
phi: |
{
eo ↦ ⟦
example ↦ ⟦
fibonacci ↦ ⟦
n ↦ ∅,
φ ↦ ξ.n.lt(
α0 ↦ Φ.org.eolang.int(
α0 ↦ Φ.org.eolang.bytes(
Δ ⤍ 00-00-00-00-00-00-00-02
)
)
).if(
α0 ↦ ξ.n,
α1 ↦ ξ.ρ.fibonacci(
α0 ↦ ξ.n.minus(
α0 ↦ Φ.org.eolang.int(
α0 ↦ Φ.org.eolang.bytes(
Δ ⤍ 00-00-00-00-00-00-00-01
)
eo ↦ ⟦
example ↦ ⟦
fibonacci ↦ ⟦
n ↦ ∅,
φ ↦ ξ.n.lt(
α0 ↦ Φ.org.eolang.int(
α0 ↦ Φ.org.eolang.bytes(
Δ ⤍ 00-00-00-00-00-00-00-02
)
)
).plus(
α0 ↦ ξ.ρ.fibonacci(
).if(
α0 ↦ ξ.n,
α1 ↦ ξ.ρ.fibonacci(
α0 ↦ ξ.n.minus(
α0 ↦ Φ.org.eolang.int(
α0 ↦ Φ.org.eolang.bytes(
Δ ⤍ 00-00-00-00-00-00-00-02
Δ ⤍ 00-00-00-00-00-00-00-01
)
)
)
).plus(
α0 ↦ ξ.ρ.fibonacci(
α0 ↦ ξ.n.minus(
α0 ↦ Φ.org.eolang.int(
α0 ↦ Φ.org.eolang.bytes(
Δ ⤍ 00-00-00-00-00-00-00-02
)
)
)
)
)
)
)
⟧,
λ ⤍ Package
⟧,
λ ⤍ Package
⟧,
λ ⤍ Package
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ eo: |
Q.org.eolang.x > y
phi: |
{
std ↦ Φ.org.eolang.io.stdout,
y ↦ Φ.org.eolang.x
std ↦ Φ.org.eolang.io.stdout,
y ↦ Φ.org.eolang.x
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,35 @@ eo: |
"org/eolang/benchmark/F"
phi: |
{
org ↦ ⟦
eolang ↦ ⟦
benchmark ↦ ⟦
j$A ↦ ⟦
access ↦ Φ.org.eolang.int(
α0 ↦ Φ.org.eolang.bytes(
Δ ⤍ 00-00-00-00-00-00-00-20
)
),
supername ↦ Φ.org.eolang.string(
α0 ↦ Φ.org.eolang.bytes(
Δ ⤍ 6A-61-76-61-2F-6C-61-6E-67-2F-4F-62-6A-65-63-74
)
),
interfaces ↦ Φ.org.eolang.tuple(
α0 ↦ Φ.org.eolang.tuple.empty,
α1 ↦ Φ.org.eolang.string(
org ↦ ⟦
eolang ↦ ⟦
benchmark ↦ ⟦
j$A ↦ ⟦
access ↦ Φ.org.eolang.int(
α0 ↦ Φ.org.eolang.bytes(
Δ ⤍ 6F-72-67-2F-65-6F-6C-61-6E-67-2F-62-65-6E-63-68-6D-61-72-6B-2F-46
Δ ⤍ 00-00-00-00-00-00-00-20
)
),
supername ↦ Φ.org.eolang.string(
α0 ↦ Φ.org.eolang.bytes(
Δ ⤍ 6A-61-76-61-2F-6C-61-6E-67-2F-4F-62-6A-65-63-74
)
),
interfaces ↦ Φ.org.eolang.tuple(
α0 ↦ Φ.org.eolang.tuple.empty,
α1 ↦ Φ.org.eolang.string(
α0 ↦ Φ.org.eolang.bytes(
Δ ⤍ 6F-72-67-2F-65-6F-6C-61-6E-67-2F-62-65-6E-63-68-6D-61-72-6B-2F-46
)
)
)
)
⟧,
λ ⤍ Package
⟧,
λ ⤍ Package
⟧,
λ ⤍ Package
⟧,
λ ⤍ Package
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
eo: x.y.z > xyz
phi: |
{
xyz ↦ Φ.org.eolang.x.y.z
xyz ↦ Φ.org.eolang.x.y.z
}

0 comments on commit 942e325

Please sign in to comment.