swc/crates/swc_visit/tests/arc.rs
Donny/강동윤 9b76783281
refactor(common): Cleanup & rustfmt (#3495)
swc_common:
 - Merge identical source codes.

swc_css_parser:
 - Deny `clippy::all`.
 - Fix lints.
2022-02-09 06:33:32 +00:00

46 lines
818 B
Rust

use std::sync::Arc;
use swc_visit::define;
pub struct Item {
pub item: Option<Arc<Item>>,
pub ref_to_enum: Option<Arc<Enum>>,
}
pub enum Enum {
Item(Arc<Item>),
Items(Arc<Vec<Item>>),
Enum(Arc<Enum>),
Enums(Arc<Vec<Enum>>),
}
define!({
pub struct Item {
pub item: Option<Arc<Item>>,
pub ref_to_enum: Option<Arc<Enum>>,
}
pub enum Enum {
Item(Arc<Item>),
Items(Arc<Vec<Item>>),
Enum(Arc<Enum>),
Enums(Arc<Vec<Enum>>),
}
});
struct Panic;
impl Visit for Panic {
fn visit_item(&mut self, _: &Item) {
panic!("Success")
}
}
#[test]
#[should_panic(expected = "Success")]
fn test_panic() {
Enum::Item(Arc::new(Item {
item: None,
ref_to_enum: None,
}))
.visit_children_with(&mut Panic)
}