1
2
3
4
5 package main
6
7 func currentMemory() int32
8 func growMemory(pages int32) int32
9
10 func main() {
11
12
13 const limit = 0x400000 / (64 << 10)
14 initial := currentMemory()
15 if initial == 0 || initial >= limit {
16 panic("unexpected initial memory size")
17 }
18 if growMemory(limit-initial+1) != -1 || currentMemory() != initial {
19 panic("memory grew past the logical PC range")
20 }
21 if growMemory(limit-initial) != initial || currentMemory() != limit {
22 panic("memory did not grow to the logical PC range")
23 }
24 if growMemory(1) != -1 || currentMemory() != limit {
25 panic("memory grew into the logical PC range")
26 }
27 }
28
View as plain text