piston/runtimes/racket.nix

61 lines
1.4 KiB
Nix
Raw Normal View History

2022-02-07 03:25:23 +01:00
{pkgs, piston, ...}:
let
pkg = pkgs.racket-minimal;
in piston.mkRuntime {
language = "racket";
version = pkg.version;
aliases = [
"rkt"
];
run = ''
${pkg}/bin/racket "$@"
'';
tests = [
# test different file extension
(piston.mkTest {
files = {
"file.code" = ''
#lang racket
(display "OK")
'';
};
args = [];
stdin = "";
packages = [];
main = "file.code";
})
#test argv
(piston.mkTest {
files = {
"test.rkt" = ''
#lang racket
(for ([arg (current-command-line-arguments)]) (displayln arg))
'';
};
args = ["OK"];
stdin = "";
packages = [];
main = "test.rkt";
})
# test stdin
(piston.mkTest {
files = {
"test.rkt" = ''
#lang racket
(let loop ()
(match (read-char)
[(? eof-object?) (void)]
[c (display c)
(loop)]))
'';
};
args = [];
stdin = "OK";
packages = [];
main = "test.rkt";
})
];
}