From 5042584e0a8a8a67cd3797d64f1826be7fbcac62 Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Tue, 16 Jan 2024 18:24:29 +0300 Subject: [PATCH 1/4] #2723 implement tuppled-stdout object and tests for it --- .../main/eo/org/eolang/io/tupled-stdout.eo | 52 ++++++++++++++++++ .../eo/org/eolang/io/tupled-stdout-test.eo | 54 +++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 eo-runtime/src/main/eo/org/eolang/io/tupled-stdout.eo create mode 100644 eo-runtime/src/test/eo/org/eolang/io/tupled-stdout-test.eo diff --git a/eo-runtime/src/main/eo/org/eolang/io/tupled-stdout.eo b/eo-runtime/src/main/eo/org/eolang/io/tupled-stdout.eo new file mode 100644 index 0000000000..d70d5c0e87 --- /dev/null +++ b/eo-runtime/src/main/eo/org/eolang/io/tupled-stdout.eo @@ -0,0 +1,52 @@ +# The MIT License (MIT) +# +# 2016-2022 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. + ++alias org.eolang.io.stdout ++architect yegor256@gmail.com ++home https://github.com/objectionary/eo ++package org.eolang.io ++rt jvm org.eolang:eo-runtime:0.0.0 ++version 0.0.0 + +# An object for testing entire applications that accepts arguments in the form of a tuple. +[args] > tupled-stdout + memory 0 > iter + args.length.minus 1 > max + if. > @ + max.lt 0 + error "tuple of arguments must contain at least one element" + if. + max.eq 0 + stdout + args.at + 0 + while. + iter.as-int.lt max + [i] + seq > @ + * + stdout + args.at + i + iter.write + iter.as-int.plus 1 + TRUE diff --git a/eo-runtime/src/test/eo/org/eolang/io/tupled-stdout-test.eo b/eo-runtime/src/test/eo/org/eolang/io/tupled-stdout-test.eo new file mode 100644 index 0000000000..d6ab02a0f3 --- /dev/null +++ b/eo-runtime/src/test/eo/org/eolang/io/tupled-stdout-test.eo @@ -0,0 +1,54 @@ +# 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. + ++alias org.eolang.io.tupled-stdout ++architect yegor256@gmail.com ++home https://github.com/objectionary/eo ++tests ++package org.eolang.io ++version 0.0.0 + +[] > tupled-stdout-single + tupled-stdout > @ + * + "Hello, world! Single tupled.\n" + +[] > tupled-stdout-several + tupled-stdout > @ + * + "Hello" + ", " + "world" + "! " + "Several " + "tupled.\n" + +[] > tupled-stdout-empty + eq. > @ + try + [] + tupled-stdout > @ + * + [e] + e > @ + nop + "tuple of arguments must contain at least one element" From 5da176c79ad3dfb1f237dcdd65805210c76260c7 Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Tue, 16 Jan 2024 18:38:04 +0300 Subject: [PATCH 2/4] #2723 enable tests from MainTest --- eo-runtime/src/test/java/org/eolang/MainTest.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/eo-runtime/src/test/java/org/eolang/MainTest.java b/eo-runtime/src/test/java/org/eolang/MainTest.java index c276f23b67..0a7e0083bb 100644 --- a/eo-runtime/src/test/java/org/eolang/MainTest.java +++ b/eo-runtime/src/test/java/org/eolang/MainTest.java @@ -69,19 +69,17 @@ void printsHelp() { } @Test - @Disabled void deliversCleanOutput() { MatcherAssert.assertThat( - MainTest.exec("org.eolang.io.stdout", "Hello!"), + MainTest.exec("org.eolang.io.tupled-stdout", "Hello!"), Matchers.equalTo(String.format("Hello!%n---%n%s%n", Arrays.toString(new byte[]{0x01}))) ); } @Test - @Disabled void executesJvmFullRun() { MatcherAssert.assertThat( - MainTest.exec("--verbose", "org.eolang.io.stdout", "Hello, dude!"), + MainTest.exec("--verbose", "org.eolang.io.tupled-stdout", "Hello, dude!"), Matchers.allOf( Matchers.containsString("EOLANG"), Matchers.containsString("Hello, "), From 6dba02216de0fece87e2be274d0307646ed1c5da Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Tue, 16 Jan 2024 18:38:40 +0300 Subject: [PATCH 3/4] #2723 remove todo --- eo-runtime/src/test/java/org/eolang/MainTest.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/eo-runtime/src/test/java/org/eolang/MainTest.java b/eo-runtime/src/test/java/org/eolang/MainTest.java index 0a7e0083bb..bc2b407a25 100644 --- a/eo-runtime/src/test/java/org/eolang/MainTest.java +++ b/eo-runtime/src/test/java/org/eolang/MainTest.java @@ -40,12 +40,6 @@ * Test case for {@link Main}. * * @since 0.1 - * @todo #2718:30min Enable the tests. Tests {@link MainTest#deliversCleanOutput()} and - * {@link MainTest#executesJvmFullRun()} were disabled because they execute "org.eolang.io.stdout" - * object that accepts "string". But arguments after "org.eolang.io.stdout" are stored into "tuple" - * and are being passed as "tuple" object. And here we get the situation where - * "stdout" accepts "tuple" and fails. We need to enable the test by finding object that accepts - * "tuple" as the first argument, or make a custom one. */ final class MainTest { From 70dd771cdbf3a3d4d3d53bbb784e3792e0f7324b Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Wed, 17 Jan 2024 14:16:52 +0300 Subject: [PATCH 4/4] #2723 moved tupled-stdout.eo to tests --- eo-runtime/src/{main => test}/eo/org/eolang/io/tupled-stdout.eo | 1 - 1 file changed, 1 deletion(-) rename eo-runtime/src/{main => test}/eo/org/eolang/io/tupled-stdout.eo (98%) diff --git a/eo-runtime/src/main/eo/org/eolang/io/tupled-stdout.eo b/eo-runtime/src/test/eo/org/eolang/io/tupled-stdout.eo similarity index 98% rename from eo-runtime/src/main/eo/org/eolang/io/tupled-stdout.eo rename to eo-runtime/src/test/eo/org/eolang/io/tupled-stdout.eo index d70d5c0e87..befc394a7c 100644 --- a/eo-runtime/src/main/eo/org/eolang/io/tupled-stdout.eo +++ b/eo-runtime/src/test/eo/org/eolang/io/tupled-stdout.eo @@ -24,7 +24,6 @@ +architect yegor256@gmail.com +home https://github.com/objectionary/eo +package org.eolang.io -+rt jvm org.eolang:eo-runtime:0.0.0 +version 0.0.0 # An object for testing entire applications that accepts arguments in the form of a tuple.