2020-02-26 16:11:40 +03:00
|
|
|
use enso_prelude::*;
|
|
|
|
|
|
|
|
use ast::Ast;
|
|
|
|
use ast::IdMap;
|
|
|
|
use data::text::*;
|
2020-01-29 23:30:09 +03:00
|
|
|
use parser::Parser;
|
2020-02-28 21:29:37 +03:00
|
|
|
use parser::api::IsParser;
|
2020-01-29 23:30:09 +03:00
|
|
|
|
2020-02-26 16:11:40 +03:00
|
|
|
use std::rc::Rc;
|
|
|
|
use uuid::Uuid;
|
|
|
|
use wasm_bindgen_test::wasm_bindgen_test_configure;
|
|
|
|
use wasm_bindgen_test::wasm_bindgen_test;
|
2020-01-29 23:30:09 +03:00
|
|
|
|
|
|
|
|
2020-02-26 16:11:40 +03:00
|
|
|
|
|
|
|
wasm_bindgen_test_configure!(run_in_browser);
|
|
|
|
|
2020-01-29 23:30:09 +03:00
|
|
|
#[wasm_bindgen_test]
|
|
|
|
fn web_test() {
|
2020-02-26 16:11:40 +03:00
|
|
|
let uuid = Uuid::parse_str("00000000-0000-0000-0000-000000000000").unwrap();
|
|
|
|
|
|
|
|
let mut parser = Parser::new_or_panic();
|
|
|
|
|
|
|
|
let mut parse = |input| {
|
2020-03-04 17:00:49 +03:00
|
|
|
let span = Span::from((0,5));
|
2020-02-26 16:11:40 +03:00
|
|
|
let ids = IdMap(vec![(span,uuid)]);
|
|
|
|
let ast = parser.parse(String::from(input), ids).unwrap().wrapped;
|
|
|
|
|
|
|
|
match Rc::try_unwrap(ast).unwrap().wrapped.wrapped {
|
|
|
|
ast::Shape::Module(ast) => ast,
|
|
|
|
_ => panic!("Expected module."),
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
let line = |term| {
|
2020-03-04 17:00:49 +03:00
|
|
|
ast::Module {lines: vec![ast::BlockLine {elem:term,off:0}]}
|
2020-02-26 16:11:40 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let app_x_y = ast::Prefix {func: Ast::var("x"), off: 3, arg: Ast::var("y")};
|
|
|
|
|
|
|
|
|
|
|
|
assert_eq!(parse(""), line(None));
|
|
|
|
assert_eq!(parse("xy"), line(Some(Ast::var("xy"))));
|
|
|
|
assert_eq!(parse("x y"), line(Some(Ast::new(app_x_y, Some(uuid)))));
|
|
|
|
|
2020-01-29 23:30:09 +03:00
|
|
|
}
|