add test with multiple names
This commit is contained in:
parent
570c725f69
commit
846f8046b0
@ -30,7 +30,8 @@ struct State {
|
||||
impl State {
|
||||
fn generate_new_name(&mut self, name: &str) -> ast::Name {
|
||||
let name = stdx::to_camel_case(name);
|
||||
let count = if let Some(count) = self.names.get(&name) {
|
||||
let count = if let Some(count) = self.names.get_mut(&name) {
|
||||
*count += 1;
|
||||
*count
|
||||
} else {
|
||||
self.names.insert(name.clone(), 1);
|
||||
@ -257,6 +258,41 @@ struct Root1{ bar: Bar1, foo: String }
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn naming() {
|
||||
check_fix(
|
||||
r#"
|
||||
{$0
|
||||
"user": {
|
||||
"address": {
|
||||
"street": "Main St",
|
||||
"house": 3
|
||||
},
|
||||
"email": "example@example.com"
|
||||
},
|
||||
"another_user": {
|
||||
"user": {
|
||||
"address": {
|
||||
"street": "Main St",
|
||||
"house": 3
|
||||
},
|
||||
"email": "example@example.com"
|
||||
}
|
||||
}
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
struct Address1{ house: i64, street: String }
|
||||
struct User1{ address: Address1, email: String }
|
||||
struct AnotherUser1{ user: User1 }
|
||||
struct Address2{ house: i64, street: String }
|
||||
struct User2{ address: Address2, email: String }
|
||||
struct Root1{ another_user: AnotherUser1, user: User2 }
|
||||
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn arrays() {
|
||||
check_fix(
|
||||
|
Loading…
Reference in New Issue
Block a user