Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions exercises/practice/list-ops/.meta/generator.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,53 @@
list-ops))

{{#test_cases.append}}
(deftest append_test_{{idx}}
(deftest ^:append append_test_{{idx}}
(testing {{context}}
(is (= {{expected}}
(list-ops/append {{input.list1}} {{input.list2}})))))
{{/test_cases.append}}

{{#test_cases.concat}}
(deftest concatenate_test_{{idx}}
(deftest ^:concatenate concatenate_test_{{idx}}
(testing {{context}}
(is (= {{expected}}
(list-ops/concatenate {{input.lists}})))))
{{/test_cases.concat}}

{{#test_cases.filter}}
(deftest select-if_test_{{idx}}
(deftest ^:select-if select-if_test_{{idx}}
(testing {{context}}
(is (= {{expected}}
(list-ops/select-if {{input.function}} {{input.list}})))))
{{/test_cases.filter}}

{{#test_cases.length}}
(deftest length_test_{{idx}}
(deftest ^:length length_test_{{idx}}
(testing {{context}}
(is (= {{expected}} (list-ops/length {{input.list}})))))
{{/test_cases.length}}

{{#test_cases.map}}
(deftest apply-to-each_test_{{idx}}
(deftest ^:apply-to-each apply-to-each_test_{{idx}}
(testing {{context}}
(is (= {{expected}}
(list-ops/apply-to-each {{input.function}} {{input.list}})))))
{{/test_cases.map}}

{{#test_cases.foldl}}
(deftest foldl_test_{{idx}}
(deftest ^:foldl foldl_test_{{idx}}
(testing {{context}}
(is (= {{expected}} (list-ops/foldl {{input.function}} {{input.list}} {{input.initial}})))))
{{/test_cases.foldl}}

{{#test_cases.foldr}}
(deftest foldr_test_{{idx}}
(deftest ^:foldr foldr_test_{{idx}}
(testing {{context}}
(is (= {{expected}} (list-ops/foldr {{input.function}} {{input.list}} {{input.initial}})))))
{{/test_cases.foldr}}

{{#test_cases.reverse}}
(deftest reverse-order_test_{{idx}}
(deftest ^:reverse-order reverse-order_test_{{idx}}
(testing {{context}}
(is (= {{expected}}
(list-ops/reverse-order {{input.list}})))))
Expand Down
10 changes: 9 additions & 1 deletion exercises/practice/list-ops/project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
(defproject list-ops "0.1.0-SNAPSHOT"
:description "list-ops exercise."
:url "https://github.com/exercism/clojure/tree/main/exercises/list-ops"
:dependencies [[org.clojure/clojure "1.12.0"]])
:dependencies [[org.clojure/clojure "1.12.0"]]
:test-selectors {:append :append
:concatenate :concatenate
:select-if :select-if
:length :length
:apply-to-each :apply-to-each
:foldl :foldl
:foldr :foldr
:reverse-order :reverse-order})
44 changes: 22 additions & 22 deletions exercises/practice/list-ops/test/list_ops_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,104 +2,104 @@
(:require [clojure.test :refer [deftest testing is]]
list-ops))

(deftest append_test_1
(deftest ^:append append_test_1
(testing "Append ▶ empty vectors"
(is (= []
(list-ops/append [] [])))))

(deftest append_test_2
(deftest ^:append append_test_2
(testing "Append ▶ vector to empty vector"
(is (= [1 2 3 4]
(list-ops/append [] [1 2 3 4])))))

(deftest append_test_3
(deftest ^:append append_test_3
(testing "Append ▶ empty vector to vector"
(is (= [1 2 3 4]
(list-ops/append [1 2 3 4] [])))))

(deftest append_test_4
(deftest ^:append append_test_4
(testing "Append ▶ non-empty vectors"
(is (= [1 2 2 3 4 5]
(list-ops/append [1 2] [2 3 4 5])))))

(deftest concatenate_test_1
(deftest ^:concatenate concatenate_test_1
(testing "Concatenate ▶ empty vector"
(is (= []
(list-ops/concatenate [])))))

(deftest concatenate_test_2
(deftest ^:concatenate concatenate_test_2
(testing "Concatenate ▶ vector of vectors"
(is (= [1 2 3 4 5 6]
(list-ops/concatenate [[1 2] [3] [] [4 5 6]])))))

(deftest concatenate_test_3
(deftest ^:concatenate concatenate_test_3
(testing "Concatenate ▶ vector of nested vectors"
(is (= [[1] [2] [3] [] [4 5 6]]
(list-ops/concatenate [[[1] [2]] [[3]] [[]] [[4 5 6]]])))))

(deftest select-if_test_1
(deftest ^:select-if select-if_test_1
(testing "Filter ▶ empty vector"
(is (= []
(list-ops/select-if odd? [])))))

(deftest select-if_test_2
(deftest ^:select-if select-if_test_2
(testing "Filter ▶ non-empty vector"
(is (= [1 3 5]
(list-ops/select-if odd? [1 2 3 5])))))

(deftest length_test_1
(deftest ^:length length_test_1
(testing "Length ▶ empty vector"
(is (= 0 (list-ops/length [])))))

(deftest length_test_2
(deftest ^:length length_test_2
(testing "Length ▶ non-empty vector"
(is (= 4 (list-ops/length [1 2 3 4])))))

(deftest apply-to-each_test_1
(deftest ^:apply-to-each apply-to-each_test_1
(testing "Map ▶ empty vector"
(is (= []
(list-ops/apply-to-each inc [])))))

(deftest apply-to-each_test_2
(deftest ^:apply-to-each apply-to-each_test_2
(testing "Map ▶ non-empty vector"
(is (= [2 4 6 8]
(list-ops/apply-to-each inc [1 3 5 7])))))

(deftest foldl_test_1
(deftest ^:foldl foldl_test_1
(testing "Foldl ▶ empty vector"
(is (= 2 (list-ops/foldl (fn [acc el] (* el acc)) [] 2)))))

(deftest foldl_test_2
(deftest ^:foldl foldl_test_2
(testing "Foldl ▶ direction independent function applied to non-empty vector"
(is (= 15 (list-ops/foldl (fn [acc el] (+ el acc)) [1 2 3 4] 5)))))

(deftest foldl_test_3
(deftest ^:foldl foldl_test_3
(testing "Foldl ▶ direction dependent function applied to non-empty vector"
(is (= 64 (list-ops/foldl (fn [acc el] (/ el acc)) [1 2 3 4] 24)))))

(deftest foldr_test_1
(deftest ^:foldr foldr_test_1
(testing "Foldr ▶ empty vector"
(is (= 2 (list-ops/foldr (fn [acc el] (* el acc)) [] 2)))))

(deftest foldr_test_2
(deftest ^:foldr foldr_test_2
(testing "Foldr ▶ direction independent function applied to non-empty vector"
(is (= 15 (list-ops/foldr (fn [acc el] (+ el acc)) [1 2 3 4] 5)))))

(deftest foldr_test_3
(deftest ^:foldr foldr_test_3
(testing "Foldr ▶ direction dependent function applied to non-empty vector"
(is (= 9 (list-ops/foldr (fn [acc el] (/ el acc)) [1 2 3 4] 24)))))

(deftest reverse-order_test_1
(deftest ^:reverse-order reverse-order_test_1
(testing "Reverse ▶ empty vector"
(is (= []
(list-ops/reverse-order [])))))

(deftest reverse-order_test_2
(deftest ^:reverse-order reverse-order_test_2
(testing "Reverse ▶ non-empty vector"
(is (= [7 5 3 1]
(list-ops/reverse-order [1 3 5 7])))))

(deftest reverse-order_test_3
(deftest ^:reverse-order reverse-order_test_3
(testing "Reverse ▶ vector of vectors is not flattened"
(is (= [[4 5 6] [] [3] [1 2]]
(list-ops/reverse-order [[1 2] [3] [] [4 5 6]])))))
Loading