@@ -398,229 +398,3 @@ impl UserData for LuaStaticReflectReference {
398
398
) ;
399
399
}
400
400
}
401
-
402
- // #[cfg(test)]
403
- // mod test {
404
-
405
- // use bevy::{
406
- // app::App,
407
- // ecs::{reflect::AppTypeRegistry, world::World},
408
- // reflect::{FromReflect, OffsetAccess, Reflect},
409
- // };
410
- // use bevy_mod_scripting_core::{
411
- // bindings::ReflectAllocator,
412
- // bindings::{ReflectBase, ReflectBaseType, WorldAccessGuard, WorldCallbackAccess},
413
- // };
414
- // use bevy_mod_scripting_derive::LuaProxy;
415
-
416
- // use crate::{bindings::world::LuaWorld, type_data::RegisterLua};
417
-
418
- // use super::*;
419
-
420
- // #[derive(Reflect)]
421
- // struct TestStruct {
422
- // value: usize,
423
- // proxy: TestProxied,
424
- // proxies: Vec<TestProxied>,
425
- // }
426
-
427
- // #[derive(Reflect)]
428
- // struct TestTupleStruct(usize, TestProxied, Vec<TestProxied>);
429
-
430
- // #[derive(Reflect)]
431
- // enum TestTupleEnum {
432
- // Value(usize),
433
- // Proxy(TestProxied),
434
- // Proxies(Vec<TestProxied>),
435
- // }
436
-
437
- // #[derive(Reflect, LuaProxy)]
438
- // #[proxy(bms_core_path = "bevy_mod_scripting_core", bms_lua_path = "crate")]
439
- // #[reflect(LuaProxied)]
440
- // pub struct TestProxied;
441
-
442
- // impl PartialEq for LuaTestProxied {
443
- // fn eq(&self, other: &Self) -> bool {
444
- // self.0 == other.0
445
- // }
446
- // }
447
-
448
- // /// asserts that setting then indexing into a LuaReflectReference of type T with the given expression returns the expected value.
449
- // /// Provides `t and `world` globals, with t being the LuaReflectReference to the provided value.
450
- // fn assert_lua_set_get_returns<
451
- // T: Reflect,
452
- // F: Fn(ReflectReference) -> O,
453
- // O: for<'l> FromLua<'l> + for<'l> IntoLua<'l> + PartialEq + std::fmt::Debug,
454
- // >(
455
- // mut world: &mut World,
456
- // val: T,
457
- // expr: &'static str,
458
- // expected: F,
459
- // ) {
460
- // let lua = Lua::new();
461
- // let mut allocator = ReflectAllocator::default();
462
- // let reflect_ref = LuaReflectReference(ReflectReference::new_allocated(val, &mut allocator));
463
- // world.insert_resource(allocator);
464
-
465
- // WorldCallbackAccess::with_callback_access(world, |access| {
466
- // let globals = lua.globals();
467
- // globals.set("test", reflect_ref.clone()).unwrap();
468
- // globals.set("world", LuaWorld(access.clone())).unwrap();
469
- // globals
470
- // .set("expected", expected(reflect_ref.0.clone()))
471
- // .unwrap();
472
-
473
- // let lua_code = format!(
474
- // r#"
475
- // {expr} = expected
476
- // return {expr}
477
- // "#
478
- // );
479
- // let result = lua
480
- // .load(&lua_code)
481
- // .into_function()
482
- // .unwrap_or_else(|e| panic!("Could not load lua code into function: `{e}`"))
483
- // .call(())
484
- // .unwrap_or_else(|e| {
485
- // panic!("Could not convert expression value to expected type: `{e}`")
486
- // });
487
- // let result: O = result;
488
- // assert_eq!(result, expected(reflect_ref.0));
489
- // });
490
- // }
491
-
492
- // #[test]
493
- // fn test_index_lua_value() {
494
- // // so we have the registry and can just do this
495
- // let mut app = App::new();
496
- // app.register_lua_value::<usize>();
497
-
498
- // assert_lua_set_get_returns(
499
- // app.world_mut(),
500
- // TestStruct {
501
- // value: 123,
502
- // proxy: TestProxied,
503
- // proxies: vec![],
504
- // },
505
- // "test.value",
506
- // |_| 123usize,
507
- // );
508
-
509
- // let mut app = App::new();
510
- // app.register_lua_value::<usize>();
511
-
512
- // assert_lua_set_get_returns(
513
- // app.world_mut(),
514
- // TestTupleStruct(123, TestProxied, vec![]),
515
- // "test._1",
516
- // |_| 123usize,
517
- // );
518
-
519
- // let mut app = App::new();
520
- // app.register_lua_value::<usize>();
521
-
522
- // assert_lua_set_get_returns(
523
- // app.world_mut(),
524
- // TestTupleEnum::Value(123usize),
525
- // "test._1",
526
- // |_| 123usize,
527
- // );
528
- // }
529
-
530
- // #[test]
531
- // fn test_index_lua_proxy() {
532
- // // so we have the registry and can just do this
533
- // let mut app = App::new();
534
- // app.register_lua_proxy::<TestProxied>();
535
-
536
- // assert_lua_set_get_returns(
537
- // app.world_mut(),
538
- // TestStruct {
539
- // value: 123,
540
- // proxy: TestProxied,
541
- // proxies: vec![],
542
- // },
543
- // "test.proxy",
544
- // |mut r| {
545
- // r.index_path(ParsedPath::parse_static("proxy").unwrap());
546
- // LuaTestProxied(r)
547
- // },
548
- // );
549
-
550
- // let mut app = App::new();
551
- // app.register_lua_proxy::<TestProxied>();
552
-
553
- // assert_lua_set_get_returns(
554
- // app.world_mut(),
555
- // TestTupleStruct(123, TestProxied, vec![]),
556
- // "test._2",
557
- // |mut r| {
558
- // r.index_path(ParsedPath::parse_static(".1").unwrap());
559
- // LuaTestProxied(r)
560
- // },
561
- // );
562
-
563
- // let mut app = App::new();
564
- // app.register_lua_proxy::<TestProxied>();
565
-
566
- // assert_lua_set_get_returns(
567
- // app.world_mut(),
568
- // TestTupleEnum::Proxy(TestProxied),
569
- // "test._1",
570
- // |mut r| {
571
- // r.index_path(ParsedPath::parse_static(".0").unwrap());
572
- // LuaTestProxied(r)
573
- // },
574
- // );
575
- // }
576
-
577
- // #[test]
578
- // fn test_index_lua_proxy_vec() {
579
- // // so we have the registry and can just do this
580
- // let mut app = App::new();
581
- // app.register_lua_proxy::<TestProxied>();
582
-
583
- // assert_lua_set_get_returns(
584
- // app.world_mut(),
585
- // TestStruct {
586
- // value: 123,
587
- // proxy: TestProxied,
588
- // proxies: vec![TestProxied],
589
- // },
590
- // "test.proxies[1]",
591
- // |mut r| {
592
- // r.index_path(ParsedPath::parse_static("proxies").unwrap());
593
- // r.index_path(ParsedPath::parse_static("[0]").unwrap());
594
- // LuaTestProxied(r)
595
- // },
596
- // );
597
-
598
- // let mut app = App::new();
599
- // app.register_lua_proxy::<TestProxied>();
600
-
601
- // assert_lua_set_get_returns(
602
- // app.world_mut(),
603
- // TestTupleStruct(123, TestProxied, vec![TestProxied]),
604
- // "test._3[1]",
605
- // |mut r| {
606
- // r.index_path(ParsedPath::parse_static(".2").unwrap());
607
- // r.index_path(ParsedPath::parse_static("[0]").unwrap());
608
- // LuaTestProxied(r)
609
- // },
610
- // );
611
-
612
- // let mut app = App::new();
613
- // app.register_lua_proxy::<TestProxied>();
614
-
615
- // assert_lua_set_get_returns(
616
- // app.world_mut(),
617
- // TestTupleEnum::Proxies(vec![TestProxied]),
618
- // "test._1[1]",
619
- // |mut r| {
620
- // r.index_path(ParsedPath::parse_static(".0").unwrap());
621
- // r.index_path(ParsedPath::parse_static("[0]").unwrap());
622
- // LuaTestProxied(r)
623
- // },
624
- // );
625
- // }
626
- // }
0 commit comments