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); +}