Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Sep 12, 2020
1 parent bcb8d6b commit 9b1b1dd
Showing 1 changed file with 7 additions and 29 deletions.
36 changes: 7 additions & 29 deletions src/rules/no_redeclare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,6 @@ impl Visit for NoRedeclareVisitor {
}
}

fn visit_for_stmt(&mut self, n: &ForStmt, _: &dyn Node) {
n.test.visit_with(n, self);
n.update.visit_with(n, self);
n.body.visit_with(n, self);
}

fn visit_for_in_stmt(&mut self, n: &ForInStmt, _: &dyn Node) {
n.right.visit_with(n, self);
n.body.visit_with(n, self);
}

fn visit_for_of_stmt(&mut self, n: &ForOfStmt, _: &dyn Node) {
n.right.visit_with(n, self);
n.body.visit_with(n, self);
}

fn visit_param(&mut self, p: &Param, _: &dyn Node) {
let ids: Vec<Ident> = find_ids(&p.pat);

Expand Down Expand Up @@ -171,34 +155,30 @@ mod tests {

#[test]
fn err_5() {
assert_lint_err::<NoRedeclare>("var Object = 0;", 4);

assert_lint_err_on_line_n::<NoRedeclare>(
"var a; var {a = 0, b: Object = 0} = {};",
vec![(1, 12), (1, 22)],
vec![(1, 12)],
);
}

#[test]
fn err_6() {
assert_lint_err_on_line_n::<NoRedeclare>(
"var a; var {a = 0, b: Object = 0} = {};",
vec![(1, 12), (1, 22)],
vec![(1, 12)],
);

assert_lint_err_on_line_n::<NoRedeclare>(
"var a; var {a = 0, b: Object = 0} = {};",
vec![(1, 12), (1, 22)],
vec![(1, 12)],
);

assert_lint_err::<NoRedeclare>("var globalThis = 0;", 5);
}

#[test]
fn err_7() {
assert_lint_err_on_line_n::<NoRedeclare>(
"var a; var {a = 0, b: globalThis = 0} = {};",
vec![(1, 12), (1, 22)],
vec![(1, 12)],
);
}

Expand All @@ -223,11 +203,6 @@ mod tests {
assert_lint_err::<NoRedeclare>("let a; const a = 0;", 13);
}

#[test]
fn err_10() {
assert_lint_err::<NoRedeclare>("var Object = 0;", 4);
}

#[test]
fn err_11() {
assert_lint_err::<NoRedeclare>("let a; const a = 0;", 13);
Expand Down Expand Up @@ -271,6 +246,9 @@ mod tests {
assert_lint_ok::<NoRedeclare>(
"class C {
constructor(a: string) {}
}
class D {
constructor(a: string) {}
}",
);
}
Expand Down

0 comments on commit 9b1b1dd

Please sign in to comment.