Fix tests.
This commit is contained in:
parent
038e3c2554
commit
df72d324ba
@ -4,8 +4,8 @@ error: conflicting namespace
|
||||
12 | #[rhai_fn(global, global)]
|
||||
| ^^^^^^
|
||||
|
||||
error[E0433]: failed to resolve: use of undeclared type or module `test_module`
|
||||
error[E0433]: failed to resolve: use of undeclared crate or module `test_module`
|
||||
--> $DIR/rhai_fn_global_multiple.rs:23:8
|
||||
|
|
||||
23 | if test_module::test_fn(n) {
|
||||
| ^^^^^^^^^^^ use of undeclared type or module `test_module`
|
||||
| ^^^^^^^^^^^ use of undeclared crate or module `test_module`
|
||||
|
@ -161,9 +161,10 @@ service::increment(x);
|
||||
x == 43;
|
||||
```
|
||||
|
||||
Any functions (usually _methods_) defined in the module with `#[rhai_fn(global)]`, as well as
|
||||
all _type iterators_, are automatically exposed to the _global_ namespace, so iteration,
|
||||
[getters/setters] and [indexers] for [custom types] can work as expected.
|
||||
All functions (usually _methods_) defined in the module and marked with `#[rhai_fn(global)]`,
|
||||
as well as all _type iterators_, are automatically exposed to the _global_ namespace, so
|
||||
[iteration]({{rootUrl}}/language/for.md), [getters/setters] and [indexers] for [custom types]
|
||||
can work as expected.
|
||||
|
||||
Therefore, in the example above, the `increment` method (defined with `#[rhai_fn(global)]`)
|
||||
works fine when called in method-call style:
|
||||
|
@ -57,16 +57,10 @@ fn test_module_sub_module() -> Result<(), Box<EvalAltResult>> {
|
||||
assert!(engine
|
||||
.eval::<INT>("inc(question::life::universe::answer)")
|
||||
.is_err());
|
||||
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
assert_eq!(
|
||||
engine.eval::<INT>("super_inc(question::life::universe::answer)")?,
|
||||
42
|
||||
);
|
||||
#[cfg(feature = "no_object")]
|
||||
assert!(engine
|
||||
.eval::<INT>("super_inc(question::life::universe::answer)")
|
||||
.is_err());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user