File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
crates/move-bytecode-verifier/src/type_safety_tests Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -895,3 +895,35 @@ fn test_eq_neq_no_args() {
895
895
let _result = type_safety:: verify ( & module, & fun_context, & mut DummyMeter ) ;
896
896
}
897
897
}
898
+
899
+
900
+ #[ test]
901
+ fn test_pop_ok ( ) {
902
+ let code = vec ! [ Bytecode :: LdU32 ( 42 ) , Bytecode :: Pop ] ;
903
+ let module = make_module ( code) ;
904
+ let fun_context = get_fun_context ( & module) ;
905
+ let result = type_safety:: verify ( & module, & fun_context, & mut DummyMeter ) ;
906
+ assert ! ( result. is_ok( ) ) ;
907
+ }
908
+
909
+ #[ test]
910
+ fn test_pop_no_drop ( ) {
911
+ let code = vec ! [ Bytecode :: LdU32 ( 42 ) , Bytecode :: Pack ( StructDefinitionIndex ( 0 ) ) , Bytecode :: Pop ] ;
912
+ let mut module = make_module ( code) ;
913
+ add_simple_struct_with_abilities ( & mut module, AbilitySet :: EMPTY ) ;
914
+ let fun_context = get_fun_context ( & module) ;
915
+ let result = type_safety:: verify ( & module, & fun_context, & mut DummyMeter ) ;
916
+ assert_eq ! (
917
+ result. unwrap_err( ) . major_status( ) ,
918
+ StatusCode :: POP_WITHOUT_DROP_ABILITY
919
+ ) ;
920
+ }
921
+
922
+ #[ test]
923
+ #[ should_panic]
924
+ fn test_pop_no_arg ( ) {
925
+ let code = vec ! [ Bytecode :: Pop ] ;
926
+ let module = make_module ( code) ;
927
+ let fun_context = get_fun_context ( & module) ;
928
+ let _result = type_safety:: verify ( & module, & fun_context, & mut DummyMeter ) ;
929
+ }
You can’t perform that action at this time.
0 commit comments