enso/app/gui/language/parser/tests/id_map.rs
Michał Wawrzyniec Urbańczyk ad69eeb4ad
Build script merge (#3743)
Merged the build script into main repository. Some related cleanups.
2022-10-10 23:38:48 +02:00

36 lines
965 B
Rust

// === Non-Standard Linter Configuration ===
#![deny(non_ascii_idents)]
#![warn(unsafe_code)]
use parser_scala::prelude::*;
use ast::HasIdMap;
use parser_scala::Parser;
use wasm_bindgen_test::wasm_bindgen_test;
use wasm_bindgen_test::wasm_bindgen_test_configure;
wasm_bindgen_test_configure!(run_in_browser);
#[wasm_bindgen_test]
fn id_map_round_tripping() {
let cases = [
"main =\n 2 + 2",
"main = \n \n 2 + 2\n foo = bar \n baz",
"main = \n foo\n\n bar",
"main = \n foo\n \n bar",
"main = \n foo\n \n bar",
"main = \n foo\n baz \n bar",
];
let parser = Parser::new().unwrap();
for case in cases.iter().copied() {
let id_map = default();
let ast1 = parser.parse_module(case, id_map).unwrap();
let id_map = ast1.id_map();
let ast2 = parser.parse_module(case, id_map).unwrap();
assert_eq!(ast1, ast2)
}
}