Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/main/resources/org/eolang/lints/tests/wrong-test-order.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
* SPDX-License-Identifier: MIT
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:eo="https://www.eolang.org" id="wrong-test-order" version="2.0">
<xsl:import href="/org/eolang/parser/_funcs.xsl"/>
<xsl:import href="/org/eolang/funcs/lineno.xsl"/>
<xsl:import href="/org/eolang/funcs/escape.xsl"/>
<xsl:import href="/org/eolang/funcs/defect-context.xsl"/>
<xsl:output encoding="UTF-8" method="xml"/>
<xsl:template match="/">
<defects>
<xsl:for-each select="/object//o[starts-with(@name, '+')]">
<xsl:variable name="next" select="following-sibling::*[1]"/>
<xsl:if test="$next[self::o] and not(starts-with($next/@name, '+'))">
<xsl:element name="defect">
<xsl:variable name="line" select="eo:lineno(@line)"/>
<xsl:attribute name="line">
<xsl:value-of select="$line"/>
</xsl:attribute>
<xsl:if test="$line = '0'">
<xsl:attribute name="context">
<xsl:value-of select="eo:defect-context(.)"/>
</xsl:attribute>
</xsl:if>
<xsl:attribute name="severity">
<xsl:text>warning</xsl:text>
</xsl:attribute>
<xsl:text>The unit test wrongly ordered: </xsl:text>
<xsl:value-of select="eo:escape(eo:escape-plus(@name))"/>
</xsl:element>
</xsl:if>
</xsl:for-each>
</defects>
</xsl:template>
</xsl:stylesheet>
19 changes: 19 additions & 0 deletions src/main/resources/org/eolang/motives/tests/wrong-test-order.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Wrong test order

Unit tests must be located after live objects:

Incorrect:

```eo
[] > foo
[] +> runs-something
[] > bar
```

Correct:

```eo
[] > foo
[] > bar
[] +> runs-something
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
# SPDX-License-Identifier: MIT
---
sheets:
- /org/eolang/lints/tests/wrong-test-order.xsl
asserts:
- /defects[count(defect[@severity='warning'])=1]
- /defects/defect[@line='3']
input: |
[] > foo
[] > bar
[] +> runs-program
[] > boom
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
# SPDX-License-Identifier: MIT
---
sheets:
- /org/eolang/lints/tests/wrong-test-order.xsl
asserts:
- /defects[count(defect[@severity='warning'])=0]
input: |
[] > foo
[] > a
[] > x
[] > y
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
# SPDX-License-Identifier: MIT
---
sheets:
- /org/eolang/lints/tests/wrong-test-order.xsl
asserts:
- /defects[count(defect[@severity='warning'])=0]
input: |
[] > main
[] +> testing
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
# SPDX-License-Identifier: MIT
---
sheets:
- /org/eolang/lints/tests/wrong-test-order.xsl
asserts:
- /defects[count(defect[@severity='warning'])=0]
input: |
[] > at
[] +> test
[] +> another-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
# SPDX-License-Identifier: MIT
---
sheets:
- /org/eolang/lints/tests/wrong-test-order.xsl
asserts:
- /defects[count(defect[@severity='warning'])=1]
- /defects/defect[@line='2']
input: |
[] > app
[] +> runs
[] > x
[] +> something
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
# SPDX-License-Identifier: MIT
---
sheets:
- /org/eolang/lints/tests/wrong-test-order.xsl
asserts:
- /defects[count(defect[@severity='warning'])=1]
- /defects/defect[@line='2']
input: |
[] > x
[] +> runs-x
[] > bool
[] > t
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
# SPDX-License-Identifier: MIT
---
sheets:
- /org/eolang/lints/tests/wrong-test-order.xsl
asserts:
- /defects[count(defect[@severity='warning'])=0]
input: |
[] > main
[] > bar
[] > boom
[] > test
Loading