@@ -251,7 +251,10 @@ mod tests {
251251 } ,
252252 variables:: { Content , LValue , LVar } ,
253253 } ,
254- types:: { Object , PackedPoint2 , ProcessorConfig , ProcessorLinkConfig , Team , colors:: COLORS } ,
254+ types:: {
255+ Object , PackedPoint2 , ProcessorConfig , ProcessorLinkConfig , Team , colors:: COLORS ,
256+ content,
257+ } ,
255258 } ;
256259
257260 use super :: {
@@ -848,6 +851,66 @@ mod tests {
848851 ) ;
849852 }
850853
854+ #[ test]
855+ fn test_getblock ( ) {
856+ let mut builder = LogicVMBuilder :: new ( ) ;
857+ builder. add_buildings (
858+ [
859+ Building :: from_processor_config (
860+ WORLD_PROCESSOR ,
861+ Point2 { x : 1 , y : 2 } ,
862+ & ProcessorConfig :: from_code (
863+ "
864+ getblock floor floor1 @thisx @thisy
865+ getblock ore ore1 @thisx @thisy
866+ getblock block block1 @thisx @thisy
867+ getblock building building1 @thisx @thisy
868+
869+ getblock floor floor2 1 3
870+ getblock ore ore2 1 3
871+ getblock block block2 1 3
872+ getblock building building2 1 3
873+
874+ getblock floor floor3 1 1
875+ getblock ore ore3 1 1
876+ getblock block block3 1 1
877+ getblock building building3 1 1
878+
879+ stop
880+ " ,
881+ ) ,
882+ & builder,
883+ ) ,
884+ Building :: from_config ( SWITCH , Point2 { x : 1 , y : 3 } , & Object :: Null , & builder) ,
885+ ]
886+ . map ( |v| v. unwrap ( ) ) ,
887+ ) ;
888+ let mut vm = builder. build ( ) . unwrap ( ) ;
889+
890+ run ( & mut vm, 2 , true ) ;
891+
892+ let state = take_processor ( & mut vm, ( 1 , 2 ) ) . state ;
893+ assert_variables (
894+ & state,
895+ map_iter ! {
896+ "floor1" : LValue :: Content ( Content :: Block ( & content:: blocks:: STONE ) ) ,
897+ "ore1" : LValue :: Content ( Content :: Block ( & content:: blocks:: AIR ) ) ,
898+ "block1" : LValue :: Content ( Content :: Block ( content:: blocks:: FROM_NAME [ "world-processor" ] ) ) ,
899+ "building1" : LValue :: Building ( Point2 { x: 1 , y: 2 } ) ,
900+
901+ "floor2" : LValue :: Content ( Content :: Block ( & content:: blocks:: STONE ) ) ,
902+ "ore2" : LValue :: Content ( Content :: Block ( & content:: blocks:: AIR ) ) ,
903+ "block2" : LValue :: Content ( Content :: Block ( content:: blocks:: FROM_NAME [ "switch" ] ) ) ,
904+ "building2" : LValue :: Building ( Point2 { x: 1 , y: 3 } ) ,
905+
906+ "floor3" : LValue :: Null ,
907+ "ore3" : LValue :: Null ,
908+ "block3" : LValue :: Null ,
909+ "building3" : LValue :: Null ,
910+ } ,
911+ ) ;
912+ }
913+
851914 #[ test]
852915 fn test_max_ticks ( ) {
853916 let mut vm = single_processor_vm (
0 commit comments