mirror of
https://github.com/swc-project/swc.git
synced 2024-11-24 02:06:08 +03:00
feat(es/parser): Add tests for static blocks (#2180)
swc_ecma_parser: - Add tests for multiple static blocks in a class.
This commit is contained in:
parent
c0b0337d1d
commit
b2c99719fd
@ -1926,6 +1926,47 @@ export default function waitUntil(callback, options = {}) {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multiple_class_static_blocks() {
|
||||
let src = "class Foo { static { 1 + 1; } static { 1 + 1; } }";
|
||||
assert_eq_ignore_span!(
|
||||
test_parser(
|
||||
src,
|
||||
Syntax::Es(EsConfig {
|
||||
static_blocks: true,
|
||||
..Default::default()
|
||||
}),
|
||||
|p| p.parse_expr()
|
||||
),
|
||||
Box::new(Expr::Class(ClassExpr {
|
||||
ident: Some(Ident {
|
||||
span,
|
||||
sym: "Foo".into(),
|
||||
optional: false,
|
||||
}),
|
||||
class: Class {
|
||||
span,
|
||||
decorators: Vec::new(),
|
||||
super_class: None,
|
||||
type_params: None,
|
||||
super_type_params: None,
|
||||
is_abstract: false,
|
||||
implements: Vec::new(),
|
||||
body: vec!(
|
||||
ClassMember::StaticBlock(StaticBlock {
|
||||
span,
|
||||
body: vec!(stmt("1 + 1;"))
|
||||
}),
|
||||
ClassMember::StaticBlock(StaticBlock {
|
||||
span,
|
||||
body: vec!(stmt("1 + 1;"))
|
||||
})
|
||||
)
|
||||
}
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn class_static_blocks_in_ts() {
|
||||
let src = "class Foo { static { 1 + 1 }; }";
|
||||
|
Loading…
Reference in New Issue
Block a user