Lines
100 %
Functions
Branches
//! IF / COND / AND / OR / NOT / PROGN 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/1) (+ X 1/1) (- X 1/1))",
));
}
fn runtime_if_without_else() {
compile_and_validate(&wrap_with_runtime_ratio("(if (= X 0/1) (+ X 1/1))"));
fn runtime_and() {
compile_and_validate(&wrap_with_runtime_ratio("(and (= X 0/1) (> X 1/1))"));
fn runtime_or() {
compile_and_validate(&wrap_with_runtime_ratio("(or (= X 0/1) (< X 1/1))"));
fn runtime_cond() {
"(cond ((= X 0/1) (+ X 1/1)) ((> X 0/1) (- X 1/1)))",
/// WHEN expands to `(if test (progn body...) nil)`. The stdlib
/// expansion isn't loaded in `with_builtins_for_wasm`, so the test
/// exercises the IF+PROGN shape directly.
fn runtime_when_equivalent() {
"(if (= X 0/1) (progn (+ X 1/1)) nil)",
/// UNLESS analog of the WHEN test above.
fn runtime_unless_equivalent() {
"(if (= X 0/1) nil (progn (- X 1/1)))",
fn runtime_not() {
compile_and_validate(&wrap_with_runtime_ratio("(not (= X 0/1))"));