Lines
100 %
Functions
Branches
//! IF / COND / AND / OR / NOT / BEGIN with a runtime Ratio operand.
use super::common::{compile_and_validate, wrap_with_runtime_ratio};
#[test]
fn runtime_if_with_else() {
compile_and_validate(&wrap_with_runtime_ratio("(if (= X 0) (+ X 1) (- X 1))"));
}
fn runtime_if_without_else() {
compile_and_validate(&wrap_with_runtime_ratio("(if (= X 0) (+ X 1))"));
fn runtime_and() {
compile_and_validate(&wrap_with_runtime_ratio("(and (= X 0) (> X 1))"));
fn runtime_or() {
compile_and_validate(&wrap_with_runtime_ratio("(or (= X 0) (< X 1))"));
fn runtime_cond() {
compile_and_validate(&wrap_with_runtime_ratio(
"(cond ((= X 0) (+ X 1)) ((> X 0) (- X 1)))",
));
/// WHEN expands to `(if test (begin body...) nil)`. The stdlib
/// expansion isn't loaded in `with_builtins_for_wasm`, so the test
/// exercises the IF+BEGIN shape directly.
fn runtime_when_equivalent() {
compile_and_validate(&wrap_with_runtime_ratio("(if (= X 0) (begin (+ X 1)) nil)"));
/// UNLESS analog of the WHEN test above.
fn runtime_unless_equivalent() {
compile_and_validate(&wrap_with_runtime_ratio("(if (= X 0) nil (begin (- X 1)))"));
fn runtime_not() {
compile_and_validate(&wrap_with_runtime_ratio("(not (= X 0))"));