From d312c41dc7d08e3dbbcce8b9209015b774bf02af Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sat, 25 Aug 2018 11:46:42 -0700 Subject: [PATCH] [parser] Integration test of parsing a single Sym! --- parser/src/lib.rs | 2 +- parser/tests/single_item.rs | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 parser/tests/single_item.rs diff --git a/parser/src/lib.rs b/parser/src/lib.rs index 7c610c6..b51bcb8 100644 --- a/parser/src/lib.rs +++ b/parser/src/lib.rs @@ -20,7 +20,7 @@ use program_parser::ProgramParser; /// The output of calling `parse()` on a Parser is one of these Result objects. pub type Result = std::result::Result; -#[derive(Debug)] +#[derive(Debug, PartialEq)] pub enum ParseError { LexerError{msg: String}, ParserError{msg: String} diff --git a/parser/tests/single_item.rs b/parser/tests/single_item.rs new file mode 100644 index 0000000..9614a16 --- /dev/null +++ b/parser/tests/single_item.rs @@ -0,0 +1,23 @@ +/* parser/tests/single_item.rs + * Eryn Wells + */ + +//! Tests that the parser can handle inputs of single tokens. + +extern crate sibillexer; +extern crate sibilparser; +extern crate sibiltypes; + +use sibillexer::{Lex, Token}; +use sibillexer::Result as LexerResult; +use sibilparser::Parser; +use sibiltypes::{Obj, Sym}; + +#[test] +fn single_sym() { + let lex: LexerResult = Ok(Lex::new(Token::Id, "abc", 0, 0)); + let tokens = vec![lex].into_iter(); + let mut parser = Parser::new(tokens); + assert_eq!(parser.next(), Some(Ok(Obj::new(Sym::with_str("abc"))))); + assert_eq!(parser.next(), None); +}