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

render_example_test.gno

1.27 Kb · 45 lines
 1package orderedmapdemo
 2
 3// ExampleRender pins the realm's Render output as a testable example.
 4func ExampleRender() {
 5	print(Render(""))
 6	// Output:
 7	// # Ordered Map
 8	//
 9	// A map that remembers insertion order, demoing the [`p/moul/x/daily/orderedmap`](/p/moul/x/daily/orderedmap/v0) library.
10	//
11	// ## Inserted
12	//
13	// `delta, alpha, charlie, bravo` → order kept as inserted, **not** sorted:
14	//
15	// | # | key | value |
16	// |---|---|---|
17	// | 1 | `delta` | `4` |
18	// | 2 | `alpha` | `1` |
19	// | 3 | `charlie` | `3` |
20	// | 4 | `bravo` | `2` |
21	//
22	// ## After `Set("alpha", "99")`
23	//
24	// Updating keeps the original position — insertion order means *first* insertion:
25	//
26	// | # | key | value |
27	// |---|---|---|
28	// | 1 | `delta` | `4` |
29	// | 2 | `alpha` | `99` |
30	// | 3 | `charlie` | `3` |
31	// | 4 | `bravo` | `2` |
32	//
33	// ## After deleting and re-adding `charlie`
34	//
35	// Re-inserting is a **new** insertion, so it goes last:
36	//
37	// | # | key | value |
38	// |---|---|---|
39	// | 1 | `delta` | `4` |
40	// | 2 | `alpha` | `99` |
41	// | 3 | `bravo` | `2` |
42	// | 4 | `charlie` | `new` |
43	//
44	// > gno map iteration order is unspecified. A realm that ranges over a built-in map to build its page can emit a different page every call — a consensus bug, not a cosmetic one. This is the fix.
45}