Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

example_test.gno

1.07 Kb · 28 lines
 1package compact
 2
 3import "strings"
 4
 5// ExampleRender pins the page's skeleton: the title and the three sections
 6// that are always there, whatever the board holds.
 7//
 8// Only the invariant lines, on purpose. Everything else on the page is
 9// derived from the current fragmentation, and an Example runs after every
10// Test in the package and sees whatever state they left. The variable half is
11// pinned by TestRenderShowsBothIntegersAndTheAction, which controls the board
12// first.
13func ExampleRender() {
14	for _, line := range strings.Split(Render(""), "\n") {
15		switch {
16		case strings.HasPrefix(line, "# "),
17			strings.HasPrefix(line, "## "),
18			strings.HasPrefix(line, "Soft-deleting"):
19			print(line + "\n")
20		}
21	}
22	// Output:
23	// # Compact
24	// Soft-deleting an entry frees nothing: the tree node stays, the bytes stay locked, and every read still walks past the hole. Compacting drops those nodes and the chain refunds their deposit **to whoever signs the transaction**. The only question is when.
25	// ## The two integers
26	// ## Why allocated minus live is not the answer
27	// ## Board
28}