mirror of
https://github.com/RGBCube/cstree
synced 2025-07-27 09:07:44 +00:00
Add derive macro for Syntax
(used to be Language
) (#51)
This commit is contained in:
parent
2aa543036f
commit
c5279bae7d
70 changed files with 1459 additions and 899 deletions
22
test_suite/tests/derive.rs
Normal file
22
test_suite/tests/derive.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
use cstree::{RawSyntaxKind, Syntax};
|
||||
|
||||
#[test]
|
||||
fn basic() {
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Syntax)]
|
||||
#[repr(u32)]
|
||||
pub enum SyntaxKind {
|
||||
A,
|
||||
#[static_text("b")]
|
||||
B,
|
||||
}
|
||||
pub type MySyntax = SyntaxKind;
|
||||
|
||||
assert_eq!(MySyntax::into_raw(SyntaxKind::A), RawSyntaxKind(0));
|
||||
assert_eq!(MySyntax::into_raw(SyntaxKind::B), RawSyntaxKind(1));
|
||||
|
||||
assert_eq!(MySyntax::from_raw(RawSyntaxKind(0)), SyntaxKind::A);
|
||||
assert_eq!(MySyntax::from_raw(RawSyntaxKind(1)), SyntaxKind::B);
|
||||
|
||||
assert!(MySyntax::static_text(SyntaxKind::A).is_none());
|
||||
assert_eq!(MySyntax::static_text(SyntaxKind::B), Some("b"));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue