Skip to content

Commit 276bfbf

Browse files
committed
Fix robot-name tests
1 parent 78c1ed5 commit 276bfbf

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

exercises/practice/robot-name/robot-name-test.rkt

+13-13
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
(define max-names (* 26 26 10 10 10))
1111

12-
(define proper-robot-name #px"\\p{Lu}{2}\\p{Nd}{3}")
12+
(define proper-robot-name #px"^\\p{Lu}{2}\\p{Nd}{3}$")
1313

1414
(define (check-proper-robot-name r)
1515
(check-regexp-match proper-robot-name (name r)))
@@ -28,20 +28,20 @@
2828
[name1 (name robby)]
2929
[_ (reset! robby)]
3030
[name2 (name robby)])
31-
(and
32-
(and (check-regexp-match proper-robot-name name1)
33-
(check-regexp-match proper-robot-name name2))
34-
(not (string=? name1 name2)))))
31+
(check-regexp-match proper-robot-name name1)
32+
(check-regexp-match proper-robot-name name2)
33+
(check-not-equal? name1 name2)))
3534

3635
;; reset cache in order to generate all the names
3736
(test-case
3837
"Check that robots are created with unique names."
39-
(begin
38+
(let ([count (/ max-names 4)])
4039
(reset-name-cache!)
41-
(= max-names
42-
(let ([names (make-hash)])
43-
(for ((_ (in-range (/ max-names 4))))
44-
(hash-set! names (name (make-robot)) #t))
45-
(hash-count names)))))))
46-
47-
(run-tests robot-name-suite))
40+
(check-equal?
41+
(let ([names (make-hash)])
42+
(for ((_ (in-range count)))
43+
(hash-set! names (name (make-robot)) #t))
44+
(hash-count names))
45+
count)))))
46+
47+
(run-tests robot-name-suite))

0 commit comments

Comments
 (0)