Skip to content

Commit

Permalink
Merge branch 'master' into fix/#2737/reversed-bound-application
Browse files Browse the repository at this point in the history
  • Loading branch information
maxonfjvipon committed Dec 27, 2023
2 parents e7a0bd8 + da9e7dc commit f85195c
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ebnf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
cp "eo-parser/target/ebnf/org/eolang/parser/${p}.pdf" .
pdfcrop --margins '10 10 10 10' "${p}.pdf" "${p}-cropped.pdf"
pdf2svg "${p}-cropped.pdf" "${p}.svg"
convert -density 300 -quality 100 -colorspace RGB "${p}.svg" "${p}.png"
convert -verbose -density 300 -quality 100 -colorspace RGB "${p}.svg" "${p}.png"
mkdir -p gh-pages/ebnf
cp "${p}.png" gh-pages/ebnf
cp "${p}.svg" gh-pages/ebnf
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ All of them have something **we don't tolerate**:
* static/class methods or attributes ([why?](http://www.yegor256.com/2014/05/05/oop-alternative-to-utility-classes.html))
* classes ([why?](http://www.yegor256.com/2016/09/20/oop-without-classes.html))
* implementation inheritance ([why?](http://www.yegor256.com/2016/09/13/inheritance-is-procedural.html))
* mutability ([why?](http://www.yegor256.com/2014/06/09/objects-should-be-immutable.html))
* mutability ([why?](http://www.yegor256.com/2014/06/09/objects-should-be-immutable.html) and [why not?](https://www.yegor256.com/2016/09/07/gradients-of-immutability.html))
* NULL ([why?](http://www.yegor256.com/2014/05/13/why-null-is-bad.html))
* global scope ([why?](https://www.yegor256.com/2018/07/03/global-variables.html))
* type casting ([why?](http://www.yegor256.com/2015/04/02/class-casting-is-anti-pattern.html))
Expand Down
4 changes: 2 additions & 2 deletions eo-maven-plugin/src/main/java/org/eolang/maven/Place.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.nio.file.Path;
import org.eolang.maven.name.DelimitedName;
import org.eolang.maven.name.ObjectName;
import org.eolang.maven.util.JoinedUnderscore;

/**
* Make the place for the object.
Expand Down Expand Up @@ -67,8 +68,7 @@ public Path make(final Path dir, final String ext) {
out.append(this.name.title().replace(".", File.separator));
this.name.label().ifPresent(
version -> {
out.append('_');
out.append(version);
out.append(new JoinedUnderscore("", version).asString());
});
if (!ext.isEmpty()) {
out.append('.').append(ext);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016-2023 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.
*/
package org.eolang.maven.util;

import java.util.List;
import org.cactoos.Text;
import org.cactoos.list.ListOf;

/**
* Text joined with underscore.
*
* @since 0.34.1
*/
public final class JoinedUnderscore implements Text {

/**
* Strings to join.
*/
private final List<String> strings;

/**
* Ctor.
* @param strngs Strings to join
*/
public JoinedUnderscore(final String... strngs) {
this(new ListOf<>(strngs));
}

/**
* Ctor.
* @param strngs Strings to join
*/
public JoinedUnderscore(final List<String> strngs) {
this.strings = strngs;
}

@Override
public String asString() {
return String.join("_", this.strings);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.eolang.maven.log.Logs;
import org.eolang.maven.objectionary.ObjsDefault;
import org.eolang.maven.objectionary.OyRemote;
import org.eolang.maven.util.JoinedUnderscore;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
Expand All @@ -47,14 +48,6 @@
/**
* Test case for {@link AssembleMojo}.
*
* @since 0.1
* @todo #1602:30min Create new object that will join two strings with "_".
* {@link Place} object makes a path for versioned objects using "_" as
* delimiter between name and hash. Here to test stored files after
* {@link AssembleMojo} execution "joinedWithUnderscore" function was
* introduced. So there's a code duplication and an ugly design. Need to
* create a new object that will join two strings with underscore and use it
* here and in {@link Place}.
* @todo #1602:30min Make up how to get rid of excessive usage of
* {@code ParseMojo.DIR}, {@code ResolveMojo.DIR} and so on. It would be nice
* to replace them with corresponding classes, or something similar
Expand All @@ -68,6 +61,7 @@
* from older repositories are not parsed successfully because of the presence of varargs there.
* So we need to make 2-3 releases and then refactor the test with more fresh versions. Don't
* forget to remove the puzzle.
* @since 0.1
*/
@ExtendWith(WeAreOnline.class)
final class AssembleMojoTest {
Expand Down Expand Up @@ -157,8 +151,8 @@ void assemblesTogetherWithVersions(@TempDir final Path temp) throws Exception {
.execute(AssembleMojo.class)
.result();
final String stdout = "**/io/stdout";
final String fifth = AssembleMojoTest.joinedWithUnderscore(stdout, "17f8929.xmir");
final String sixth = AssembleMojoTest.joinedWithUnderscore(stdout, "9c93528.xmir");
final String fifth = new JoinedUnderscore(stdout, "17f8929.xmir").asString();
final String sixth = new JoinedUnderscore(stdout, "9c93528.xmir").asString();
final String path = "target/%s/org/eolang";
final String parse = String.format(path, ParseMojo.DIR);
final String optimize = String.format(path, OptimizeMojo.DIR);
Expand All @@ -167,7 +161,7 @@ void assemblesTogetherWithVersions(@TempDir final Path temp) throws Exception {
final String seq = "**/seq.xmir";
final String string = "**/string.xmir";
final String hash = String.join(".", master.value(), "eo");
final String[] jars = new String[] {
final String[] jars = {
"**/eo-runtime-0.28.5.jar",
"**/eo-runtime-0.28.6.jar",
};
Expand All @@ -194,10 +188,10 @@ void assemblesTogetherWithVersions(@TempDir final Path temp) throws Exception {
),
result.get(pull).toAbsolutePath(),
new ContainsFiles(
AssembleMojoTest.joinedWithUnderscore(stdout, "17f8929.eo"),
AssembleMojoTest.joinedWithUnderscore(stdout, "9c93528.eo"),
AssembleMojoTest.joinedWithUnderscore("**/seq", hash),
AssembleMojoTest.joinedWithUnderscore("**/string", hash)
new JoinedUnderscore(stdout, "17f8929.eo").asString(),
new JoinedUnderscore(stdout, "9c93528.eo").asString(),
new JoinedUnderscore("**/seq", hash).asString(),
new JoinedUnderscore("**/string", hash).asString()
)
);
MatcherAssert.assertThat(
Expand Down Expand Up @@ -272,8 +266,4 @@ void configuresChildParameters(@TempDir final Path temp) throws IOException {
)
);
}

private static String joinedWithUnderscore(final String first, final String second) {
return String.join("_", first, second);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.hamcrest.io.FileMatchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -112,7 +113,12 @@ void optimizesIfExpired(@TempDir final Path temp) throws Exception {
*
* @param temp Temporary test directory.
* @throws Exception if unexpected error happened.
* @todo #2422:60min This test is unstable for now.
* We should resolve issues with unstable failures and only
* then enable the test.
* Also, see this <a href="https://github.com/objectionary/eo/issues/2727">issue</a>.
*/
@Disabled
@Test
void getsAlreadyOptimizedResultsFromCache(@TempDir final Path temp) throws Exception {
final TextOf cached = new TextOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.hamcrest.io.FileMatchers;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.xembly.Directives;
Expand All @@ -44,7 +45,19 @@
* Test case for {@link org.eolang.maven.optimization.OptCached}.
* @since 0.28.12
*/
class OptCachedTest {
final class OptCachedTest {

/**
* Test case for XML program in cache.
*
* @param tmp Temp dir
* @throws IOException if I/O fails
* @todo #2422:60min returnsFromCacheIfXmlAlreadyInCache: this test is unstable.
* We should resolve issues with unstable failures and only
* then enable the test.
* Also, see this <a href="https://github.com/objectionary/eo/issues/2727">issue</a>.
*/
@Disabled
@Test
void returnsFromCacheIfXmlAlreadyInCache(@TempDir final Path tmp) throws IOException {
final XML program = OptCachedTest.program(ZonedDateTime.now());
Expand Down Expand Up @@ -78,7 +91,7 @@ void optimizesIfXmlIsAbsentInCache(@TempDir final Path tmp) {
}

@Test
void optimizesBecauseChacheIsExpired(@TempDir final Path tmp) throws IOException {
void optimizesBecauseCacheIsExpired(@TempDir final Path tmp) throws IOException {
final XML outdated = OptCachedTest.program(ZonedDateTime.now().minusMinutes(1));
final XML updated = OptCachedTest.program(ZonedDateTime.now());
OptCachedTest.save(tmp, outdated);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016-2023 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.
*/
package org.eolang.maven.util;

import org.hamcrest.MatcherAssert;
import org.hamcrest.core.IsEqual;
import org.junit.jupiter.api.Test;

/**
* Test case for {@link JoinedUnderscore}.
*
* @since 0.34.1
*/
final class JoinedUnderscoreTest {

@Test
void readsJoinedString() {
MatcherAssert.assertThat(
"Joined string does not match with expected format",
new JoinedUnderscore("first", "second").asString(),
new IsEqual<>("first_second")
);
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ SOFTWARE.
<dependency>
<groupId>com.yegor256</groupId>
<artifactId>jping</artifactId>
<version>0.0.1</version>
<version>0.0.3</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down

1 comment on commit f85195c

@0pdd
Copy link

@0pdd 0pdd commented on f85195c Dec 28, 2023

Choose a reason for hiding this comment

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

Puzzle 2729-a3e8db24 disappeared from eo-parser/src/test/resources/org/eolang/parser/packs/syntax/binded-reversed-application.yaml), that's why I closed #2737. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

Please sign in to comment.