Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Apr 19, 2024
2 parents a510606 + d5195dd commit b2aed6a
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
/**
* Optimisation train of XLS`s.
* @since 0.28.12
* @todo #3115:30min Return constant-folding.xsl when it's ready. This optimization was removed from
* the train because it's not really ready and works only with `bool` object which was removed. We
* need to make this optimization great again and add to the train.
*/
public final class OptTrain implements Optimization {

Expand All @@ -57,7 +60,6 @@ public final class OptTrain implements Optimization {
"/org/eolang/parser/optimize/fix-missed-names.xsl",
"/org/eolang/parser/add-refs.xsl",
"/org/eolang/parser/errors/broken-refs.xsl",
"/org/eolang/parser/optimize/constant-folding.xsl",
"/org/eolang/parser/set-locators.xsl"
).back(),
TrFast.class,
Expand Down
12 changes: 0 additions & 12 deletions eo-parser/src/main/java/org/eolang/parser/StUnhex.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.yegor256.xsline.StSequence;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
import org.apache.commons.text.StringEscapeUtils;
import org.xembly.Directive;
import org.xembly.Directives;
Expand Down Expand Up @@ -72,17 +71,6 @@ public StUnhex() {
)
)
),
new StXPath(
StUnhex.xpath("bool"),
xml -> StUnhex.append(
"bool",
Boolean.toString(
!"00".equals(
StUnhex.unspace(xml.xpath("./o/text()").get(0))
)
).toUpperCase(Locale.ENGLISH)
)
),
new StXPath(
StUnhex.xpath("string"),
xml -> StUnhex.append(
Expand Down
1 change: 0 additions & 1 deletion eo-parser/src/main/resources/org/eolang/parser/_datas.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@ SOFTWARE.
<a>org.eolang.string</a>
<a>org.eolang.int</a>
<a>org.eolang.float</a>
<a>org.eolang.bool</a>
</xsl:variable>
</xsl:stylesheet>
12 changes: 5 additions & 7 deletions eo-parser/src/main/resources/org/eolang/parser/explicit-data.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,16 @@ SOFTWARE.
00 00 00 00 00 00 00 01 => 00 00 00 00 00 00 00 01
</o> </o>
</o> </o>
- <o base=".bool" name="b"> <o base=".bool" name="b">
- <o base=".int" name="b"> <o base=".int" name="b">
<o base=".eolang"> <o base=".eolang">
<o base=".org"> <o base="org">
<o base="Q"></o> <o base="Q"/>
</o> </o>
</o> </o>
<o base="org.eolang.bool" data="bytes"> => <o base="org.eolang.bool">
01 <o base="org.eolang.bytes" data="bytes">
</o> 01
</o> </o>
</o>
</o>
<o base="org.eolang.int" data="bytes"> => <o base="org.eolang.bytes" data="bytes">
01 01
</o> </o>
</o> </o>
-->
<xsl:import href="/org/eolang/parser/_datas.xsl"/>
<xsl:output encoding="UTF-8" method="xml"/>
Expand Down
34 changes: 0 additions & 34 deletions eo-parser/src/test/java/org/eolang/parser/StUnhexTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,38 +115,4 @@ void convertsFloatFromHexToEo() {
)
);
}

@Test
void convertsTrueFromHexToEo() {
MatcherAssert.assertThat(
StUnhexTest.EMPTY_MSG,
new Xsline(new StUnhex()).pass(
new XMLDocument(
String.join(
"",
"<p><o base='bool' name='a'><o base='bytes' data='bytes'>01</o></o>",
"<o base='bool' name='b'><o base='bytes' data='bytes'>00</o></o></p>"
)
)
),
XhtmlMatchers.hasXPaths(
"//o[text()='TRUE' and @data='bool' and @name='a']",
"//o[text()='FALSE' and @data='bool' and @name='b']"
)
);
}

@Test
void convertsFalseFromHexToEo() {
MatcherAssert.assertThat(
StUnhexTest.EMPTY_MSG,
new Xsline(new StUnhex()).pass(
new XMLDocument(
"<p><o base='bool'><o base='org.eolang.bytes' data='bytes'>00</o></o></p>"
)
),
XhtmlMatchers.hasXPaths("//o[text()='FALSE' and @data='bool']")
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ tests:
- //o[@base='org.eolang.int' and @name='first' and o[@base='org.eolang.bytes' and @data]]
- //o[@base='org.eolang.float' and @name='bts' and o[@base='org.eolang.bytes' and @data]]
- //o[@base='org.eolang.float' and @name='second' and o[@base='org.eolang.bytes' and @data]]
- //o[@name='third' or (@base='true' and @name='third' and not(@data) and count(o)=0)]
- //o[@name='tfalse' or (@base='false' and @name='tfalse' and not(@data) and count(o)=0)]
- //o[@base='org.eolang.bytes' and @name='fourth' and count(o)=0 and @data]
- //o[@base='.string' and @name='str' and count(o)=2 and o[last() and @base='org.eolang.bytes' and @data]]
- //o[@base='org.eolang.bytes' and @name='bt' and count(o)=0 and @data]
Expand All @@ -18,8 +16,6 @@ eo: |
42 > first
float 11-21 > bts
float 22.2 > second
QQ.bool 01- > third
Q.org.eolang.bool 00- > tfalse
QQ.bytes > fourth
11-21
Q.org.eolang.string "Hey" > str
Expand Down
43 changes: 0 additions & 43 deletions eo-runtime/src/main/eo/org/eolang/bool.eo

This file was deleted.

2 changes: 1 addition & 1 deletion eo-runtime/src/main/eo/org/eolang/bytes.eo
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# Bytes.
[] > bytes
# Equals to another object.
[x] > eq /bool
[b] > eq /bool

# Total number of bytes.
[] > size /int
Expand Down
5 changes: 3 additions & 2 deletions eo-runtime/src/main/eo/org/eolang/false.eo
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
+rt jvm org.eolang:eo-runtime:0.0.0
+version 0.0.0

# True.
# False.
[] > false
bool 00- > @
00- > @
true > not

# Control structure that allows for conditional execution of code.
# Since $ is FALSE - behaves as `right` object.
Expand Down
3 changes: 2 additions & 1 deletion eo-runtime/src/main/eo/org/eolang/true.eo
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@

# True.
[] > true
bool 01- > @
01- > @
false > not

# Control structure that allows for conditional execution of code.
# Since $ is TRUE - behaves as `left` object.
Expand Down
8 changes: 4 additions & 4 deletions eo-runtime/src/test/eo/org/eolang/while-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@

# Test.
[] > simple-while-with-false-first
while > res
false
true > [i]
(bool res).not > @
not. > @
while > res
false
true > [i]

# Test.
[] > simple-bool-expression-via-memory-in-while
Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/test/resources/org/eolang/snippets/all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ eo: |
42
# This is the default 64+ symbols comment in front of named abstract object.
[x] > foo
if > @
if. > @
x.eq 0
error "x is zero"
42
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ eo: |
[args] > fibo
# This is the default 64+ symbols comment in front of named abstract object.
[n] > f
if > @
if. > @
n.lt 2
n
plus.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ eo: |
[args] > ifthenelse
# This is the default 64+ symbols comment in front of named abstract object.
[n] > f
if > @
if. > @
n.lt 0
"smaller"
"greater"
Expand Down

1 comment on commit b2aed6a

@0pdd
Copy link

@0pdd 0pdd commented on b2aed6a Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 3115-d79bda11 discovered in eo-maven-plugin/src/main/java/org/eolang/maven/optimization/OptTrain.java) and submitted as #3120. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.