Refactor(English): Rename all files and identifiers from Dutch to English
Renamed files: constanten→constants, adt-positie→adt-position, adt-doolhof→adt-maze, adt-sleutel→adt-key, adt-tijdslimiet→adt-timer, adt-teken→adt-draw, adt-spel→adt-game. All message names, variables, comments, and tests converted to English. Also fixed counter location bug (time-label x/y were swapped). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
55
pacman-project/tests/test-timer.rkt
Normal file
55
pacman-project/tests/test-timer.rkt
Normal file
@@ -0,0 +1,55 @@
|
||||
#lang r7rs
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Tests: Timer ADT ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(define-library (pacman-project tests test-timer)
|
||||
(import (scheme base)
|
||||
(pp1 tests)
|
||||
(pacman-project adt-timer))
|
||||
(export test)
|
||||
|
||||
(begin
|
||||
|
||||
;; Test initial time
|
||||
(define (test-initial)
|
||||
(define t (make-timer))
|
||||
(check-eq? (t 'remaining-time) 60 "Initial time should be 60 seconds")
|
||||
(check (not ((t 'time-up?))) "Time should not be up at start"))
|
||||
|
||||
;; Test decrease after 1 second
|
||||
(define (test-decrease)
|
||||
(define t (make-timer))
|
||||
((t 'decrease!) 1000)
|
||||
(check-eq? (t 'remaining-time) 59 "Time should be 59 after 1 second"))
|
||||
|
||||
;; Test increase (coin bonus)
|
||||
(define (test-increase)
|
||||
(define t (make-timer))
|
||||
((t 'decrease!) 1000)
|
||||
((t 'increase!))
|
||||
(check-eq? (t 'remaining-time) 60 "Time should be 60 after decrease + increase"))
|
||||
|
||||
;; Test format-time
|
||||
(define (test-format)
|
||||
(define t (make-timer))
|
||||
(check-eq? ((t 'format-time)) "1:00" "60 seconds = 1:00")
|
||||
((t 'decrease!) 1000)
|
||||
(check-eq? ((t 'format-time)) "0:59" "59 seconds = 0:59"))
|
||||
|
||||
;; Test time-up?
|
||||
(define (test-time-up)
|
||||
(define t (make-timer))
|
||||
;; Decrease 60 times by 1 second
|
||||
(do ((i 0 (+ i 1)))
|
||||
((= i 60))
|
||||
((t 'decrease!) 1000))
|
||||
(check ((t 'time-up?)) "Time should be up after 60 seconds"))
|
||||
|
||||
(define (test)
|
||||
(run-test test-initial "Timer: initial time")
|
||||
(run-test test-decrease "Timer: decrease")
|
||||
(run-test test-increase "Timer: increase")
|
||||
(run-test test-format "Timer: format-time")
|
||||
(run-test test-time-up "Timer: time-up?"))))
|
||||
Reference in New Issue
Block a user