Skip to content

Commit

Permalink
Fix negative exponents in scientific notation (#837)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfellis authored Aug 9, 2024
1 parent 097ee30 commit 1bf44e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/compile/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down

0 comments on commit 1bf44e4

Please sign in to comment.