1
//! Unit tests for entity-accessor eval handlers.
2

            
3
use crate::ast::{Expr, WasmType};
4
use crate::runtime::SymbolTable;
5

            
6
use super::meta::{
7
    context_type, entity_count, entity_type, primary_entity_idx, primary_entity_type,
8
};
9
use super::split::split_account_name;
10

            
11
#[test]
12
1
fn split_account_name_returns_wasm_runtime_string() {
13
1
    let mut symbols = SymbolTable::new();
14
1
    let idx = Expr::Number(crate::ast::Fraction::from_integer(1));
15
1
    let result = split_account_name(&mut symbols, &[idx]).unwrap();
16
1
    assert_eq!(result, Expr::WasmRuntime(WasmType::StringRef));
17
1
}
18

            
19
#[test]
20
1
fn split_account_name_arity_error() {
21
1
    let mut symbols = SymbolTable::new();
22
1
    assert!(split_account_name(&mut symbols, &[]).is_err());
23
1
}
24

            
25
#[test]
26
1
fn test_entity_count_returns_wasm_runtime_i32() {
27
1
    let mut symbols = SymbolTable::new();
28
1
    let result = entity_count(&mut symbols, &[]).unwrap();
29
1
    assert_eq!(result, Expr::WasmRuntime(WasmType::I32));
30
1
}
31

            
32
#[test]
33
1
fn test_context_type_returns_wasm_runtime_i32() {
34
1
    let mut symbols = SymbolTable::new();
35
1
    let result = context_type(&mut symbols, &[]).unwrap();
36
1
    assert_eq!(result, Expr::WasmRuntime(WasmType::I32));
37
1
}
38

            
39
#[test]
40
1
fn test_primary_entity_type_returns_wasm_runtime_i32() {
41
1
    let mut symbols = SymbolTable::new();
42
1
    let result = primary_entity_type(&mut symbols, &[]).unwrap();
43
1
    assert_eq!(result, Expr::WasmRuntime(WasmType::I32));
44
1
}
45

            
46
#[test]
47
1
fn test_primary_entity_idx_returns_wasm_runtime_i32() {
48
1
    let mut symbols = SymbolTable::new();
49
1
    let result = primary_entity_idx(&mut symbols, &[]).unwrap();
50
1
    assert_eq!(result, Expr::WasmRuntime(WasmType::I32));
51
1
}
52

            
53
#[test]
54
1
fn test_entity_count_arity_error() {
55
1
    let mut symbols = SymbolTable::new();
56
1
    assert!(entity_count(&mut symbols, &[Expr::Nil]).is_err());
57
1
}
58

            
59
#[test]
60
1
fn test_entity_type_arity_error() {
61
1
    let mut symbols = SymbolTable::new();
62
1
    assert!(entity_type(&mut symbols, &[]).is_err());
63
1
}