Skip to content

Commit

Permalink
adjust test for removal of Regions.region0
Browse files Browse the repository at this point in the history
  • Loading branch information
crusso committed Aug 16, 2023
1 parent cbf172c commit 557419c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
8 changes: 0 additions & 8 deletions test/run-drun/ok/stable-region0-danger.drun-run.ok

This file was deleted.

12 changes: 9 additions & 3 deletions test/run-drun/stable-region0-danger.mo
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
//MOC-FLAG --stable-regions

// THIS TEST IS NOT RUN ON ANY FLAVOUR
// Its a counterexample to show what goes wrong if we naively support Region.region0() without
// extra steps to ensure correct aliasing.
import P "mo:⛔";
import Region "stable-region/Region";
import Region0 "stable-mem/StableMemory";

// test shows why we can't expose region0 without further steps to ensure
// counter-example: shows why we can't expose region0 without further steps to ensure
// correct aliasing of all region0 objects, pre and post upgrade
actor {

stable let r0 = Region.region0();
stable let r0 = Region.region0(); // THIS WOULD BE DANGEROUS if permitted

ignore Region.grow(r0, 1);

system func preupgrade() {
};

public func sanityTest() {
// test that r01 correctly aliases r0, even after upgrade.
let r01 = Region.region0();
P.debugPrint(debug_show {s0 = Region.size(r0); s01 = Region.size(r01)});
assert Region.size(r0) == Region.size(r01);
Expand All @@ -24,9 +28,11 @@ actor {
};
}

//SKIP tc
//SKIP run
//SKIP run-low
//SKIP run-ir
//SKIP run-drun
// too slow on ic-ref-run:
//SKIP comp-ref
//CALL ingress sanityTest "DIDL\x00\x00"
Expand Down
2 changes: 1 addition & 1 deletion test/run-drun/stable-regions-are-isolated.mo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Region "stable-region/Region";
import Region0 "stable-mem/StableMemory";

actor {
var r0 = Region.region0();
var r0 = Region.new();
var r1 = Region.new();
var r2 = Region.new();

Expand Down

0 comments on commit 557419c

Please sign in to comment.