* Upgrade to rust toolchain 1.82.0 * Fix lint about variant being too large * Fix lint about Err variant being too large
45 lines
1.3 KiB
Rust
45 lines
1.3 KiB
Rust
extern crate alloc;
|
|
use kcl_lib::ast::types::{
|
|
BodyItem, Expr, Identifier, ItemVisibility, Literal, LiteralValue, NonCodeMeta, Program, VariableDeclaration,
|
|
VariableDeclarator, VariableKind,
|
|
};
|
|
use kcl_macros::parse;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[test]
|
|
fn basic() {
|
|
let actual = parse!("const y = 4");
|
|
let expected = Program {
|
|
start: 0,
|
|
end: 11,
|
|
body: vec![BodyItem::VariableDeclaration(Box::new(VariableDeclaration {
|
|
start: 0,
|
|
end: 11,
|
|
declarations: vec![VariableDeclarator {
|
|
start: 6,
|
|
end: 11,
|
|
id: Identifier {
|
|
start: 6,
|
|
end: 7,
|
|
name: "y".to_owned(),
|
|
digest: None,
|
|
},
|
|
init: Expr::Literal(Box::new(Literal {
|
|
start: 10,
|
|
end: 11,
|
|
value: LiteralValue::IInteger(4),
|
|
raw: "4".to_owned(),
|
|
digest: None,
|
|
})),
|
|
digest: None,
|
|
}],
|
|
visibility: ItemVisibility::Default,
|
|
kind: VariableKind::Const,
|
|
digest: None,
|
|
}))],
|
|
non_code_meta: NonCodeMeta::default(),
|
|
digest: None,
|
|
};
|
|
assert_eq!(expected, actual);
|
|
}
|