diff --git a/kclvm/lexer/src/number.rs b/kclvm/lexer/src/number.rs index f9f7d9ab2..0458b1fd1 100644 --- a/kclvm/lexer/src/number.rs +++ b/kclvm/lexer/src/number.rs @@ -66,7 +66,7 @@ impl<'a> Cursor<'a> { // with a number self.bump(); let mut empty_exponent = false; - if self.peek().is_digit(10) { + if self.peek().is_ascii_digit() { self.eat_decimal_digits(); match self.peek() { 'e' | 'E' => { diff --git a/kclvm/lexer/src/tests.rs b/kclvm/lexer/src/tests.rs index 2bd614658..6b430f45e 100644 --- a/kclvm/lexer/src/tests.rs +++ b/kclvm/lexer/src/tests.rs @@ -1,10 +1,12 @@ use super::*; use expect_test::{expect, Expect}; +use std::fmt::Write; fn check_lexing(src: &str, expect: Expect) { - let actual: String = tokenize(src) - .map(|token| format!("{:?}\n", token)) - .collect(); + let actual: String = tokenize(src).fold(String::new(), |mut acc, token| { + writeln!(acc, "{:?}", token).expect("Failed to write to string"); + acc + }); expect.assert_eq(&actual) }