From 9992db0bffe369380350d20d538dd53e1973b0c9 Mon Sep 17 00:00:00 2001 From: unsigable Date: Mon, 16 Sep 2024 16:48:42 +0600 Subject: [PATCH 01/11] [#460] test and add output example for 22nd lesson only --- modules/30-variables/19-naming-style/ru/EXERCISE.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/30-variables/19-naming-style/ru/EXERCISE.md b/modules/30-variables/19-naming-style/ru/EXERCISE.md index 1ba3540..4959e11 100644 --- a/modules/30-variables/19-naming-style/ru/EXERCISE.md +++ b/modules/30-variables/19-naming-style/ru/EXERCISE.md @@ -1,4 +1,8 @@ Создайте две переменные с именами «первое число» и «второе число» на английском языке, используя lowerCamelCase. Запишите в первую переменную число `11`, во вторую — `-100`. Выведите на экран произведение чисел, записанных в получившихся переменных. +
+-1100
+
+ Код будет работать с любыми названиями, а наша система всегда проверяет только результат на экране, поэтому выполнение этого задания — под вашу ответственность. From d808b43e2cf850b26a69fb51c326dd1cb1be2753 Mon Sep 17 00:00:00 2001 From: unsigable Date: Mon, 16 Sep 2024 19:47:44 +0600 Subject: [PATCH 02/11] fixing 22nd java lesson output --- modules/30-variables/19-naming-style/Test.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/30-variables/19-naming-style/Test.java b/modules/30-variables/19-naming-style/Test.java index 28fcd6b..0eff2c1 100644 --- a/modules/30-variables/19-naming-style/Test.java +++ b/modules/30-variables/19-naming-style/Test.java @@ -7,8 +7,6 @@ class Test { public static void main(String[] args) { final var expected = "-1100"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +14,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } From 7c0869420eff01f4d25d561c6185d44811914411 Mon Sep 17 00:00:00 2001 From: unsigable Date: Sun, 22 Sep 2024 19:03:02 +0600 Subject: [PATCH 03/11] [#278] fixing output 1,4,5 lessons --- modules/10-basics/10-hello-world/Test.java | 11 +++++++---- modules/10-basics/40-testing/Test.java | 8 +++++--- modules/10-basics/50-syntax-error/Test.java | 7 +++++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/modules/10-basics/10-hello-world/Test.java b/modules/10-basics/10-hello-world/Test.java index bfc97be..0d23c54 100644 --- a/modules/10-basics/10-hello-world/Test.java +++ b/modules/10-basics/10-hello-world/Test.java @@ -1,14 +1,14 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; -import org.assertj.core.api.Assertions; +import static org.assertj.core.api.Assertions.assertThat; class Test { public static void main(final String[] args) { final var expected = "Hello, World!"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(final String[] args) { final var actual = out.toString().trim(); - Assertions.assertThat(actual).isEqualTo(expected); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/10-basics/40-testing/Test.java b/modules/10-basics/40-testing/Test.java index 192ea26..a2eff62 100644 --- a/modules/10-basics/40-testing/Test.java +++ b/modules/10-basics/40-testing/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -8,8 +10,6 @@ class Test { public static void main(String[] args) { final var expected = "420262531"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -17,8 +17,10 @@ public static void main(String[] args) { final var actual = out.toString().trim(); - assertThat(actual).isEqualTo(expected); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/10-basics/50-syntax-error/Test.java b/modules/10-basics/50-syntax-error/Test.java index adfbe03..edcf84c 100644 --- a/modules/10-basics/50-syntax-error/Test.java +++ b/modules/10-basics/50-syntax-error/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(final String[] args) { final var expected = "What Is Dead May Never Die"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(final String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } From 51f9d314e7f1bf06adf303cd59035e6187dd7381 Mon Sep 17 00:00:00 2001 From: unsigable Date: Sun, 22 Sep 2024 19:30:37 +0600 Subject: [PATCH 04/11] [#278] fixing output 6,7,9,10,11,12 lessons --- modules/20-arithmetics/10-basics/Test.java | 7 +++++-- modules/20-arithmetics/20-operators/Test.java | 8 +++++--- modules/20-arithmetics/40-composition/Test.java | 7 +++++-- modules/20-arithmetics/50-priority/Test.java | 7 +++++-- modules/20-arithmetics/60-float/Test.java | 7 +++++-- modules/20-arithmetics/80-linting/Test.java | 7 +++++-- 6 files changed, 30 insertions(+), 13 deletions(-) diff --git a/modules/20-arithmetics/10-basics/Test.java b/modules/20-arithmetics/10-basics/Test.java index 4b9f24a..57b6077 100644 --- a/modules/20-arithmetics/10-basics/Test.java +++ b/modules/20-arithmetics/10-basics/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "9"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/20-arithmetics/20-operators/Test.java b/modules/20-arithmetics/20-operators/Test.java index 536cb22..00e23f8 100644 --- a/modules/20-arithmetics/20-operators/Test.java +++ b/modules/20-arithmetics/20-operators/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -8,8 +10,6 @@ class Test { public static void main(String[] args) { final var expected = "87"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -17,8 +17,10 @@ public static void main(String[] args) { final var actual = out.toString().trim(); - assertThat(actual).isEqualTo(expected); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/20-arithmetics/40-composition/Test.java b/modules/20-arithmetics/40-composition/Test.java index a886ea2..2f5d7e1 100644 --- a/modules/20-arithmetics/40-composition/Test.java +++ b/modules/20-arithmetics/40-composition/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "10"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/20-arithmetics/50-priority/Test.java b/modules/20-arithmetics/50-priority/Test.java index f8bc3cf..5fafc04 100644 --- a/modules/20-arithmetics/50-priority/Test.java +++ b/modules/20-arithmetics/50-priority/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "49"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/20-arithmetics/60-float/Test.java b/modules/20-arithmetics/60-float/Test.java index fee6cab..33a18ae 100644 --- a/modules/20-arithmetics/60-float/Test.java +++ b/modules/20-arithmetics/60-float/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "0.0858"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/20-arithmetics/80-linting/Test.java b/modules/20-arithmetics/80-linting/Test.java index 0ba95cf..6848de0 100644 --- a/modules/20-arithmetics/80-linting/Test.java +++ b/modules/20-arithmetics/80-linting/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "-14"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } From 6b23d7460c124571a281eefed048f8d7171e4d5c Mon Sep 17 00:00:00 2001 From: unsigable Date: Sun, 22 Sep 2024 19:42:26 +0600 Subject: [PATCH 05/11] [#278] fixing output 13,15 lessons --- modules/25-strings/10-quotes/Test.java | 7 +++++-- modules/25-strings/20-strings-concatenation/Test.java | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/25-strings/10-quotes/Test.java b/modules/25-strings/10-quotes/Test.java index 5b785eb..c73d1c1 100644 --- a/modules/25-strings/10-quotes/Test.java +++ b/modules/25-strings/10-quotes/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "\"Khal Drogo's favorite word is \"athjahakar\"\""; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/25-strings/20-strings-concatenation/Test.java b/modules/25-strings/20-strings-concatenation/Test.java index a71b960..a76ad85 100644 --- a/modules/25-strings/20-strings-concatenation/Test.java +++ b/modules/25-strings/20-strings-concatenation/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "Winter " + "came " + "for " + "the " + "House " + "of " + "Frey."; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } From 47c0045135bb040924267450f6fac4ed764374d3 Mon Sep 17 00:00:00 2001 From: unsigable Date: Sun, 22 Sep 2024 19:55:13 +0600 Subject: [PATCH 06/11] [#278] fixing output 16,17,18,19,23 lessons --- modules/30-variables/10-definition/Test.java | 7 +++++-- modules/30-variables/12-change/Test.java | 7 +++++-- modules/30-variables/13-variables-naming/Test.java | 7 +++++-- modules/30-variables/14-errors/Test.java | 7 +++++-- modules/30-variables/20-magic-numbers/Test.java | 7 +++++-- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/modules/30-variables/10-definition/Test.java b/modules/30-variables/10-definition/Test.java index 38f7bf0..b52d238 100644 --- a/modules/30-variables/10-definition/Test.java +++ b/modules/30-variables/10-definition/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "What Is Dead May Never Die!"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/30-variables/12-change/Test.java b/modules/30-variables/12-change/Test.java index 6438035..5d840ca 100644 --- a/modules/30-variables/12-change/Test.java +++ b/modules/30-variables/12-change/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "anneirB"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/30-variables/13-variables-naming/Test.java b/modules/30-variables/13-variables-naming/Test.java index 625f34d..512f317 100644 --- a/modules/30-variables/13-variables-naming/Test.java +++ b/modules/30-variables/13-variables-naming/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "-110.00000000000001"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/30-variables/14-errors/Test.java b/modules/30-variables/14-errors/Test.java index ba84ccd..602a83c 100644 --- a/modules/30-variables/14-errors/Test.java +++ b/modules/30-variables/14-errors/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "Targaryen and Dragon"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/30-variables/20-magic-numbers/Test.java b/modules/30-variables/20-magic-numbers/Test.java index 178c10c..6d0d440 100644 --- a/modules/30-variables/20-magic-numbers/Test.java +++ b/modules/30-variables/20-magic-numbers/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "King Balon the 6th has 102 rooms."; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } From f155ee8f3457d26d66c9bbc5f7be36bbdc4811a8 Mon Sep 17 00:00:00 2001 From: unsigable Date: Sun, 22 Sep 2024 20:00:52 +0600 Subject: [PATCH 07/11] [#278] fixing output 25,26,27,28 lessons --- modules/33-data-types/41-data-types-basics/Test.java | 7 +++++-- modules/33-data-types/45-explicit-types/Test.java | 5 ++++- modules/33-data-types/47-data-types-list/Test.java | 7 +++++-- modules/33-data-types/50-null/Test.java | 7 +++++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/modules/33-data-types/41-data-types-basics/Test.java b/modules/33-data-types/41-data-types-basics/Test.java index 9b1078b..acb3586 100644 --- a/modules/33-data-types/41-data-types-basics/Test.java +++ b/modules/33-data-types/41-data-types-basics/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "1"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/33-data-types/45-explicit-types/Test.java b/modules/33-data-types/45-explicit-types/Test.java index 61c825d..d66e4f5 100644 --- a/modules/33-data-types/45-explicit-types/Test.java +++ b/modules/33-data-types/45-explicit-types/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -14,7 +16,8 @@ public static void main(String[] args) { final var actual = out.toString().trim(); - App.main(null); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); assertThat(actual).isEqualTo(expected); } diff --git a/modules/33-data-types/47-data-types-list/Test.java b/modules/33-data-types/47-data-types-list/Test.java index 666d60e..f5d6858 100644 --- a/modules/33-data-types/47-data-types-list/Test.java +++ b/modules/33-data-types/47-data-types-list/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "hexlet-7"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/33-data-types/50-null/Test.java b/modules/33-data-types/50-null/Test.java index daca321..8a9dd7f 100644 --- a/modules/33-data-types/50-null/Test.java +++ b/modules/33-data-types/50-null/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "Hello Hexlet!"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } From dfa1182d06a9dd2c5071fce63feec9e78ca06e82 Mon Sep 17 00:00:00 2001 From: unsigable Date: Sun, 22 Sep 2024 20:18:10 +0600 Subject: [PATCH 08/11] [#278] fixing output 30,31,33 lessons --- modules/35-methods-using/100-methods/Test.java | 7 +++++-- modules/35-methods-using/105-methods-parameters/Test.java | 7 +++++-- modules/35-methods-using/115-string-immutability/Test.java | 7 +++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/modules/35-methods-using/100-methods/Test.java b/modules/35-methods-using/100-methods/Test.java index d07b111..b1b5fca 100644 --- a/modules/35-methods-using/100-methods/Test.java +++ b/modules/35-methods-using/100-methods/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "12"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/35-methods-using/105-methods-parameters/Test.java b/modules/35-methods-using/105-methods-parameters/Test.java index 07e9d0b..280db67 100644 --- a/modules/35-methods-using/105-methods-parameters/Test.java +++ b/modules/35-methods-using/105-methods-parameters/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "h o d o r"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/35-methods-using/115-string-immutability/Test.java b/modules/35-methods-using/115-string-immutability/Test.java index 285a34b..f875d6a 100644 --- a/modules/35-methods-using/115-string-immutability/Test.java +++ b/modules/35-methods-using/115-string-immutability/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "support@hexlet.io"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } From 10188d073c9a2f4e887d1e24052b21e1b50cb36a Mon Sep 17 00:00:00 2001 From: unsigable Date: Tue, 24 Sep 2024 12:34:25 +0600 Subject: [PATCH 09/11] fixing (FileDescriptor.out) --- modules/30-variables/19-naming-style/Test.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/30-variables/19-naming-style/Test.java b/modules/30-variables/19-naming-style/Test.java index 0eff2c1..b3bad13 100644 --- a/modules/30-variables/19-naming-style/Test.java +++ b/modules/30-variables/19-naming-style/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; From 1d75f6124c451bbe72f8dacda33a280ba190e59c Mon Sep 17 00:00:00 2001 From: unsigable Date: Wed, 25 Sep 2024 18:45:09 +0600 Subject: [PATCH 10/11] [#278] fixing output 38,39 lessons --- .../100-method-definition-static/Test.java | 9 ++++++--- modules/40-methods-definition/150-method-main/Test.java | 7 +++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/40-methods-definition/100-method-definition-static/Test.java b/modules/40-methods-definition/100-method-definition-static/Test.java index 4f4931c..70a48dd 100644 --- a/modules/40-methods-definition/100-method-definition-static/Test.java +++ b/modules/40-methods-definition/100-method-definition-static/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,15 +9,16 @@ class Test { public static void main(String[] args) { final var expected = "Winter is coming"; - App.printMotto(); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); - App.printMotto(); + App.main(null); final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/40-methods-definition/150-method-main/Test.java b/modules/40-methods-definition/150-method-main/Test.java index fa83817..b86e413 100644 --- a/modules/40-methods-definition/150-method-main/Test.java +++ b/modules/40-methods-definition/150-method-main/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "It works!"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } From 88765ac9fc45aed5c7d7bd0bc461cee36a5b7123 Mon Sep 17 00:00:00 2001 From: unsigable Date: Sat, 26 Oct 2024 17:52:32 +0600 Subject: [PATCH 11/11] [#278] return printMotto method --- .../100-method-definition-static/Test.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/40-methods-definition/100-method-definition-static/Test.java b/modules/40-methods-definition/100-method-definition-static/Test.java index 70a48dd..9f9ad50 100644 --- a/modules/40-methods-definition/100-method-definition-static/Test.java +++ b/modules/40-methods-definition/100-method-definition-static/Test.java @@ -12,7 +12,7 @@ public static void main(String[] args) { ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); - App.main(null); + App.printMotto(); final var actual = out.toString().trim();