File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
crates/languages/bevy_mod_scripting_rhai/tests Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 1
- assert(world.get_type_by_name('UnregisteredType') == (), 'Unregistered type was found')
1
+ assert(false);
2
+ assert(world.get_type_by_name("UnregisteredType") == (), "Unregistered type was found");
Original file line number Diff line number Diff line change
1
+ use bevy_mod_scripting_core:: AddRuntimeInitializer ;
1
2
use bevy_mod_scripting_rhai:: RhaiScriptingPlugin ;
2
3
use libtest_mimic:: { Arguments , Failed , Trial } ;
4
+ use rhai:: Dynamic ;
3
5
use script_integration_test_harness:: execute_integration_test;
4
6
use std:: {
5
7
fs:: { self , DirEntry } ,
@@ -21,6 +23,28 @@ impl Test {
21
23
} ,
22
24
|app| {
23
25
app. add_plugins ( RhaiScriptingPlugin :: default ( ) ) ;
26
+ app. add_runtime_initializer :: < RhaiScriptingPlugin > ( |runtime| {
27
+ runtime. register_fn ( "assert" , |a : Dynamic , b : & str | {
28
+ if !a. is :: < bool > ( ) {
29
+ panic ! ( "Expected a boolean value, but got {:?}" , a) ;
30
+ }
31
+ if !a. as_bool ( ) . unwrap ( ) {
32
+ panic ! ( "Assertion failed. {}" , b) ;
33
+ }
34
+ } ) ;
35
+ } ) ;
36
+
37
+ app. add_runtime_initializer :: < RhaiScriptingPlugin > ( |runtime| {
38
+ runtime. register_fn ( "assert" , |a : Dynamic | {
39
+ if !a. is :: < bool > ( ) {
40
+ panic ! ( "Expected a boolean value, but got {:?}" , a) ;
41
+ }
42
+ if !a. as_bool ( ) . unwrap ( ) {
43
+ panic ! ( "Assertion failed" ) ;
44
+ }
45
+ } ) ;
46
+ } ) ;
47
+
24
48
// app.add_context_initializer::<LuaScriptingPlugin>(|_,ctxt: &mut Lua| {
25
49
// let globals = ctxt.globals();
26
50
// globals.set(
You can’t perform that action at this time.
0 commit comments