1
//! IF / COND / AND / OR / NOT / BEGIN with a runtime Ratio operand.
2

            
3
use super::common::{compile_and_validate, wrap_with_runtime_ratio};
4

            
5
#[test]
6
1
fn runtime_if_with_else() {
7
1
    compile_and_validate(&wrap_with_runtime_ratio("(if (= X 0) (+ X 1) (- X 1))"));
8
1
}
9

            
10
#[test]
11
1
fn runtime_if_without_else() {
12
1
    compile_and_validate(&wrap_with_runtime_ratio("(if (= X 0) (+ X 1))"));
13
1
}
14

            
15
#[test]
16
1
fn runtime_and() {
17
1
    compile_and_validate(&wrap_with_runtime_ratio("(and (= X 0) (> X 1))"));
18
1
}
19

            
20
#[test]
21
1
fn runtime_or() {
22
1
    compile_and_validate(&wrap_with_runtime_ratio("(or (= X 0) (< X 1))"));
23
1
}
24

            
25
#[test]
26
1
fn runtime_cond() {
27
1
    compile_and_validate(&wrap_with_runtime_ratio(
28
1
        "(cond ((= X 0) (+ X 1)) ((> X 0) (- X 1)))",
29
1
    ));
30
1
}
31

            
32
/// WHEN expands to `(if test (begin body...) nil)`. The stdlib
33
/// expansion isn't loaded in `with_builtins_for_wasm`, so the test
34
/// exercises the IF+BEGIN shape directly.
35
#[test]
36
1
fn runtime_when_equivalent() {
37
1
    compile_and_validate(&wrap_with_runtime_ratio("(if (= X 0) (begin (+ X 1)) nil)"));
38
1
}
39

            
40
/// UNLESS analog of the WHEN test above.
41
#[test]
42
1
fn runtime_unless_equivalent() {
43
1
    compile_and_validate(&wrap_with_runtime_ratio("(if (= X 0) nil (begin (- X 1)))"));
44
1
}
45

            
46
#[test]
47
1
fn runtime_not() {
48
1
    compile_and_validate(&wrap_with_runtime_ratio("(not (= X 0))"));
49
1
}