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
4 changes: 2 additions & 2 deletions exercises/practice/robot-simulator/.meta/generator.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
robot-simulator))

{{#test_cases.create}}
(deftest robot_test_{{idx}}
(deftest ^:robot robot_test_{{idx}}
(testing {{context}}
(let [molly (robot-simulator/robot {:x {{input.position.x}} :y {{input.position.y}} } {{input.direction}})]
(is (= {:bearing {{expected.direction}} :coordinates {:x {{expected.position.x}} :y {{expected.position.y}} }}
molly)))))
{{/test_cases.create}}

{{#test_cases.move}}
(deftest simulate_test_{{idx}}
(deftest ^:simulate simulate_test_{{idx}}
(testing {{context}}
(let [molly (robot-simulator/robot {:x {{input.position.x}} :y {{input.position.y}} } {{input.direction}})]
(is (= {:bearing {{expected.direction}} :coordinates {:x {{expected.position.x}} :y {{expected.position.y}} }}
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/robot-simulator/project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
(defproject robot-simulator "0.1.0-SNAPSHOT"
:description "robot-simulator exercise."
:url "https://github.com/exercism/clojure/tree/main/exercises/practice/robot-simulator"
:dependencies [[org.clojure/clojure "1.12.0"]])
:dependencies [[org.clojure/clojure "1.12.0"]]
:test-selectors {:robot :robot
:simulate :simulate})
36 changes: 18 additions & 18 deletions exercises/practice/robot-simulator/test/robot_simulator_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,109 +2,109 @@
(:require [clojure.test :refer [deftest testing is]]
robot-simulator))

(deftest robot_test_1
(deftest ^:robot robot_test_1
(testing "Create robot ▶ at origin facing north"
(let [molly (robot-simulator/robot {:x 0 :y 0} :north)]
(is (= {:bearing :north :coordinates {:x 0 :y 0}}
molly)))))

(deftest robot_test_2
(deftest ^:robot robot_test_2
(testing "Create robot ▶ at negative position facing south"
(let [molly (robot-simulator/robot {:x -1 :y -1} :south)]
(is (= {:bearing :south :coordinates {:x -1 :y -1}}
molly)))))

(deftest simulate_test_1
(deftest ^:simulate simulate_test_1
(testing "Rotating clockwise ▶ changes north to east"
(let [molly (robot-simulator/robot {:x 0 :y 0} :north)]
(is (= {:bearing :east :coordinates {:x 0 :y 0}}
(robot-simulator/simulate "R" molly))))))

(deftest simulate_test_2
(deftest ^:simulate simulate_test_2
(testing "Rotating clockwise ▶ changes east to south"
(let [molly (robot-simulator/robot {:x 0 :y 0} :east)]
(is (= {:bearing :south :coordinates {:x 0 :y 0}}
(robot-simulator/simulate "R" molly))))))

(deftest simulate_test_3
(deftest ^:simulate simulate_test_3
(testing "Rotating clockwise ▶ changes south to west"
(let [molly (robot-simulator/robot {:x 0 :y 0} :south)]
(is (= {:bearing :west :coordinates {:x 0 :y 0}}
(robot-simulator/simulate "R" molly))))))

(deftest simulate_test_4
(deftest ^:simulate simulate_test_4
(testing "Rotating clockwise ▶ changes west to north"
(let [molly (robot-simulator/robot {:x 0 :y 0} :west)]
(is (= {:bearing :north :coordinates {:x 0 :y 0}}
(robot-simulator/simulate "R" molly))))))

(deftest simulate_test_5
(deftest ^:simulate simulate_test_5
(testing "Rotating counter-clockwise ▶ changes north to west"
(let [molly (robot-simulator/robot {:x 0 :y 0} :north)]
(is (= {:bearing :west :coordinates {:x 0 :y 0}}
(robot-simulator/simulate "L" molly))))))

(deftest simulate_test_6
(deftest ^:simulate simulate_test_6
(testing "Rotating counter-clockwise ▶ changes west to south"
(let [molly (robot-simulator/robot {:x 0 :y 0} :west)]
(is (= {:bearing :south :coordinates {:x 0 :y 0}}
(robot-simulator/simulate "L" molly))))))

(deftest simulate_test_7
(deftest ^:simulate simulate_test_7
(testing "Rotating counter-clockwise ▶ changes south to east"
(let [molly (robot-simulator/robot {:x 0 :y 0} :south)]
(is (= {:bearing :east :coordinates {:x 0 :y 0}}
(robot-simulator/simulate "L" molly))))))

(deftest simulate_test_8
(deftest ^:simulate simulate_test_8
(testing "Rotating counter-clockwise ▶ changes east to north"
(let [molly (robot-simulator/robot {:x 0 :y 0} :east)]
(is (= {:bearing :north :coordinates {:x 0 :y 0}}
(robot-simulator/simulate "L" molly))))))

(deftest simulate_test_9
(deftest ^:simulate simulate_test_9
(testing "Moving forward one ▶ facing north increments Y"
(let [molly (robot-simulator/robot {:x 0 :y 0} :north)]
(is (= {:bearing :north :coordinates {:x 0 :y 1}}
(robot-simulator/simulate "A" molly))))))

(deftest simulate_test_10
(deftest ^:simulate simulate_test_10
(testing "Moving forward one ▶ facing south decrements Y"
(let [molly (robot-simulator/robot {:x 0 :y 0} :south)]
(is (= {:bearing :south :coordinates {:x 0 :y -1}}
(robot-simulator/simulate "A" molly))))))

(deftest simulate_test_11
(deftest ^:simulate simulate_test_11
(testing "Moving forward one ▶ facing east increments X"
(let [molly (robot-simulator/robot {:x 0 :y 0} :east)]
(is (= {:bearing :east :coordinates {:x 1 :y 0}}
(robot-simulator/simulate "A" molly))))))

(deftest simulate_test_12
(deftest ^:simulate simulate_test_12
(testing "Moving forward one ▶ facing west decrements X"
(let [molly (robot-simulator/robot {:x 0 :y 0} :west)]
(is (= {:bearing :west :coordinates {:x -1 :y 0}}
(robot-simulator/simulate "A" molly))))))

(deftest simulate_test_13
(deftest ^:simulate simulate_test_13
(testing "Follow series of instructions ▶ moving east and north from README"
(let [molly (robot-simulator/robot {:x 7 :y 3} :north)]
(is (= {:bearing :west :coordinates {:x 9 :y 4}}
(robot-simulator/simulate "RAALAL" molly))))))

(deftest simulate_test_14
(deftest ^:simulate simulate_test_14
(testing "Follow series of instructions ▶ moving west and north"
(let [molly (robot-simulator/robot {:x 0 :y 0} :north)]
(is (= {:bearing :west :coordinates {:x -4 :y 1}}
(robot-simulator/simulate "LAAARALA" molly))))))

(deftest simulate_test_15
(deftest ^:simulate simulate_test_15
(testing "Follow series of instructions ▶ moving west and south"
(let [molly (robot-simulator/robot {:x 2 :y -7} :east)]
(is (= {:bearing :south :coordinates {:x -3 :y -8}}
(robot-simulator/simulate "RRAAAAALA" molly))))))

(deftest simulate_test_16
(deftest ^:simulate simulate_test_16
(testing "Follow series of instructions ▶ moving east and north"
(let [molly (robot-simulator/robot {:x 8 :y 4} :south)]
(is (= {:bearing :north :coordinates {:x 11 :y 5}}
Expand Down
Loading