From 6944c9af16bf326bd252edb10c4e49ed1494cdbd Mon Sep 17 00:00:00 2001 From: maxonfjvipon Date: Fri, 27 Dec 2024 18:30:40 +0300 Subject: [PATCH] bug(#3691): tested phi sugar --- .../parser/phi/wrap-default-package.xsl | 12 ++++++-- .../java/org/eolang/parser/PhiSyntaxTest.java | 30 +++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/eo-parser/src/main/resources/org/eolang/parser/phi/wrap-default-package.xsl b/eo-parser/src/main/resources/org/eolang/parser/phi/wrap-default-package.xsl index 5d66e01bbf..bbd989a2c6 100644 --- a/eo-parser/src/main/resources/org/eolang/parser/phi/wrap-default-package.xsl +++ b/eo-parser/src/main/resources/org/eolang/parser/phi/wrap-default-package.xsl @@ -38,15 +38,21 @@ SOFTWARE. --> - + - + + org.eolang + + - + + + + diff --git a/eo-parser/src/test/java/org/eolang/parser/PhiSyntaxTest.java b/eo-parser/src/test/java/org/eolang/parser/PhiSyntaxTest.java index d97dac865c..805d94b5e2 100644 --- a/eo-parser/src/test/java/org/eolang/parser/PhiSyntaxTest.java +++ b/eo-parser/src/test/java/org/eolang/parser/PhiSyntaxTest.java @@ -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; @@ -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 {