From 7e3d67c9c59ecb74da7c48509fd239af41bc9379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20=22phoe=22=20Herda?= Date: Sat, 9 May 2020 11:04:40 +0200 Subject: [PATCH] Obviously another fix was necessary --- koans-solved/dice-project.lisp | 19 +++++++++---------- koans/dice-project.lisp | 17 ++++++++--------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/koans-solved/dice-project.lisp b/koans-solved/dice-project.lisp index bc26513b..e73ef66f 100644 --- a/koans-solved/dice-project.lisp +++ b/koans-solved/dice-project.lisp @@ -26,10 +26,10 @@ ;; (defmethod dice-values ((object dice-set)) ;; ____) -(defmethod roll ((count integer) (object dice-set)) +(defmethod roll (count (object dice-set)) (check-type count (integer 1)) (setf (dice-values object) - (loop repeat count collect (random 6)))) + (loop repeat count collect (1+ (random 6))))) (define-test make-dice-set (let ((dice (make-instance 'dice-set))) @@ -78,7 +78,7 @@ (define-test junk-as-dice-count (let ((dice (make-instance 'dice-set))) (labels ((dice-failure (count) - (handler-case (progn (roll-dice count dice) + (handler-case (progn (roll count dice) (error "Test failure")) (error (condition) condition))) (test-dice-failure (value) @@ -86,11 +86,10 @@ (expected-type (type-error-expected-type condition))) (assert-true (typep condition 'type-error)) (assert-equal value (type-error-datum condition)) - (assert-true (subtypep expected-type '(integer 1 6))) (assert-true (subtypep '(integer 1 6) expected-type))))) - (dice-failure 0) - (dice-failure "0") - (dice-failure :zero) - (dice-failure 18.0) - (dice-failure -7) - (dice-failure '(6 6 6))))) + (test-dice-failure 0) + (test-dice-failure "0") + (test-dice-failure :zero) + (test-dice-failure 18.0) + (test-dice-failure -7) + (test-dice-failure '(6 6 6))))) diff --git a/koans/dice-project.lisp b/koans/dice-project.lisp index ea6e7b0c..d48f72b9 100644 --- a/koans/dice-project.lisp +++ b/koans/dice-project.lisp @@ -26,7 +26,7 @@ (defmethod dice-values ((object dice-set)) ____) -(defmethod roll ((count integer) (object dice-set)) +(defmethod roll (count (object dice-set)) ____) (define-test make-dice-set @@ -76,7 +76,7 @@ (define-test junk-as-dice-count (let ((dice (make-instance 'dice-set))) (labels ((dice-failure (count) - (handler-case (progn (roll-dice count dice) + (handler-case (progn (roll count dice) (error "Test failure")) (error (condition) condition))) (test-dice-failure (value) @@ -84,11 +84,10 @@ (expected-type (type-error-expected-type condition))) (assert-true (typep condition 'type-error)) (assert-equal value (type-error-datum condition)) - (assert-true (subtypep expected-type '(integer 1 6))) (assert-true (subtypep '(integer 1 6) expected-type))))) - (dice-failure 0) - (dice-failure "0") - (dice-failure :zero) - (dice-failure 18.0) - (dice-failure -7) - (dice-failure '(6 6 6))))) + (test-dice-failure 0) + (test-dice-failure "0") + (test-dice-failure :zero) + (test-dice-failure 18.0) + (test-dice-failure -7) + (test-dice-failure '(6 6 6)))))