File tree 1 file changed +13
-13
lines changed
exercises/practice/robot-name
1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change 9
9
10
10
(define max-names (* 26 26 10 10 10 ))
11
11
12
- (define proper-robot-name #px"\\p{Lu}{2}\\p{Nd}{3} " )
12
+ (define proper-robot-name #px"^ \\p{Lu}{2}\\p{Nd}{3}$ " )
13
13
14
14
(define (check-proper-robot-name r)
15
15
(check-regexp-match proper-robot-name (name r)))
28
28
[name1 (name robby)]
29
29
[_ (reset! robby)]
30
30
[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)))
35
34
36
35
;; reset cache in order to generate all the names
37
36
(test-case
38
37
"Check that robots are created with unique names. "
39
- (begin
38
+ (let ([count (/ max-names 4 )])
40
39
(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))
You can’t perform that action at this time.
0 commit comments