yyyi_ru/mtgott/tests/april_24.rs

126 lines
4.5 KiB
Rust

extern crate mtgott;
use mtgott::dirsearch::*;
use mtgott::runtime::*;
macro_rules! assert_gave {
($a:expr, $str:literal) => {
assert_eq!($a, String::from($str))
};
}
#[test]
fn t001(){
let i = MtgottDirContent{mtgott: vec![
FileWithPath{v_path: "boba".into(), text: "{$ aboba = \"xdds\" $}".into()}
], imtgott: vec![
FileWithPath{v_path: "index".into(), text: "{{ boba.aboba }}".into()}
], plain: vec![]};
let r = get_root_html_from_dir_text_html(i).unwrap();
assert_gave!(r.render(Value::Int(0), "index", 50).unwrap(), "xdds");
}
#[test]
fn t002(){
let i = MtgottDirContent{mtgott: vec![
FileWithPath{v_path: "boba/biba/aaa/bbb".into(), text: "{$ aboba = \"xdds\" $}".into()}
], imtgott: vec![
FileWithPath{v_path: "index".into(), text: "{{ boba. biba .aaa.bbb.aboba }}".into()}
], plain: vec![]};
let r = get_root_html_from_dir_text_html(i).unwrap();
assert_gave!(r.render(Value::Int(0), "index", 50).unwrap(), "xdds");
}
#[test]
fn t003(){
let i = MtgottDirContent{mtgott: vec![
FileWithPath{v_path: "boba/biba/aaa/bbb".into(), text: "{$ aboba = \"xdds\" $}".into()}
], imtgott: vec![
FileWithPath{v_path: "index/yyy/eee".into(), text: "{{ boba. biba .aaa.bbb.aboba }}".into()}
], plain: vec![]};
let r = get_root_html_from_dir_text_html(i).unwrap();
assert_gave!(r.render(Value::Int(0), "index.yyy.eee", 50).unwrap(), "xdds");
}
#[test]
fn t004(){
let i = MtgottDirContent{mtgott: vec![
FileWithPath{v_path: "boba/biba/aaa/bbb".into(), text: "{$ pack $} {$ AAA = \"xdds\" $} {$}".into()}
], imtgott: vec![
FileWithPath{v_path: "index/yyy/eee".into(), text: "{{ boba. biba .aaa.bbb.pack.AAA }}".into()}
], plain: vec![]};
let r = get_root_html_from_dir_text_html(i).unwrap();
assert_gave!(r.render(Value::Int(0), "index.yyy.eee", 50).unwrap(), "xdds");
}
#[test]
fn t005(){
let i = MtgottDirContent{mtgott: vec![
FileWithPath{v_path: "file".into(), text: "{$ pack $} {$ const = 12345 $} {$}".into()}
], imtgott: vec![
FileWithPath{v_path: "index".into(), text: "{{ file.pack.const }}".into()}
], plain: vec![]};
let r = get_root_html_from_dir_text_html(i).unwrap();
assert_gave!(r.render(Value::Int(0), "index", 50).unwrap(), "12345");
}
#[test]
fn t006(){
let i = MtgottDirContent{mtgott: vec![
FileWithPath{v_path: "file".into(), text: "{$ pack $} {$ const = file.pack.pack2.chislo $} {$ pack2 $} {$ chislo = 123 $} {$} {$}".into()}
], imtgott: vec![
FileWithPath{v_path: "index".into(), text: "{{ file.pack.const }}".into()}
], plain: vec![]};
let r = get_root_html_from_dir_text_html(i).unwrap();
assert_gave!(r.render(Value::Int(0), "index", 50).unwrap(), "123");
}
#[test]
fn t007(){
let i = MtgottDirContent{mtgott: vec![
FileWithPath{v_path: "file".into(), text: "{$ pack $}{$c=45$}{$} {@ el @}---{{this.pack.c}}---{@} ".into()}
], imtgott: vec![
FileWithPath{v_path: "index".into(), text: "{[file.el]}".into()}
], plain: vec![]};
let r = get_root_html_from_dir_text_html(i).unwrap();
assert_gave!(r.render(Value::Int(0), "index", 50).unwrap(), "---45---");
}
#[test]
fn t008(){
let i = MtgottDirContent{mtgott: vec![
FileWithPath{v_path: "file".into(), text: "{@ el a@}---{{a}}---{@} ".into()}
], imtgott: vec![
FileWithPath{v_path: "index".into(), text: "{[file.el \"45\"]}".into()}
], plain: vec![]};
let r = get_root_html_from_dir_text_html(i).unwrap();
assert_gave!(r.render(Value::Int(0), "index", 50).unwrap(), "---45---");
}
#[test]
fn t009(){
let i = MtgottDirContent{mtgott: vec![
FileWithPath{v_path: "file".into(), text: "{@ el a b c d e f g @}---{{a}}---{{c}}---{{e}}---{{g}}---{@} ".into()}
], imtgott: vec![
FileWithPath{v_path: "index".into(), text: "{[file.el 1 2 3 4 5 6 7]}".into()}
], plain: vec![]};
let r = get_root_html_from_dir_text_html(i).unwrap();
assert_gave!(r.render(Value::Int(0), "index", 50).unwrap(), "---1---3---5---7---");
}
#[test]
fn t010(){
let i = MtgottDirContent{mtgott: vec![
FileWithPath{v_path: "file".into(), text: "{@el a b @} {{a}}{{b}} {@} ".into()}
], imtgott: vec![
FileWithPath{v_path: "index".into(), text: "{[file.el 1 2]}".into()}
], plain: vec![]};
let r = get_root_html_from_dir_text_html(i).unwrap();
assert_gave!(r.render(Value::Int(0), "index", 50).unwrap(), "12");
}