diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/UnphiMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/UnphiMojoTest.java index a4879b5bdef..4bcf9ace2e6 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/UnphiMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/UnphiMojoTest.java @@ -255,7 +255,8 @@ void convertsValidXmirAndParsableEO(@Mktmp final Path temp) "[args] > app", " QQ.io.stdout > @", " \"Hello, world!\"", - " args.@ > phi!" + " args.@ > phi!", + " * (* 1 2) (* 3 4) (* 5 6) > mx" ) .with("printSourcesDir", temp.resolve("target/1-parse").toFile()) .with("printOutputDir", temp.resolve("target/generated-sources").toFile()) diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/shake-packs/locators/add-locators.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/shake-packs/locators/add-locators.yaml index 77fa8f11985..ebe891fdb9c 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/shake-packs/locators/add-locators.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/shake-packs/locators/add-locators.yaml @@ -14,8 +14,8 @@ asserts: - //o[@base='Q.org.eolang.string' and @loc='Φ.org.abc.a.φ.α0.α0' and @original-name='a.φ.α0.α0'] - //o[@base='Q.x' and @name='tt' and @loc='Φ.org.abc.tt' and @original-name='tt'] - //o[@base='Q.org.eolang.number' and @loc='Φ.org.abc.tt.α0' and @original-name='tt.α0'] - - //o[@base='Q.org.eolang.tuple.empty.with' and @loc='Φ.org.abc.tt.α1.ρ' and @original-name='tt.α1.ρ'] - - //o[@base='Q.org.eolang.number' and @loc='Φ.org.abc.tt.α1.ρ.α0' and @original-name='tt.α1.ρ.α0'] + - //o[@base='Q.org.eolang.tuple.empty' and @loc='Φ.org.abc.tt.α1.α0.α0' and @original-name='tt.α1.α0.α0'] + - //o[@base='Q.org.eolang.number' and @loc='Φ.org.abc.tt.α1.α0.α1' and @original-name='tt.α1.α0.α1'] - //o[not(@base) and @loc='Φ.org.abc.tt.α2' and @original-name='tt.α2'] - //o[@base='∅' and @name='e' and @loc='Φ.org.abc.tt.α2.e' and @original-name='tt.α2.e'] - //o[@base='$.e.hello' and @loc='Φ.org.abc.tt.α2.φ' and @original-name='tt.α2.φ'] diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/transpile-packs/tuple-to-java.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/transpile-packs/tuple-to-java.yaml index 7c172066b9f..6ac8a4218ce 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/transpile-packs/tuple-to-java.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/transpile-packs/tuple-to-java.yaml @@ -8,11 +8,14 @@ sheets: - /org/eolang/maven/transpile/to-java.xsl asserts: - /program[not(errors)] - - //java[contains(text(), ' Phi rbb = Phi.Φ.take("org").take("eolang").take("tuple").take("empty").take("with");')] - - //java[contains(text(), ' rbb = new PhWith(rbb, 0, rbb1);')] - - //java[contains(text(), ' Phi rb = new PhMethod(rbb, "with");')] - - //java[contains(text(), ' rb = new PhWith(rb, 0, rb1);')] - - //java[contains(text(), ' Phi r = new PhMethod(rb, "with");')] + - //java[contains(text(), 'Phi r11 = Phi.Φ.take("org").take("eolang").take("tuple");')] + - //java[contains(text(), 'r11 = new PhCopy(r11);')] + - //java[contains(text(), ' Phi r111 = Phi.Φ.take("org").take("eolang").take("tuple").take("empty");')] + - //java[contains(text(), ' Phi r112 = Phi.Φ.take("org").take("eolang").take("number");')] + - //java[contains(text(), ' Phi r113 = Phi.Φ.take("org").take("eolang").take("number");')] + - //java[contains(text(), 'r11 = new PhWith(r11, 0, r111);')] + - //java[contains(text(), 'r11 = new PhWith(r11, 1, r112);')] + - //java[contains(text(), 'r11 = new PhWith(r11, 2, r113);')] input: | # No comments. [] > foo diff --git a/eo-parser/src/main/java/org/eolang/parser/EoSyntax.java b/eo-parser/src/main/java/org/eolang/parser/EoSyntax.java index 4395b8e9c1b..f088a7f60b3 100644 --- a/eo-parser/src/main/java/org/eolang/parser/EoSyntax.java +++ b/eo-parser/src/main/java/org/eolang/parser/EoSyntax.java @@ -9,6 +9,8 @@ import com.jcabi.xml.XMLDocument; import com.yegor256.xsline.Shift; import com.yegor256.xsline.TrClasspath; +import com.yegor256.xsline.TrDefault; +import com.yegor256.xsline.TrJoined; import com.yegor256.xsline.Train; import com.yegor256.xsline.Xsline; import java.io.IOException; @@ -78,22 +80,25 @@ public final class EoSyntax implements Syntax { */ private static final Function CANONICAL = new Xsline( new TrFull( - new TrClasspath<>( - "/org/eolang/parser/parse/move-voids-up.xsl", - "/org/eolang/parser/parse/validate-before-stars.xsl", - "/org/eolang/parser/parse/resolve-before-stars.xsl", - "/org/eolang/parser/parse/wrap-method-calls.xsl", - "/org/eolang/parser/parse/const-to-dataized.xsl", - "/org/eolang/parser/parse/stars-to-tuples.xsl", - "/org/eolang/parser/parse/vars-float-up.xsl", - "/org/eolang/parser/parse/build-fqns.xsl", - "/org/eolang/parser/parse/expand-qqs.xsl", - "/org/eolang/parser/parse/expand-aliases.xsl", - "/org/eolang/parser/parse/resolve-aliases.xsl", - "/org/eolang/parser/parse/add-default-package.xsl", - "/org/eolang/parser/parse/explicit-data.xsl", - "/org/eolang/parser/parse/roll-bases.xsl" - ).back() + new TrJoined<>( + new TrClasspath<>( + "/org/eolang/parser/parse/move-voids-up.xsl", + "/org/eolang/parser/parse/validate-before-stars.xsl", + "/org/eolang/parser/parse/resolve-before-stars.xsl", + "/org/eolang/parser/parse/wrap-method-calls.xsl", + "/org/eolang/parser/parse/const-to-dataized.xsl", + "/org/eolang/parser/parse/stars-to-tuples.xsl", + "/org/eolang/parser/parse/vars-float-up.xsl", + "/org/eolang/parser/parse/build-fqns.xsl", + "/org/eolang/parser/parse/expand-qqs.xsl", + "/org/eolang/parser/parse/expand-aliases.xsl", + "/org/eolang/parser/parse/resolve-aliases.xsl", + "/org/eolang/parser/parse/add-default-package.xsl", + "/org/eolang/parser/parse/explicit-data.xsl", + "/org/eolang/parser/parse/roll-bases.xsl" + ).back(), + new TrDefault<>(new StHex()) + ) ) )::pass; diff --git a/eo-parser/src/main/java/org/eolang/parser/StHex.java b/eo-parser/src/main/java/org/eolang/parser/StHex.java new file mode 100644 index 00000000000..ae92a19da28 --- /dev/null +++ b/eo-parser/src/main/java/org/eolang/parser/StHex.java @@ -0,0 +1,43 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com + * SPDX-License-Identifier: MIT + */ +package org.eolang.parser; + +import com.yegor256.xsline.Shift; +import com.yegor256.xsline.StEnvelope; +import java.nio.ByteBuffer; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +/** + * This {@link Shift} turns regular data (numbers) inside XMIR + * into hexadecimal representation. + * + * @since 0.54 + */ +final class StHex extends StEnvelope { + /** + * Ctor. + */ + StHex() { + super( + new StXnav( + "st-hex", + "//o[@hex]", + xnav -> { + final Node node = xnav.node(); + node.setTextContent( + new BytesToHex( + ByteBuffer + .allocate(Double.BYTES) + .putDouble(Double.parseDouble(xnav.text().orElseThrow())) + .array() + ).get() + ); + ((Element) node).removeAttribute("hex"); + } + ) + ); + } +} diff --git a/eo-parser/src/main/java/org/eolang/parser/StXnav.java b/eo-parser/src/main/java/org/eolang/parser/StXnav.java index 57f4504590d..955dd98791e 100644 --- a/eo-parser/src/main/java/org/eolang/parser/StXnav.java +++ b/eo-parser/src/main/java/org/eolang/parser/StXnav.java @@ -17,7 +17,7 @@ * * @since 0.53.0 */ -public final class StXnav implements Shift { +final class StXnav implements Shift { /** * XPath to search for. */ @@ -28,19 +28,35 @@ public final class StXnav implements Shift { */ private final Consumer fun; + /** + * UID. + */ + private final String identifier; + + /** + * Ctor. + * @param path The XPath + * @param func The function + */ + StXnav(final String path, final Consumer func) { + this("st-xnav", path, func); + } + /** * Ctor. + * @param identifier UID * @param path The XPath * @param func The function */ - public StXnav(final String path, final Consumer func) { + StXnav(final String identifier, final String path, final Consumer func) { + this.identifier = identifier; this.xpath = path; this.fun = func; } @Override public String uid() { - return this.getClass().getSimpleName(); + return this.identifier; } @Override diff --git a/eo-parser/src/main/java/org/eolang/parser/Xmir.java b/eo-parser/src/main/java/org/eolang/parser/Xmir.java index 40464d7c8e3..ffa97675267 100644 --- a/eo-parser/src/main/java/org/eolang/parser/Xmir.java +++ b/eo-parser/src/main/java/org/eolang/parser/Xmir.java @@ -9,9 +9,9 @@ import com.jcabi.xml.XML; import com.yegor256.xsline.Shift; import com.yegor256.xsline.StClasspath; -import com.yegor256.xsline.StEndless; import com.yegor256.xsline.TrClasspath; import com.yegor256.xsline.TrDefault; +import com.yegor256.xsline.TrJoined; import com.yegor256.xsline.Xsline; import java.util.Collection; import java.util.List; @@ -47,14 +47,14 @@ public final class Xmir implements XML { */ private static final Xsline FOR_EO = new Xsline( new TrFull( - new TrDefault<>( - new StEndless( - new StClasspath("/org/eolang/parser/print/tuples-to-stars.xsl") - ), - Xmir.UNHEX, - new StClasspath("/org/eolang/parser/print/inline-cactoos.xsl"), - new StClasspath("/org/eolang/parser/print/dataized-to-const.xsl"), - new StClasspath("/org/eolang/parser/print/to-eo.xsl") + new TrJoined<>( + new TrDefault<>(Xmir.UNHEX), + new TrClasspath<>( + "/org/eolang/parser/print/tuples-to-stars.xsl", + "/org/eolang/parser/print/inline-cactoos.xsl", + "/org/eolang/parser/print/dataized-to-const.xsl", + "/org/eolang/parser/print/to-eo.xsl" + ).back() ) ) ); @@ -204,6 +204,13 @@ private String converted(final Xsline train, final String node) { .element("program") .element(node) .text() - .get(); + .orElseThrow( + () -> new IllegalStateException( + String.format( + "Couldn't find element '/program/%s' after converting to %s", + node, node + ) + ) + ); } } diff --git a/eo-parser/src/main/resources/org/eolang/parser/parse/stars-to-tuples.xsl b/eo-parser/src/main/resources/org/eolang/parser/parse/stars-to-tuples.xsl index 1a3d118428a..c76bcb10dd2 100644 --- a/eo-parser/src/main/resources/org/eolang/parser/parse/stars-to-tuples.xsl +++ b/eo-parser/src/main/resources/org/eolang/parser/parse/stars-to-tuples.xsl @@ -15,17 +15,24 @@ Into the next one without @star: - - - - - - + + + + + + 1 + + + 2 + + + 3 + --> @@ -39,19 +46,24 @@ - + + + + + + + + + - + - - - diff --git a/eo-parser/src/main/resources/org/eolang/parser/print/tuples-to-stars.xsl b/eo-parser/src/main/resources/org/eolang/parser/print/tuples-to-stars.xsl index 782e6e01aa8..c4dbb5c71ac 100644 --- a/eo-parser/src/main/resources/org/eolang/parser/print/tuples-to-stars.xsl +++ b/eo-parser/src/main/resources/org/eolang/parser/print/tuples-to-stars.xsl @@ -8,28 +8,31 @@ Performs the reverse operation of "/org/eolang/parser/stars-to-tuples.xsl" --> - + + + + - + + + - - - - - - - + + + + + + + + - - - - - - - - + + + + + diff --git a/eo-parser/src/test/java/org/eolang/parser/StHexTest.java b/eo-parser/src/test/java/org/eolang/parser/StHexTest.java new file mode 100644 index 00000000000..61022f40da3 --- /dev/null +++ b/eo-parser/src/test/java/org/eolang/parser/StHexTest.java @@ -0,0 +1,48 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com + * SPDX-License-Identifier: MIT + */ +package org.eolang.parser; + +import com.jcabi.matchers.XhtmlMatchers; +import com.jcabi.xml.XMLDocument; +import com.yegor256.xsline.Xsline; +import org.hamcrest.MatcherAssert; +import org.hamcrest.Matchers; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +/** + * Test case for {@link StHex}. + * + * @since 0.54.0 + */ +final class StHexTest { + @ParameterizedTest + @CsvSource({ + "1, 3F-F0-00-00-00-00-00-00", + "2, 40-00-00-00-00-00-00-00", + "3, 40-08-00-00-00-00-00-00", + "10, 40-24-00-00-00-00-00-00" + }) + void convertsNumberToHex(final String number, final String bytes) { + MatcherAssert.assertThat( + String.format( + "StHex must convert number '%s' to '%s' bytes and remove @hex attribute", + number, bytes + ), + new Xsline(new StHex()).pass( + new XMLDocument( + String.format( + "

%s

", + number + ) + ) + ), + Matchers.allOf( + XhtmlMatchers.hasXPath(String.format("//o[text()='%s']", bytes)), + XhtmlMatchers.hasXPath("/p[not(//o[@hex])]") + ) + ); + } +} diff --git a/eo-parser/src/test/resources/org/eolang/parser/eo-packs/parse/explicit-data.yaml b/eo-parser/src/test/resources/org/eolang/parser/eo-packs/parse/explicit-data.yaml index 29d61e55d84..ce679957e5d 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/eo-packs/parse/explicit-data.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/eo-packs/parse/explicit-data.yaml @@ -16,7 +16,7 @@ asserts: - //o[@base='Q.org.eolang.bytes' and @name='fourth' and not(o) and text()='11-21'] - //o[@base='.string' and @name='str' and count(o)=2 and o[last() and @base='Q.org.eolang.bytes' and text()='48-65-79']] - //o[@base='Q.org.eolang.bytes' and @name='bt' and count(o)=0 and text()='A2-'] - - //o[@base='.with']/o[@base='.with']/o[@base='.with']/o[@base='Q.org.eolang.number']/o[@base='Q.org.eolang.bytes' and text()='3F-F0-00-00-00-00-00-00'] + - //o[@base='Q.org.eolang.tuple']/o[@base='Q.org.eolang.tuple']/o[@base='Q.org.eolang.tuple']/o[@base='Q.org.eolang.number']/o[@base='Q.org.eolang.bytes' and text()='3F-F0-00-00-00-00-00-00'] input: | 42 > first number 11-21 > bts diff --git a/eo-parser/src/test/resources/org/eolang/parser/eo-packs/parse/roll-bases.yaml b/eo-parser/src/test/resources/org/eolang/parser/eo-packs/parse/roll-bases.yaml index c4a356b127a..a4d58772fc8 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/eo-packs/parse/roll-bases.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/eo-packs/parse/roll-bases.yaml @@ -21,7 +21,7 @@ asserts: - //o[@base='$.two.a' and @name='one'] - //o[@base='$.three.b' and @name='two'] - //o[@base='Q.org.eolang.c' and @name='three'] - - //o[@base='.with']/o[@base='Q.org.eolang.tuple.empty.with' and o[@base='Q.org.eolang.number']] + - //o[@base='Q.org.eolang.tuple']/o[@base='Q.org.eolang.tuple' and o[@base='Q.org.eolang.tuple.empty'] and o[@base='Q.org.eolang.number']] - //o[@base='Q.org.eolang.true.if' and count(o)=2] - //o[@base='.if' and count(o)=3]/o[1][@base='$.x']/o[1][@base='Q.org.eolang.y'] - //o[@base='.and']/o[1][@base='.eq']/o[1][@base='.as-bytes']/o[@base='Q.org.eolang.bytes' and text()!=''] diff --git a/eo-parser/src/test/resources/org/eolang/parser/eo-packs/parse/stars-to-tuples.yaml b/eo-parser/src/test/resources/org/eolang/parser/eo-packs/parse/stars-to-tuples.yaml index aff0da93e46..e1bdf93f65c 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/eo-packs/parse/stars-to-tuples.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/eo-packs/parse/stars-to-tuples.yaml @@ -5,29 +5,35 @@ sheets: - /org/eolang/parser/parse/wrap-method-calls.xsl - /org/eolang/parser/parse/stars-to-tuples.xsl asserts: - - //objects[count(o)=7] + - //objects[count(o)=8] - //objects[count(//o[@star])=0] # first - - //o[@base='.empty' and @line=1 and @name='xs']/o[@base='Q.org.eolang.tuple' and not(@name)] + - //o[@base='Q.org.eolang.tuple.empty' and @line=1 and @name='xs'] # second - - //o[@base='.with' and @line=2 and @name='xl']/o[@base='.empty']/o[@base='Q.org.eolang.tuple'] - - //o[@base='.with' and @line=2 and @name='xl']/o[@base='Q.org.eolang.number'] + - //o[@base='Q.org.eolang.tuple' and @line=2 and @name='xl']/o[1][@base='Q.org.eolang.tuple.empty'] + - //o[@base='Q.org.eolang.tuple' and @line=2 and @name='xl']/o[2][@base='Q.org.eolang.number'] + - //o[@base='Q.org.eolang.tuple' and @line=2 and @name='xl']/o[3][@base='Q.org.eolang.number']/o[1][@hex and text()='1'] # third - - //o[@base='.with' and @line=3 and not(@name)]/o[@base='.with']/o[@base='.empty']/o[@base='Q.org.eolang.tuple'] - - //o[@base='.with' and @line=3 and not(@name)]/o[@base='.with']/o[@base='Q.org.eolang.number'] - - //o[@base='.with' and @line=3 and not(@name)]/o[@base='Q.org.eolang.number'] + - //o[@base='Q.org.eolang.tuple' and @line=3]/o[1][@base='Q.org.eolang.tuple']/o[1][@base='Q.org.eolang.tuple.empty'] + - //o[@base='Q.org.eolang.tuple' and @line=3]/o[1][@base='Q.org.eolang.tuple']/o[2][@base='Q.org.eolang.number'] + - //o[@base='Q.org.eolang.tuple' and @line=3]/o[1][@base='Q.org.eolang.tuple']/o[3][@base='Q.org.eolang.number']/o[1][@hex and text()='1'] + - //o[@base='Q.org.eolang.tuple' and @line=3]/o[2][@base='Q.org.eolang.number'] + - //o[@base='Q.org.eolang.tuple' and @line=3]/o[3][@base='Q.org.eolang.number']/o[1][@hex and text()='2'] # fourth - - //o[@base='.empty' and @line=4]/o[@base='.empty']/o[@base='Q.org.eolang.tuple'] + - //o[@base='.empty' and @line=4]/o[@base='Q.org.eolang.tuple.empty'] # fifth - - //o[@base='.with' and @line=5 and not(@name)]/o[@base='.with']/o[@base='.with']/o[@base='.empty']/o[@base='Q.org.eolang.tuple'] - - //o[@base='.with' and @line=5 and not(@name)]/o[@base='.with']/o[@base='.with']/o[@base='.c'] - - //o[@base='.with' and @line=5 and not(@name)]/o[@base='.with']/o[@base='.f'] - - //o[@base='.with' and @line=5 and not(@name)]/o[@base='.i'] + - //o[@base='Q.org.eolang.tuple' and @line=5]/o[1][@base='Q.org.eolang.tuple']/o[1][@base='Q.org.eolang.tuple']/o[1][@base='Q.org.eolang.tuple.empty'] + - //o[@base='Q.org.eolang.tuple' and @line=5]/o[1][@base='Q.org.eolang.tuple']/o[1][@base='Q.org.eolang.tuple']/o[2][@base='.c'] + - //o[@base='Q.org.eolang.tuple' and @line=5]/o[1][@base='Q.org.eolang.tuple']/o[1][@base='Q.org.eolang.tuple']/o[3][@base='Q.org.eolang.number']/o[@hex and text()='1'] + - //o[@base='Q.org.eolang.tuple' and @line=5]/o[1][@base='Q.org.eolang.tuple']/o[2][@base='.f'] + - //o[@base='Q.org.eolang.tuple' and @line=5]/o[1][@base='Q.org.eolang.tuple']/o[3][@base='Q.org.eolang.number']/o[@hex and text()='2'] + - //o[@base='Q.org.eolang.tuple' and @line=5]/o[2][@base='.i'] + - //o[@base='Q.org.eolang.tuple' and @line=5]/o[3][@base='Q.org.eolang.number']/o[@hex and text()='3'] # sixth - - //o[@base='.elements']/o[@base='arr']/o[@base='.empty']/o[@base='Q.org.eolang.tuple'] + - //o[@base='.elements']/o[@base='arr']/o[@base='Q.org.eolang.tuple.empty'] # seventh - //o[@base='.reduced']/o[@base='list'] - - //o[@base='.reduced']/o[@base='.empty']/o[@base='Q.org.eolang.tuple'] + - //o[@base='.reduced']/o[@base='Q.org.eolang.tuple.empty'] - //o[@base='.reduced']/o[not(@base)]/o[@base='∅' and @name='x'] input: | * > xs @@ -43,3 +49,4 @@ input: | .reduced > y * [x] + * (* 1 2) (* 3 4) (* 5 6) > last diff --git a/eo-parser/src/test/resources/org/eolang/parser/eo-packs/print/tuples-of-tuples-to-stars.yaml b/eo-parser/src/test/resources/org/eolang/parser/eo-packs/print/tuples-of-tuples-to-stars.yaml index 2fb5b0e7727..4c4d7f2fd24 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/eo-packs/print/tuples-of-tuples-to-stars.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/eo-packs/print/tuples-of-tuples-to-stars.yaml @@ -1,7 +1,6 @@ # SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com # SPDX-License-Identifier: MIT --- -skip: true sheets: - /org/eolang/parser/parse/move-voids-up.xsl - /org/eolang/parser/parse/validate-before-stars.xsl @@ -18,10 +17,9 @@ sheets: - /org/eolang/parser/parse/explicit-data.xsl - /org/eolang/parser/parse/roll-bases.xsl - /org/eolang/parser/print/tuples-to-stars.xsl - - /org/eolang/parser/print/tuples-to-stars.xsl - - /org/eolang/parser/print/tuples-to-stars.xsl asserts: - - /program/objects/o[@name='foo']/o[@star and count(o[@star])=3] + - /program/objects/o[@name='foo']/o[@name='xs' and @star and count(o[@star])=3] + - /program/objects/o[@name='foo']/o[@name='yx' and @star and count(o[@star])=3] input: | +package test @@ -31,3 +29,13 @@ input: | * 1 2 * 3 4 * 5 6 + * > yx + *:0 + 1:0 + 2:1 + *:1 + 3:0 + 4:1 + *:2 + 5:0 + 6:1 diff --git a/eo-parser/src/test/resources/org/eolang/parser/eo-packs/print/tuples-to-stars.yaml b/eo-parser/src/test/resources/org/eolang/parser/eo-packs/print/tuples-to-stars.yaml index bcdfb36fc62..40ef0d80a53 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/eo-packs/print/tuples-to-stars.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/eo-packs/print/tuples-to-stars.yaml @@ -17,8 +17,6 @@ sheets: - /org/eolang/parser/parse/explicit-data.xsl - /org/eolang/parser/parse/roll-bases.xsl - /org/eolang/parser/print/tuples-to-stars.xsl - - /org/eolang/parser/print/tuples-to-stars.xsl - - /org/eolang/parser/print/tuples-to-stars.xsl asserts: - /program/objects/o[@name='foo']/o[@base='Q.org.eolang.tuple' and @star and count(o)=3 and count(o[@star]=0)] input: | @@ -26,10 +24,13 @@ input: | # No comments. [] > foo - with. - with. - with. + tuple + tuple + tuple tuple.empty + "hey" 1 + "jeff" 2 + "!" 3 diff --git a/eo-parser/src/test/resources/org/eolang/parser/phi-packs/jeo-part.yaml b/eo-parser/src/test/resources/org/eolang/parser/phi-packs/jeo-part.yaml index 0fd0997a448..8fd50db6b42 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/phi-packs/jeo-part.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/phi-packs/jeo-part.yaml @@ -18,7 +18,7 @@ sweet: |- j$A ↦ ⟦ access ↦ 32, supername ↦ "java/lang/Object", - interfaces ↦ Φ̇.tuple.empty.with("org/eolang/benchmark/F") + interfaces ↦ Φ̇.tuple(Φ̇.tuple.empty, "org/eolang/benchmark/F", 1) ⟧, λ ⤍ Package ⟧, @@ -44,11 +44,17 @@ salty: |- α0 ↦ ⟦ Δ ⤍ 6A-61-76-61-2F-6C-61-6E-67-2F-4F-62-6A-65-63-74 ⟧ ) ), - interfaces ↦ Φ.org.eolang.tuple.empty.with( - α0 ↦ Φ.org.eolang.string( + interfaces ↦ Φ.org.eolang.tuple( + α0 ↦ Φ.org.eolang.tuple.empty, + α1 ↦ Φ.org.eolang.string( α0 ↦ Φ.org.eolang.bytes( α0 ↦ ⟦ Δ ⤍ 6F-72-67-2F-65-6F-6C-61-6E-67-2F-62-65-6E-63-68-6D-61-72-6B-2F-46 ⟧ ) + ), + α2 ↦ Φ.org.eolang.number( + α0 ↦ Φ.org.eolang.bytes( + α0 ↦ ⟦ Δ ⤍ 3F-F0-00-00-00-00-00-00 ⟧ + ) ) ) ⟧, diff --git a/eo-parser/src/test/resources/org/eolang/parser/phi-packs/string-part.yaml b/eo-parser/src/test/resources/org/eolang/parser/phi-packs/string-part.yaml index 4942d86f3fe..3cf6d9d17d3 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/phi-packs/string-part.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/phi-packs/string-part.yaml @@ -30,8 +30,12 @@ sweet: |- Φ̇.error( Φ̇.txt.sprintf( "Expected %d byte character at %d index, but there are not enough bytes for it: %x", - Φ̇.tuple.empty.with(ξ.char-size).with(ξ.index).with( - ξ.ρ.ρ.as-bytes + Φ̇.tuple( + Φ̇.tuple( + Φ̇.tuple(Φ̇.tuple.empty, ξ.char-size, 1), ξ.index, 2 + ), + ξ.ρ.ρ.as-bytes, + 3 ) ) ) @@ -68,12 +72,30 @@ salty: |- α0 ↦ ⟦ Δ ⤍ 45-78-70-65-63-74-65-64-20-25-64-20-62-79-74-65-20-63-68-61-72-61-63-74-65-72-20-61-74-20-25-64-20-69-6E-64-65-78-2C-20-62-75-74-20-74-68-65-72-65-20-61-72-65-20-6E-6F-74-20-65-6E-6F-75-67-68-20-62-79-74-65-73-20-66-6F-72-20-69-74-3A-20-25-78 ⟧ ) ), - α1 ↦ Φ.org.eolang.tuple.empty.with( - α0 ↦ ξ.char-size - ).with( - α0 ↦ ξ.index - ).with( - α0 ↦ ξ.ρ.ρ.as-bytes + α1 ↦ Φ.org.eolang.tuple( + α0 ↦ Φ.org.eolang.tuple( + α0 ↦ Φ.org.eolang.tuple( + α0 ↦ Φ.org.eolang.tuple.empty, + α1 ↦ ξ.char-size, + α2 ↦ Φ.org.eolang.number( + α0 ↦ Φ.org.eolang.bytes( + α0 ↦ ⟦ Δ ⤍ 3F-F0-00-00-00-00-00-00 ⟧ + ) + ) + ), + α1 ↦ ξ.index, + α2 ↦ Φ.org.eolang.number( + α0 ↦ Φ.org.eolang.bytes( + α0 ↦ ⟦ Δ ⤍ 40-00-00-00-00-00-00-00 ⟧ + ) + ) + ), + α1 ↦ ξ.ρ.ρ.as-bytes, + α2 ↦ Φ.org.eolang.number( + α0 ↦ Φ.org.eolang.bytes( + α0 ↦ ⟦ Δ ⤍ 40-08-00-00-00-00-00-00 ⟧ + ) + ) ) ) ) diff --git a/eo-parser/src/test/resources/org/eolang/parser/print-packs/yaml/stars-tuples.yaml b/eo-parser/src/test/resources/org/eolang/parser/print-packs/yaml/stars-tuples.yaml index d7400127eb2..a31cd03d8ec 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/print-packs/yaml/stars-tuples.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/print-packs/yaml/stars-tuples.yaml @@ -3,9 +3,30 @@ --- origin: | * 1 "Hello" x > array + * > xs + *:0 + 1:0 + 2:1 + *:1 + 3:0 + 4:1 + *:2 + 5:0 + 6:1 printed: | * > array 1 "Hello" x + + * > xs + * + 1 + 2 + * + 3 + 4 + * + 5 + 6 diff --git a/eo-runtime/src/main/eo/org/eolang/bytes.eo b/eo-runtime/src/main/eo/org/eolang/bytes.eo index 4b168c0e7f2..364123c8dd7 100644 --- a/eo-runtime/src/main/eo/org/eolang/bytes.eo +++ b/eo-runtime/src/main/eo/org/eolang/bytes.eo @@ -9,6 +9,7 @@ +spdx SPDX-License-Identifier: MIT +unlint rt-without-atoms +unlint empty-object ++unlint wrong-sprintf-arguments # The object encapsulates a chain of bytes, adding a few # convenient operations to it. Objects like `int`, `string`, diff --git a/eo-runtime/src/main/eo/org/eolang/fs/dir.eo b/eo-runtime/src/main/eo/org/eolang/fs/dir.eo index b5887783a62..337bd6b5982 100644 --- a/eo-runtime/src/main/eo/org/eolang/fs/dir.eo +++ b/eo-runtime/src/main/eo/org/eolang/fs/dir.eo @@ -9,6 +9,7 @@ +spdx SPDX-License-Identifier: MIT +unlint rt-without-atoms +unlint empty-object ++unlint wrong-sprintf-arguments # Directory in the file system. # Apparently every directory is a file. diff --git a/eo-runtime/src/main/eo/org/eolang/fs/file.eo b/eo-runtime/src/main/eo/org/eolang/fs/file.eo index 574d2c4e1f8..58ef9caea70 100644 --- a/eo-runtime/src/main/eo/org/eolang/fs/file.eo +++ b/eo-runtime/src/main/eo/org/eolang/fs/file.eo @@ -9,6 +9,7 @@ +spdx SPDX-License-Identifier: MIT +unlint rt-without-atoms +unlint empty-object ++unlint wrong-sprintf-arguments # The file object in the filesystem. [path] > file diff --git a/eo-runtime/src/main/eo/org/eolang/i16.eo b/eo-runtime/src/main/eo/org/eolang/i16.eo index 4800253eb0b..7498f7ca75d 100644 --- a/eo-runtime/src/main/eo/org/eolang/i16.eo +++ b/eo-runtime/src/main/eo/org/eolang/i16.eo @@ -9,6 +9,7 @@ +spdx SPDX-License-Identifier: MIT +unlint rt-without-atoms +unlint empty-object ++unlint wrong-sprintf-arguments # The 16 bits signed integer. # Here `as-bytes` must be a `bytes` object. diff --git a/eo-runtime/src/main/eo/org/eolang/i32.eo b/eo-runtime/src/main/eo/org/eolang/i32.eo index 7a5afdc9455..fdfd73ea8d8 100644 --- a/eo-runtime/src/main/eo/org/eolang/i32.eo +++ b/eo-runtime/src/main/eo/org/eolang/i32.eo @@ -9,6 +9,7 @@ +spdx SPDX-License-Identifier: MIT +unlint rt-without-atoms +unlint empty-object ++unlint wrong-sprintf-arguments # The 32 bits signed integer. # Here `as-bytes` must be a `bytes` object. diff --git a/eo-runtime/src/main/eo/org/eolang/i64.eo b/eo-runtime/src/main/eo/org/eolang/i64.eo index ffce073005b..711c4871c2f 100644 --- a/eo-runtime/src/main/eo/org/eolang/i64.eo +++ b/eo-runtime/src/main/eo/org/eolang/i64.eo @@ -9,6 +9,7 @@ +spdx SPDX-License-Identifier: MIT +unlint rt-without-atoms +unlint empty-object ++unlint wrong-sprintf-arguments # The 64 bits signed integer. # Here `as-bytes` must be a `bytes` object. diff --git a/eo-runtime/src/main/eo/org/eolang/net/socket.eo b/eo-runtime/src/main/eo/org/eolang/net/socket.eo index 8b25fb7cdba..be0ee1304c8 100644 --- a/eo-runtime/src/main/eo/org/eolang/net/socket.eo +++ b/eo-runtime/src/main/eo/org/eolang/net/socket.eo @@ -9,6 +9,7 @@ +spdx SPDX-FileCopyrightText Copyright (c) 2016-2025 Objectionary.com +spdx SPDX-License-Identifier: MIT +unlint unit-test-missing ++unlint wrong-sprintf-arguments # Socket. # diff --git a/eo-runtime/src/main/eo/org/eolang/string.eo b/eo-runtime/src/main/eo/org/eolang/string.eo index a043a21e8d7..59c83caba2f 100644 --- a/eo-runtime/src/main/eo/org/eolang/string.eo +++ b/eo-runtime/src/main/eo/org/eolang/string.eo @@ -5,6 +5,7 @@ +version 0.0.0 +spdx SPDX-FileCopyrightText Copyright (c) 2016-2025 Objectionary.com +spdx SPDX-License-Identifier: MIT ++unlint wrong-sprintf-arguments # The `string` object is an abstraction of a text string, which # internally is a chain of bytes. diff --git a/eo-runtime/src/main/eo/org/eolang/structs/map.eo b/eo-runtime/src/main/eo/org/eolang/structs/map.eo index 57106d07835..9d09f906b1d 100644 --- a/eo-runtime/src/main/eo/org/eolang/structs/map.eo +++ b/eo-runtime/src/main/eo/org/eolang/structs/map.eo @@ -7,6 +7,7 @@ +version 0.0.0 +spdx SPDX-FileCopyrightText Copyright (c) 2016-2025 Objectionary.com +spdx SPDX-License-Identifier: MIT ++unlint wrong-sprintf-arguments # Hash-map. # Here `pairs` must be a `tuple` of `map.entry` object. diff --git a/eo-runtime/src/main/eo/org/eolang/txt/text.eo b/eo-runtime/src/main/eo/org/eolang/txt/text.eo index 68213869e5a..a0c3463fc71 100644 --- a/eo-runtime/src/main/eo/org/eolang/txt/text.eo +++ b/eo-runtime/src/main/eo/org/eolang/txt/text.eo @@ -9,6 +9,7 @@ +version 0.0.0 +spdx SPDX-FileCopyrightText Copyright (c) 2016-2025 Objectionary.com +spdx SPDX-License-Identifier: MIT ++unlint wrong-sprintf-arguments # Text. # A sequence of characters representing words, sentences, or data. diff --git a/eo-runtime/src/test/eo/org/eolang/fs/file-tests.eo b/eo-runtime/src/test/eo/org/eolang/fs/file-tests.eo index 3fb75a9a0e0..c2161f5548a 100644 --- a/eo-runtime/src/test/eo/org/eolang/fs/file-tests.eo +++ b/eo-runtime/src/test/eo/org/eolang/fs/file-tests.eo @@ -11,6 +11,7 @@ +spdx SPDX-FileCopyrightText Copyright (c) 2016-2025 Objectionary.com +spdx SPDX-License-Identifier: MIT +unlint sparse-decoration ++unlint wrong-sprintf-arguments # This unit test is supposed to check the functionality of the corresponding object. [] > tests-check-if-current-directory-is-directory diff --git a/eo-runtime/src/test/eo/org/eolang/structs/list-tests.eo b/eo-runtime/src/test/eo/org/eolang/structs/list-tests.eo index 3d43013ac91..21e1a966007 100644 --- a/eo-runtime/src/test/eo/org/eolang/structs/list-tests.eo +++ b/eo-runtime/src/test/eo/org/eolang/structs/list-tests.eo @@ -8,6 +8,7 @@ +spdx SPDX-FileCopyrightText Copyright (c) 2016-2025 Objectionary.com +spdx SPDX-License-Identifier: MIT +unlint sparse-decoration ++unlint wrong-sprintf-arguments # This unit test is supposed to check the functionality of the corresponding object. [] > tests-list-should-not-be-empty diff --git a/eo-runtime/src/test/eo/org/eolang/txt/sscanf-tests.eo b/eo-runtime/src/test/eo/org/eolang/txt/sscanf-tests.eo index 29037bc2e45..f7eb5911092 100644 --- a/eo-runtime/src/test/eo/org/eolang/txt/sscanf-tests.eo +++ b/eo-runtime/src/test/eo/org/eolang/txt/sscanf-tests.eo @@ -9,6 +9,7 @@ +spdx SPDX-FileCopyrightText Copyright (c) 2016-2025 Objectionary.com +spdx SPDX-License-Identifier: MIT +unlint sparse-decoration ++unlint wrong-sprintf-arguments # This unit test is supposed to check the functionality of the corresponding object. [] > tests-sscanf-with-string diff --git a/eo-runtime/src/test/java/integration/PhiUnphiIT.java b/eo-runtime/src/test/java/integration/PhiUnphiIT.java index 170d895fc36..c8d726a7af9 100644 --- a/eo-runtime/src/test/java/integration/PhiUnphiIT.java +++ b/eo-runtime/src/test/java/integration/PhiUnphiIT.java @@ -16,7 +16,6 @@ import java.nio.file.Path; import java.nio.file.Paths; import org.hamcrest.MatcherAssert; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -24,12 +23,6 @@ * Integration test for phi-unphi. * * @since 0.1 - * @todo #3199:30min Enable PhiUnphiIT. The test was disabled because tuples are converted to EO - * incorrectly after phi-unphi. The key problem is recursive representation of tuples via - * tuple.with method. It should be done via simple application of tuple like it was done before, - * but with calculated length. - * Check the disabled org/eolang/parser/eo-packs/print/tuples-of-tuples-to-stars.yaml pack in - * eo-parser module. * @checkstyle MethodLengthCheck (500 lines) */ @SuppressWarnings({"JTCOP.RuleAllTestsHaveProductionClass", "JTCOP.RuleNotContainsTestWord"}) @@ -37,7 +30,6 @@ final class PhiUnphiIT { @Test - @Disabled @ExtendWith(MayBeSlow.class) @ExtendWith(WeAreOnline.class) void runsTestsAfterPhiAndUnphi(final @Mktmp Path temp) throws IOException { diff --git a/eo-runtime/src/test/resources/junit-platform.properties b/eo-runtime/src/test/resources/junit-platform.properties index 86b582e49e3..b8c3e861196 100644 --- a/eo-runtime/src/test/resources/junit-platform.properties +++ b/eo-runtime/src/test/resources/junit-platform.properties @@ -1,4 +1,4 @@ # SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com # SPDX-License-Identifier: MIT -junit.jupiter.execution.timeout.test.method.default = 3m +junit.jupiter.execution.timeout.test.method.default = 5m