1
//! IF / COND / AND / OR / NOT / PROGN 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(
8
1
        "(if (= X 0/1) (+ X 1/1) (- X 1/1))",
9
1
    ));
10
1
}
11

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

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

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

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

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

            
44
/// UNLESS analog of the WHEN test above.
45
#[test]
46
1
fn runtime_unless_equivalent() {
47
1
    compile_and_validate(&wrap_with_runtime_ratio(
48
1
        "(if (= X 0/1) nil (progn (- X 1/1)))",
49
1
    ));
50
1
}
51

            
52
#[test]
53
1
fn runtime_not() {
54
1
    compile_and_validate(&wrap_with_runtime_ratio("(not (= X 0/1))"));
55
1
}