Skip to content

Commit d4fd2ee

Browse files
committed
tests for the Pop operation
1 parent 1615c49 commit d4fd2ee

File tree

1 file changed

+32
-0
lines changed
  • crates/move-bytecode-verifier/src/type_safety_tests

1 file changed

+32
-0
lines changed

crates/move-bytecode-verifier/src/type_safety_tests/mod.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,3 +895,35 @@ fn test_eq_neq_no_args() {
895895
let _result = type_safety::verify(&module, &fun_context, &mut DummyMeter);
896896
}
897897
}
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+
}

0 commit comments

Comments
 (0)