Skip to content

Commit

Permalink
macros: Add a test for raw identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
dennis-hamester committed Oct 31, 2024
1 parent ed0970c commit 30a1af4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ extern crate proc_macro;
mod codegen;
mod derive;
mod service;
#[cfg(test)]
mod test;

use proc_macro2::TokenStream;
use syn::{DeriveInput, Result};
Expand Down
42 changes: 42 additions & 0 deletions macros/src/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
mod raw_identifiers {
#![allow(non_camel_case_types)]

use aldrin::core::ServiceUuid;
use aldrin::{service, AsSerializeArg, Deserialize, Introspectable, Serialize};
use uuid::uuid;

service! {
#[aldrin(schema = "raw_identifiers", introspection)]
service r#extern {
uuid = ServiceUuid(uuid!("f431a87f-85b8-4659-a310-0b7636b2d673"));
version = 1;

fn r#fn @ 1 {
args = r#struct;
ok = r#struct;
err = r#struct;
}

event r#pub @ 1 = r#enum;
}
}

#[derive(Debug, Clone, Serialize, Deserialize, AsSerializeArg, Introspectable)]
#[aldrin(schema = "raw_identifiers")]
struct r#struct {
r#struct: r#false,

#[aldrin(optional)]
r#enum: Option<r#enum>,
}

#[derive(Debug, Clone, Serialize, Deserialize, AsSerializeArg, Introspectable)]
#[aldrin(schema = "raw_identifiers")]
enum r#enum {
r#enum(r#false),
}

#[derive(Debug, Clone, Serialize, Deserialize, AsSerializeArg, Introspectable)]
#[aldrin(schema = "raw_identifiers")]
enum r#false {}
}

0 comments on commit 30a1af4

Please sign in to comment.