Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use insta for parser ast tests, remove defunct tokenizer tests #375

Merged
merged 1 commit into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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