use insta::assert_debug_snapshot as assert_snapshot; use oyster_parser::{ParseEvent, Parser}; fn parse(s: &str) -> Vec { Parser::new(s).collect() } #[test] fn empty() { let source = ""; let actual = parse(source); assert_snapshot!(actual); } #[test] fn word() { let source = "word"; let actual = parse(source); assert_snapshot!(actual); } #[test] fn word_with_escape() { let source = "hello\\world"; let actual = parse(source); assert_snapshot!(actual); } #[test] fn unicode() { let source = "谚语"; let actual = parse(source); assert_snapshot!(actual); } #[test] fn simple_command() { let source = "echo hi"; let actual = parse(source); assert_snapshot!(actual); } #[test] fn semicolon() { let source = "hello; hi"; let actual = parse(source); assert_snapshot!(actual); } #[test] fn comment() { let source = r"# a # b"; let actual = parse(source); assert_snapshot!(actual); } #[test] fn inline_comment() { let source = "whoami # hello"; let actual = parse(source); assert_snapshot!(actual); } #[test] fn pipeline() { let source = "whoami | cat"; let actual = parse(source); assert_snapshot!(actual); } #[test] fn multiline_pipeline() { let source = r"whoami | wc -l"; let actual = parse(source); assert_snapshot!(actual); } #[test] fn comment_in_pipeline() { let source = r"whoami | # comment wc -l"; let actual = parse(source); assert_snapshot!(actual); } #[test] fn reject_leading_pipe() { let source = r"whoami | cat"; let actual = parse(source); assert_snapshot!(actual); } #[test] fn reject_trailing_pipe() { let source = "whoami |"; let actual = parse(source); assert_snapshot!(actual); } #[test] fn reject_pipe_semicolon() { let source = "whoami | ; cat"; let actual = parse(source); assert_snapshot!(actual); } #[test] fn reject_double_pipe() { let source = "whoami | | cat"; let actual = parse(source); assert_snapshot!(actual); }