File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
crates/move-bytecode-verifier/src/type_safety_tests Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -995,3 +995,36 @@ fn test_borrow_loc_reference() {
995
995
}
996
996
}
997
997
}
998
+
999
+
1000
+ #[ test]
1001
+ fn test_copy_loc_ok ( ) {
1002
+ let code = vec ! [ Bytecode :: CopyLoc ( 0 ) ] ;
1003
+ let module = make_module_with_local ( code, SignatureToken :: U64 ) ;
1004
+ let fun_context = get_fun_context ( & module) ;
1005
+ let result = type_safety:: verify ( & module, & fun_context, & mut DummyMeter ) ;
1006
+ assert ! ( result. is_ok( ) ) ;
1007
+ }
1008
+
1009
+ #[ test]
1010
+ fn test_copy_loc_no_copy ( ) {
1011
+ let code = vec ! [ Bytecode :: CopyLoc ( 0 ) ] ;
1012
+ let mut module = make_module_with_local ( code, SignatureToken :: Struct ( StructHandleIndex ( 0 ) ) ) ;
1013
+ add_simple_struct_with_abilities ( & mut module, AbilitySet :: EMPTY ) ;
1014
+ let fun_context = get_fun_context ( & module) ;
1015
+ let result = type_safety:: verify ( & module, & fun_context, & mut DummyMeter ) ;
1016
+ assert_eq ! (
1017
+ result. unwrap_err( ) . major_status( ) ,
1018
+ StatusCode :: COPYLOC_WITHOUT_COPY_ABILITY
1019
+ ) ;
1020
+ }
1021
+
1022
+
1023
+ #[ test]
1024
+ fn test_move_loc_ok ( ) {
1025
+ let code = vec ! [ Bytecode :: MoveLoc ( 0 ) ] ;
1026
+ let module = make_module_with_local ( code, SignatureToken :: U64 ) ;
1027
+ let fun_context = get_fun_context ( & module) ;
1028
+ let result = type_safety:: verify ( & module, & fun_context, & mut DummyMeter ) ;
1029
+ assert ! ( result. is_ok( ) ) ;
1030
+ }
You can’t perform that action at this time.
0 commit comments