From ce84b1d1c0330241902a29a63fa37bcd5fae70a5 Mon Sep 17 00:00:00 2001 From: Joshua Groves Date: Sat, 13 Feb 2021 17:24:31 -0330 Subject: [PATCH] [wgsl] Add parser error snapshot --- tests/errors.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/errors.rs diff --git a/tests/errors.rs b/tests/errors.rs new file mode 100644 index 000000000..81841a82e --- /dev/null +++ b/tests/errors.rs @@ -0,0 +1,15 @@ +#[cfg(feature = "wgsl-in")] +macro_rules! err { + ($value:expr, @$snapshot:literal) => { + ::insta::assert_snapshot!(naga::front::wgsl::parse_str($value).expect_err("expected parser error").to_string(), @$snapshot); + }; +} + +#[cfg(feature = "wgsl-in")] +#[test] +fn function_without_identifier() { + err!( + "fn () {}", + @"error while parsing WGSL in scopes [FunctionDecl] at line 1 pos 4: unexpected token Paren('('), expected ident" + ); +}