fix: ignore underscore in input
I accidentally removed this before... oops :3
This commit is contained in:
parent
f1f9c11a04
commit
c74abdace3
1 changed files with 6 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ use crate::nodes::{self, Error};
|
||||||
|
|
||||||
pub fn pretty_eval(input: &str, max_digits: usize) -> Result<String, Error> {
|
pub fn pretty_eval(input: &str, max_digits: usize) -> Result<String, Error> {
|
||||||
let (prefix, deliminator, input) = input.rsplit_once_last(&["= ", "& ", "plus.minus "]);
|
let (prefix, deliminator, input) = input.rsplit_once_last(&["= ", "& ", "plus.minus "]);
|
||||||
|
let input = input.replace('_', "");
|
||||||
|
|
||||||
// no need to remove the character here,
|
// no need to remove the character here,
|
||||||
// as we ignore it in all other logic already
|
// as we ignore it in all other logic already
|
||||||
|
|
@ -134,6 +135,11 @@ mod tests {
|
||||||
assert_pretty_eval!("plus.minus 5 & = 5");
|
assert_pretty_eval!("plus.minus 5 & = 5");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn underscore_input() {
|
||||||
|
assert_pretty_eval!("10_000 * 10_000 * 4", "4 * 10^8")
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic_get_significant_digits() {
|
fn basic_get_significant_digits() {
|
||||||
let many_zeros = eval("14.00643 + 1.00784 * 4 + 35.446 + 15.9994 * 4");
|
let many_zeros = eval("14.00643 + 1.00784 * 4 + 35.446 + 15.9994 * 4");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue