Skip to content

Commit

Permalink
More exponent tests for float_literal_trailing_zero option
Browse files Browse the repository at this point in the history
  • Loading branch information
amatveiakin committed Jan 5, 2025
1 parent 3436b40 commit 004bc6b
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 49 deletions.
15 changes: 15 additions & 0 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2397,11 +2397,26 @@ mod test {
assert_eq!(parts.fractional_part, Some("456"));
assert_eq!(parts.exponent, Some("e789"));

let parts = parse_float_symbol("123.456e+789");
assert_eq!(parts.integer_part, "123");
assert_eq!(parts.fractional_part, Some("456"));
assert_eq!(parts.exponent, Some("e+789"));

let parts = parse_float_symbol("123.456e-789");
assert_eq!(parts.integer_part, "123");
assert_eq!(parts.fractional_part, Some("456"));
assert_eq!(parts.exponent, Some("e-789"));

let parts = parse_float_symbol("123e789");
assert_eq!(parts.integer_part, "123");
assert_eq!(parts.fractional_part, None);
assert_eq!(parts.exponent, Some("e789"));

let parts = parse_float_symbol("123E789");
assert_eq!(parts.integer_part, "123");
assert_eq!(parts.fractional_part, None);
assert_eq!(parts.exponent, Some("E789"));

let parts = parse_float_symbol("123.");
assert_eq!(parts.integer_part, "123");
assert_eq!(parts.fractional_part, None);
Expand Down
20 changes: 13 additions & 7 deletions tests/source/configs/float_literal_trailing_zero/always.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ fn float_literals() {
let d = 100.0;
let e = 5e3;
let f = 5.0e3;
let g = 7f32;
let h = 7.0f32;
let i = 9e3f32;
let j = 9.0e3f32;
let k = 1000.00;
let l = 1_000_.;
let m = 1_000_.000_000;
let g = 5e+3;
let h = 5.0e+3;
let i = 5e-3;
let j = 5.0e-3;
let k = 5E3;
let l = 5.0E3;
let m = 7f32;
let n = 7.0f32;
let o = 9e3f32;
let p = 9.0e3f32;
let q = 1000.00;
let r = 1_000_.;
let s = 1_000_.000_000;
}

fn line_wrapping() {
Expand Down
20 changes: 13 additions & 7 deletions tests/source/configs/float_literal_trailing_zero/if-no-postfix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ fn float_literals() {
let d = 100.0;
let e = 5e3;
let f = 5.0e3;
let g = 7f32;
let h = 7.0f32;
let i = 9e3f32;
let j = 9.0e3f32;
let k = 1000.00;
let l = 1_000_.;
let m = 1_000_.000_000;
let g = 5e+3;
let h = 5.0e+3;
let i = 5e-3;
let j = 5.0e-3;
let k = 5E3;
let l = 5.0E3;
let m = 7f32;
let n = 7.0f32;
let o = 9e3f32;
let p = 9.0e3f32;
let q = 1000.00;
let r = 1_000_.;
let s = 1_000_.000_000;
}

fn line_wrapping() {
Expand Down
20 changes: 13 additions & 7 deletions tests/source/configs/float_literal_trailing_zero/never.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ fn float_literals() {
let d = 100.0;
let e = 5e3;
let f = 5.0e3;
let g = 7f32;
let h = 7.0f32;
let i = 9e3f32;
let j = 9.0e3f32;
let k = 1000.00;
let l = 1_000_.;
let m = 1_000_.000_000;
let g = 5e+3;
let h = 5.0e+3;
let i = 5e-3;
let j = 5.0e-3;
let k = 5E3;
let l = 5.0E3;
let m = 7f32;
let n = 7.0f32;
let o = 9e3f32;
let p = 9.0e3f32;
let q = 1000.00;
let r = 1_000_.;
let s = 1_000_.000_000;
}

fn line_wrapping() {
Expand Down
20 changes: 13 additions & 7 deletions tests/target/configs/float_literal_trailing_zero/always.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ fn float_literals() {
let d = 100.0;
let e = 5.0e3;
let f = 5.0e3;
let g = 7.0f32;
let h = 7.0f32;
let i = 9.0e3f32;
let j = 9.0e3f32;
let k = 1000.00;
let l = 1_000_.0;
let m = 1_000_.000_000;
let g = 5.0e+3;
let h = 5.0e+3;
let i = 5.0e-3;
let j = 5.0e-3;
let k = 5.0E3;
let l = 5.0E3;
let m = 7.0f32;
let n = 7.0f32;
let o = 9.0e3f32;
let p = 9.0e3f32;
let q = 1000.00;
let r = 1_000_.0;
let s = 1_000_.000_000;
}

fn line_wrapping() {
Expand Down
20 changes: 13 additions & 7 deletions tests/target/configs/float_literal_trailing_zero/if-no-postfix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ fn float_literals() {
let d = 100.0;
let e = 5e3;
let f = 5e3;
let g = 7f32;
let h = 7f32;
let i = 9e3f32;
let j = 9e3f32;
let k = 1000.00;
let l = 1_000_.0;
let m = 1_000_.000_000;
let g = 5e+3;
let h = 5e+3;
let i = 5e-3;
let j = 5e-3;
let k = 5E3;
let l = 5E3;
let m = 7f32;
let n = 7f32;
let o = 9e3f32;
let p = 9e3f32;
let q = 1000.00;
let r = 1_000_.0;
let s = 1_000_.000_000;
}

fn line_wrapping() {
Expand Down
20 changes: 13 additions & 7 deletions tests/target/configs/float_literal_trailing_zero/never.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ fn float_literals() {
let d = 100.;
let e = 5e3;
let f = 5e3;
let g = 7f32;
let h = 7f32;
let i = 9e3f32;
let j = 9e3f32;
let k = 1000.;
let l = 1_000_.;
let m = 1_000_.;
let g = 5e+3;
let h = 5e+3;
let i = 5e-3;
let j = 5e-3;
let k = 5E3;
let l = 5E3;
let m = 7f32;
let n = 7f32;
let o = 9e3f32;
let p = 9e3f32;
let q = 1000.;
let r = 1_000_.;
let s = 1_000_.;
}

fn line_wrapping() {
Expand Down
20 changes: 13 additions & 7 deletions tests/target/configs/float_literal_trailing_zero/preserve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ fn float_literals() {
let d = 100.0;
let e = 5e3;
let f = 5.0e3;
let g = 7f32;
let h = 7.0f32;
let i = 9e3f32;
let j = 9.0e3f32;
let k = 1000.00;
let l = 1_000_.;
let m = 1_000_.000_000;
let g = 5e+3;
let h = 5.0e+3;
let i = 5e-3;
let j = 5.0e-3;
let k = 5E3;
let l = 5.0E3;
let m = 7f32;
let n = 7.0f32;
let o = 9e3f32;
let p = 9.0e3f32;
let q = 1000.00;
let r = 1_000_.;
let s = 1_000_.000_000;
}

0 comments on commit 004bc6b

Please sign in to comment.