#[cfg(test)] mod integer_tests { use ellie_core::{defs, error}; use ellie_tokenizer::{processors::Processor, syntax::types::integer_type}; use std::{ collections::hash_map::DefaultHasher, hash::{Hash, Hasher}, }; #[test] fn integer_with_no_error() { let code = "123"; let mut pos = defs::CursorPosition::default(); let mut errors: Vec = Vec::new(); let mut processor: integer_type::IntegerTypeCollector = integer_type::IntegerTypeCollector::default(); let mut last_char = '\0'; for letter_char in code.chars() { processor.iterate(&mut errors, pos, last_char, letter_char); pos.1 += 1; last_char = letter_char; } let mut result_hash = DefaultHasher::new(); format!("{:?}", processor).hash(&mut result_hash); assert!(errors.is_empty() && result_hash.finish() == 12111085105946201499); } #[test] fn negative_integer_with_no_error() { let code = "-123"; let mut pos = defs::CursorPosition::default(); let mut errors: Vec = Vec::new(); let mut processor: integer_type::IntegerTypeCollector = integer_type::IntegerTypeCollector::default(); let mut last_char = '\0'; for letter_char in code.chars() { processor.iterate(&mut errors, pos, last_char, letter_char); pos.1 += 1; last_char = letter_char; } let mut result_hash = DefaultHasher::new(); format!("{:?}", processor).hash(&mut result_hash); assert!(errors.is_empty() && result_hash.finish() == 7962439497365308812); } }