Skip to content

Commit

Permalink
Merge pull request #3243 from levBagryansky/1249_add-test
Browse files Browse the repository at this point in the history
#1249: It should align inner classes in tests
  • Loading branch information
yegor256 authored Jul 15, 2024
2 parents 5fb5af7 + 5f71785 commit f26ee33
Show file tree
Hide file tree
Showing 8 changed files with 230 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public final class TranspileMojo extends SafeMojo {
"/org/eolang/maven/pre/package.xsl",
"/org/eolang/maven/pre/tests.xsl",
"/org/eolang/maven/pre/rename-tests-inners.xsl",
"/org/eolang/maven/pre/align-test-classes.xsl",
"/org/eolang/maven/pre/remove-high-level-inner-classes.xsl",
"/org/eolang/maven/pre/attrs.xsl",
"/org/eolang/maven/pre/data.xsl"
).back(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" id="align-test-classes" version="2.0">
<!-- Copies all high-level nesting classes inside the main class.
@todo #1249:90min Add link to corresponding xmir2xmir test here as documentation when such tests arrive.
Such tests would describe xsl sense via example of input/output. -->
<xsl:output encoding="UTF-8" method="xml"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="program/objects/class">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
<xsl:if test="//meta[head='tests']">
<xsl:for-each select="class//class">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:for-each>
</xsl:if>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" id="remove-high-level-inner-classes" version="2.0">
<!-- Removes all high-level nesting classes inside the main class.
@todo #1249:90min Create xmir2xmir tests. This tests should be represented in yaml file and contain xsls,
input(xmir) and output(xmir) sections. Add link to corresponding xmir2xmir test here as documentation -->
<xsl:output encoding="UTF-8" method="xml"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="program/objects/class/class//class">
<xsl:if test="not(//meta[head='tests'])">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ SOFTWARE.
could be too long class names.
-->
<xsl:output encoding="UTF-8" method="xml"/>
<xsl:variable name="tests" select="exists(//meta[head='junit' or head='tests'])"/>
<xsl:variable name="tests" select="exists(//meta[head='tests'])"/>
<xsl:function name="eo:name-of" as="xs:string">
<xsl:param name="class" as="node()"/>
<xsl:variable name="ret">
Expand All @@ -39,6 +39,8 @@ SOFTWARE.
<xsl:text>ω</xsl:text>
<xsl:value-of select="$class/@ancestors"/>
<xsl:value-of select="substring-after($class/@name, concat($class/@parent, '$'))"/>
<xsl:text>-hash-</xsl:text>
<xsl:value-of select="generate-id($class)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$class/@name"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ SOFTWARE.
<xsl:template match="class/@name">
<xsl:attribute name="name">
<xsl:choose>
<xsl:when test="//meta[head='tests' or head='junit']">
<xsl:when test="//meta[head='tests']">
<xsl:value-of select="eo:name(.)"/>
</xsl:when>
<xsl:otherwise>
Expand All @@ -61,7 +61,7 @@ SOFTWARE.
<xsl:variable name="ourRef" select="parent::o/@ref"/>
<xsl:attribute name="{name()}">
<xsl:choose>
<xsl:when test="//meta[head='tests' or head='junit']">
<xsl:when test="//meta[head='tests']">
<xsl:choose>
<xsl:when test="//class[@name=$a and @line=$ourRef]">
<xsl:value-of select="eo:name($a)"/>
Expand All @@ -81,7 +81,7 @@ SOFTWARE.
<xsl:variable name="a" select="."/>
<xsl:attribute name="{name()}">
<xsl:choose>
<xsl:when test="//meta[head='tests' or head='junit']">
<xsl:when test="//meta[head='tests']">
<xsl:choose>
<xsl:when test="//class[@name=$a]">
<xsl:value-of select="eo:name($a)"/>
Expand All @@ -100,15 +100,15 @@ SOFTWARE.
<xsl:template match="class" mode="#all">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
<xsl:if test="//meta[head='tests' or head='junit']">
<xsl:if test="//meta[head='tests']">
<xsl:variable name="c" select="."/>
<xsl:apply-templates select="//class[@parent=$c/@name]" mode="copy"/>
</xsl:if>
</xsl:copy>
</xsl:template>
<xsl:template match="objects/class[@parent]" mode="#default">
<xsl:choose>
<xsl:when test="//meta[head='tests' or head='junit']">
<xsl:when test="//meta[head='tests']">
<!-- kill them -->
</xsl:when>
<xsl:otherwise>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void checksPacks(final String pack) throws IOException {
);
}
MatcherAssert.assertThat(
BinarizeParseTest.TO_ADD_MESSAGE,
"All yaml tests in packs/ should pass",
check.failures(),
Matchers.empty()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ xsls:
- /org/eolang/maven/pre/classes.xsl
- /org/eolang/parser/remove-noise.xsl
- /org/eolang/maven/pre/tests.xsl
- /org/eolang/maven/pre/align-test-classes.xsl
- /org/eolang/maven/pre/remove-high-level-inner-classes.xsl
- /org/eolang/maven/pre/rename-tests-inners.xsl
tests:
- /program/errors[count(*)=0]
- /program[count(//class)=5]
- /program/objects[count(class)=1]
- //class[@name='ω3t0$a0' and @parent='ω2c']
- //o[@base='ω2c' and @name='c']
- /program/objects/class[count(class)=4]
- /program[count(objects/class/class//class)=0]
- //class[starts-with(@name, 'ω3t0$a0-hash-') and starts-with(@parent, 'ω2c-hash-')]
- //o[starts-with(@base, 'ω2c-hash-') and @name='c']
eo: |
+tests
Expand Down
124 changes: 124 additions & 0 deletions eo-runtime/src/test/eo/org/eolang/runtime-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,127 @@
2
build 2 > @
9

# Nesting blah test.
[] > nesting-blah-test
blah0 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah0
blah1 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah1
blah2 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah2
blah3 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah3
blah4 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah4
blah5 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah5
blah6 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah6
blah7 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah7
blah8 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah8
blah9 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah9
blah10 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah10
blah11 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah11
blah12 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah12
blah13 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah13
blah14 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah14
blah15 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah15
blah16 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah16
blah17 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah17
blah18 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah18
blah19 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah19
blah20 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah20
blah21 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah21
blah22 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah22
blah23 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah23
blah24 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah24
blah25 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah25
blah26 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah26
blah27 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah27
blah28 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah28
blah29 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah29
blah30 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah30
blah31 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah31
blah32 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah32
blah33 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah33
blah34 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah34
blah35 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah35
blah36 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah36
blah37 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah37
blah38 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah38
blah39 > @
# This is the default 64+ symbols comment in front of named abstract object.
[] > blah39
true > @

2 comments on commit f26ee33

@0pdd
Copy link

@0pdd 0pdd commented on f26ee33 Jul 15, 2024

Choose a reason for hiding this comment

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

Puzzle 1249-130f8649 discovered in eo-maven-plugin/src/main/resources/org/eolang/maven/pre/align-test-classes.xsl) and submitted as #3266. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link

@0pdd 0pdd commented on f26ee33 Jul 15, 2024

Choose a reason for hiding this comment

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

Puzzle 1249-cbc24ee5 discovered in eo-maven-plugin/src/main/resources/org/eolang/maven/pre/remove-high-level-inner-classes.xsl) and submitted as #3267. 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.