Skip to content

Commit

Permalink
stage back some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
makspll committed Apr 4, 2024
1 parent b2315ae commit 2997127
Show file tree
Hide file tree
Showing 29 changed files with 300 additions and 242 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
use bevy::prelude::*;
use bevy_mod_scripting::api::*;

#[derive(ScriptProxy, Reflect)]
#[proxy(languages("lua"), derive(Clone))]
#[functions[
#[lua(Function)]
fn fn_returning_some_string(some_str: &str) -> String;
]]
#[derive(Clone)]
#[derive(LuaProxy, Reflect, Clone)]
#[proxy(functions = [
r#"
#[lua(kind="Function")]
fn fn_returning_some_string(some_str: &str) -> String
"#,
])]
pub struct MyStruct {
some_string: String,
me_vec: Vec<usize>,
}

impl MyStruct {
pub fn fn_returning_some_string(some_str: &str) -> String {
some_str.to_owned()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use bevy::prelude::*;
use bevy_mod_scripting::api::*;

#[derive(ScriptProxy, Reflect)]
#[proxy(languages("lua"), derive(Clone))]
#[functions[
#[lua(Function, output(proxy))]
fn fn_returning_some_string(#[proxy] ref_: &Self ) -> &Self {
#[derive(LuaProxy, Reflect, Clone)]
#[proxy(functions = [
r#"
#[lua(kind="Function", output(proxy))]
fn fn_returning_some_string(ref_: &Self ) -> &Self {
ref_
}
]]
#[derive(Clone)]
"#,
])]
pub struct MyStruct;

pub fn main() {}
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
use bevy::prelude::*;
use bevy_mod_scripting::api::*;

#[derive(ScriptProxy, Reflect)]
#[proxy(languages("lua"), derive(Clone))]
#[functions[
#[lua(Function)]
#[derive(LuaProxy, Reflect, Clone)]
#[proxy(functions = [
r#"
#[lua(kind="Function")]
fn fn_returning_some_string(self) {
}
"#,
#[lua(Function)]
r#"
#[lua(kind="Function")]
fn fn_returning_proxy(&self) {
}
]]
#[derive(Clone)]
"#,
])]
pub struct MyStruct;

pub fn main() {}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use bevy::prelude::*;
use bevy_mod_scripting::api::*;

#[derive(ScriptProxy, Reflect)]
#[proxy(languages("lua"), derive(Clone))]
#[functions[
#[lua(Method)]
fn my_fn(&self);
]]
#[derive(Clone)]
#[derive(LuaProxy, Reflect, Clone)]
#[proxy(functions = [
r#"
#[lua(kind="Method")]
fn my_fn(&self)
"#,
])]
pub struct MyStruct;

impl MyStruct {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use bevy::prelude::*;
use bevy_mod_scripting::api::*;

#[derive(ScriptProxy, Reflect)]
#[proxy(languages("lua"), derive(Clone))]
#[functions[
#[lua(Method)]
fn my_fn(&self, arg: String);
]]
#[derive(Clone)]
#[derive(LuaProxy, Reflect, Clone)]
#[proxy(functions = [
r#"
#[lua(kind="Method")]
fn my_fn(&self, arg: String)
"#,
])]
pub struct MyStruct;

impl MyStruct {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use bevy::prelude::*;
use bevy_mod_scripting::api::*;

#[derive(ScriptProxy, Reflect)]
#[proxy(languages("lua"), derive(Clone))]
#[functions[
#[lua(AMASJDIASDKAW)]
#[derive(LuaProxy, Reflect, Clone)]
#[proxy(functions = [
r#"
#[lua(kind="AMASJDIASDKAW")]
fn fn_taking_nothing() {
}
]]
#[derive(Clone)]
"#,
])]
pub struct MyStruct;

pub fn main() {}
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
use bevy::prelude::*;
use bevy_mod_scripting::api::*;

#[derive(ScriptProxy, Reflect)]
#[proxy(languages("lua"), derive(Clone))]
#[functions[
#[lua(Function)]
#[derive(LuaProxy, Reflect, Clone)]
#[proxy(functions = [
r#"
#[lua(kind="Function", output(proxy))]
fn fn_returning_proxy() -> Self {
2
}
]]
#[derive(Clone)]
"#,
])]
pub struct MyStruct;

pub fn main() {}
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
use bevy::prelude::*;
use bevy_mod_scripting::api::*;

#[derive(ScriptProxy, Reflect)]
#[proxy(languages("lua"), derive(Clone))]
#[functions[
#[lua(Function)]
fn my_fn() -> usize;
]]
#[derive(Clone)]
#[derive(LuaProxy, Reflect, Clone)]
#[proxy(functions = [
r#"
#[lua(kind="Function")]
fn my_fn() -> usize
"#,
])]
pub struct MyStruct;

impl MyStruct {
pub fn my_fn() -> Self {
MyStruct
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
use bevy::prelude::*;
use bevy_mod_scripting::api::*;

#[derive(ScriptProxy, Reflect)]
#[proxy(languages("lua"), derive(Clone))]
#[functions[
#[lua(Method)]
#[derive(LuaProxy, Reflect, Clone)]
#[proxy(functions = [
r#"
#[lua(kind="Method")]
fn fn_taking_nothing() {
}
"#,
#[lua(Method)]
r#"
#[lua(kind="Method")]
fn fn_taking_usize(arg: usize) {
}
]]
#[derive(Clone)]
"#,
])]
pub struct MyStruct;

pub fn main() {}
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
use bevy::prelude::*;
use bevy_mod_scripting::api::*;

#[derive(ScriptProxy, Reflect)]
#[proxy(languages("lua"), derive(Clone))]
#[functions[
#[lua(Function)]
#[derive(LuaProxy, Reflect, Clone)]
#[proxy(functions = [
r#"
#[lua(kind="Function", output(proxy))]
fn fn_returning_proxy() -> Self {
MyStruct
}
]]
#[derive(Clone)]
"#,
])]
pub struct MyStruct;

pub fn main() {}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#[test]
fn success() {
// let t = trybuild::TestCases::new();
// t.pass("tests/success/**/*.rs");
let t = trybuild::TestCases::new();
t.pass("tests/success/**/*.rs");
}

#[test]
fn fail() {
// let t = trybuild::TestCases::new();
// t.compile_fail("tests/fail/**/*.rs");
let t = trybuild::TestCases::new();
t.compile_fail("tests/fail/**/*.rs");
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
use bevy::prelude::*;
use bevy_mod_scripting::api::*;

#[derive(ScriptProxy, Reflect, Clone)]
#[proxy(languages("lua"), derive(Clone))]
#[functions[
#[lua(Function)]
fn fn_returning_string_option(_opt: Option<String>) {
}
#[derive(LuaProxy, Reflect, Clone)]
#[proxy(functions[
r#"
#[lua(kind="Function")]
fn fn_returning_string_option(_opt: Option<String>)
"#,r#"
#[lua(kind="Function")]
fn fn_returning_some_proxy(#[proxy] _opt: Option<Self>)
"#
])]
pub struct MyStruct;

pub fn main() {}

#[lua(kind = "Function")]
fn fn_returning_string_option(_opt: Option<String>) {}

#[lua(kind = "Function")]
fn fn_returning_some_proxy(#[proxy] _opt: Option<Self>) {}

#[lua(Function)]
fn fn_returning_some_proxy(#[proxy] _opt: Option<Self>) {
}
]]
pub struct MyStruct;

pub fn main() {}
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
use bevy::prelude::*;
use bevy_mod_scripting::api::*;

#[derive(ScriptProxy, Reflect, Clone)]
#[proxy(languages("lua"), derive(Clone))]
#[functions[
#[lua(Function)]
#[derive(LuaProxy, Reflect, Clone)]
#[proxy(functions[
r#"
#[lua(kind="Function")]
fn fn_returning_string_option() -> Option<String> {
Some("hello".to_owned())
}
"#,
#[lua(Function)]
r#"
#[lua(kind="Function")]
fn fn_returning_string_option_none() -> Option<String> {
None
}
"#,
#[lua(Function, output(proxy))]
r#"
#[lua(kind="Function", output(proxy="proxy"))]
fn fn_returning_some_proxy() -> Option<Self> {
Some(MyStruct)
}
"#,
#[lua(Function, output(proxy))]
r#"
#[lua(kind="Function", output(proxy="proxy"))]
fn fn_returning_none_proxy() -> Option<Self> {
None
}
]]
"#,
])]
pub struct MyStruct;

pub fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,36 @@ impl Display for MyError {
}
}

#[derive(ScriptProxy, Reflect, Clone)]
#[proxy(languages("lua"), derive(Clone))]
#[functions[
#[lua(Function)]
#[derive(LuaProxy, Reflect, Clone)]
#[proxy(functions = [
r#"
#[lua(kind="Function")]
fn fn_returning_usize_result() -> Result<usize, MyError> {
Ok(2)
}
"#,
#[lua(Function)]
r#"
#[lua(kind="Function")]
fn fn_returning_usize_result_err() -> Result<usize, MyError> {
Err(MyError)
}
"#,
#[lua(Function, output(proxy))]
r#"
#[lua(kind="Function", output(proxy))]
fn fn_returning_ok_proxy() -> Result<Self, MyError> {
Ok(MyStruct)
}
"#,
#[lua(Function, output(proxy))]
r#"
#[lua(kind="Function", output(proxy))]
fn fn_returning_err_proxy() -> Result<Self, MyError> {
Err(MyError)
}
]]
"#,
])]
pub struct MyStruct;

pub fn main() {}
Loading

0 comments on commit 2997127

Please sign in to comment.