@@ -997,6 +997,37 @@ fn test_borrow_loc_reference() {
997
997
}
998
998
999
999
1000
+ #[ test]
1001
+ fn test_st_lock_correct_type ( ) {
1002
+ let code = vec ! [ Bytecode :: LdU32 ( 51 ) , Bytecode :: StLoc ( 0 ) ] ;
1003
+ let module = make_module_with_local ( code, SignatureToken :: U32 ) ;
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_st_lock_mismatched_types ( ) {
1011
+ let code = vec ! [ Bytecode :: LdU64 ( 51 ) , Bytecode :: StLoc ( 0 ) ] ;
1012
+ let module = make_module_with_local ( code, SignatureToken :: U32 ) ;
1013
+ let fun_context = get_fun_context ( & module) ;
1014
+ let result = type_safety:: verify ( & module, & fun_context, & mut DummyMeter ) ;
1015
+ assert_eq ! (
1016
+ result. unwrap_err( ) . major_status( ) ,
1017
+ StatusCode :: STLOC_TYPE_MISMATCH_ERROR
1018
+ ) ;
1019
+ }
1020
+
1021
+ #[ test]
1022
+ #[ should_panic]
1023
+ fn test_st_lock_no_arg ( ) {
1024
+ let code = vec ! [ Bytecode :: StLoc ( 0 ) ] ;
1025
+ let module = make_module_with_local ( code, SignatureToken :: U32 ) ;
1026
+ let fun_context = get_fun_context ( & module) ;
1027
+ let _result = type_safety:: verify ( & module, & fun_context, & mut DummyMeter ) ;
1028
+ }
1029
+
1030
+
1000
1031
#[ test]
1001
1032
fn test_copy_loc_ok ( ) {
1002
1033
let code = vec ! [ Bytecode :: CopyLoc ( 0 ) ] ;
0 commit comments