feat: Added option to rename struct in Lua
This commit is contained in:
23
tests/rename.rs
Normal file
23
tests/rename.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
use lua_typed::Typed;
|
||||
|
||||
#[derive(Typed)]
|
||||
#[typed(as = "Lua")]
|
||||
struct Rust;
|
||||
|
||||
#[derive(Typed)]
|
||||
struct Other {
|
||||
pub rust: Rust,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rename() {
|
||||
insta::assert_snapshot!(<Rust as Typed>::generate_full().unwrap(), @"---@class Lua");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rename_nested() {
|
||||
insta::assert_snapshot!(<Other as Typed>::generate_full().unwrap(), @r"
|
||||
---@class Other
|
||||
---@field rust Lua
|
||||
");
|
||||
}
|
||||
7
tests/ui/empty_rename.rs
Normal file
7
tests/ui/empty_rename.rs
Normal file
@@ -0,0 +1,7 @@
|
||||
use lua_typed::Typed;
|
||||
|
||||
#[derive(Typed)]
|
||||
#[typed(as = "")]
|
||||
struct A;
|
||||
|
||||
fn main() {}
|
||||
5
tests/ui/empty_rename.stderr
Normal file
5
tests/ui/empty_rename.stderr
Normal file
@@ -0,0 +1,5 @@
|
||||
error: Name is not allowed to be empty
|
||||
--> tests/ui/empty_rename.rs:4:14
|
||||
|
|
||||
4 | #[typed(as = "")]
|
||||
| ^^
|
||||
7
tests/ui/unknown_attribute.rs
Normal file
7
tests/ui/unknown_attribute.rs
Normal file
@@ -0,0 +1,7 @@
|
||||
use lua_typed::Typed;
|
||||
|
||||
#[derive(Typed)]
|
||||
#[typed(cool)]
|
||||
struct A;
|
||||
|
||||
fn main() {}
|
||||
5
tests/ui/unknown_attribute.stderr
Normal file
5
tests/ui/unknown_attribute.stderr
Normal file
@@ -0,0 +1,5 @@
|
||||
error: Unknown attribute
|
||||
--> tests/ui/unknown_attribute.rs:4:9
|
||||
|
|
||||
4 | #[typed(cool)]
|
||||
| ^^^^
|
||||
Reference in New Issue
Block a user