From 151fd4846fa9928c8940b9736fe2433afba663c3 Mon Sep 17 00:00:00 2001 From: VasilevNStas Date: Mon, 10 Aug 2026 17:07:34 +0300 Subject: [PATCH] feat(#553): add test-word lint --- .../org/eolang/lints/tests/test-word.xsl | 38 +++++++++++++++++++ .../org/eolang/motives/tests/test-word.md | 26 +++++++++++++ .../test-word/allows-clean-test-names.yaml | 16 ++++++++ .../allows-test-word-in-regular-object.yaml | 14 +++++++ .../catches-test-in-nested-object.yaml | 17 +++++++++ .../catches-test-in-test-object.yaml | 17 +++++++++ .../catches-test-word-in-helper.yaml | 17 +++++++++ 7 files changed, 145 insertions(+) create mode 100644 src/main/resources/org/eolang/lints/tests/test-word.xsl create mode 100644 src/main/resources/org/eolang/motives/tests/test-word.md create mode 100644 src/test/resources/org/eolang/lints/packs/single/test-word/allows-clean-test-names.yaml create mode 100644 src/test/resources/org/eolang/lints/packs/single/test-word/allows-test-word-in-regular-object.yaml create mode 100644 src/test/resources/org/eolang/lints/packs/single/test-word/catches-test-in-nested-object.yaml create mode 100644 src/test/resources/org/eolang/lints/packs/single/test-word/catches-test-in-test-object.yaml create mode 100644 src/test/resources/org/eolang/lints/packs/single/test-word/catches-test-word-in-helper.yaml diff --git a/src/main/resources/org/eolang/lints/tests/test-word.xsl b/src/main/resources/org/eolang/lints/tests/test-word.xsl new file mode 100644 index 000000000..80dd521d1 --- /dev/null +++ b/src/main/resources/org/eolang/lints/tests/test-word.xsl @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + warning + + The name of the object + + must not contain the word 'test' + + + + + + diff --git a/src/main/resources/org/eolang/motives/tests/test-word.md b/src/main/resources/org/eolang/motives/tests/test-word.md new file mode 100644 index 000000000..b32615a0c --- /dev/null +++ b/src/main/resources/org/eolang/motives/tests/test-word.md @@ -0,0 +1,26 @@ +# Test word + +Names of objects in test files must not contain the word 'test'. If an object +is a unit test, or a helper inside a unit test, or lives in a file whose top +object name ends with `-tests`, its name should describe the behavior it +verifies instead of repeating the word 'test'. + +Incorrect: + +```eo +# Tests for foo. +[] > foo-tests + # Test. + [] +> can-test-add + 42 > @ +``` + +Correct: + +```eo +# Tests for foo. +[] > foo-tests + # Test. + [] +> can-add-two-and-two + 42 > @ +``` diff --git a/src/test/resources/org/eolang/lints/packs/single/test-word/allows-clean-test-names.yaml b/src/test/resources/org/eolang/lints/packs/single/test-word/allows-clean-test-names.yaml new file mode 100644 index 000000000..f49e87597 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/test-word/allows-clean-test-names.yaml @@ -0,0 +1,16 @@ +# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com +# SPDX-License-Identifier: MIT +--- +sheets: + - /org/eolang/lints/tests/test-word.xsl +asserts: + - /defects[count(defect[@severity='warning'])=0] +ignore-schema: true +document: | + + + + + + + diff --git a/src/test/resources/org/eolang/lints/packs/single/test-word/allows-test-word-in-regular-object.yaml b/src/test/resources/org/eolang/lints/packs/single/test-word/allows-test-word-in-regular-object.yaml new file mode 100644 index 000000000..66a182bc1 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/test-word/allows-test-word-in-regular-object.yaml @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com +# SPDX-License-Identifier: MIT +--- +sheets: + - /org/eolang/lints/tests/test-word.xsl +asserts: + - /defects[count(defect[@severity='warning'])=0] +ignore-schema: true +document: | + + + + + diff --git a/src/test/resources/org/eolang/lints/packs/single/test-word/catches-test-in-nested-object.yaml b/src/test/resources/org/eolang/lints/packs/single/test-word/catches-test-in-nested-object.yaml new file mode 100644 index 000000000..320ad5127 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/test-word/catches-test-in-nested-object.yaml @@ -0,0 +1,17 @@ +# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com +# SPDX-License-Identifier: MIT +--- +sheets: + - /org/eolang/lints/tests/test-word.xsl +asserts: + - /defects[count(defect[@severity='warning'])=1] + - /defects/defect[@line='5'] +ignore-schema: true +document: | + + + + + + + diff --git a/src/test/resources/org/eolang/lints/packs/single/test-word/catches-test-in-test-object.yaml b/src/test/resources/org/eolang/lints/packs/single/test-word/catches-test-in-test-object.yaml new file mode 100644 index 000000000..30947499e --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/test-word/catches-test-in-test-object.yaml @@ -0,0 +1,17 @@ +# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com +# SPDX-License-Identifier: MIT +--- +sheets: + - /org/eolang/lints/tests/test-word.xsl +asserts: + - /defects[count(defect[@severity='warning'])=1] + - /defects/defect[@line='3'] +ignore-schema: true +document: | + + + + + + + diff --git a/src/test/resources/org/eolang/lints/packs/single/test-word/catches-test-word-in-helper.yaml b/src/test/resources/org/eolang/lints/packs/single/test-word/catches-test-word-in-helper.yaml new file mode 100644 index 000000000..e3c84dc46 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/test-word/catches-test-word-in-helper.yaml @@ -0,0 +1,17 @@ +# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com +# SPDX-License-Identifier: MIT +--- +sheets: + - /org/eolang/lints/tests/test-word.xsl +asserts: + - /defects[count(defect[@severity='warning'])=1] + - /defects/defect[@line='5'] +ignore-schema: true +document: | + + + + + + +