2020-04-24 18:15:54 +03:00
|
|
|
use enso_prelude::*;
|
|
|
|
|
|
|
|
use ast::crumbs::Crumbable;
|
|
|
|
use ast::HasRepr;
|
|
|
|
use parser::Parser;
|
|
|
|
|
|
|
|
use wasm_bindgen_test::wasm_bindgen_test;
|
2021-11-02 16:05:43 +03:00
|
|
|
use wasm_bindgen_test::wasm_bindgen_test_configure;
|
2020-04-24 18:15:54 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wasm_bindgen_test_configure!(run_in_browser);
|
|
|
|
|
|
|
|
|
|
|
|
#[wasm_bindgen_test]
|
|
|
|
fn macro_crumb_test() {
|
2021-11-02 16:05:43 +03:00
|
|
|
let ast = Parser::new_or_panic().parse_line_ast("foo -> bar").unwrap();
|
2020-04-24 18:15:54 +03:00
|
|
|
let crumbs = ast.iter_subcrumbs().collect_vec();
|
|
|
|
|
|
|
|
assert_eq!(ast.get(&crumbs[0]).unwrap().repr(), "foo");
|
|
|
|
assert_eq!(ast.get(&crumbs[1]).unwrap().repr(), "->");
|
|
|
|
assert_eq!(ast.get(&crumbs[2]).unwrap().repr(), "bar");
|
|
|
|
|
2021-11-02 16:05:43 +03:00
|
|
|
let ast = Parser::new_or_panic().parse_line_ast("( foo bar )").unwrap();
|
2020-04-24 18:15:54 +03:00
|
|
|
let crumbs = ast.iter_subcrumbs().collect_vec();
|
|
|
|
|
|
|
|
assert_eq!(ast.get(&crumbs[0]).unwrap().repr(), "(");
|
|
|
|
assert_eq!(ast.get(&crumbs[1]).unwrap().repr(), "foo bar");
|
|
|
|
assert_eq!(ast.get(&crumbs[2]).unwrap().repr(), ")");
|
|
|
|
}
|