Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(scheme r5rs) library #1925

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions features/r5rs.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
Feature: The R5RS library
Scenario: Add numbers
Given a file named "main.scm" with:
"""scheme
(import (scheme r5rs))

(write (+ 40 2))
"""
When I successfully run `scheme main.scm`
Then the stdout should contain exactly "42"

Scenario: Quote a list
Given a file named "main.scm" with:
"""scheme
(import (scheme r5rs))

(for-each write-char '(#\A #\B #\C))
"""
When I successfully run `scheme main.scm`
Then the stdout should contain exactly "ABC"

Scenario: Read an S-expression
Given a file named "main.scm" with:
"""scheme
(import (scheme r5rs))

(write (read))
"""
And a file named "input.txt" with:
"""text
(1 2 3)
"""
When I run `scheme 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)"

Scenario: Write an S-expression
Given a file named "main.scm" with:
"""scheme
(import (scheme r5rs))

(write '(1 2 3))
"""
When I successfully run `scheme main.scm`
Then the stdout should contain exactly "(1 2 3)"

Scenario: Force a promise
Given a file named "main.scm" with:
"""scheme
(import (scheme r5rs))

(write-char (force (delay (integer->char 65))))
"""
When I successfully run `scheme main.scm`
Then the stdout should contain exactly "A"

Scenario: Evaluate an S-expression
Given a file named "main.scm" with:
"""scheme
(import (scheme r5rs))

(write
(eval
'(+ 40 2)
(scheme-report-environment 5)))
"""
When I successfully run `scheme main.scm`
Then the stdout should contain exactly "42"
236 changes: 236 additions & 0 deletions prelude.scm
Original file line number Diff line number Diff line change
Expand Up @@ -3354,3 +3354,239 @@
'())))))))

(define environment list)))

(define-library (scheme r5rs)
(import
(scheme base)
(scheme char)
(scheme cxr)
(scheme eval)
(scheme file)
(scheme inexact)
(scheme lazy)
(scheme read)
(scheme repl)
(scheme write))

(export
*
+
-
/
<
<=
=
>
>=
abs
acos
and
angle
append
apply
asin
assoc
assq
assv
atan
begin
boolean?
caaaar
caaadr
caaar
caadar
caaddr
caadr
caar
cadaar
cadadr
cadar
caddar
cadddr
caddr
cadr
call-with-current-continuation
call-with-input-file
call-with-output-file
call-with-values
car
case
cdaaar
cdaadr
cdaar
cdadar
cdaddr
cdadr
cdar
cddaar
cddadr
cddar
cdddar
cddddr
cdddr
cddr
cdr
ceiling
char->integer
char-alphabetic?
char-ci<=?
char-ci<?
char-ci=?
char-ci>=?
char-ci>?
char-downcase
char-lower-case?
char-numeric?
char-ready?
char-upcase
char-upper-case?
char-whitespace?
char<=?
char<?
char=?
char>=?
char>?
char?
close-input-port
close-output-port
complex?
cond
cons
cos
current-input-port
current-output-port
define
define-syntax
delay
denominator
display
do
dynamic-wind
eof-object?
eq?
equal?
eqv?
eval
even?
exact->inexact
exact?
exp
expt
floor
for-each
force
gcd
if
imag-part
inexact->exact
inexact?
input-port?
integer->char
integer?
interaction-environment
lambda
lcm
length
let
let*
let-syntax
letrec
letrec-syntax
list
list->string
list->vector
list-ref
list-tail
list?
load
log
magnitude
make-polar
make-rectangular
make-string
make-vector
map
max
member
memq
memv
min
modulo
negative?
newline
not
null-environment
null?
number->string
number?
numerator
odd?
open-input-file
open-output-file
or
output-port?
pair?
peek-char
positive?
procedure?
quasiquote
quote
quotient
rational?
rationalize
read
read-char
real-part
real?
remainder
reverse
round
scheme-report-environment
set!
set-car!
set-cdr!
sin
sqrt
string
string->list
string->number
string->symbol
string-append
string-ci<=?
string-ci<?
string-ci=?
string-ci>=?
string-ci>?
string-copy
string-fill!
string-length
string-ref
string-set!
string<=?
string<?
string=?
string>=?
string>?
string?
substring
symbol->string
symbol?
tan
truncate
values
vector
vector->list
vector-fill!
vector-length
vector-ref
vector-set!
vector?
with-input-from-file
with-output-to-file
write
write-char
zero?)

(begin
(define (scheme-report-environment version)
'((scheme r5rs)))))
1 change: 1 addition & 0 deletions run.scm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
(only (scheme inexact))
(only (scheme lazy))
(scheme process-context)
(only (scheme r5rs))
(scheme read)
(scheme repl)
(only (scheme time))
Expand Down
Loading