Lines
100 %
Functions
Branches
use super::*;
async fn assert_reader_error(form: &str, message: &str) {
let response = eval_value_of(form).await;
assert!(
response.contains(":error") && response.contains(message),
"{form} must be a reader error mentioning {message:?}, got: {response}"
);
}
#[tokio::test]
async fn t_and_every_spelling_of_nil_print_lowercase() {
assert_values(&[
("t", "t"),
("nil", "nil"),
("()", "nil"),
("'()", "nil"),
("(list)", "nil"),
])
.await;
async fn scheme_boolean_literals_are_reader_errors() {
assert_reader_error("#t", "#t is not nomiscript syntax; use t").await;
assert_reader_error("#f", "#f is not nomiscript syntax; use nil").await;
async fn t_and_nil_are_unique_objects() {
assert_values(&[("(eql nil '())", "t"), ("(eq? t 't)", "t")]).await;
async fn a_runtime_comparison_frame_carries_lowercase_t() {
assert_values(&[("(> (rpc-protocol-version) 0)", "t")]).await;
async fn empty_parens_still_serve_as_empty_parameter_and_binding_lists() {
("(let () 3)", "3"),
("(let* () 3)", "3"),
("(funcall (lambda () 5))", "5"),
("(do () (t 7))", "7"),
async fn empty_constant_list_folds_are_nil() {
("(filter (lambda (x) nil) (list 1 2))", "nil"),
("(null? (map '+ '()))", "t"),
("(append '() '())", "nil"),
("(reverse '())", "nil"),
async fn quoted_lists_print_through_one_printer() {
("'(a . nil)", "\"(A)\""),
("'(1 . (2 3))", "\"(1 2 3)\""),
("'(1 . 2)", "\"(1 . 2)\""),
("'(1 2)", "\"(1 2)\""),
("'a", "\"A\""),
("':k", "\":K\""),
("'`(a)", "\"`(A)\""),
async fn a_quoted_datum_still_has_no_cell_representation() {
for form in [
"(list '(1) (rpc-protocol-version))",
"(cons 'a (list (rpc-protocol-version)))",
] {
response.contains("cannot compile to WASM stack value"),
"{form}: {response}"
async fn labels_produces_a_stack_value() {
("(+ 1 (labels ((f (x) x)) (f 2)))", "3"),
("(let ((v (labels ((g () 4)) (g)))) v)", "4"),
("(labels ((f () 6)) (f))", "6"),
("(labels ((f (x) (+ x 1))) (f (rpc-protocol-version)))", "2"),
async fn the_empty_list_is_nil_to_if_null_and_length() {
("(if '() 1 2)", "2"),
("(null? '())", "t"),
("(length '())", "0"),
async fn handler_case_catch_all_t_returns_nil() {
assert_values(&[("(handler-case (error 'x \"m\") (t (e) nil))", "nil")]).await;