swc/crates/swc_ecma_visit/tests/main.rs
Donny/강동윤 581aafb4df
perf(visit): Introduce Pass API and adjust visitor APIs for it (#9680)
**Description:**

 - `Pass`: `FnMut(&mut Program)`.

**Breaking Changes:**

- `chain!`: Use a tuple instead. You can replace all `chain!(` with `(` with IDE feature and it will work.
- `chain!` with 13 or more args: Use nested tuples for items after 13th element.


**Related issue:**

 - Related to https://github.com/swc-project/swc/issues/9601
2024-10-29 11:25:16 +09:00

31 lines
677 B
Rust

use swc_common::DUMMY_SP;
use swc_ecma_ast::*;
use swc_ecma_visit::NodeRef;
#[test]
fn traverse_lookup() {
let node = Expr::Call(CallExpr {
span: DUMMY_SP,
callee: Callee::Expr(
AwaitExpr {
span: DUMMY_SP,
arg: Ident::new_no_ctxt("foo".into(), DUMMY_SP).into(),
}
.into(),
),
args: Vec::new(),
..Default::default()
});
let node_ref = NodeRef::from(&node);
let iter = node_ref.experimental_traverse();
let mut has_await = false;
for node in iter {
has_await |= matches!(node, NodeRef::AwaitExpr(..));
}
assert!(has_await);
}