Lines
100 %
Functions
Branches
//! `UPCASE-STRING` and `STRING=` native fn codegen.
use super::common::{compile_and_validate, compile_expect_error, wrap_with_runtime_ratio};
#[test]
fn upcase_string_constant_folds() {
// Static-string arg constant-folds to the upcased literal; the wasm
// still validates as a script that prints/uses the string.
compile_and_validate("(upcase-string \"hello\")");
}
fn upcase_string_wrong_arity_errors() {
let err = compile_expect_error("(upcase-string)");
assert!(err.contains("UPCASE-STRING"), "got: {err}");
fn upcase_string_non_string_errors() {
let err = compile_expect_error("(upcase-string 42)");
assert!(
err.contains("UPCASE-STRING") && err.contains("string"),
"got: {err}",
);
fn string_eq_constant_folds_equal() {
compile_and_validate("(string= \"foo\" \"foo\")");
fn string_eq_constant_folds_unequal() {
compile_and_validate("(string= \"foo\" \"bar\")");
fn string_eq_wrong_arity_errors() {
let err = compile_expect_error("(string= \"foo\")");
assert!(err.contains("STRING="), "got: {err}");
/// Non-string operand at compile_for_stack must surface a structured
/// error. `X` here is a Ratio runtime local — not a string — and the
/// arg-coercion path refuses it.
fn string_eq_non_string_runtime_arg_errors() {
let err = compile_expect_error(&wrap_with_runtime_ratio("(string= X \"foo\")"));
err.contains("STRING=") && err.contains("string"),