Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

two-fer: add generator and regenerate tests #733

Merged
merged 2 commits into from
Jan 13, 2025
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
8 changes: 8 additions & 0 deletions exercises/practice/two-fer/.meta/generator.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(ns two-fer-test
(:require [clojure.test :refer [deftest testing is]]
two-fer))
{{#test_cases.twoFer}}
(deftest two-fer_test_{{idx}}
(testing "{{description}}"
(is (= "{{expected}}" (two-fer/two-fer{{#input.name}} "{{input.name}}"{{/input.name}})))))
{{/test_cases.twoFer~}}
8 changes: 5 additions & 3 deletions exercises/practice/two-fer/src/two_fer.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
(ns two-fer)

(defn two-fer [name] ;; <- arglist goes here
;; your code goes here
)
(defn two-fer
"Return what you will say as you give away the extra cookie"
[name]
;; function body
)
17 changes: 10 additions & 7 deletions exercises/practice/two-fer/test/two_fer_test.clj
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
(ns two-fer-test
(:require [clojure.test :refer [deftest is]]
(:require [clojure.test :refer [deftest testing is]]
two-fer))

(deftest two-fer-test
(is (= "One for you, one for me." (two-fer/two-fer))))
(deftest two-fer_test_1
(testing "no name given"
(is (= "One for you, one for me." (two-fer/two-fer)))))

(deftest name-alice-test
(is (= "One for Alice, one for me." (two-fer/two-fer "Alice"))))
(deftest two-fer_test_2
(testing "a name given"
(is (= "One for Alice, one for me." (two-fer/two-fer "Alice")))))

(deftest name-bob-test
(is (= "One for Bob, one for me." (two-fer/two-fer "Bob"))))
(deftest two-fer_test_3
(testing "another name given"
(is (= "One for Bob, one for me." (two-fer/two-fer "Bob")))))