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() {
("'(1 . (2 3))", "(1 2 3)"),
("'(1 . nil)", "(1)"),
("'(1 2)", "(1 2)"),
("'a", "A"),
("':k", ":K"),
("'`(a)", "\"`(A)\""),
("'(a . nil)", "(A)"),
// A non-list tail has no `$pair` cell representation (plan 0014 Stage 1):
// the structured rejection, never a printed string.
let response = eval_value_of("'(1 . 2)").await;
response.contains("'(1 . 2) has no list cell representation"),
"{response}"
async fn a_quoted_symbol_rides_a_list_cell() {
// A nested constant LIST materializes as a real `$pair` chain (ADR-0033
// Phase 6 — see `phase6_anyref_decode_tests`), and a quoted symbol rides
// a symbol cell beside it (plan 0014 Stage 8).
assert_values(&[("(cons 'a (list (rpc-protocol-version)))", "(A 1)")]).await;
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;