Skip to content

Commit

Permalink
#3549: tests fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Nov 26, 2024
1 parent beabd79 commit 0a47bce
Show file tree
Hide file tree
Showing 13 changed files with 148 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void exec() throws IOException {
}
} else {
Logger.info(
this, "The directory is absent, nothing to place to %[file]s",
this, "The directory %[file]s is absent, nothing to place from it",
home
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ SOFTWARE.
<xsl:value-of select="."/>
</xsl:attribute>
<xsl:attribute name="java-name">
<xsl:variable name="pkg" select="//metas/meta[head='package']/part[1]"/>
<xsl:variable name="pkg" select="/program/metas/meta[head='package']/part[1]"/>
<xsl:if test="$pkg">
<xsl:value-of select="eo:class-name($pkg, eo:suffix(../@line, ../@pos))"/>
<xsl:text>.</xsl:text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,9 @@ void assemblesSuccessfullyInOfflineMode(final Logs out, @Mktmp final Path temp)
MatcherAssert.assertThat(
"While execution AssembleMojo log should have contained message about offline mode, but it didn't",
String.join("\n", out.captured()),
Matchers.containsString("No programs were pulled because eo.offline flag is TRUE")
Matchers.containsString(
"No programs were pulled because eo.offline flag is set to TRUE"
)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ void showsWhereNotFoundWasDiscoveredAt(@Mktmp final Path tmp, final Logs out)
);
Assertions.assertTrue(
out.captured().stream().anyMatch(
line -> line.contains("Failed to pull object 'org.eolang.org' discovered at")
line -> line.contains("Failed to pull 'org.eolang.org' earlier discovered at")
),
"Log should contain info where failed to pull object was discovered at, but it does not"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
*/
package org.eolang.maven.name;

import com.yegor256.WeAreOnline;
import org.eolang.maven.hash.CommitHashesMap;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

Expand Down Expand Up @@ -125,6 +127,7 @@ void convertsToStringWithEmptyVersion() {
}

@Test
@ExtendWith(WeAreOnline.class)
void convertsToStringFromOtherObjectName() {
final ObjectName name = new OnReplaced(
new OnVersioned(
Expand Down
23 changes: 20 additions & 3 deletions eo-parser/src/main/resources/XMIR.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ SOFTWARE.
<xs:annotation>
<xs:appinfo>Whole number</xs:appinfo>
<xs:documentation>
Whole numbers, include zero.
Whole numbers, include zero. This type is used for line numbers, positions, etc.
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:integer">
Expand All @@ -47,6 +47,7 @@ SOFTWARE.
<xs:appinfo>A non-empty string</xs:appinfo>
<xs:documentation>
The value that is not empty (contains at least one character).
This type is used for names, etc.
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
Expand Down Expand Up @@ -86,8 +87,24 @@ SOFTWARE.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="name" type="non-empty"/>
<xs:attribute name="base" type="non-empty"/>
<xs:attribute name="name" type="non-empty">
<xs:annotation>
<xs:appinfo>The name of the EO object inside its scope of visibility (another object or global)</xs:appinfo>
<xs:documentation>
The attribute contains the name of the EO object inside its scope of visibility.
The name is used to reference the object from other objects or from the global scope.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="base" type="non-empty">
<xs:annotation>
<xs:appinfo>The name of the object of which this one is a copy</xs:appinfo>
<xs:documentation>
The attribute contains the name of the object of which this one is a copy.
The base object is used to define the structure of the current object.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="star" type="empty"/>
<xs:attribute name="as" type="non-empty"/>
<xs:attribute name="atom" type="non-empty"/>
Expand Down
67 changes: 40 additions & 27 deletions eo-parser/src/main/resources/org/eolang/parser/add-probes.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:eo="https://www.eolang.org" xmlns:xs="http://www.w3.org/2001/XMLSchema" id="add-probes" version="2.0">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:eo="https://www.eolang.org" xmlns:xs="http://www.w3.org/2001/XMLSchema" id="add-probes" version="2.0" exclude-result-prefixes="eo xs">
<!--
For every object that starts with '.' add probe meta
with fully qualified name of the object.
Expand Down Expand Up @@ -57,35 +57,48 @@ SOFTWARE.
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<xsl:template match="/program/metas">
<xsl:variable name="mts">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
<xsl:for-each select="//o[starts-with(@base, '.')]">
<xsl:variable name="p" select="eo:qualify(.)"/>
<xsl:variable name="c" select="string-length($p) - string-length(translate($p, '.', ''))"/>
<xsl:if test="not(eo:contains-any-of($p, ('$', '^', '@', '&lt;'))) and not(starts-with($p, '.')) and $c &gt; 1">
<xsl:element name="meta">
<xsl:attribute name="line">
<xsl:value-of select="if (@line) then @line else '0'"/>
</xsl:attribute>
<xsl:element name="head">
<xsl:text>probe</xsl:text>
</xsl:element>
<xsl:element name="tail">
<xsl:value-of select="string-join(($p, @ver),'|')"/>
</xsl:element>
<xsl:element name="part">
<xsl:value-of select="$p"/>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:copy>
<xsl:template match="/program[not(metas)]">
<xsl:variable name="candidates">
<metas>
<xsl:apply-templates select="//o[starts-with(@base, '.')]" mode="create"/>
</metas>
</xsl:variable>
<xsl:apply-templates select="$mts"/>
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
<xsl:apply-templates select="$candidates"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/program/metas">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
<xsl:variable name="candidates">
<xsl:apply-templates select="//o[starts-with(@base, '.')]" mode="create"/>
</xsl:variable>
<xsl:apply-templates select="$candidates"/>
</xsl:copy>
</xsl:template>
<xsl:template match="metas[not(meta)]"/>
<xsl:template match="meta[head/text() = 'probe' and tail/text() = following::meta/tail/text()]"/>
<xsl:template match="o" mode="create">
<xsl:variable name="p" select="eo:qualify(.)"/>
<xsl:variable name="c" select="string-length($p) - string-length(translate($p, '.', ''))"/>
<xsl:if test="not(eo:contains-any-of($p, ('$', '^', '@', '&lt;'))) and not(starts-with($p, '.')) and $c &gt; 1">
<xsl:element name="meta">
<xsl:attribute name="line">
<xsl:value-of select="if (@line) then @line else '0'"/>
</xsl:attribute>
<xsl:element name="head">
<xsl:text>probe</xsl:text>
</xsl:element>
<xsl:element name="tail">
<xsl:value-of select="string-join(($p, @ver),'|')"/>
</xsl:element>
<xsl:element name="part">
<xsl:value-of select="$p"/>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:template>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# The MIT License (MIT)
#
# Copyright (c) 2016-2024 Objectionary.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
---
tests:
- /program[not(errors)]
- //metas[count(.//meta[head/text()='probe'])=1]
- /program/sheets[sheet='add-probes']
eo: |
# Test.
[] > app
Q.foo.boom > @
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# The MIT License (MIT)
#
# Copyright (c) 2016-2024 Objectionary.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
---
tests:
- /program[not(errors)]
- /program[not(metas)]
- /program/sheets[sheet='add-probes']
eo: |
# Test.
[] > app
42 > @
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ SOFTWARE.
<xsl:template match="/program/errors">
<!-- Not important -->
</xsl:template>
<xsl:template match="program/sheets">
<xsl:template match="/program/sheets">
<!-- Not important -->
</xsl:template>
<xsl:template match="@line">
Expand Down
17 changes: 16 additions & 1 deletion eo-runtime/src/main/java/org/eolang/Dataized.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,22 @@ public Dataized(final Phi src, final Logger log) {
}

/**
* Extract the data from the object.
* Extracts the data from the EO object as a byte array.
*
* <p>This method performs the dataization process, which involves converting
* the EO object into a byte array. It logs the dataization process if the
* logging level is set to FINE and the current dataization level is within
* the maximum allowed level. If an error occurs during dataization, it logs
* the error details and rethrows the exception.</p>
*
* <p>Usage example:</p>
*
* <pre>{@code
* Phi phi = ...; // Initialize your EO object
* Dataized dataized = new Dataized(phi);
* byte[] data = dataized.take();
* }</pre>
*
* @return The data
*/
public byte[] take() {
Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/test/java/EOorg/EOeolang/EOerrorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void getsReadableError(final byte[] cnst, final String text) {
}

/**
* Static method providing sources for parametrized test.
* Static method providing sources for parameterized test.
* @return Stream of sources.
*/
private static Stream<Arguments> getTestSources() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void representsString(final byte[] bytes, final String text) {
}

/**
* Static method providing sources for parametrized test.
* Static method providing sources for parameterized test.
* @return Stream of sources.
*/
private static Stream<Arguments> getTestSources() {
Expand Down

0 comments on commit 0a47bce

Please sign in to comment.