Skip to content

Commit

Permalink
[move-prover] add a test case for the asserted/assumed memory in usage
Browse files Browse the repository at this point in the history
  • Loading branch information
meng-xu-cs authored and bors-libra committed Aug 25, 2021
1 parent 4f3e5f2 commit 0099e4f
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
50 changes: 50 additions & 0 deletions language/move-prover/bytecode/tests/usage_analysis/test.exp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ public fun Test::update<#0>($t0|x: #0) {
}


[variant baseline]
public fun Test::assert_assume_memory() {
0: assume exists<Test::A<bool, u64>>(1)
1: assert exists<Test::A<u64, bool>>(1)
2: return ()
}


[variant baseline]
public fun Test::call_assert_assume_memory() {
0: Test::assert_assume_memory()
1: return ()
}


[variant baseline]
public fun Test::publish<#0>($t0|signer: &signer, $t1|x: Test::A<#0, u8>) {
var $t2: &signer
Expand Down Expand Up @@ -76,6 +91,21 @@ public fun Test::update<#0>($t0|x: #0) {
}


[variant baseline]
public fun Test::assert_assume_memory() {
0: assume exists<Test::A<bool, u64>>(1)
1: assert exists<Test::A<u64, bool>>(1)
2: return ()
}


[variant baseline]
public fun Test::call_assert_assume_memory() {
0: Test::assert_assume_memory()
1: return ()
}


[variant baseline]
public fun Test::publish<#0>($t0|signer: &signer, $t1|x: Test::A<#0, u8>) {
var $t2: &signer
Expand Down Expand Up @@ -135,6 +165,26 @@ function Test::update [baseline] {
asserted = {}
directly asserted = {}
}
function Test::assert_assume_memory [baseline] {
accessed = {}
directly accessed = {}
modified = {}
directly modified = {}
assumed = {Test::A<bool, u64>}
directly assumed = {Test::A<bool, u64>}
asserted = {Test::A<u64, bool>}
directly asserted = {Test::A<u64, bool>}
}
function Test::call_assert_assume_memory [baseline] {
accessed = {}
directly accessed = {}
modified = {}
directly modified = {}
assumed = {Test::A<bool, u64>}
directly assumed = {}
asserted = {Test::A<u64, bool>}
directly asserted = {}
}
function Test::publish [baseline] {
accessed = {Test::A<#0, u8>}
directly accessed = {Test::A<#0, u8>}
Expand Down
10 changes: 10 additions & 0 deletions language/move-prover/bytecode/tests/usage_analysis/test.move
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,15 @@ module Test {
public fun publish<T: store>(signer: &signer, x: A<T, u8>) {
move_to<A<T, u8>>(signer, x)
}

public fun assert_assume_memory() {
spec {
assume exists<A<bool, u64>>(@0x1);
assert exists<A<u64, bool>>(@0x1);
};
}
public fun call_assert_assume_memory() {
assert_assume_memory();
}
}
}

0 comments on commit 0099e4f

Please sign in to comment.