From 43b18977e1564bc3e7e7422fc6771659bf4278da Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Thu, 11 Jan 2024 18:01:53 +0300 Subject: [PATCH] #2750 fix xmir-to-eo.xsl --- .../main/java/org/eolang/parser/StUnhex.java | 17 +++++++---------- .../resources/org/eolang/parser/xmir-to-eo.xsl | 2 +- .../java/org/eolang/parser/StUnhexTest.java | 6 +++--- .../test/java/org/eolang/parser/XMIRTest.java | 8 ++++---- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/eo-parser/src/main/java/org/eolang/parser/StUnhex.java b/eo-parser/src/main/java/org/eolang/parser/StUnhex.java index 902b59048c..93a74ae813 100644 --- a/eo-parser/src/main/java/org/eolang/parser/StUnhex.java +++ b/eo-parser/src/main/java/org/eolang/parser/StUnhex.java @@ -87,22 +87,19 @@ public StUnhex() { StUnhex.xpath("string"), xml -> StUnhex.append( "string", - String.format( - "\"%s\"", - StringEscapeUtils.escapeJava( - new String( - StUnhex.buffer( - StUnhex.unspace(xml.xpath("./o/text()").get(0)) - ).array(), - StandardCharsets.UTF_8 - ) + StringEscapeUtils.escapeJava( + new String( + StUnhex.buffer( + StUnhex.unspace(xml.xpath("./o/text()").get(0)) + ).array(), + StandardCharsets.UTF_8 ) ) ) ), new StXPath( "(//o[@data='bytes' and (@base='bytes' or @base='org.eolang.bytes') and empty(text())]/parent::o[(@base='string' or @base='org.eolang.string')])[1]", - xml -> new Directives().set("\"\"").attr("data", "string") + xml -> new Directives().set("").attr("data", "string") ) ) ) diff --git a/eo-parser/src/main/resources/org/eolang/parser/xmir-to-eo.xsl b/eo-parser/src/main/resources/org/eolang/parser/xmir-to-eo.xsl index 392e1b4b74..fbf936dacb 100644 --- a/eo-parser/src/main/resources/org/eolang/parser/xmir-to-eo.xsl +++ b/eo-parser/src/main/resources/org/eolang/parser/xmir-to-eo.xsl @@ -132,7 +132,7 @@ SOFTWARE. - + """ diff --git a/eo-parser/src/test/java/org/eolang/parser/StUnhexTest.java b/eo-parser/src/test/java/org/eolang/parser/StUnhexTest.java index c6bcea81e5..8e90f2f633 100644 --- a/eo-parser/src/test/java/org/eolang/parser/StUnhexTest.java +++ b/eo-parser/src/test/java/org/eolang/parser/StUnhexTest.java @@ -73,8 +73,8 @@ void convertsStringFromHexToEo() { ) ), XhtmlMatchers.hasXPaths( - "//o[text()='\"AB\\n\\t\"' and @data='string']", - "//o[text()='\"AB\"' and @data='string']" + "//o[text()='AB\\n\\t' and @data='string']", + "//o[text()='AB' and @data='string']" ) ); } @@ -88,7 +88,7 @@ void convertsEmptyStringFromHexToEo() { ) ), XhtmlMatchers.hasXPaths( - "//o[text()='\"\"' and @data='string']" + "//o[empty(text()) and @data='string']" ) ); } diff --git a/eo-parser/src/test/java/org/eolang/parser/XMIRTest.java b/eo-parser/src/test/java/org/eolang/parser/XMIRTest.java index 3cb50a9cfd..3f99a05520 100644 --- a/eo-parser/src/test/java/org/eolang/parser/XMIRTest.java +++ b/eo-parser/src/test/java/org/eolang/parser/XMIRTest.java @@ -57,13 +57,13 @@ final class XMIRTest { @ParameterizedTest @ClasspathSource(value = "org/eolang/parser/xmir-samples/", glob = "**.eo") void printsToEO(final String src) throws Exception { - Logger.debug(this, "Original EOLANG:%n%s", src); + Logger.warnForced(this, "Original EOLANG:%n%s", src); final XML first = XMIRTest.clean(XMIRTest.parse(src)); - Logger.debug(this, "First:%n%s", first); + Logger.warnForced(this, "First:%n%s", first); final String eolang = new XMIR(first).toEO(); - Logger.debug(this, "EOLANG:%n%s", eolang); + Logger.warnForced(this, "EOLANG:%n%s", eolang); final XML second = XMIRTest.clean(XMIRTest.parse(eolang)); - Logger.debug(this, "Second:%n%s", second); + Logger.warnForced(this, "Second:%n%s", second); final String ignore = "data=\"\\S+\""; MatcherAssert.assertThat( first