From 7db18d202727dbf236b3acbd0bc2446cc8cfc7df Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Wed, 8 Jan 2025 13:18:03 +0100 Subject: [PATCH] Simplify directory structure --- .../expected_results.json | 0 .../project.clj | 8 +- .../src/leap.clj | 16 +- .../test/leap_test.clj | 60 +-- tests/empty-file/expected_results.json | 5 + .../project.clj | 8 +- .../src/leap.clj | 0 .../test/leap_test.clj | 60 +-- .../example-empty-file/expected_results.json | 5 - tests/example-partial-fail/project.clj | 4 - tests/example-runtime-error/project.clj | 4 - tests/example-spec/project.clj | 4 - tests/example-success/project.clj | 4 - tests/example-success/test/leap_test.clj | 30 -- .../expected_results.json | 5 - tests/example-syntax-error/project.clj | 4 - tests/example-syntax-error/test/leap_test.clj | 30 -- .../expected_results.json | 0 .../project.clj | 8 +- .../src/leap.clj | 16 +- .../test/leap_test.clj | 94 ++--- .../expected_results.json | 0 .../project.clj | 8 +- .../src/leap.clj | 6 +- .../test/leap_test.clj | 384 +++++++++--------- .../expected_results.json | 0 tests/partial-fail/project.clj | 4 + .../src/leap.clj | 12 +- .../test/leap_test.clj | 60 +-- .../expected_results.json | 0 tests/runtime-error/project.clj | 4 + .../src/leap.clj | 16 +- .../test/leap_test.clj | 62 +-- .../expected_results.json | 0 tests/spec/project.clj | 4 + tests/{example-spec => spec}/src/leap.clj | 38 +- .../test/leap_test.clj | 60 +-- .../expected_results.json | 0 tests/success/project.clj | 4 + .../{example-success => success}/src/leap.clj | 12 +- tests/success/test/leap_test.clj | 30 ++ tests/syntax-error/expected_results.json | 5 + tests/syntax-error/project.clj | 4 + .../src/leap.clj | 6 +- tests/syntax-error/test/leap_test.clj | 30 ++ .../expected_results.json | 0 .../project.clj | 0 .../src/tracks_on_tracks_on_tracks.clj | 0 .../test/leap_test.clj | 0 49 files changed, 557 insertions(+), 557 deletions(-) rename tests/{example-all-fail => all-fail}/expected_results.json (100%) rename tests/{example-all-fail => all-fail}/project.clj (97%) rename tests/{example-all-fail => all-fail}/src/leap.clj (95%) rename tests/{example-empty-file => all-fail}/test/leap_test.clj (96%) create mode 100644 tests/empty-file/expected_results.json rename tests/{example-empty-file => empty-file}/project.clj (97%) rename tests/{example-empty-file => empty-file}/src/leap.clj (100%) rename tests/{example-spec => empty-file}/test/leap_test.clj (96%) delete mode 100644 tests/example-empty-file/expected_results.json delete mode 100644 tests/example-partial-fail/project.clj delete mode 100644 tests/example-runtime-error/project.clj delete mode 100644 tests/example-spec/project.clj delete mode 100644 tests/example-success/project.clj delete mode 100644 tests/example-success/test/leap_test.clj delete mode 100644 tests/example-syntax-error/expected_results.json delete mode 100644 tests/example-syntax-error/project.clj delete mode 100644 tests/example-syntax-error/test/leap_test.clj rename tests/{example-flat-multiple-assertions => flat-multiple-assertions}/expected_results.json (100%) rename tests/{example-flat-multiple-assertions => flat-multiple-assertions}/project.clj (97%) rename tests/{example-flat-multiple-assertions => flat-multiple-assertions}/src/leap.clj (97%) rename tests/{example-flat-multiple-assertions => flat-multiple-assertions}/test/leap_test.clj (95%) rename tests/{example-nested-multiple-assertions => nested-multiple-assertions}/expected_results.json (100%) rename tests/{example-nested-multiple-assertions => nested-multiple-assertions}/project.clj (97%) rename tests/{example-nested-multiple-assertions => nested-multiple-assertions}/src/leap.clj (92%) rename tests/{example-nested-multiple-assertions => nested-multiple-assertions}/test/leap_test.clj (96%) rename tests/{example-partial-fail => partial-fail}/expected_results.json (100%) create mode 100644 tests/partial-fail/project.clj rename tests/{example-partial-fail => partial-fail}/src/leap.clj (95%) rename tests/{example-all-fail => partial-fail}/test/leap_test.clj (96%) rename tests/{example-runtime-error => runtime-error}/expected_results.json (100%) create mode 100644 tests/runtime-error/project.clj rename tests/{example-runtime-error => runtime-error}/src/leap.clj (97%) rename tests/{example-runtime-error => runtime-error}/test/leap_test.clj (96%) rename tests/{example-spec => spec}/expected_results.json (100%) create mode 100644 tests/spec/project.clj rename tests/{example-spec => spec}/src/leap.clj (96%) rename tests/{example-partial-fail => spec}/test/leap_test.clj (96%) rename tests/{example-success => success}/expected_results.json (100%) create mode 100644 tests/success/project.clj rename tests/{example-success => success}/src/leap.clj (95%) create mode 100644 tests/success/test/leap_test.clj create mode 100644 tests/syntax-error/expected_results.json create mode 100644 tests/syntax-error/project.clj rename tests/{example-syntax-error => syntax-error}/src/leap.clj (93%) create mode 100644 tests/syntax-error/test/leap_test.clj rename tests/{example-test-metadata => test-metadata}/expected_results.json (100%) rename tests/{example-test-metadata => test-metadata}/project.clj (100%) rename tests/{example-test-metadata => test-metadata}/src/tracks_on_tracks_on_tracks.clj (100%) rename tests/{example-test-metadata => test-metadata}/test/leap_test.clj (100%) diff --git a/tests/example-all-fail/expected_results.json b/tests/all-fail/expected_results.json similarity index 100% rename from tests/example-all-fail/expected_results.json rename to tests/all-fail/expected_results.json diff --git a/tests/example-all-fail/project.clj b/tests/all-fail/project.clj similarity index 97% rename from tests/example-all-fail/project.clj rename to tests/all-fail/project.clj index 2dc84fc..70a196a 100644 --- a/tests/example-all-fail/project.clj +++ b/tests/all-fail/project.clj @@ -1,4 +1,4 @@ -(defproject leap "0.1.0-SNAPSHOT" - :description "leap exercise." - :url "https://github.com/exercism/clojure/tree/master/exercises/leap" - :dependencies [[org.clojure/clojure "1.10.0"]]) +(defproject leap "0.1.0-SNAPSHOT" + :description "leap exercise." + :url "https://github.com/exercism/clojure/tree/master/exercises/leap" + :dependencies [[org.clojure/clojure "1.10.0"]]) diff --git a/tests/example-all-fail/src/leap.clj b/tests/all-fail/src/leap.clj similarity index 95% rename from tests/example-all-fail/src/leap.clj rename to tests/all-fail/src/leap.clj index 076898b..93b41c8 100644 --- a/tests/example-all-fail/src/leap.clj +++ b/tests/all-fail/src/leap.clj @@ -1,8 +1,8 @@ -(ns leap) - -(defn leap-year? [year] - (let [[p c s] (map #(= 0 (rem year %1)) [4 100 400])] - (not - (or (and p (not c)) - (and c s))))) - +(ns leap) + +(defn leap-year? [year] + (let [[p c s] (map #(= 0 (rem year %1)) [4 100 400])] + (not + (or (and p (not c)) + (and c s))))) + diff --git a/tests/example-empty-file/test/leap_test.clj b/tests/all-fail/test/leap_test.clj similarity index 96% rename from tests/example-empty-file/test/leap_test.clj rename to tests/all-fail/test/leap_test.clj index b75ded1..d5851a5 100644 --- a/tests/example-empty-file/test/leap_test.clj +++ b/tests/all-fail/test/leap_test.clj @@ -1,30 +1,30 @@ -(ns leap-test - (:require [clojure.test :refer [deftest is]] - leap)) - -(deftest year-not-divisible-by-4 - (is (not (leap/leap-year? 2015)))) - -(deftest year-divisible-by-2-but-not-4 - (is (not (leap/leap-year? 1970)))) - -(deftest year-divisible-by-4-but-not-100 - (is (leap/leap-year? 1996))) - -(deftest year-divisible-by-4-and-5 - (is (leap/leap-year? 1960))) - -(deftest year-divisible-by-100-but-not-400 - (is (not (leap/leap-year? 2100)))) - -(deftest year-divisible-by-100-but-not-by-3 - (is (not (leap/leap-year? 1900)))) - -(deftest year-divisible-by-400 - (is (leap/leap-year? 2000))) - -(deftest year-divisible-by-400-but-not-125 - (is (leap/leap-year? 2400))) - -(deftest year-divisible-by-200-but-not-by-400 - (is (not (leap/leap-year? 1800)))) +(ns leap-test + (:require [clojure.test :refer [deftest is]] + leap)) + +(deftest year-not-divisible-by-4 + (is (not (leap/leap-year? 2015)))) + +(deftest year-divisible-by-2-but-not-4 + (is (not (leap/leap-year? 1970)))) + +(deftest year-divisible-by-4-but-not-100 + (is (leap/leap-year? 1996))) + +(deftest year-divisible-by-4-and-5 + (is (leap/leap-year? 1960))) + +(deftest year-divisible-by-100-but-not-400 + (is (not (leap/leap-year? 2100)))) + +(deftest year-divisible-by-100-but-not-by-3 + (is (not (leap/leap-year? 1900)))) + +(deftest year-divisible-by-400 + (is (leap/leap-year? 2000))) + +(deftest year-divisible-by-400-but-not-125 + (is (leap/leap-year? 2400))) + +(deftest year-divisible-by-200-but-not-by-400 + (is (not (leap/leap-year? 1800)))) diff --git a/tests/empty-file/expected_results.json b/tests/empty-file/expected_results.json new file mode 100644 index 0000000..83c7ae9 --- /dev/null +++ b/tests/empty-file/expected_results.json @@ -0,0 +1,5 @@ +{ + "version": 3, + "status": "error", + "message": "----- Error --------------------------------------------------------------------\nType: clojure.lang.ExceptionInfo\nMessage: Could not resolve symbol: leap/leap-year?\nData: {:type :sci/error, :line 5, :column 1, :file \"/opt/test-runner/tests/empty-file/test/leap_test.clj\", :phase \"analysis\"}\nLocation: /opt/test-runner/tests/empty-file/test/leap_test.clj:6:12\nPhase: analysis\n\n----- Context ------------------------------------------------------------------\n 2: (:require [clojure.test :refer [deftest is]]\n 3: leap))\n 4: \n 5: (deftest year-not-divisible-by-4\n 6: (is (not (leap/leap-year? 2015))))\n ^--- Could not resolve symbol: leap/leap-year?\n 7: \n 8: (deftest year-divisible-by-2-but-not-4\n 9: (is (not (leap/leap-year? 1970))))\n10: \n11: (deftest year-divisible-by-4-but-not-100\n\n----- Stack trace --------------------------------------------------------------\nleap-test - /opt/test-runner/tests/empty-file/test/leap_test.clj:6:12\nclojure.core/list - \nclojure.core/let - \nleap-test - /opt/test-runner/tests/empty-file/test/leap_test.clj:6:3\nleap-test/is - /opt/test-runner/tests/empty-file/test/leap_test.clj:6:3\n... (run with --debug to see elided elements)\nclojure.core/fn - \nleap-test - /opt/test-runner/tests/empty-file/test/leap_test.clj:5:1\nleap-test - /opt/test-runner/tests/empty-file/test/leap_test.clj:5:1\nleap-test - /opt/test-runner/tests/empty-file/test/leap_test.clj:5:1\nuser - /opt/test-runner/./test-runner.clj:19:1" +} diff --git a/tests/example-empty-file/project.clj b/tests/empty-file/project.clj similarity index 97% rename from tests/example-empty-file/project.clj rename to tests/empty-file/project.clj index 2dc84fc..70a196a 100644 --- a/tests/example-empty-file/project.clj +++ b/tests/empty-file/project.clj @@ -1,4 +1,4 @@ -(defproject leap "0.1.0-SNAPSHOT" - :description "leap exercise." - :url "https://github.com/exercism/clojure/tree/master/exercises/leap" - :dependencies [[org.clojure/clojure "1.10.0"]]) +(defproject leap "0.1.0-SNAPSHOT" + :description "leap exercise." + :url "https://github.com/exercism/clojure/tree/master/exercises/leap" + :dependencies [[org.clojure/clojure "1.10.0"]]) diff --git a/tests/example-empty-file/src/leap.clj b/tests/empty-file/src/leap.clj similarity index 100% rename from tests/example-empty-file/src/leap.clj rename to tests/empty-file/src/leap.clj diff --git a/tests/example-spec/test/leap_test.clj b/tests/empty-file/test/leap_test.clj similarity index 96% rename from tests/example-spec/test/leap_test.clj rename to tests/empty-file/test/leap_test.clj index b75ded1..d5851a5 100644 --- a/tests/example-spec/test/leap_test.clj +++ b/tests/empty-file/test/leap_test.clj @@ -1,30 +1,30 @@ -(ns leap-test - (:require [clojure.test :refer [deftest is]] - leap)) - -(deftest year-not-divisible-by-4 - (is (not (leap/leap-year? 2015)))) - -(deftest year-divisible-by-2-but-not-4 - (is (not (leap/leap-year? 1970)))) - -(deftest year-divisible-by-4-but-not-100 - (is (leap/leap-year? 1996))) - -(deftest year-divisible-by-4-and-5 - (is (leap/leap-year? 1960))) - -(deftest year-divisible-by-100-but-not-400 - (is (not (leap/leap-year? 2100)))) - -(deftest year-divisible-by-100-but-not-by-3 - (is (not (leap/leap-year? 1900)))) - -(deftest year-divisible-by-400 - (is (leap/leap-year? 2000))) - -(deftest year-divisible-by-400-but-not-125 - (is (leap/leap-year? 2400))) - -(deftest year-divisible-by-200-but-not-by-400 - (is (not (leap/leap-year? 1800)))) +(ns leap-test + (:require [clojure.test :refer [deftest is]] + leap)) + +(deftest year-not-divisible-by-4 + (is (not (leap/leap-year? 2015)))) + +(deftest year-divisible-by-2-but-not-4 + (is (not (leap/leap-year? 1970)))) + +(deftest year-divisible-by-4-but-not-100 + (is (leap/leap-year? 1996))) + +(deftest year-divisible-by-4-and-5 + (is (leap/leap-year? 1960))) + +(deftest year-divisible-by-100-but-not-400 + (is (not (leap/leap-year? 2100)))) + +(deftest year-divisible-by-100-but-not-by-3 + (is (not (leap/leap-year? 1900)))) + +(deftest year-divisible-by-400 + (is (leap/leap-year? 2000))) + +(deftest year-divisible-by-400-but-not-125 + (is (leap/leap-year? 2400))) + +(deftest year-divisible-by-200-but-not-by-400 + (is (not (leap/leap-year? 1800)))) diff --git a/tests/example-empty-file/expected_results.json b/tests/example-empty-file/expected_results.json deleted file mode 100644 index fa9ca8f..0000000 --- a/tests/example-empty-file/expected_results.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "version": 3, - "status": "error", - "message": "----- Error --------------------------------------------------------------------\nType: clojure.lang.ExceptionInfo\nMessage: Could not resolve symbol: leap/leap-year?\nData: {:type :sci/error, :line 5, :column 1, :file \"/opt/test-runner/tests/example-empty-file/test/leap_test.clj\", :phase \"analysis\"}\nLocation: /opt/test-runner/tests/example-empty-file/test/leap_test.clj:6:12\nPhase: analysis\n\n----- Context ------------------------------------------------------------------\n 2: (:require [clojure.test :refer [deftest is]]\n 3: leap))\n 4: \n 5: (deftest year-not-divisible-by-4\n 6: (is (not (leap/leap-year? 2015))))\n ^--- Could not resolve symbol: leap/leap-year?\n 7: \n 8: (deftest year-divisible-by-2-but-not-4\n 9: (is (not (leap/leap-year? 1970))))\n10: \n11: (deftest year-divisible-by-4-but-not-100\n\n----- Stack trace --------------------------------------------------------------\nleap-test - /opt/test-runner/tests/example-empty-file/test/leap_test.clj:6:12\nclojure.core/list - \nclojure.core/let - \nleap-test - /opt/test-runner/tests/example-empty-file/test/leap_test.clj:6:3\nleap-test/is - /opt/test-runner/tests/example-empty-file/test/leap_test.clj:6:3\n... (run with --debug to see elided elements)\nclojure.core/fn - \nleap-test - /opt/test-runner/tests/example-empty-file/test/leap_test.clj:5:1\nleap-test - /opt/test-runner/tests/example-empty-file/test/leap_test.clj:5:1\nleap-test - /opt/test-runner/tests/example-empty-file/test/leap_test.clj:5:1\nuser - /opt/test-runner/./test-runner.clj:19:1" -} diff --git a/tests/example-partial-fail/project.clj b/tests/example-partial-fail/project.clj deleted file mode 100644 index 2dc84fc..0000000 --- a/tests/example-partial-fail/project.clj +++ /dev/null @@ -1,4 +0,0 @@ -(defproject leap "0.1.0-SNAPSHOT" - :description "leap exercise." - :url "https://github.com/exercism/clojure/tree/master/exercises/leap" - :dependencies [[org.clojure/clojure "1.10.0"]]) diff --git a/tests/example-runtime-error/project.clj b/tests/example-runtime-error/project.clj deleted file mode 100644 index 2dc84fc..0000000 --- a/tests/example-runtime-error/project.clj +++ /dev/null @@ -1,4 +0,0 @@ -(defproject leap "0.1.0-SNAPSHOT" - :description "leap exercise." - :url "https://github.com/exercism/clojure/tree/master/exercises/leap" - :dependencies [[org.clojure/clojure "1.10.0"]]) diff --git a/tests/example-spec/project.clj b/tests/example-spec/project.clj deleted file mode 100644 index 2dc84fc..0000000 --- a/tests/example-spec/project.clj +++ /dev/null @@ -1,4 +0,0 @@ -(defproject leap "0.1.0-SNAPSHOT" - :description "leap exercise." - :url "https://github.com/exercism/clojure/tree/master/exercises/leap" - :dependencies [[org.clojure/clojure "1.10.0"]]) diff --git a/tests/example-success/project.clj b/tests/example-success/project.clj deleted file mode 100644 index 2dc84fc..0000000 --- a/tests/example-success/project.clj +++ /dev/null @@ -1,4 +0,0 @@ -(defproject leap "0.1.0-SNAPSHOT" - :description "leap exercise." - :url "https://github.com/exercism/clojure/tree/master/exercises/leap" - :dependencies [[org.clojure/clojure "1.10.0"]]) diff --git a/tests/example-success/test/leap_test.clj b/tests/example-success/test/leap_test.clj deleted file mode 100644 index b75ded1..0000000 --- a/tests/example-success/test/leap_test.clj +++ /dev/null @@ -1,30 +0,0 @@ -(ns leap-test - (:require [clojure.test :refer [deftest is]] - leap)) - -(deftest year-not-divisible-by-4 - (is (not (leap/leap-year? 2015)))) - -(deftest year-divisible-by-2-but-not-4 - (is (not (leap/leap-year? 1970)))) - -(deftest year-divisible-by-4-but-not-100 - (is (leap/leap-year? 1996))) - -(deftest year-divisible-by-4-and-5 - (is (leap/leap-year? 1960))) - -(deftest year-divisible-by-100-but-not-400 - (is (not (leap/leap-year? 2100)))) - -(deftest year-divisible-by-100-but-not-by-3 - (is (not (leap/leap-year? 1900)))) - -(deftest year-divisible-by-400 - (is (leap/leap-year? 2000))) - -(deftest year-divisible-by-400-but-not-125 - (is (leap/leap-year? 2400))) - -(deftest year-divisible-by-200-but-not-by-400 - (is (not (leap/leap-year? 1800)))) diff --git a/tests/example-syntax-error/expected_results.json b/tests/example-syntax-error/expected_results.json deleted file mode 100644 index e2daddc..0000000 --- a/tests/example-syntax-error/expected_results.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "version": 3, - "status": "error", - "message": "----- Error --------------------------------------------------------------------\nType: java.lang.Exception\nMessage: No reader function for tag leap\nLocation: /opt/test-runner/tests/example-syntax-error/test/leap_test.clj:2:3\n\n----- Context ------------------------------------------------------------------\n1: (ns leap-test\n2: (:require [clojure.test :refer [deftest is]]\n ^--- No reader function for tag leap\n3: leap))\n4: \n5: (deftest year-not-divisible-by-4\n6: (is (not (leap/leap-year? 2015))))\n7: \n\n----- Stack trace --------------------------------------------------------------\nedamame.impl.parser/parse-sharp - \nedamame.impl.parser/dispatch - \nedamame.impl.parser/parse-next - \nedamame.impl.parser/dispatch - \nedamame.impl.parser/parse-next - \n... (run with --debug to see elided elements)\nedamame.impl.parser/dispatch - \nedamame.impl.parser/parse-next - \nedamame.core/parse-next - \nleap-test - /opt/test-runner/tests/example-syntax-error/test/leap_test.clj:2:3\nuser - /opt/test-runner/./test-runner.clj:19:1" -} diff --git a/tests/example-syntax-error/project.clj b/tests/example-syntax-error/project.clj deleted file mode 100644 index 2dc84fc..0000000 --- a/tests/example-syntax-error/project.clj +++ /dev/null @@ -1,4 +0,0 @@ -(defproject leap "0.1.0-SNAPSHOT" - :description "leap exercise." - :url "https://github.com/exercism/clojure/tree/master/exercises/leap" - :dependencies [[org.clojure/clojure "1.10.0"]]) diff --git a/tests/example-syntax-error/test/leap_test.clj b/tests/example-syntax-error/test/leap_test.clj deleted file mode 100644 index b75ded1..0000000 --- a/tests/example-syntax-error/test/leap_test.clj +++ /dev/null @@ -1,30 +0,0 @@ -(ns leap-test - (:require [clojure.test :refer [deftest is]] - leap)) - -(deftest year-not-divisible-by-4 - (is (not (leap/leap-year? 2015)))) - -(deftest year-divisible-by-2-but-not-4 - (is (not (leap/leap-year? 1970)))) - -(deftest year-divisible-by-4-but-not-100 - (is (leap/leap-year? 1996))) - -(deftest year-divisible-by-4-and-5 - (is (leap/leap-year? 1960))) - -(deftest year-divisible-by-100-but-not-400 - (is (not (leap/leap-year? 2100)))) - -(deftest year-divisible-by-100-but-not-by-3 - (is (not (leap/leap-year? 1900)))) - -(deftest year-divisible-by-400 - (is (leap/leap-year? 2000))) - -(deftest year-divisible-by-400-but-not-125 - (is (leap/leap-year? 2400))) - -(deftest year-divisible-by-200-but-not-by-400 - (is (not (leap/leap-year? 1800)))) diff --git a/tests/example-flat-multiple-assertions/expected_results.json b/tests/flat-multiple-assertions/expected_results.json similarity index 100% rename from tests/example-flat-multiple-assertions/expected_results.json rename to tests/flat-multiple-assertions/expected_results.json diff --git a/tests/example-flat-multiple-assertions/project.clj b/tests/flat-multiple-assertions/project.clj similarity index 97% rename from tests/example-flat-multiple-assertions/project.clj rename to tests/flat-multiple-assertions/project.clj index 2dc84fc..70a196a 100644 --- a/tests/example-flat-multiple-assertions/project.clj +++ b/tests/flat-multiple-assertions/project.clj @@ -1,4 +1,4 @@ -(defproject leap "0.1.0-SNAPSHOT" - :description "leap exercise." - :url "https://github.com/exercism/clojure/tree/master/exercises/leap" - :dependencies [[org.clojure/clojure "1.10.0"]]) +(defproject leap "0.1.0-SNAPSHOT" + :description "leap exercise." + :url "https://github.com/exercism/clojure/tree/master/exercises/leap" + :dependencies [[org.clojure/clojure "1.10.0"]]) diff --git a/tests/example-flat-multiple-assertions/src/leap.clj b/tests/flat-multiple-assertions/src/leap.clj similarity index 97% rename from tests/example-flat-multiple-assertions/src/leap.clj rename to tests/flat-multiple-assertions/src/leap.clj index 6de5bf5..6b4477f 100644 --- a/tests/example-flat-multiple-assertions/src/leap.clj +++ b/tests/flat-multiple-assertions/src/leap.clj @@ -1,8 +1,8 @@ -(ns leap) - -(defn leap-year? [year] - (assert (not= year 1996)) ;; throws AssertionError - (when (= year 1960) (case :foo)) ;; throws IllegalArgumentException - (let [[p c s] (map #(= 0 (rem year %1)) [4 100 401])] - (or (and p (not c)) - (and c s)))) +(ns leap) + +(defn leap-year? [year] + (assert (not= year 1996)) ;; throws AssertionError + (when (= year 1960) (case :foo)) ;; throws IllegalArgumentException + (let [[p c s] (map #(= 0 (rem year %1)) [4 100 401])] + (or (and p (not c)) + (and c s)))) diff --git a/tests/example-flat-multiple-assertions/test/leap_test.clj b/tests/flat-multiple-assertions/test/leap_test.clj similarity index 95% rename from tests/example-flat-multiple-assertions/test/leap_test.clj rename to tests/flat-multiple-assertions/test/leap_test.clj index 14c9e40..d98f8dd 100644 --- a/tests/example-flat-multiple-assertions/test/leap_test.clj +++ b/tests/flat-multiple-assertions/test/leap_test.clj @@ -1,47 +1,47 @@ -(ns leap-test - (:require [clojure.test :refer [deftest is]] - leap)) - -(deftest pass-fail-error - (is (= true true) :1) - (is (= true false) :2) - (is (assert false) :3)) - -(deftest fail-error-pass - (is (= true false) :1) - (is (assert false) :2) - (is (= true true) :3)) - -(deftest error-pass-fail - (is (assert false) :1) - (is (= true true) :2) - (is (= true false) :3)) - -(deftest pass-fail-pass - (is (= true true) :1) - (is (= true false) :2) - (is (= true true) :3)) - -(deftest pass-pass-pass - (is (= true true) :1) - (is (= true true) :2) - (is (= true true) :3)) - -(deftest error-pass-error - (is (assert false) :1) - (is true :2) - (is (assert false) :3)) - -(deftest pass-error-pass-error - (is (not (leap/leap-year? 1900))) - (is (leap/leap-year? 1960)) - (is (not (leap/leap-year? 1970))) - (is (leap/leap-year? 1996))) - -(deftest fail-pass - (is (leap/leap-year? 2000)) - (is (not (leap/leap-year? 2015)))) - -(deftest pass-pass - (is (not (leap/leap-year? 2100))) - (is (not (leap/leap-year? 1800)))) +(ns leap-test + (:require [clojure.test :refer [deftest is]] + leap)) + +(deftest pass-fail-error + (is (= true true) :1) + (is (= true false) :2) + (is (assert false) :3)) + +(deftest fail-error-pass + (is (= true false) :1) + (is (assert false) :2) + (is (= true true) :3)) + +(deftest error-pass-fail + (is (assert false) :1) + (is (= true true) :2) + (is (= true false) :3)) + +(deftest pass-fail-pass + (is (= true true) :1) + (is (= true false) :2) + (is (= true true) :3)) + +(deftest pass-pass-pass + (is (= true true) :1) + (is (= true true) :2) + (is (= true true) :3)) + +(deftest error-pass-error + (is (assert false) :1) + (is true :2) + (is (assert false) :3)) + +(deftest pass-error-pass-error + (is (not (leap/leap-year? 1900))) + (is (leap/leap-year? 1960)) + (is (not (leap/leap-year? 1970))) + (is (leap/leap-year? 1996))) + +(deftest fail-pass + (is (leap/leap-year? 2000)) + (is (not (leap/leap-year? 2015)))) + +(deftest pass-pass + (is (not (leap/leap-year? 2100))) + (is (not (leap/leap-year? 1800)))) diff --git a/tests/example-nested-multiple-assertions/expected_results.json b/tests/nested-multiple-assertions/expected_results.json similarity index 100% rename from tests/example-nested-multiple-assertions/expected_results.json rename to tests/nested-multiple-assertions/expected_results.json diff --git a/tests/example-nested-multiple-assertions/project.clj b/tests/nested-multiple-assertions/project.clj similarity index 97% rename from tests/example-nested-multiple-assertions/project.clj rename to tests/nested-multiple-assertions/project.clj index 2dc84fc..70a196a 100644 --- a/tests/example-nested-multiple-assertions/project.clj +++ b/tests/nested-multiple-assertions/project.clj @@ -1,4 +1,4 @@ -(defproject leap "0.1.0-SNAPSHOT" - :description "leap exercise." - :url "https://github.com/exercism/clojure/tree/master/exercises/leap" - :dependencies [[org.clojure/clojure "1.10.0"]]) +(defproject leap "0.1.0-SNAPSHOT" + :description "leap exercise." + :url "https://github.com/exercism/clojure/tree/master/exercises/leap" + :dependencies [[org.clojure/clojure "1.10.0"]]) diff --git a/tests/example-nested-multiple-assertions/src/leap.clj b/tests/nested-multiple-assertions/src/leap.clj similarity index 92% rename from tests/example-nested-multiple-assertions/src/leap.clj rename to tests/nested-multiple-assertions/src/leap.clj index f95dd30..23cff5c 100644 --- a/tests/example-nested-multiple-assertions/src/leap.clj +++ b/tests/nested-multiple-assertions/src/leap.clj @@ -1,3 +1,3 @@ -(ns leap) - -(defn leap-year? [year]) +(ns leap) + +(defn leap-year? [year]) diff --git a/tests/example-nested-multiple-assertions/test/leap_test.clj b/tests/nested-multiple-assertions/test/leap_test.clj similarity index 96% rename from tests/example-nested-multiple-assertions/test/leap_test.clj rename to tests/nested-multiple-assertions/test/leap_test.clj index cedd54f..0726509 100644 --- a/tests/example-nested-multiple-assertions/test/leap_test.clj +++ b/tests/nested-multiple-assertions/test/leap_test.clj @@ -1,192 +1,192 @@ -(ns leap-test - (:require [clojure.test :refer [deftest is testing]] - leap)) - -;; below tests are adapted from examples of nested tests found in the clojure track -;; each has a case where all assertions pass, where one fails, and where one errors - -(deftest day-test-pass - (testing "numeric pattern for day matches" - (testing "un-padded 1" - (is (= "1" "1"))) - (testing "un-padded 2" - (is (= "2" "2"))) - (testing "un-padded 3" - (is (= "3" "3"))) - (testing "un-padded 4" - (is (= "4" "4")))) - (testing "numeric pattern for day doesn't match" - (testing "too few digits" - (is (nil? nil))) - (testing "too many digits" - (is (nil? nil))) - (testing "one letter" - (is (nil? nil))) - (testing "two letters" - (is (nil? nil))))) - -(deftest day-test-fail - (testing "numeric pattern for day matches" - (testing "un-padded 1" - (is (= "1" "1"))) - (testing "un-padded 2" - (is (= "2" "2"))) - (testing "un-padded 3" - (is (= "3" "WRONG"))) - (testing "un-padded 4" - (is (= "4" "4")))) - (testing "numeric pattern for day doesn't match" - (testing "too few digits" - (is (nil? nil))) - (testing "too many digits" - (is (nil? nil))) - (testing "one letter" - (is (nil? nil))) - (testing "two letters" - (is (nil? nil))))) - -(deftest day-test-error - (testing "numeric pattern for day matches" - (testing "un-padded 1" - (is (= "1" "1"))) - (testing "un-padded 2" - (is (= "2" "2"))) - (testing "un-padded 3" - (is (= "3" "3"))) - (testing "un-padded 4" - (is (= "4" "4")))) - (testing "numeric pattern for day doesn't match" - (testing "too few digits" - (is (nil? nil))) - (testing "too many digits" - (is (nil? nil))) - (testing "one letter" - (is (nil? (case :oh-no!)))) - (testing "two letters" - (is (nil? nil))))) - -(deftest day-names-test-pass - (testing "day names match" - (is (= "Sunday" "Sunday")) - (is (= "Monday" "Monday")) - (is (= "Tuesday" "Tuesday")) - (is (= "Wednesday" "Wednesday")) - (is (= "Thursday" "Thursday")) - (is (= "Friday" "Friday")) - (is (= "Saturday" "Saturday"))) - (testing "day names don't match" - (testing "combined" - (is (nil? nil))) - (testing "short name" - (is (nil? nil))) - (testing "numeric day of the week (0-indexed)" - (is (nil? nil))) - (testing "numeric day of the week (1-indexed)" - (is (nil? nil))))) - -(deftest day-names-test-fail - (testing "day names match" - (is (= "Sunday" "Sunday")) - (is (= "Monday" "Monday")) - (is (= "Tuesday" "Tuesday")) - (is (= "Wednesday" "Wednesday")) - (is (= "Thursday" "Thursday")) - (is (= "Friday" "Friday")) - (is (= "Saturday" "Saturday"))) - (testing "day names don't match" - (testing "combined" - (is (nil? false))) - (testing "short name" - (is (nil? nil))) - (testing "numeric day of the week (0-indexed)" - (is (nil? nil))) - (testing "numeric day of the week (1-indexed)" - (is (nil? nil))))) - -(deftest day-names-test-error - (testing "day names match" - (is (= "Sunday" "Sunday")) - (is (= "Monday" "Monday")) - (is (= "Tuesday" "Tuesday")) - (is (= "Wednesday" "Wednesday")) - (is (= "Thursday" "Thursday")) - (is (= "Friday" "Friday")) - (is (= "Saturday" (assert nil)))) - (testing "day names don't match" - (testing "combined" - (is (nil? nil))) - (testing "short name" - (is (nil? nil))) - (testing "numeric day of the week (0-indexed)" - (is (nil? nil))) - (testing "numeric day of the week (1-indexed)" - (is (nil? nil))))) - -(deftest increment-decrement-and-get-balance-pass - (testing "Taking money out of the account works" - (let [account (atom 0)] - (is (= 0 @account)) - (swap! account + 10) - (is (= 10 @account)) - (swap! account + -10) - (is (= 0 @account))))) - -(deftest increment-decrement-and-get-balance-fail - (testing "Taking money out of the account works" - (let [account (atom 0)] - (is (= 0 @account)) - (swap! account + 10) - (is (= 1000 @account)) - (swap! account + -10) - (is (= 0 @account))))) - -(deftest increment-decrement-and-get-balance-error - (testing "Taking money out of the account works" - (let [account (atom 0)] - (is (= 0 @account)) - (swap! account + 10) - (is (= 10 @@account)) - (swap! account + -10) - (is (= 0 @account))))) - -(deftest largest-series-tests-pass - (testing "can find the largest product of 2 with numbers in order" - (is (= 72 72))) - (testing "can find the largest product of 2" - (is (= 48 48))) - (testing "finds the largest product if span equals length" - (is (= 18 18)))) - -(deftest largest-series-tests-fail - (testing "can find the largest product of 2 with numbers in order" - (is (= 72 "WRONG"))) - (testing "can find the largest product of 2" - (is (= 48 48))) - (testing "finds the largest product if span equals length" - (is (= 18 18)))) - -(deftest largest-series-tests-error - (testing "can find the largest product of 2 with numbers in order" - (is (= 72 72))) - (testing "can find the largest product of 2" - (is (= 48 48))) - (testing "finds the largest product if span equals length" - (is (= 18 (+ :foo))))) - -(deftest is-inside-let-pass - (let [v [1 2 3 4]] - (is (= 4 (count v))) - (is (sequential? v)) - (is (= 2 (second v))))) - -(deftest is-inside-let-fail - (let [v (range 4)] - (is (= 4 (count v))) - (is (sequential? v)) - (is (= 2 (second v))))) - -(deftest is-inside-let-error - (let [v 4] - (is (= 4 (count v))) - (is (sequential? v)) - (is (= 2 (second v))))) +(ns leap-test + (:require [clojure.test :refer [deftest is testing]] + leap)) + +;; below tests are adapted from examples of nested tests found in the clojure track +;; each has a case where all assertions pass, where one fails, and where one errors + +(deftest day-test-pass + (testing "numeric pattern for day matches" + (testing "un-padded 1" + (is (= "1" "1"))) + (testing "un-padded 2" + (is (= "2" "2"))) + (testing "un-padded 3" + (is (= "3" "3"))) + (testing "un-padded 4" + (is (= "4" "4")))) + (testing "numeric pattern for day doesn't match" + (testing "too few digits" + (is (nil? nil))) + (testing "too many digits" + (is (nil? nil))) + (testing "one letter" + (is (nil? nil))) + (testing "two letters" + (is (nil? nil))))) + +(deftest day-test-fail + (testing "numeric pattern for day matches" + (testing "un-padded 1" + (is (= "1" "1"))) + (testing "un-padded 2" + (is (= "2" "2"))) + (testing "un-padded 3" + (is (= "3" "WRONG"))) + (testing "un-padded 4" + (is (= "4" "4")))) + (testing "numeric pattern for day doesn't match" + (testing "too few digits" + (is (nil? nil))) + (testing "too many digits" + (is (nil? nil))) + (testing "one letter" + (is (nil? nil))) + (testing "two letters" + (is (nil? nil))))) + +(deftest day-test-error + (testing "numeric pattern for day matches" + (testing "un-padded 1" + (is (= "1" "1"))) + (testing "un-padded 2" + (is (= "2" "2"))) + (testing "un-padded 3" + (is (= "3" "3"))) + (testing "un-padded 4" + (is (= "4" "4")))) + (testing "numeric pattern for day doesn't match" + (testing "too few digits" + (is (nil? nil))) + (testing "too many digits" + (is (nil? nil))) + (testing "one letter" + (is (nil? (case :oh-no!)))) + (testing "two letters" + (is (nil? nil))))) + +(deftest day-names-test-pass + (testing "day names match" + (is (= "Sunday" "Sunday")) + (is (= "Monday" "Monday")) + (is (= "Tuesday" "Tuesday")) + (is (= "Wednesday" "Wednesday")) + (is (= "Thursday" "Thursday")) + (is (= "Friday" "Friday")) + (is (= "Saturday" "Saturday"))) + (testing "day names don't match" + (testing "combined" + (is (nil? nil))) + (testing "short name" + (is (nil? nil))) + (testing "numeric day of the week (0-indexed)" + (is (nil? nil))) + (testing "numeric day of the week (1-indexed)" + (is (nil? nil))))) + +(deftest day-names-test-fail + (testing "day names match" + (is (= "Sunday" "Sunday")) + (is (= "Monday" "Monday")) + (is (= "Tuesday" "Tuesday")) + (is (= "Wednesday" "Wednesday")) + (is (= "Thursday" "Thursday")) + (is (= "Friday" "Friday")) + (is (= "Saturday" "Saturday"))) + (testing "day names don't match" + (testing "combined" + (is (nil? false))) + (testing "short name" + (is (nil? nil))) + (testing "numeric day of the week (0-indexed)" + (is (nil? nil))) + (testing "numeric day of the week (1-indexed)" + (is (nil? nil))))) + +(deftest day-names-test-error + (testing "day names match" + (is (= "Sunday" "Sunday")) + (is (= "Monday" "Monday")) + (is (= "Tuesday" "Tuesday")) + (is (= "Wednesday" "Wednesday")) + (is (= "Thursday" "Thursday")) + (is (= "Friday" "Friday")) + (is (= "Saturday" (assert nil)))) + (testing "day names don't match" + (testing "combined" + (is (nil? nil))) + (testing "short name" + (is (nil? nil))) + (testing "numeric day of the week (0-indexed)" + (is (nil? nil))) + (testing "numeric day of the week (1-indexed)" + (is (nil? nil))))) + +(deftest increment-decrement-and-get-balance-pass + (testing "Taking money out of the account works" + (let [account (atom 0)] + (is (= 0 @account)) + (swap! account + 10) + (is (= 10 @account)) + (swap! account + -10) + (is (= 0 @account))))) + +(deftest increment-decrement-and-get-balance-fail + (testing "Taking money out of the account works" + (let [account (atom 0)] + (is (= 0 @account)) + (swap! account + 10) + (is (= 1000 @account)) + (swap! account + -10) + (is (= 0 @account))))) + +(deftest increment-decrement-and-get-balance-error + (testing "Taking money out of the account works" + (let [account (atom 0)] + (is (= 0 @account)) + (swap! account + 10) + (is (= 10 @@account)) + (swap! account + -10) + (is (= 0 @account))))) + +(deftest largest-series-tests-pass + (testing "can find the largest product of 2 with numbers in order" + (is (= 72 72))) + (testing "can find the largest product of 2" + (is (= 48 48))) + (testing "finds the largest product if span equals length" + (is (= 18 18)))) + +(deftest largest-series-tests-fail + (testing "can find the largest product of 2 with numbers in order" + (is (= 72 "WRONG"))) + (testing "can find the largest product of 2" + (is (= 48 48))) + (testing "finds the largest product if span equals length" + (is (= 18 18)))) + +(deftest largest-series-tests-error + (testing "can find the largest product of 2 with numbers in order" + (is (= 72 72))) + (testing "can find the largest product of 2" + (is (= 48 48))) + (testing "finds the largest product if span equals length" + (is (= 18 (+ :foo))))) + +(deftest is-inside-let-pass + (let [v [1 2 3 4]] + (is (= 4 (count v))) + (is (sequential? v)) + (is (= 2 (second v))))) + +(deftest is-inside-let-fail + (let [v (range 4)] + (is (= 4 (count v))) + (is (sequential? v)) + (is (= 2 (second v))))) + +(deftest is-inside-let-error + (let [v 4] + (is (= 4 (count v))) + (is (sequential? v)) + (is (= 2 (second v))))) diff --git a/tests/example-partial-fail/expected_results.json b/tests/partial-fail/expected_results.json similarity index 100% rename from tests/example-partial-fail/expected_results.json rename to tests/partial-fail/expected_results.json diff --git a/tests/partial-fail/project.clj b/tests/partial-fail/project.clj new file mode 100644 index 0000000..70a196a --- /dev/null +++ b/tests/partial-fail/project.clj @@ -0,0 +1,4 @@ +(defproject leap "0.1.0-SNAPSHOT" + :description "leap exercise." + :url "https://github.com/exercism/clojure/tree/master/exercises/leap" + :dependencies [[org.clojure/clojure "1.10.0"]]) diff --git a/tests/example-partial-fail/src/leap.clj b/tests/partial-fail/src/leap.clj similarity index 95% rename from tests/example-partial-fail/src/leap.clj rename to tests/partial-fail/src/leap.clj index 9614820..876abaf 100644 --- a/tests/example-partial-fail/src/leap.clj +++ b/tests/partial-fail/src/leap.clj @@ -1,6 +1,6 @@ -(ns leap) - -(defn leap-year? [year] - (let [[p c s] (map #(= 0 (rem year %1)) [4 100 401])] - (or (and p (not c)) - (and c s)))) +(ns leap) + +(defn leap-year? [year] + (let [[p c s] (map #(= 0 (rem year %1)) [4 100 401])] + (or (and p (not c)) + (and c s)))) diff --git a/tests/example-all-fail/test/leap_test.clj b/tests/partial-fail/test/leap_test.clj similarity index 96% rename from tests/example-all-fail/test/leap_test.clj rename to tests/partial-fail/test/leap_test.clj index b75ded1..d5851a5 100644 --- a/tests/example-all-fail/test/leap_test.clj +++ b/tests/partial-fail/test/leap_test.clj @@ -1,30 +1,30 @@ -(ns leap-test - (:require [clojure.test :refer [deftest is]] - leap)) - -(deftest year-not-divisible-by-4 - (is (not (leap/leap-year? 2015)))) - -(deftest year-divisible-by-2-but-not-4 - (is (not (leap/leap-year? 1970)))) - -(deftest year-divisible-by-4-but-not-100 - (is (leap/leap-year? 1996))) - -(deftest year-divisible-by-4-and-5 - (is (leap/leap-year? 1960))) - -(deftest year-divisible-by-100-but-not-400 - (is (not (leap/leap-year? 2100)))) - -(deftest year-divisible-by-100-but-not-by-3 - (is (not (leap/leap-year? 1900)))) - -(deftest year-divisible-by-400 - (is (leap/leap-year? 2000))) - -(deftest year-divisible-by-400-but-not-125 - (is (leap/leap-year? 2400))) - -(deftest year-divisible-by-200-but-not-by-400 - (is (not (leap/leap-year? 1800)))) +(ns leap-test + (:require [clojure.test :refer [deftest is]] + leap)) + +(deftest year-not-divisible-by-4 + (is (not (leap/leap-year? 2015)))) + +(deftest year-divisible-by-2-but-not-4 + (is (not (leap/leap-year? 1970)))) + +(deftest year-divisible-by-4-but-not-100 + (is (leap/leap-year? 1996))) + +(deftest year-divisible-by-4-and-5 + (is (leap/leap-year? 1960))) + +(deftest year-divisible-by-100-but-not-400 + (is (not (leap/leap-year? 2100)))) + +(deftest year-divisible-by-100-but-not-by-3 + (is (not (leap/leap-year? 1900)))) + +(deftest year-divisible-by-400 + (is (leap/leap-year? 2000))) + +(deftest year-divisible-by-400-but-not-125 + (is (leap/leap-year? 2400))) + +(deftest year-divisible-by-200-but-not-by-400 + (is (not (leap/leap-year? 1800)))) diff --git a/tests/example-runtime-error/expected_results.json b/tests/runtime-error/expected_results.json similarity index 100% rename from tests/example-runtime-error/expected_results.json rename to tests/runtime-error/expected_results.json diff --git a/tests/runtime-error/project.clj b/tests/runtime-error/project.clj new file mode 100644 index 0000000..70a196a --- /dev/null +++ b/tests/runtime-error/project.clj @@ -0,0 +1,4 @@ +(defproject leap "0.1.0-SNAPSHOT" + :description "leap exercise." + :url "https://github.com/exercism/clojure/tree/master/exercises/leap" + :dependencies [[org.clojure/clojure "1.10.0"]]) diff --git a/tests/example-runtime-error/src/leap.clj b/tests/runtime-error/src/leap.clj similarity index 97% rename from tests/example-runtime-error/src/leap.clj rename to tests/runtime-error/src/leap.clj index 223d3a7..b05d3ed 100644 --- a/tests/example-runtime-error/src/leap.clj +++ b/tests/runtime-error/src/leap.clj @@ -1,8 +1,8 @@ -(ns leap) - -(defn leap-year? [year] - (assert (not= year 1996)) ;; throws AssertionError on the 3rd test - (when (= year 1960) (case :foo)) ;; throws IllegalArgumentException on 4th test - (let [[p c s] (map #(= 0 (rem year %1)) [4 100 400])] - (or (and p (not c)) - (and c s)))) +(ns leap) + +(defn leap-year? [year] + (assert (not= year 1996)) ;; throws AssertionError on the 3rd test + (when (= year 1960) (case :foo)) ;; throws IllegalArgumentException on 4th test + (let [[p c s] (map #(= 0 (rem year %1)) [4 100 400])] + (or (and p (not c)) + (and c s)))) diff --git a/tests/example-runtime-error/test/leap_test.clj b/tests/runtime-error/test/leap_test.clj similarity index 96% rename from tests/example-runtime-error/test/leap_test.clj rename to tests/runtime-error/test/leap_test.clj index bf19a67..ca4a118 100644 --- a/tests/example-runtime-error/test/leap_test.clj +++ b/tests/runtime-error/test/leap_test.clj @@ -1,31 +1,31 @@ -(ns leap-test - (:require [clojure.test :refer [deftest is]] - leap)) - -(deftest year-not-divisible-by-4 - (leap/leap-year?) ;; throws an ex-info - (is (not (leap/leap-year? 2015)))) - -(deftest year-divisible-by-2-but-not-4 - (is (not (leap/leap-year? 1970)))) - -(deftest year-divisible-by-4-but-not-100 - (is (leap/leap-year? 1996))) - -(deftest year-divisible-by-4-and-5 - (is (leap/leap-year? 1960))) - -(deftest year-divisible-by-100-but-not-400 - (is (not (leap/leap-year? 2100)))) - -(deftest year-divisible-by-100-but-not-by-3 - (is (not (leap/leap-year? 1900)))) - -(deftest year-divisible-by-400 - (is (leap/leap-year? 2000))) - -(deftest year-divisible-by-400-but-not-125 - (is (leap/leap-year? 2400))) - -(deftest year-divisible-by-200-but-not-by-400 - (is (not (leap/leap-year? 1800)))) +(ns leap-test + (:require [clojure.test :refer [deftest is]] + leap)) + +(deftest year-not-divisible-by-4 + (leap/leap-year?) ;; throws an ex-info + (is (not (leap/leap-year? 2015)))) + +(deftest year-divisible-by-2-but-not-4 + (is (not (leap/leap-year? 1970)))) + +(deftest year-divisible-by-4-but-not-100 + (is (leap/leap-year? 1996))) + +(deftest year-divisible-by-4-and-5 + (is (leap/leap-year? 1960))) + +(deftest year-divisible-by-100-but-not-400 + (is (not (leap/leap-year? 2100)))) + +(deftest year-divisible-by-100-but-not-by-3 + (is (not (leap/leap-year? 1900)))) + +(deftest year-divisible-by-400 + (is (leap/leap-year? 2000))) + +(deftest year-divisible-by-400-but-not-125 + (is (leap/leap-year? 2400))) + +(deftest year-divisible-by-200-but-not-by-400 + (is (not (leap/leap-year? 1800)))) diff --git a/tests/example-spec/expected_results.json b/tests/spec/expected_results.json similarity index 100% rename from tests/example-spec/expected_results.json rename to tests/spec/expected_results.json diff --git a/tests/spec/project.clj b/tests/spec/project.clj new file mode 100644 index 0000000..70a196a --- /dev/null +++ b/tests/spec/project.clj @@ -0,0 +1,4 @@ +(defproject leap "0.1.0-SNAPSHOT" + :description "leap exercise." + :url "https://github.com/exercism/clojure/tree/master/exercises/leap" + :dependencies [[org.clojure/clojure "1.10.0"]]) diff --git a/tests/example-spec/src/leap.clj b/tests/spec/src/leap.clj similarity index 96% rename from tests/example-spec/src/leap.clj rename to tests/spec/src/leap.clj index 743cc59..bcd6724 100644 --- a/tests/example-spec/src/leap.clj +++ b/tests/spec/src/leap.clj @@ -1,19 +1,19 @@ -(ns leap - (:require [clojure.spec.alpha :as s] - [clojure.spec.gen.alpha :as gen] - [clojure.string :as str])) - -(defn leap-year? [year] - (let [[p c s] (map #(= 0 (rem year %1)) [4 100 400])] - (or (and p (not c)) - (and c s)))) - -(gen/sample (s/gen int?)) - -(s/def ::street (s/and string? (complement str/blank?))) -(s/def ::street-number int?) -(s/def ::address (s/keys :req-un [::street ::street-number])) -(s/def ::name (s/and string? (complement str/blank?))) -(s/def ::contact (s/keys :req-un [::name ::address])) -(gen/sample (s/gen ::contact)) - +(ns leap + (:require [clojure.spec.alpha :as s] + [clojure.spec.gen.alpha :as gen] + [clojure.string :as str])) + +(defn leap-year? [year] + (let [[p c s] (map #(= 0 (rem year %1)) [4 100 400])] + (or (and p (not c)) + (and c s)))) + +(gen/sample (s/gen int?)) + +(s/def ::street (s/and string? (complement str/blank?))) +(s/def ::street-number int?) +(s/def ::address (s/keys :req-un [::street ::street-number])) +(s/def ::name (s/and string? (complement str/blank?))) +(s/def ::contact (s/keys :req-un [::name ::address])) +(gen/sample (s/gen ::contact)) + diff --git a/tests/example-partial-fail/test/leap_test.clj b/tests/spec/test/leap_test.clj similarity index 96% rename from tests/example-partial-fail/test/leap_test.clj rename to tests/spec/test/leap_test.clj index b75ded1..d5851a5 100644 --- a/tests/example-partial-fail/test/leap_test.clj +++ b/tests/spec/test/leap_test.clj @@ -1,30 +1,30 @@ -(ns leap-test - (:require [clojure.test :refer [deftest is]] - leap)) - -(deftest year-not-divisible-by-4 - (is (not (leap/leap-year? 2015)))) - -(deftest year-divisible-by-2-but-not-4 - (is (not (leap/leap-year? 1970)))) - -(deftest year-divisible-by-4-but-not-100 - (is (leap/leap-year? 1996))) - -(deftest year-divisible-by-4-and-5 - (is (leap/leap-year? 1960))) - -(deftest year-divisible-by-100-but-not-400 - (is (not (leap/leap-year? 2100)))) - -(deftest year-divisible-by-100-but-not-by-3 - (is (not (leap/leap-year? 1900)))) - -(deftest year-divisible-by-400 - (is (leap/leap-year? 2000))) - -(deftest year-divisible-by-400-but-not-125 - (is (leap/leap-year? 2400))) - -(deftest year-divisible-by-200-but-not-by-400 - (is (not (leap/leap-year? 1800)))) +(ns leap-test + (:require [clojure.test :refer [deftest is]] + leap)) + +(deftest year-not-divisible-by-4 + (is (not (leap/leap-year? 2015)))) + +(deftest year-divisible-by-2-but-not-4 + (is (not (leap/leap-year? 1970)))) + +(deftest year-divisible-by-4-but-not-100 + (is (leap/leap-year? 1996))) + +(deftest year-divisible-by-4-and-5 + (is (leap/leap-year? 1960))) + +(deftest year-divisible-by-100-but-not-400 + (is (not (leap/leap-year? 2100)))) + +(deftest year-divisible-by-100-but-not-by-3 + (is (not (leap/leap-year? 1900)))) + +(deftest year-divisible-by-400 + (is (leap/leap-year? 2000))) + +(deftest year-divisible-by-400-but-not-125 + (is (leap/leap-year? 2400))) + +(deftest year-divisible-by-200-but-not-by-400 + (is (not (leap/leap-year? 1800)))) diff --git a/tests/example-success/expected_results.json b/tests/success/expected_results.json similarity index 100% rename from tests/example-success/expected_results.json rename to tests/success/expected_results.json diff --git a/tests/success/project.clj b/tests/success/project.clj new file mode 100644 index 0000000..70a196a --- /dev/null +++ b/tests/success/project.clj @@ -0,0 +1,4 @@ +(defproject leap "0.1.0-SNAPSHOT" + :description "leap exercise." + :url "https://github.com/exercism/clojure/tree/master/exercises/leap" + :dependencies [[org.clojure/clojure "1.10.0"]]) diff --git a/tests/example-success/src/leap.clj b/tests/success/src/leap.clj similarity index 95% rename from tests/example-success/src/leap.clj rename to tests/success/src/leap.clj index 30097b6..d6713f9 100644 --- a/tests/example-success/src/leap.clj +++ b/tests/success/src/leap.clj @@ -1,6 +1,6 @@ -(ns leap) - -(defn leap-year? [year] - (let [[p c s] (map #(= 0 (rem year %1)) [4 100 400])] - (or (and p (not c)) - (and c s)))) +(ns leap) + +(defn leap-year? [year] + (let [[p c s] (map #(= 0 (rem year %1)) [4 100 400])] + (or (and p (not c)) + (and c s)))) diff --git a/tests/success/test/leap_test.clj b/tests/success/test/leap_test.clj new file mode 100644 index 0000000..d5851a5 --- /dev/null +++ b/tests/success/test/leap_test.clj @@ -0,0 +1,30 @@ +(ns leap-test + (:require [clojure.test :refer [deftest is]] + leap)) + +(deftest year-not-divisible-by-4 + (is (not (leap/leap-year? 2015)))) + +(deftest year-divisible-by-2-but-not-4 + (is (not (leap/leap-year? 1970)))) + +(deftest year-divisible-by-4-but-not-100 + (is (leap/leap-year? 1996))) + +(deftest year-divisible-by-4-and-5 + (is (leap/leap-year? 1960))) + +(deftest year-divisible-by-100-but-not-400 + (is (not (leap/leap-year? 2100)))) + +(deftest year-divisible-by-100-but-not-by-3 + (is (not (leap/leap-year? 1900)))) + +(deftest year-divisible-by-400 + (is (leap/leap-year? 2000))) + +(deftest year-divisible-by-400-but-not-125 + (is (leap/leap-year? 2400))) + +(deftest year-divisible-by-200-but-not-by-400 + (is (not (leap/leap-year? 1800)))) diff --git a/tests/syntax-error/expected_results.json b/tests/syntax-error/expected_results.json new file mode 100644 index 0000000..66ed517 --- /dev/null +++ b/tests/syntax-error/expected_results.json @@ -0,0 +1,5 @@ +{ + "version": 3, + "status": "error", + "message": "----- Error --------------------------------------------------------------------\nType: java.lang.Exception\nMessage: No reader function for tag leap\nLocation: /opt/test-runner/tests/syntax-error/test/leap_test.clj:2:3\n\n----- Context ------------------------------------------------------------------\n1: (ns leap-test\n2: (:require [clojure.test :refer [deftest is]]\n ^--- No reader function for tag leap\n3: leap))\n4: \n5: (deftest year-not-divisible-by-4\n6: (is (not (leap/leap-year? 2015))))\n7: \n\n----- Stack trace --------------------------------------------------------------\nedamame.impl.parser/parse-sharp - \nedamame.impl.parser/dispatch - \nedamame.impl.parser/parse-next - \nedamame.impl.parser/dispatch - \nedamame.impl.parser/parse-next - \n... (run with --debug to see elided elements)\nedamame.impl.parser/dispatch - \nedamame.impl.parser/parse-next - \nedamame.core/parse-next - \nleap-test - /opt/test-runner/tests/syntax-error/test/leap_test.clj:2:3\nuser - /opt/test-runner/./test-runner.clj:19:1" +} diff --git a/tests/syntax-error/project.clj b/tests/syntax-error/project.clj new file mode 100644 index 0000000..70a196a --- /dev/null +++ b/tests/syntax-error/project.clj @@ -0,0 +1,4 @@ +(defproject leap "0.1.0-SNAPSHOT" + :description "leap exercise." + :url "https://github.com/exercism/clojure/tree/master/exercises/leap" + :dependencies [[org.clojure/clojure "1.10.0"]]) diff --git a/tests/example-syntax-error/src/leap.clj b/tests/syntax-error/src/leap.clj similarity index 93% rename from tests/example-syntax-error/src/leap.clj rename to tests/syntax-error/src/leap.clj index 4ac4bc7..a2720e9 100644 --- a/tests/example-syntax-error/src/leap.clj +++ b/tests/syntax-error/src/leap.clj @@ -1,3 +1,3 @@ -(ns@#@# leap) - -(defnEWEQw leap-year? [year] +(ns@#@# leap) + +(defnEWEQw leap-year? [year] diff --git a/tests/syntax-error/test/leap_test.clj b/tests/syntax-error/test/leap_test.clj new file mode 100644 index 0000000..d5851a5 --- /dev/null +++ b/tests/syntax-error/test/leap_test.clj @@ -0,0 +1,30 @@ +(ns leap-test + (:require [clojure.test :refer [deftest is]] + leap)) + +(deftest year-not-divisible-by-4 + (is (not (leap/leap-year? 2015)))) + +(deftest year-divisible-by-2-but-not-4 + (is (not (leap/leap-year? 1970)))) + +(deftest year-divisible-by-4-but-not-100 + (is (leap/leap-year? 1996))) + +(deftest year-divisible-by-4-and-5 + (is (leap/leap-year? 1960))) + +(deftest year-divisible-by-100-but-not-400 + (is (not (leap/leap-year? 2100)))) + +(deftest year-divisible-by-100-but-not-by-3 + (is (not (leap/leap-year? 1900)))) + +(deftest year-divisible-by-400 + (is (leap/leap-year? 2000))) + +(deftest year-divisible-by-400-but-not-125 + (is (leap/leap-year? 2400))) + +(deftest year-divisible-by-200-but-not-by-400 + (is (not (leap/leap-year? 1800)))) diff --git a/tests/example-test-metadata/expected_results.json b/tests/test-metadata/expected_results.json similarity index 100% rename from tests/example-test-metadata/expected_results.json rename to tests/test-metadata/expected_results.json diff --git a/tests/example-test-metadata/project.clj b/tests/test-metadata/project.clj similarity index 100% rename from tests/example-test-metadata/project.clj rename to tests/test-metadata/project.clj diff --git a/tests/example-test-metadata/src/tracks_on_tracks_on_tracks.clj b/tests/test-metadata/src/tracks_on_tracks_on_tracks.clj similarity index 100% rename from tests/example-test-metadata/src/tracks_on_tracks_on_tracks.clj rename to tests/test-metadata/src/tracks_on_tracks_on_tracks.clj diff --git a/tests/example-test-metadata/test/leap_test.clj b/tests/test-metadata/test/leap_test.clj similarity index 100% rename from tests/example-test-metadata/test/leap_test.clj rename to tests/test-metadata/test/leap_test.clj