Skip to content

Commit

Permalink
Use insta for parser ast tests; remove defunct tokenizer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sbillig committed Apr 28, 2021
1 parent 74015b0 commit 162121c
Show file tree
Hide file tree
Showing 140 changed files with 3,953 additions and 76,749 deletions.
9 changes: 4 additions & 5 deletions parser/tests/errors.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use fe_common::diagnostics::diagnostics_string;
use fe_parser::grammar::{contracts, expressions, functions, module, types};

use fe_parser::{ParseResult, Parser};
use insta::assert_snapshot;

pub fn err_string<F, T>(mut parse_fn: F, should_fail: bool, src: &str) -> String
pub fn err_string<F, T>(test_name: &str, mut parse_fn: F, should_fail: bool, src: &str) -> String
where
F: FnMut(&mut Parser) -> ParseResult<T>,
T: std::fmt::Debug,
{
let mut files = fe_common::files::FileStore::new();
let id = files.add_file("[test snippet]", src);
let id = files.add_file(test_name, src);
let mut parser = Parser::new(src, id);

if should_fail != parse_fn(&mut parser).is_err() {
Expand All @@ -23,10 +22,10 @@ where
}

macro_rules! test_parse_err {
($name:ident, $parse_fn:expr, $should_fail:expr, $string:expr) => {
($name:ident, $parse_fn:expr, $should_fail:expr, $src:expr) => {
#[test]
fn $name() {
let err = err_string($parse_fn, $should_fail, $string);
let err = err_string(stringify!($name), $parse_fn, $should_fail, $src);
assert_snapshot!(err);
}
};
Expand Down
43 changes: 0 additions & 43 deletions parser/tests/fixtures/parsers/assert_stmt.ron

This file was deleted.

Loading

0 comments on commit 162121c

Please sign in to comment.