Skip to content

Commit

Permalink
Closes #108.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvanhorn committed Dec 8, 2022
1 parent ce080a4 commit fc31655
Show file tree
Hide file tree
Showing 14 changed files with 99 additions and 14 deletions.
20 changes: 18 additions & 2 deletions langs/loot/test/interp-defun.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,21 @@
"../interp-defun.rkt"
"../interp-io.rkt")

(test-runner (λ p (interp (parse p))))
(test-runner-io (λ (s . p) (interp/io (parse p) s)))
(define (closure->proc xs e r)
;; Could make this better by calling the interpreter,
;; but it's only used in tests where all we care about
;; is that you get a procedure.
(lambda _
(error "This function is not callable.")))

(test-runner
(λ p
(match (interp (parse p))
[(Closure xs e r) (closure->proc xs e r)]
[v v])))
(test-runner-io
(λ (s . p)
(match (interp/io (parse p) s)
[(cons (Closure xs e r) o)
(cons (closure->proc xs e r) o)]
[r r])))
3 changes: 2 additions & 1 deletion langs/loot/test/test-runner.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@
(check-equal? (run '(match (box 1) [(box x) x] [_ 2]))
1)

;; Loot examples
;; Loot examples
(check-true (procedure? (run '(λ (x) x))))
(check-equal? (run '((λ (x) x) 5))
5)

Expand Down
5 changes: 4 additions & 1 deletion langs/loot/unload-bits-asm.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
(string)
(build-string (heap-ref i)
(lambda (j)
(char-ref (+ i 8) j))))]))
(char-ref (+ i 8) j))))]
[(? proc-bits? i)
(lambda _
(error "This function is not callable."))]))

(define (untag i)
(arithmetic-shift (arithmetic-shift i (- (integer-length ptr-mask)))
Expand Down
20 changes: 18 additions & 2 deletions langs/mountebank/test/interp-defun.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,21 @@
"../interp-defun.rkt"
"../interp-io.rkt")

(test-runner (λ p (interp (parse p))))
(test-runner-io (λ (s . p) (interp/io (parse p) s)))
(define (closure->proc xs e r)
;; Could make this better by calling the interpreter,
;; but it's only used in tests where all we care about
;; is that you get a procedure.
(lambda _
(error "This function is not callable.")))

(test-runner
(λ p
(match (interp (parse p))
[(Closure xs e r) (closure->proc xs e r)]
[v v])))
(test-runner-io
(λ (s . p)
(match (interp/io (parse p) s)
[(cons (Closure xs e r) o)
(cons (closure->proc xs e r) o)]
[r r])))
3 changes: 2 additions & 1 deletion langs/mountebank/test/test-runner.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@
(check-equal? (run '(match (box 1) [(box x) x] [_ 2]))
1)

;; Loot examples
;; Loot examples
(check-true (procedure? (run '(λ (x) x))))
(check-equal? (run '((λ (x) x) 5))
5)

Expand Down
5 changes: 4 additions & 1 deletion langs/mountebank/unload-bits-asm.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
(string)
(build-string (heap-ref i)
(lambda (j)
(char-ref (+ i 8) j)))))]))
(char-ref (+ i 8) j)))))]
[(? proc-bits? i)
(lambda _
(error "This function is not callable."))]))

(define (untag i)
(arithmetic-shift (arithmetic-shift i (- (integer-length ptr-mask)))
Expand Down
20 changes: 18 additions & 2 deletions langs/mug/test/interp-defun.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,21 @@
"../interp-defun.rkt"
"../interp-io.rkt")

(test-runner (λ p (interp (parse p))))
(test-runner-io (λ (s . p) (interp/io (parse p) s)))
(define (closure->proc xs e r)
;; Could make this better by calling the interpreter,
;; but it's only used in tests where all we care about
;; is that you get a procedure.
(lambda _
(error "This function is not callable.")))

(test-runner
(λ p
(match (interp (parse p))
[(Closure xs e r) (closure->proc xs e r)]
[v v])))
(test-runner-io
(λ (s . p)
(match (interp/io (parse p) s)
[(cons (Closure xs e r) o)
(cons (closure->proc xs e r) o)]
[r r])))
3 changes: 2 additions & 1 deletion langs/mug/test/test-runner.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@
(check-equal? (run '(match (box 1) [(box x) x] [_ 2]))
1)

;; Loot examples
;; Loot examples
(check-true (procedure? (run '(λ (x) x))))
(check-equal? (run '((λ (x) x) 5))
5)

Expand Down
6 changes: 5 additions & 1 deletion langs/mug/unload-bits-asm.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@
(string)
(build-string (heap-ref i)
(lambda (j)
(char-ref (+ i 8) j)))))]))
(char-ref (+ i 8) j)))))]
[(? proc-bits? i)
(lambda _
(error "This function is not callable."))]))


(define (untag i)
(arithmetic-shift (arithmetic-shift i (- (integer-length ptr-mask)))
Expand Down
20 changes: 18 additions & 2 deletions langs/neerdowell/test/interp-defun.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,21 @@
"../interp-defun.rkt"
"../interp-io.rkt")

(test-runner (λ p (interp (parse p))))
(test-runner-io (λ (s . p) (interp/io (parse p) s)))
(define (closure->proc xs e r)
;; Could make this better by calling the interpreter,
;; but it's only used in tests where all we care about
;; is that you get a procedure.
(lambda _
(error "This function is not callable.")))

(test-runner
(λ p
(match (interp (parse p))
[(Closure xs e r) (closure->proc xs e r)]
[v v])))
(test-runner-io
(λ (s . p)
(match (interp/io (parse p) s)
[(cons (Closure xs e r) o)
(cons (closure->proc xs e r) o)]
[r r])))
1 change: 1 addition & 0 deletions langs/neerdowell/test/test-runner.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@
1)

;; Loot examples
(check-true (procedure? (run '(λ (x) x))))
(check-equal? (run '((λ (x) x) 5))
5)

Expand Down
3 changes: 3 additions & 0 deletions langs/neerdowell/unload-bits-asm.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
(build-string (heap-ref i)
(lambda (j)
(char-ref (+ i 8) j)))))]
[(? proc-bits? i)
(lambda _
(error "This function is not callable."))]
[(? struct-bits? i)
(struct-val)]))

Expand Down
1 change: 1 addition & 0 deletions langs/outlaw/test/test-runner.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
1)

;; Loot examples
(check-true (procedure? (run '(λ (x) x))))
(check-equal? (run '((λ (x) x) 5))
5)

Expand Down
3 changes: 3 additions & 0 deletions langs/outlaw/unload-bits-asm.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
(build-string (heap-ref i)
(lambda (j)
(char-ref (+ i 8) j)))))]
[(? proc-bits? i)
(lambda _
(error "This function is not callable."))]
[(? struct-bits? i)
(struct-val)]))

Expand Down

0 comments on commit fc31655

Please sign in to comment.