Skip to content

Commit

Permalink
#127 documentation extended
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Dec 10, 2024
1 parent 4cd37b5 commit af8a986
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 65 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Broken Alias (First Part)

The first part of the `+alias` meta may only contain the name
of the object, not its FQN. For example, here is how it may look
in EO:

```

Check failure on line 7 in src/main/resources/org/eolang/motives/aliases/broken-alias-first.md

View workflow job for this annotation

GitHub Actions / markdown-lint

Fenced code blocks should have a language specified [Context: "```"]
+alias stdout org.eolang.io.stdout
# Basic object.
[] > foo
stdout
"Hello, world!\n"
```

Here, the `stdout` part of the `+alias` meta is the name of the

Check failure on line 16 in src/main/resources/org/eolang/motives/aliases/broken-alias-first.md

View workflow job for this annotation

GitHub Actions / markdown-lint

Trailing spaces [Expected: 0 or 2; Actual: 1]
object used later in the code. It will automatically be replaced
with `org.eolang.io.stdout`.

The error may also indicate incorrect usage of the `<meta>` element
in XMIR. The alias defined above must look like this, in XMIR:

```xml
<program>
<metas>
<meta>
<head>alias</head>
<tail>stdout org.eolang.io.stdout</tail>
<part>stdout</part>
<part>org.eolang.io.stdout</part>
</meta>
</metas>
</program>
```

Here, the `part` elements in the `meta` element must be used to define
separate parts of the `+alias` meta.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Broken Alias (Second Part)

The second part of the `+alias` meta may only contain FQN
(fully qualified name) of the object. For example, here is how it may look
in EO:

```

Check failure on line 7 in src/main/resources/org/eolang/motives/aliases/broken-alias-second.md

View workflow job for this annotation

GitHub Actions / markdown-lint

Fenced code blocks should have a language specified [Context: "```"]
+alias stdout org.eolang.io.stdout
# Basic object.
[] > foo
stdout
"Hello, world!\n"
```

Here, the `org.eolang.io.stdout` part of the `+alias` meta is the
FQN of the object later in the code referred to as `stdout`.
46 changes: 0 additions & 46 deletions src/main/resources/org/eolang/motives/aliases/broken-alias.md

This file was deleted.

24 changes: 5 additions & 19 deletions src/test/java/org/eolang/lints/misc/UnitTestIsNotVerbTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@
*/
package org.eolang.lints.misc;

import com.jcabi.xml.XML;
import com.yegor256.MayBeSlow;
import com.yegor256.WeAreOnline;
import java.io.IOException;
import org.cactoos.io.ResourceOf;
import org.eolang.lints.Lint;
import org.eolang.parser.EoSyntax;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

Expand All @@ -43,23 +39,13 @@
*/
final class UnitTestIsNotVerbTest {

/**
* Lint.
*/
private static Lint<XML> lint;

@BeforeAll
static void setUp() throws Exception {
UnitTestIsNotVerbTest.lint = new UnitTestIsNotVerb();
}

@Test
@ExtendWith(WeAreOnline.class)
@ExtendWith(MayBeSlow.class)
@Test
void catchesBadName() throws Exception {
MatcherAssert.assertThat(
"Defects size doesn't match with expected",
UnitTestIsNotVerbTest.lint.defects(
new UnitTestIsNotVerb().defects(
new EoSyntax(
new ResourceOf(
"org/eolang/lints/misc/test-object-is-not-verb-in-singular/bad-tests.eo"
Expand All @@ -70,13 +56,13 @@ void catchesBadName() throws Exception {
);
}

@Test
@ExtendWith(WeAreOnline.class)
@ExtendWith(MayBeSlow.class)
@Test
void allowsGoodNames() throws IOException {
void allowsGoodNames() throws Exception {
MatcherAssert.assertThat(
"Defects are not empty, but they shouldn't be",
UnitTestIsNotVerbTest.lint.defects(
new UnitTestIsNotVerb().defects(
new EoSyntax(
new ResourceOf(
"org/eolang/lints/misc/test-object-is-not-verb-in-singular/good-tests.eo"
Expand Down

0 comments on commit af8a986

Please sign in to comment.