Skip to content

Commit

Permalink
objectionary#1869 introduce +xunit
Browse files Browse the repository at this point in the history
  • Loading branch information
mximp committed Apr 19, 2023
1 parent e117f1a commit 79e7909
Show file tree
Hide file tree
Showing 35 changed files with 50 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public final class TranspileMojo extends SafeMojo {
new ParsingTrain().empty().with(new StUnhex()),
"/org/eolang/maven/pre/classes.xsl",
"/org/eolang/maven/pre/package.xsl",
"/org/eolang/maven/pre/junit.xsl",
"/org/eolang/maven/pre/rename-junit-inners.xsl",
"/org/eolang/maven/pre/xunit.xsl",
"/org/eolang/maven/pre/rename-xunit-inners.xsl",
"/org/eolang/maven/pre/attrs.xsl",
"/org/eolang/maven/pre/varargs.xsl",
"/org/eolang/maven/pre/data.xsl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ 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="rename-junit-inners" 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="rename-xunit-inners" version="2.0">
<!--
This stylesheet renames inner classes, which were placed
into junit objects by junit.xsl. Without this cleaning there
into xunit objects by xunit.xsl. Without this cleaning there
could be too long class names.
-->
<xsl:output encoding="UTF-8" method="xml"/>
<xsl:variable name="junit" select="exists(//meta[head='junit'])"/>
<xsl:variable name="xunit" select="exists(//meta[head='junit' or head='xunit'])"/>
<xsl:function name="eo:name-of" as="xs:string">
<xsl:param name="class" as="node()"/>
<xsl:variable name="ret">
<xsl:choose>
<xsl:when test="$junit and $class/@parent">
<xsl:when test="$xunit and $class/@parent">
<xsl:variable name="parent" select="$class/@parent"/>
<xsl:text>ω</xsl:text>
<xsl:value-of select="$class/@ancestors"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ SOFTWARE.
<xsl:apply-templates select="//meta[head='package']" mode="head"/>
<xsl:text>import org.eolang.*;</xsl:text>
<xsl:value-of select="eo:eol(0)"/>
<xsl:apply-templates select="//meta[head='junit']" mode="head"/>
<xsl:apply-templates select="//meta[head='junit' or head='xunit']" mode="head"/>
<xsl:apply-templates select="." mode="body"/>
</xsl:element>
</xsl:copy>
Expand Down Expand Up @@ -160,7 +160,7 @@ SOFTWARE.
<xsl:value-of select="eo:eol(0)"/>
<xsl:apply-templates select="." mode="ctors"/>
<xsl:apply-templates select="." mode="equals-and-hashCode"/>
<xsl:if test="//meta[head='junit'] and not(@parent)">
<xsl:if test="//meta[head='junit' or head='xunit'] and not(@parent)">
<xsl:apply-templates select="." mode="tests"/>
</xsl:if>
<xsl:apply-templates select="class" mode="body"/>
Expand All @@ -177,7 +177,7 @@ SOFTWARE.
<xsl:template match="class" mode="ctors">
<xsl:value-of select="eo:tabs(1)"/>
<xsl:choose>
<xsl:when test="//meta[head='junit'] and not(@parent)">
<xsl:when test="//meta[head='junit' or head='xunit'] and not(@parent)">
<xsl:text>public </xsl:text>
<xsl:value-of select="eo:class-name(@name, eo:suffix(@line, @pos))"/>
<xsl:text>() {</xsl:text>
Expand Down Expand Up @@ -646,7 +646,7 @@ SOFTWARE.
<xsl:value-of select="eo:eol(0)"/>
<xsl:value-of select="eo:eol(0)"/>
</xsl:template>
<xsl:template match="meta[head='junit']" mode="head">
<xsl:template match="meta[head='junit' or head='xunit']" mode="head">
<xsl:text>import org.junit.jupiter.api.Assertions;</xsl:text>
<xsl:value-of select="eo:eol(0)"/>
<xsl:text>import org.junit.jupiter.api.Test;</xsl:text>
Expand Down
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="junit" 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="xunit" version="2.0">
<!--
This stylesheet will take outer objects and put them into
classes that are unit tests.
Expand All @@ -47,7 +47,7 @@ SOFTWARE.
<xsl:template match="class/@name">
<xsl:attribute name="name">
<xsl:choose>
<xsl:when test="//meta[head='junit']">
<xsl:when test="//meta[head='xunit' or head='junit']">
<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='junit']">
<xsl:when test="//meta[head='xunit' or head='junit']">
<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='junit']">
<xsl:when test="//meta[head='xunit' or head='junit']">
<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='junit']">
<xsl:if test="//meta[head='xunit' or head='junit']">
<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='junit']">
<xsl:when test="//meta[head='xunit' or head='junit']">
<!-- kill them -->
</xsl:when>
<xsl:otherwise>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void failsOnWarning(@TempDir final Path temp) throws Exception {
final FakeMaven maven = new FakeMaven(temp)
.withProgram(
"+architect [email protected]",
"+junit",
"+xunit",
"+package org.eolang.examples\n",
"[] > main",
" [] > @",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
+architect [email protected]
+package org.eolang.examples
+alias org.eolang.io.stdout
+junit
+xunit

3.14 > pi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ xsls:
- /org/eolang/parser/optimize/abstracts-float-up.xsl
- /org/eolang/maven/pre/classes.xsl
- /org/eolang/parser/remove-noise.xsl
- /org/eolang/maven/pre/junit.xsl
- /org/eolang/maven/pre/rename-junit-inners.xsl
- /org/eolang/maven/pre/xunit.xsl
- /org/eolang/maven/pre/rename-xunit-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']
eo: |
+junit
+xunit
[] > a
[] > b
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tests:
- /program/errors[count(*)=0]
- //java[contains(text(), '@Test')]
eo: |
+junit
+xunit
[] > works
1.eq 1 > @
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

+architect [email protected]
+package org.eolang.examples
+junit
+xunit

[] > main
[] < @
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# program, to be ignored.

+architect [email protected]
+junit
+xunit
+package org.eolang.examples

[] > main
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ SOFTWARE.
<xsl:template match="/program/errors">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
<xsl:for-each select="/program[//meta[head='junit']]/objects/o[@abstract][count(o[@name='@'])=0]">
<xsl:for-each select="/program[//meta[head='junit' or head='xunit']]/objects/o[@abstract][count(o[@name='@'])=0]">
<xsl:element name="error">
<xsl:attribute name="check">
<xsl:text>unit-test-without-phi</xsl:text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ tests:
- /program/errors/error[@check='unit-test-without-phi']
- //o[@name='test']
eo: |
+junit
+xunit
[] > test
TRUE
2 changes: 1 addition & 1 deletion eo-runtime/src/test/eo/org/eolang/array-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
+alias org.eolang.hamcrest.assert-that
+architect [email protected]
+home https://github.com/objectionary/eo
+junit
+xunit
+package org.eolang
+version 0.0.0

Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/test/eo/org/eolang/as-phi-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
+alias org.eolang.io.stdout
+architect [email protected]
+home https://github.com/objectionary/eo
+junit
+xunit
+package org.eolang
+version 0.0.0

Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/test/eo/org/eolang/bool-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
+alias org.eolang.txt.sprintf
+architect [email protected]
+home https://github.com/objectionary/eo
+junit
+xunit
+package org.eolang
+version 0.0.0

Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/test/eo/org/eolang/bytes-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
+alias org.eolang.hamcrest.assert-that
+architect [email protected]
+home https://github.com/objectionary/eo
+junit
+xunit
+package org.eolang
+version 0.0.0

Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/test/eo/org/eolang/cage-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
+alias org.eolang.hamcrest.assert-that
+architect [email protected]
+home https://github.com/objectionary/eo
+junit
+xunit
+package org.eolang
+version 0.0.0

Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/test/eo/org/eolang/float-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
+architect [email protected]
+home https://github.com/objectionary/eo
+package org.eolang
+junit
+xunit
+version 0.0.0

[] > less-true
Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/test/eo/org/eolang/goto-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
+alias org.eolang.io.stdout
+architect [email protected]
+home https://github.com/objectionary/eo
+junit
+xunit
+package org.eolang
+version 0.0.0

Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/test/eo/org/eolang/heap-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
+alias org.eolang.heap
+architect [email protected]
+home https://github.com/objectionary/eo
+junit
+xunit
+package org.eolang
+version 0.0.0

Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/test/eo/org/eolang/int-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
+alias org.eolang.txt.sprintf
+architect [email protected]
+home https://github.com/objectionary/eo
+junit
+xunit
+package org.eolang
+version 0.0.0

Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/test/eo/org/eolang/io/stdout-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
+alias stdout org.eolang.io.stdout
+architect [email protected]
+home https://github.com/objectionary/eo
+junit
+xunit
+package org.eolang.io
+version 0.0.0

Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/test/eo/org/eolang/memory-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
+alias org.eolang.txt.sprintf
+architect [email protected]
+home https://github.com/objectionary/eo
+junit
+xunit
+package org.eolang
+version 0.0.0

Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/test/eo/org/eolang/nan-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
+architect [email protected]
+home https://github.com/objectionary/eo
+package org.eolang
+junit
+xunit
+version 0.0.0

[] > nan-not-eq-number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
+architect [email protected]
+home https://github.com/objectionary/eo
+package org.eolang
+junit
+xunit
+version 0.0.0

# Equal to
Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/test/eo/org/eolang/nop-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
+alias org.eolang.nop
+architect [email protected]
+home https://github.com/objectionary/eo
+junit
+xunit
+package org.eolang
+version 0.0.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
+architect [email protected]
+home https://github.com/objectionary/eo
+package org.eolang
+junit
+xunit
+version 0.0.0

# Equal to
Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/test/eo/org/eolang/ram-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
+alias org.eolang.ram
+architect [email protected]
+home https://github.com/objectionary/eo
+junit
+xunit
+package org.eolang
+version 0.0.0

Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/test/eo/org/eolang/runtime-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
+alias org.eolang.txt.sprintf
+architect [email protected]
+home https://github.com/objectionary/eo
+junit
+xunit
+package org.eolang
+version 0.0.0

Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/test/eo/org/eolang/rust-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

+alias org.eolang.hamcrest.assert-that
+home https://github.com/objectionary/eo
+junit
+xunit
+package org.eolang
+version 0.0.0

Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/test/eo/org/eolang/seq-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
+alias org.eolang.hamcrest.assert-that
+architect [email protected]
+home https://github.com/objectionary/eo
+junit
+xunit
+package org.eolang
+version 0.0.0

Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/test/eo/org/eolang/string-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
+alias org.eolang.hamcrest.assert-that
+architect [email protected]
+home https://github.com/objectionary/eo
+junit
+xunit
+package org.eolang
+version 0.0.0

Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/test/eo/org/eolang/switch-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
+alias org.eolang.hamcrest.assert-that
+architect [email protected]
+home https://github.com/objectionary/eo
+junit
+xunit
+package org.eolang
+version 0.0.0

Expand Down
Loading

0 comments on commit 79e7909

Please sign in to comment.