From f3353273c80815281e11e0aece2130d31d9d800c Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Sun, 1 Oct 2023 17:18:54 +0200 Subject: [PATCH] extend lexer test --- src/test/lexer.rs | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/test/lexer.rs b/src/test/lexer.rs index f0b259e..221aa55 100644 --- a/src/test/lexer.rs +++ b/src/test/lexer.rs @@ -17,8 +17,7 @@ fn test_lexer_num() { } #[test] -fn test_lexer_num_error() -{ +fn test_lexer_num_error() { let mut lex = LadderTypeLexer::new("123xxx".chars()); assert_eq!( lex.next(), Some(Err(LexError::InvalidDigit)) ); } @@ -81,7 +80,17 @@ fn test_lexer_app_space() { #[test] fn test_lexer_large() { - let mut lex = LadderTypeLexer::new("~~ℕ~~~Unicode>".chars()); + let mut lex = LadderTypeLexer::new( + " \ + ~ \ + ~ℕ \ + ~ \ + ~< Seq ~Unicode > > \ + ~ \ + ~ \ + ~UTF-8 \ + ~".chars()); assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Open))); assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Symbol("Seq".into())))); @@ -114,6 +123,26 @@ fn test_lexer_large() { assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Ladder))); assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Symbol("Unicode".into())))); assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Close))); + assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Close))); + assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Ladder))); + assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Open))); + assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Symbol("SepSeq".into())))); + assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Symbol("Unicode".into())))); + assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Char(':')))); + assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Close))); + assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Ladder))); + assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Open))); + assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Symbol("Seq".into())))); + assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Symbol("Unicode".into())))); + assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Close))); + assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Ladder))); + assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Symbol("UTF-8".into())))); + assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Ladder))); + assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Open))); + assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Symbol("Seq".into())))); + assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Symbol("Byte".into())))); + assert_eq!( lex.next(), Some(Ok(LadderTypeToken::Close))); + assert_eq!( lex.next(), None ); }