Add tests for multiple renames.
This commit is contained in:
committed by
J Henry Waugh
parent
dbfd3df810
commit
397acb4fce
@@ -0,0 +1,30 @@
|
||||
use rhai::plugin::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Point {
|
||||
x: f32,
|
||||
y: f32,
|
||||
}
|
||||
|
||||
#[export_module]
|
||||
pub mod test_module {
|
||||
pub use super::Point;
|
||||
#[rhai_fn(name = "foo", get = "bar")]
|
||||
pub fn test_fn(input: Point) -> bool {
|
||||
input.x > input.y
|
||||
}
|
||||
|
||||
#[rhai_fn(get = "bar")]
|
||||
pub fn foo(input: Point) -> bool {
|
||||
input.x < input.y
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let n = Point { x: 0.0, y: 10.0 };
|
||||
if test_module::test_fn(n) {
|
||||
println!("yes");
|
||||
} else {
|
||||
println!("no");
|
||||
}
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
error: duplicate Rhai signature for 'get$bar'
|
||||
--> $DIR/rhai_fn_rename_collision_oneattr_multiple.rs:17:15
|
||||
|
|
||||
17 | #[rhai_fn(get = "bar")]
|
||||
| ^^^
|
||||
|
||||
error: duplicated function renamed 'get$bar'
|
||||
--> $DIR/rhai_fn_rename_collision_oneattr_multiple.rs:12:15
|
||||
|
|
||||
12 | #[rhai_fn(name = "foo", get = "bar")]
|
||||
| ^^^^
|
||||
|
||||
error[E0433]: failed to resolve: use of undeclared type or module `test_module`
|
||||
--> $DIR/rhai_fn_rename_collision_oneattr_multiple.rs:25:8
|
||||
|
|
||||
25 | if test_module::test_fn(n) {
|
||||
| ^^^^^^^^^^^ use of undeclared type or module `test_module`
|
25
codegen/ui_tests/rhai_fn_rename_collision_with_itself.rs
Normal file
25
codegen/ui_tests/rhai_fn_rename_collision_with_itself.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
use rhai::plugin::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Point {
|
||||
x: f32,
|
||||
y: f32,
|
||||
}
|
||||
|
||||
#[export_module]
|
||||
pub mod test_module {
|
||||
pub use super::Point;
|
||||
#[rhai_fn(name = "foo", name = "bar", name = "foo")]
|
||||
pub fn test_fn(input: Point) -> bool {
|
||||
input.x > input.y
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let n = Point { x: 0.0, y: 10.0 };
|
||||
if test_module::test_fn(n) {
|
||||
println!("yes");
|
||||
} else {
|
||||
println!("no");
|
||||
}
|
||||
}
|
17
codegen/ui_tests/rhai_fn_rename_collision_with_itself.stderr
Normal file
17
codegen/ui_tests/rhai_fn_rename_collision_with_itself.stderr
Normal file
@@ -0,0 +1,17 @@
|
||||
error: duplicate Rhai signature for 'foo'
|
||||
--> $DIR/rhai_fn_rename_collision_with_itself.rs:12:15
|
||||
|
|
||||
12 | #[rhai_fn(name = "foo", name = "bar", name = "foo")]
|
||||
| ^^^^
|
||||
|
||||
error: duplicated function renamed 'foo'
|
||||
--> $DIR/rhai_fn_rename_collision_with_itself.rs:12:15
|
||||
|
|
||||
12 | #[rhai_fn(name = "foo", name = "bar", name = "foo")]
|
||||
| ^^^^
|
||||
|
||||
error[E0433]: failed to resolve: use of undeclared type or module `test_module`
|
||||
--> $DIR/rhai_fn_rename_collision_with_itself.rs:20:8
|
||||
|
|
||||
20 | if test_module::test_fn(n) {
|
||||
| ^^^^^^^^^^^ use of undeclared type or module `test_module`
|
Reference in New Issue
Block a user