The R5RS library
Add numbers
Section titled “Add numbers”Given a file named “main.scm” with:
(import (scheme r5rs))
(write (+ 40 2))When I successfully run stak main.scm
Then the stdout should contain exactly “42”.
Quote a list
Section titled “Quote a list”Given a file named “main.scm” with:
(import (scheme r5rs))
(for-each write-char '(#\A #\B #\C))When I successfully run stak main.scm
Then the stdout should contain exactly “ABC”.
Read an S-expression
Section titled “Read an S-expression”Given a file named “main.scm” with:
(import (scheme r5rs))
(write (read))And a file named “input.txt” with:
(1 2 3)When I run stak main.scm interactively
And I pipe in the file “input.txt”
Then the exit status should be 0
And the stdout should contain exactly “(1 2 3)”.
Write an S-expression
Section titled “Write an S-expression”Given a file named “main.scm” with:
(import (scheme r5rs))
(write '(1 2 3))When I successfully run stak main.scm
Then the stdout should contain exactly “(1 2 3)”.
Force a promise
Section titled “Force a promise”Given a file named “main.scm” with:
(import (scheme r5rs))
(write-char (force (delay (integer->char 65))))When I successfully run stak main.scm
Then the stdout should contain exactly “A”.
Evaluate an S-expression
Section titled “Evaluate an S-expression”Given a file named “main.scm” with:
(import (scheme r5rs))
(write (eval '(+ 40 2) (scheme-report-environment 5)))When I successfully run stak main.scm
Then the stdout should contain exactly “42”.
Convert between exact and inexact numbers
Section titled “Convert between exact and inexact numbers”Given a file named “main.scm” with:
(import (scheme r5rs))
(write-char (if (= <expression> 2) #\A #\B))When I successfully run stak main.scm
Then the stdout should contain exactly “A”.
Examples
Section titled “Examples”| expression |
|---|
| (exact->inexact 2) |
| (inexact->exact 2) |
| (inexact->exact (exact->inexact 2)) |
Build a null environment
Section titled “Build a null environment”Given a file named “main.scm” with:
(import (scheme r5rs))
(null-environment 5)(write-char #\A)When I successfully run stak main.scm
Then the stdout should contain exactly “A”.
Load a file
Section titled “Load a file”Given a file named “main.scm” with:
(import (scheme r5rs) (scheme eval))
(load "./foo.scm" (environment '(scheme base)))And a file named “foo.scm” with:
(write-u8 65)When I successfully run stak main.scm
Then the stdout should contain exactly “A”.