File tree Expand file tree Collapse file tree 3 files changed +5
-27
lines changed
assets/tests/asset_operations
crates/testing_crates/script_integration_test_harness/src Expand file tree Collapse file tree 3 files changed +5
-27
lines changed Original file line number Diff line number Diff line change 11function on_test ()
2- local asset_data = create_test_asset (42 , " TestAssetName" )
3- local test_handle = asset_data [1 ]
4- local asset_type_reg = asset_data [2 ]
2+ local test_handle = create_test_asset (42 , " TestAssetName" )
53
64 assert (test_handle ~= nil , " Test asset handle should not be nil" )
7- assert (asset_type_reg ~= nil , " TestAsset type registration should exist" )
8-
9- -- Check asset exists and retrieve it
105 assert (world .has_asset (test_handle ) == true , " has_asset should return true" )
116
12- local retrieved_asset = world .get_asset (test_handle , asset_type_reg )
13- assert (retrieved_asset ~= nil , " Should be able to retrieve the test asset" )
7+ local retrieved_asset = world .get_asset (test_handle , types .TestAsset )
148 assert (retrieved_asset .value == 42 , " Asset value should be 42" )
159 assert (retrieved_asset .name == " TestAssetName" , " Asset name should be 'TestAssetName'" )
1610end
Original file line number Diff line number Diff line change 11fn on_test() {
2- let asset_data = create_test_asset(42, "TestAssetName");
3- let test_handle = asset_data[0];
4- let asset_type_reg = asset_data[1];
2+ let test_handle = create_test_asset(42, "TestAssetName");
53
64 assert(test_handle != (), "Test asset handle should not be nil");
7- assert(asset_type_reg != (), "TestAsset type registration should exist");
8-
9- // Check asset exists and retrieve it
105 assert(world.has_asset.call(test_handle) == true, "has_asset should return true");
116
12- let retrieved_asset = world.get_asset.call(test_handle, asset_type_reg);
13- assert(retrieved_asset != (), "Should be able to retrieve the test asset");
7+ let retrieved_asset = world.get_asset.call(test_handle, types.TestAsset);
148 assert(retrieved_asset.value == 42, "Asset value should be 42");
159 assert(retrieved_asset.name == "TestAssetName", "Asset name should be 'TestAssetName'");
1610}
Original file line number Diff line number Diff line change @@ -153,22 +153,12 @@ pub fn register_test_functions(world: &mut App) {
153153 |s : FunctionCallContext , value : i32 , name : String | {
154154 let world = s. world ( ) ?;
155155 let test_asset = TestAsset :: new ( value, name) ;
156-
157156 let handle = world. with_resource_mut ( |mut assets : Mut < Assets < TestAsset > > | {
158157 assets. add ( test_asset)
159158 } ) ?;
160- let type_registry = world. type_registry ( ) ;
161- let type_registry = type_registry. read ( ) ;
162- let registration = type_registry. get ( std:: any:: TypeId :: of :: < TestAsset > ( ) )
163- . ok_or_else ( || InteropError :: str ( "TestAsset type not registered" ) ) ?;
164- let reg = ScriptTypeRegistration :: new ( Arc :: new ( registration. clone ( ) ) ) ;
165-
166159 let allocator = world. allocator ( ) ;
167160 let mut allocator = allocator. write ( ) ;
168- Ok ( vec ! [
169- ReflectReference :: new_allocated( handle, & mut allocator) ,
170- ReflectReference :: new_allocated( reg, & mut allocator)
171- ] )
161+ Ok ( ReflectReference :: new_allocated ( handle, & mut allocator) )
172162 } ,
173163 ) ;
174164}
You can’t perform that action at this time.
0 commit comments