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 ;
12use bevy_mod_scripting_rhai:: RhaiScriptingPlugin ;
23use libtest_mimic:: { Arguments , Failed , Trial } ;
4+ use rhai:: Dynamic ;
35use script_integration_test_harness:: execute_integration_test;
46use std:: {
57 fs:: { self , DirEntry } ,
@@ -21,6 +23,28 @@ impl Test {
2123 } ,
2224 |app| {
2325 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+
2448 // app.add_context_initializer::<LuaScriptingPlugin>(|_,ctxt: &mut Lua| {
2549 // let globals = ctxt.globals();
2650 // globals.set(
You can’t perform that action at this time.
0 commit comments