[parser] Integration test of parsing a single Sym!

This commit is contained in:
Eryn Wells 2018-08-25 11:46:42 -07:00
parent 9a728c9489
commit d312c41dc7
2 changed files with 24 additions and 1 deletions

View file

@ -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<Obj, ParseError>;
#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub enum ParseError {
LexerError{msg: String},
ParserError{msg: String}

View file

@ -0,0 +1,23 @@
/* parser/tests/single_item.rs
* Eryn Wells <eryn@erynwells.me>
*/
//! 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);
}