mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Merge #6490
6490: Minimize convert_integer_literal tests r=matklad a=m-ysk Closes #6455 This PR removes some redundant tests around convert_integer_literal. First, it removes test cases about converting integer with underscores except for just one case. This is because the process of removing of underscores in given integer literals is independent from radix. Second, as well as underscore cases, it removes test cases about converting integer with suffix except for just one case. This is because the process of handling suffix is independent from radix. Finally, it removes small decimal integer cases. This is because "special case where they return early" has been removed by the PR #6482, so we have no need to retain this cases. Co-authored-by: m-ysk <myskjp@gmail.com>
This commit is contained in:
commit
1b147306b4
1 changed files with 2 additions and 368 deletions
|
@ -129,34 +129,6 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
// Decimal numbers under 3 digits have a special case where they return early because we can't fit a
|
||||
// other base's prefix, so we have a separate test for that.
|
||||
#[test]
|
||||
fn convert_small_decimal_integer() {
|
||||
let before = "const _: i32 = 10<|>;";
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0b1010;",
|
||||
"Convert 10 to 0b1010",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0o12;",
|
||||
"Convert 10 to 0o12",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0xA;",
|
||||
"Convert 10 to 0xA",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn convert_hexadecimal_integer() {
|
||||
let before = "const _: i32 = 0xFF<|>;";
|
||||
|
@ -236,7 +208,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn convert_decimal_integer_with_underscores() {
|
||||
fn convert_integer_with_underscores() {
|
||||
let before = "const _: i32 = 1_00_0<|>;";
|
||||
|
||||
check_assist_by_label(
|
||||
|
@ -262,111 +234,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn convert_small_decimal_integer_with_underscores() {
|
||||
let before = "const _: i32 = 1_0<|>;";
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0b1010;",
|
||||
"Convert 1_0 to 0b1010",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0o12;",
|
||||
"Convert 1_0 to 0o12",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0xA;",
|
||||
"Convert 1_0 to 0xA",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn convert_hexadecimal_integer_with_underscores() {
|
||||
let before = "const _: i32 = 0x_F_F<|>;";
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0b11111111;",
|
||||
"Convert 0x_F_F to 0b11111111",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0o377;",
|
||||
"Convert 0x_F_F to 0o377",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 255;",
|
||||
"Convert 0x_F_F to 255",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn convert_binary_integer_with_underscores() {
|
||||
let before = "const _: i32 = 0b1111_1111<|>;";
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0o377;",
|
||||
"Convert 0b1111_1111 to 0o377",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 255;",
|
||||
"Convert 0b1111_1111 to 255",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0xFF;",
|
||||
"Convert 0b1111_1111 to 0xFF",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn convert_octal_integer_with_underscores() {
|
||||
let before = "const _: i32 = 0o3_77<|>;";
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0b11111111;",
|
||||
"Convert 0o3_77 to 0b11111111",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 255;",
|
||||
"Convert 0o3_77 to 255",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0xFF;",
|
||||
"Convert 0o3_77 to 0xFF",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn convert_decimal_integer_with_suffix() {
|
||||
fn convert_integer_with_suffix() {
|
||||
let before = "const _: i32 = 1000i32<|>;";
|
||||
|
||||
check_assist_by_label(
|
||||
|
@ -391,240 +259,6 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn convert_small_decimal_integer_with_suffix() {
|
||||
let before = "const _: i32 = 10i32<|>;";
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0b1010i32;",
|
||||
"Convert 10i32 to 0b1010i32",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0o12i32;",
|
||||
"Convert 10i32 to 0o12i32",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0xAi32;",
|
||||
"Convert 10i32 to 0xAi32",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn convert_hexadecimal_integer_with_suffix() {
|
||||
let before = "const _: i32 = 0xFFi32<|>;";
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0b11111111i32;",
|
||||
"Convert 0xFFi32 to 0b11111111i32",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0o377i32;",
|
||||
"Convert 0xFFi32 to 0o377i32",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 255i32;",
|
||||
"Convert 0xFFi32 to 255i32",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn convert_binary_integer_with_suffix() {
|
||||
let before = "const _: i32 = 0b11111111i32<|>;";
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0o377i32;",
|
||||
"Convert 0b11111111i32 to 0o377i32",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 255i32;",
|
||||
"Convert 0b11111111i32 to 255i32",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0xFFi32;",
|
||||
"Convert 0b11111111i32 to 0xFFi32",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn convert_octal_integer_with_suffix() {
|
||||
let before = "const _: i32 = 0o377i32<|>;";
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0b11111111i32;",
|
||||
"Convert 0o377i32 to 0b11111111i32",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 255i32;",
|
||||
"Convert 0o377i32 to 255i32",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0xFFi32;",
|
||||
"Convert 0o377i32 to 0xFFi32",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn convert_decimal_integer_with_underscores_and_suffix() {
|
||||
let before = "const _: i32 = 1_00_0i32<|>;";
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0b1111101000i32;",
|
||||
"Convert 1_00_0i32 to 0b1111101000i32",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0o1750i32;",
|
||||
"Convert 1_00_0i32 to 0o1750i32",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0x3E8i32;",
|
||||
"Convert 1_00_0i32 to 0x3E8i32",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn convert_small_decimal_integer_with_underscores_and_suffix() {
|
||||
let before = "const _: i32 = 1_0i32<|>;";
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0b1010i32;",
|
||||
"Convert 1_0i32 to 0b1010i32",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0o12i32;",
|
||||
"Convert 1_0i32 to 0o12i32",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0xAi32;",
|
||||
"Convert 1_0i32 to 0xAi32",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn convert_hexadecimal_integer_with_underscores_and_suffix() {
|
||||
let before = "const _: i32 = 0x_F_Fi32<|>;";
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0b11111111i32;",
|
||||
"Convert 0x_F_Fi32 to 0b11111111i32",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0o377i32;",
|
||||
"Convert 0x_F_Fi32 to 0o377i32",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 255i32;",
|
||||
"Convert 0x_F_Fi32 to 255i32",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn convert_binary_integer_with_underscores_and_suffix() {
|
||||
let before = "const _: i32 = 0b1111_1111i32<|>;";
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0o377i32;",
|
||||
"Convert 0b1111_1111i32 to 0o377i32",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 255i32;",
|
||||
"Convert 0b1111_1111i32 to 255i32",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0xFFi32;",
|
||||
"Convert 0b1111_1111i32 to 0xFFi32",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn convert_octal_integer_with_underscores_and_suffix() {
|
||||
let before = "const _: i32 = 0o3_77i32<|>;";
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0b11111111i32;",
|
||||
"Convert 0o3_77i32 to 0b11111111i32",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 255i32;",
|
||||
"Convert 0o3_77i32 to 255i32",
|
||||
);
|
||||
|
||||
check_assist_by_label(
|
||||
convert_integer_literal,
|
||||
before,
|
||||
"const _: i32 = 0xFFi32;",
|
||||
"Convert 0o3_77i32 to 0xFFi32",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn convert_overflowing_literal() {
|
||||
let before = "const _: i32 =
|
||||
|
|
Loading…
Reference in a new issue