From bf6c2f1d2a1a7e9a445b634337bcab47ddb8fbe6 Mon Sep 17 00:00:00 2001 From: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> Date: Sat, 9 Nov 2024 12:03:53 +0200 Subject: [PATCH 1/5] sync tests --- exercises/practice/minesweeper/.meta/tests.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/exercises/practice/minesweeper/.meta/tests.toml b/exercises/practice/minesweeper/.meta/tests.toml index d9a44cb6..9b637f4b 100644 --- a/exercises/practice/minesweeper/.meta/tests.toml +++ b/exercises/practice/minesweeper/.meta/tests.toml @@ -4,6 +4,7 @@ [0c5ec4bd-dea7-4138-8651-1203e1cb9f44] description = "no rows" +include = false [650ac4c0-ad6b-4b41-acde-e4ea5852c3b8] description = "no columns" From 4aeeeb9875433418d791bb2d3dfa550771bcbc0f Mon Sep 17 00:00:00 2001 From: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> Date: Sat, 9 Nov 2024 12:39:14 +0200 Subject: [PATCH 2/5] implement & refactor tests --- .../minesweeper/test/minesweeper_test.clj | 173 ++++++++++++------ 1 file changed, 113 insertions(+), 60 deletions(-) diff --git a/exercises/practice/minesweeper/test/minesweeper_test.clj b/exercises/practice/minesweeper/test/minesweeper_test.clj index 1f60dcdf..d0692fd8 100644 --- a/exercises/practice/minesweeper/test/minesweeper_test.clj +++ b/exercises/practice/minesweeper/test/minesweeper_test.clj @@ -1,62 +1,115 @@ (ns minesweeper-test - (:require [clojure.test :refer [deftest is]] - [clojure.string :refer [join]] - [minesweeper :refer [draw]])) - -(def line-separator (System/getProperty "line.separator")) - -(deftest zero-size-board - (is (= (draw "") ""))) - -(deftest empty-board - (is (= (draw (join line-separator [" " - " " - " "])) - (join line-separator [" " - " " - " "])))) - -(deftest surrounded - (is (= (draw (join line-separator ["***" - "* *" - "***"])) - (join line-separator ["***" - "*8*" - "***"])))) - -(deftest board-full-of-mines - (is (= (draw (join line-separator ["***" - "***" - "***"])) - (join line-separator ["***" - "***" - "***"])))) - -(deftest horizontal-line - (is (= (draw " * * ") - "1*2*1"))) - -(deftest vertical-line - (is (= (draw (join line-separator [" " - "*" - " " - "*" - " "])) - (join line-separator ["1" - "*" - "2" - "*" - "1"])))) - -(deftest cross - (is (= (draw (join line-separator [" * " - " * " - "*****" - " * " - " * "])) - (join line-separator [" 2*2 " - "25*52" - "*****" - "25*52" - " 2*2 "])))) + (:require [clojure.test :refer [deftest testing is]] + minesweeper)) +(def separator (System/getProperty "line.separator")) + +(defn- join + [coll] + (clojure.string/join separator coll)) + +(deftest test-650ac4c0-ad6b-4b41-acde-e4ea5852c3b8 + (testing "no columns" + (is (= (join [""]) + (minesweeper/draw (join [""])))))) + +(deftest test-6fbf8f6d-a03b-42c9-9a58-b489e9235478 + (testing "no mines" + (is (= (join [" " + " " + " "]) + (minesweeper/draw (join [" " + " " + " "])))))) + +(deftest test-61aff1c4-fb31-4078-acad-cd5f1e635655 + (testing "minefield with only mines" + (is (= (join ["***" + "***" + "***"]) + (minesweeper/draw (join ["***" + "***" + "***"])))))) + +(deftest test-84167147-c504-4896-85d7-246b01dea7c5 + (testing "mine surrounded by spaces" + (is (= (join ["111" + "1*1" + "111"]) + (minesweeper/draw (join [" " + " * " + " "])))))) + + +(deftest test-cb878f35-43e3-4c9d-93d9-139012cccc4a + (testing "space surrounded by mines" + (is (= (join ["***" + "*8*" + "***"]) + (minesweeper/draw (join ["***" + "* *" + "***"])))))) + +(deftest test-7037f483-ddb4-4b35-b005-0d0f4ef4606f + (testing "horizontal line" + (is (= (join ["1*2*1"]) + (minesweeper/draw (join [" * * "])))))) + +(deftest test-e359820f-bb8b-4eda-8762-47b64dba30a6 + (testing "horizontal line, mines at edges" + (is (= (join ["*1 1*"]) + (minesweeper/draw (join ["* *"])))))) + +(deftest test-c5198b50-804f-47e9-ae02-c3b42f7ce3ab + (testing "vertical line" + (is (= (join ["1" + "*" + "2" + "*" + "1"]) + (minesweeper/draw (join [" " + "*" + " " + "*" + " "])))))) + +(deftest test-0c79a64d-703d-4660-9e90-5adfa5408939 + (testing "vertical line, mines at edges" + (is (= (join ["*" + "1" + " " + "1" + "*"]) + (minesweeper/draw (join ["*" + " " + " " + " " + "*"])))))) + +(deftest test-4b098563-b7f3-401c-97c6-79dd1b708f34 + (testing "cross" + (is (= (join [" 2*2 " + "25*52" + "*****" + "25*52" + " 2*2 "]) + (minesweeper/draw (join [" * " + " * " + "*****" + " * " + " * "])))))) + +(deftest test-04a260f1-b40a-4e89-839e-8dd8525abe0e + (testing "large minefield" + (is (= (join ["1*22*1" + "12*322" + " 123*2" + "112*4*" + "1*22*2" + "111111"]) + (minesweeper/draw (join [" * * " + " * " + " * " + " * *" + " * * " + " "])))))) From ea575c3daf8773f0903df94a454a37bf9fb126ef Mon Sep 17 00:00:00 2001 From: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> Date: Sat, 9 Nov 2024 12:39:41 +0200 Subject: [PATCH 3/5] update config --- exercises/practice/minesweeper/.meta/config.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exercises/practice/minesweeper/.meta/config.json b/exercises/practice/minesweeper/.meta/config.json index 0ee7c9c6..0c8d816a 100644 --- a/exercises/practice/minesweeper/.meta/config.json +++ b/exercises/practice/minesweeper/.meta/config.json @@ -4,7 +4,8 @@ ], "contributors": [ "AndreaCrotti", - "haus" + "haus", + "tasxatzial" ], "files": { "solution": [ From 62186215fcc70c853cf8008b21a091c66b30ab7f Mon Sep 17 00:00:00 2001 From: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> Date: Sat, 9 Nov 2024 13:21:57 +0200 Subject: [PATCH 4/5] update starter file --- exercises/practice/minesweeper/src/minesweeper.clj | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/exercises/practice/minesweeper/src/minesweeper.clj b/exercises/practice/minesweeper/src/minesweeper.clj index a1d95744..6fc02ceb 100644 --- a/exercises/practice/minesweeper/src/minesweeper.clj +++ b/exercises/practice/minesweeper/src/minesweeper.clj @@ -1,5 +1,6 @@ (ns minesweeper) -(defn draw [] ;; <- arglist goes here - ;; your code goes here -) +(defn draw + [board] + ;; function body + ) From ddfbc035ad919a93d922b92f44d81a4a230c7599 Mon Sep 17 00:00:00 2001 From: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> Date: Sat, 9 Nov 2024 18:44:42 +0200 Subject: [PATCH 5/5] reformat tests --- .../minesweeper/test/minesweeper_test.clj | 157 ++++++++++-------- 1 file changed, 84 insertions(+), 73 deletions(-) diff --git a/exercises/practice/minesweeper/test/minesweeper_test.clj b/exercises/practice/minesweeper/test/minesweeper_test.clj index d0692fd8..817763d1 100644 --- a/exercises/practice/minesweeper/test/minesweeper_test.clj +++ b/exercises/practice/minesweeper/test/minesweeper_test.clj @@ -4,112 +4,123 @@ (def separator (System/getProperty "line.separator")) -(defn- join +(defn join-with-line-separator [coll] (clojure.string/join separator coll)) (deftest test-650ac4c0-ad6b-4b41-acde-e4ea5852c3b8 (testing "no columns" - (is (= (join [""]) - (minesweeper/draw (join [""])))))) + (is (= (join-with-line-separator [""]) + (minesweeper/draw + (join-with-line-separator [""])))))) (deftest test-6fbf8f6d-a03b-42c9-9a58-b489e9235478 (testing "no mines" - (is (= (join [" " - " " - " "]) - (minesweeper/draw (join [" " - " " - " "])))))) + (is (= (join-with-line-separator [" " + " " + " "]) + (minesweeper/draw + (join-with-line-separator [" " + " " + " "])))))) (deftest test-61aff1c4-fb31-4078-acad-cd5f1e635655 (testing "minefield with only mines" - (is (= (join ["***" - "***" - "***"]) - (minesweeper/draw (join ["***" - "***" - "***"])))))) + (is (= (join-with-line-separator ["***" + "***" + "***"]) + (minesweeper/draw + (join-with-line-separator ["***" + "***" + "***"])))))) (deftest test-84167147-c504-4896-85d7-246b01dea7c5 (testing "mine surrounded by spaces" - (is (= (join ["111" - "1*1" - "111"]) - (minesweeper/draw (join [" " - " * " - " "])))))) + (is (= (join-with-line-separator ["111" + "1*1" + "111"]) + (minesweeper/draw + (join-with-line-separator [" " + " * " + " "])))))) (deftest test-cb878f35-43e3-4c9d-93d9-139012cccc4a (testing "space surrounded by mines" - (is (= (join ["***" - "*8*" - "***"]) - (minesweeper/draw (join ["***" - "* *" - "***"])))))) + (is (= (join-with-line-separator ["***" + "*8*" + "***"]) + (minesweeper/draw + (join-with-line-separator ["***" + "* *" + "***"])))))) (deftest test-7037f483-ddb4-4b35-b005-0d0f4ef4606f (testing "horizontal line" - (is (= (join ["1*2*1"]) - (minesweeper/draw (join [" * * "])))))) + (is (= (join-with-line-separator ["1*2*1"]) + (minesweeper/draw + (join-with-line-separator [" * * "])))))) (deftest test-e359820f-bb8b-4eda-8762-47b64dba30a6 (testing "horizontal line, mines at edges" - (is (= (join ["*1 1*"]) - (minesweeper/draw (join ["* *"])))))) + (is (= (join-with-line-separator ["*1 1*"]) + (minesweeper/draw + (join-with-line-separator ["* *"])))))) (deftest test-c5198b50-804f-47e9-ae02-c3b42f7ce3ab (testing "vertical line" - (is (= (join ["1" - "*" - "2" - "*" - "1"]) - (minesweeper/draw (join [" " - "*" - " " - "*" - " "])))))) + (is (= (join-with-line-separator ["1" + "*" + "2" + "*" + "1"]) + (minesweeper/draw + (join-with-line-separator [" " + "*" + " " + "*" + " "])))))) (deftest test-0c79a64d-703d-4660-9e90-5adfa5408939 (testing "vertical line, mines at edges" - (is (= (join ["*" - "1" - " " - "1" - "*"]) - (minesweeper/draw (join ["*" - " " - " " - " " - "*"])))))) + (is (= (join-with-line-separator ["*" + "1" + " " + "1" + "*"]) + (minesweeper/draw + (join-with-line-separator ["*" + " " + " " + " " + "*"])))))) (deftest test-4b098563-b7f3-401c-97c6-79dd1b708f34 (testing "cross" - (is (= (join [" 2*2 " - "25*52" - "*****" - "25*52" - " 2*2 "]) - (minesweeper/draw (join [" * " - " * " - "*****" - " * " - " * "])))))) + (is (= (join-with-line-separator [" 2*2 " + "25*52" + "*****" + "25*52" + " 2*2 "]) + (minesweeper/draw + (join-with-line-separator [" * " + " * " + "*****" + " * " + " * "])))))) (deftest test-04a260f1-b40a-4e89-839e-8dd8525abe0e (testing "large minefield" - (is (= (join ["1*22*1" - "12*322" - " 123*2" - "112*4*" - "1*22*2" - "111111"]) - (minesweeper/draw (join [" * * " - " * " - " * " - " * *" - " * * " - " "])))))) + (is (= (join-with-line-separator ["1*22*1" + "12*322" + " 123*2" + "112*4*" + "1*22*2" + "111111"]) + (minesweeper/draw + (join-with-line-separator [" * * " + " * " + " * " + " * *" + " * * " + " "]))))))