From 1bf44e43d11039bd30751f61d42a34f5addbd753 Mon Sep 17 00:00:00 2001 From: David Ellis Date: Fri, 9 Aug 2024 16:17:03 -0500 Subject: [PATCH] Fix negative exponents in scientific notation (#837) --- src/compile/integration_tests.rs | 6 ++++-- src/parse.rs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/compile/integration_tests.rs b/src/compile/integration_tests.rs index f407434a..127c127d 100644 --- a/src/compile/integration_tests.rs +++ b/src/compile/integration_tests.rs @@ -218,18 +218,20 @@ test!(other_integer_syntaxes => r#" print(0b10 == 2); print(0o10 == 8); print(0x10 == 16); + print(0xF == 15); } "#; - stdout "true\ntrue\ntrue\n"; + stdout "true\ntrue\ntrue\ntrue\n"; ); test!(scientific_notation => r#" export fn main { print(15.0 == 1.5e1); print(-5.0 == -5e0); print(1e3 == 1000.0); + print(1e-3 == 0.001); } "#; - stdout "true\ntrue\ntrue\n"; + stdout "true\ntrue\ntrue\ntrue\n"; ); test!(void_values => r#" export fn main { diff --git a/src/parse.rs b/src/parse.rs index 64597d9d..f2c214fa 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -437,9 +437,9 @@ build!( normalints, dot, natural, - opt(and!(or!(token!("e"), token!("E")), natural)) + opt(and!(or!(token!("e"), token!("E")), normalints)) ), - and!(normalints, or!(token!("e"), token!("E")), natural), + and!(normalints, or!(token!("e"), token!("E")), normalints), ) ); test!(real =>