Skip to content

Evaluation

Given a file named “main.scm” with:

(import (scheme eval))

When I successfully run stak main.scm

Then the exit status should be 0.

Given a file named “main.scm” with:

(import (scheme base) (scheme eval))
(write-u8 (if (eval #f (environment)) 65 66))

When I successfully run stak main.scm

Then the stdout should contain exactly “B”.

Given a file named “main.scm” with:

(import (scheme base) (scheme eval))
(write-u8 (eval 65 (environment)))

When I successfully run stak main.scm

Then the stdout should contain exactly “A”.

Given a file named “main.scm” with:

(import (scheme base) (scheme eval))
(write-string (eval "foo" (environment)))

When I successfully run stak main.scm

Then the stdout should contain exactly “foo”.

Given a file named “main.scm” with:

(import (scheme base) (scheme eval))
(write-u8 (eval 65 (environment '(scheme base))))

When I successfully run stak main.scm

Then the stdout should contain exactly “A”.

Given a file named “main.scm” with:

(import (scheme base) (scheme eval))
(write-u8 (eval 65 (environment '(scheme base) '(scheme write))))

When I successfully run stak main.scm

Then the stdout should contain exactly “A”.

Given a file named “main.scm” with:

(import (scheme base) (scheme eval) (scheme repl))
(write-u8 (eval 65 (interaction-environment)))

When I successfully run stak main.scm

Then the stdout should contain exactly “A”.

Define variables in an interaction environment

Section titled “Define variables in an interaction environment”

Given a file named “main.scm” with:

(import (scheme base) (scheme eval) (scheme repl))
(eval '(import (scheme base)) (interaction-environment))
(eval '(define x 42) (interaction-environment))
(eval '(define y 23) (interaction-environment))
(write-u8 (eval '(+ x y) (interaction-environment)))

When I successfully run stak main.scm

Then the stdout should contain exactly “A”.

Given a file named “main.scm” with:

(import (scheme base) (scheme eval))
(eval
'(begin
(define x 65)
(write-u8 x))
(environment '(scheme base)))

When I successfully run stak main.scm

Then the stdout should contain exactly “A”.

Given a file named “main.scm” with:

(import (scheme base) (scheme eval))
(eval
'(begin
(define (f x)
(+ x 65))
(write-u8 (f 1)))
(environment '(scheme base)))

When I successfully run stak main.scm

Then the stdout should contain exactly “B”.

Given a file named “main.scm” with:

(import (scheme base) (scheme eval))
(define x #t)
(eval
'(unless x (error "Oh, no!"))
(environment '(scheme base)))

When I run stak main.scm

Then the exit status should not be 0.

Given a file named “main.scm” with:

(import (scheme base) (scheme eval))
(define x 65)
(eval
'(begin (define x 66))
(environment '(scheme base)))
(write-u8 x)

When I successfully run stak main.scm

Then the stdout should contain exactly “A”.

Given a file named “main.scm” with:

(import (scheme base) (scheme eval))
(write-u8 (eval '(+ 60 5) (environment '(scheme base))))

When I successfully run stak main.scm

Then the stdout should contain exactly “A”.

Given a file named “main.scm” with:

(import (scheme base) (scheme eval) (scheme write))
(eval '(display "foo") (environment '(scheme write)))

When I successfully run stak main.scm

Then the stdout should contain exactly “foo”.

Given a file named “main.scm” with:

(import (scheme base) (scheme eval))
(write-u8
(eval
'(let ((x 0))
(set! x 65)
x)
(environment '(scheme base))))

When I successfully run stak main.scm

Then the stdout should contain exactly “A”.

Given a file named “main.scm” with:

(import (scheme base) (scheme eval))
(write-u8
(eval
'(begin 42 65)
(environment '(scheme base))))

When I successfully run stak main.scm

Then the stdout should contain exactly “A”.

Given a file named “main.scm” with:

(import (scheme base) (scheme eval))
(eval '(write-u8 (if <value> 65 66)) (environment '(scheme base)))

When I successfully run stak main.scm

Then the stdout should contain exactly “<output>”.

valueoutput
#fB
#tA

Given a file named “main.scm” with:

(import (scheme base) (scheme eval))
(write-u8
(eval
'((lambda () 65))
(environment '(scheme base))))

When I successfully run stak main.scm

Then the stdout should contain exactly “A”.

Given a file named “main.scm” with:

(import (scheme base) (scheme eval))
(write-u8
(eval
'((lambda (x) x) 65)
(environment '(scheme base))))

When I successfully run stak main.scm

Then the stdout should contain exactly “A”.