Skip to content

Commit

Permalink
Merge pull request #3773 from maxonfjvipon/bug/#3691/phy-sugar-tests
Browse files Browse the repository at this point in the history
bug(#3691): tested phi sugar
  • Loading branch information
yegor256 authored Dec 27, 2024
2 parents 8328050 + 6944c9a commit fa3d342
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,21 @@ SOFTWARE.
-->
<xsl:import href="/org/eolang/parser/_funcs.xsl"/>
<xsl:output encoding="UTF-8" method="xml"/>
<xsl:template match="o[@base='.eolang' and o[1][@base='.org' and o[1][@base='Q']]]">
<xsl:template match="o[starts-with(@base, '.') and o[1][@base='.eolang' and o[1][@base='.org' and o[1][@base='Q']]]]">
<xsl:element name="o">
<xsl:for-each select="@*[name()!='base']">
<xsl:attribute name="{name()}" select="."/>
</xsl:for-each>
<xsl:attribute name="base" select="'org.eolang'"/>
<xsl:attribute name="base">
<xsl:text>org.eolang</xsl:text>
<xsl:value-of select="@base"/>
</xsl:attribute>
<xsl:for-each select="o[position()!=1]">
<xsl:value-of select="."/>
<xsl:apply-templates select="."/>
</xsl:for-each>
<xsl:if test="eo:has-data(.)">
<xsl:value-of select="normalize-space(string-join(text(), ''))"/>
</xsl:if>
</xsl:element>
</xsl:template>
<xsl:template match="node()|@*">
Expand Down
30 changes: 30 additions & 0 deletions eo-parser/src/test/java/org/eolang/parser/PhiSyntaxTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
import com.jcabi.xml.XML;
import java.io.IOException;
import org.eolang.jucs.ClasspathSource;
import org.eolang.xax.XtSticky;
import org.eolang.xax.XtYaml;
import org.eolang.xax.Xtory;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -94,6 +98,32 @@ void addsMetaForPackage() throws IOException {
);
}

@ParameterizedTest
@ClasspathSource(value = "org/eolang/parser/phi-packs", glob = "**.yaml")
void printsSaltyToSweet(final String pack) throws IOException {
final Xtory xtory = new XtSticky(new XtYaml(pack));
MatcherAssert.assertThat(
"Salty XMIR should be equivalent to sweet one",
new Xmir(
new PhiSyntax((String) xtory.map().get("salty")).parsed()
).toPhi(xtory.map().get("conservative") != null),
Matchers.equalTo(xtory.map().get("sweet"))
);
}

@ParameterizedTest
@ClasspathSource(value = "org/eolang/parser/phi-packs", glob = "**.yaml")
void printsSweetToSalty(final String pack) throws IOException {
final Xtory xtory = new XtSticky(new XtYaml(pack));
MatcherAssert.assertThat(
"Sweet XMIR should be equivalent to salty one",
new Xmir(
new PhiSyntax((String) xtory.map().get("sweet")).parsed()
).toSaltyPhi(),
Matchers.equalTo(xtory.map().get("salty"))
);
}

@ParameterizedTest
@ClasspathSource(value = "org/eolang/parser/phi-syntax/", glob = "**.phi")
void checksValidPhiExpressions(final String phi) throws IOException {
Expand Down

0 comments on commit fa3d342

Please sign in to comment.