render_example_test.gno
1.12 Kb · 33 lines
1package rot13demo
2
3// ExampleRender pins the realm's Render output as a gno testable example.
4func ExampleRender() {
5 print(Render(""))
6 // Output:
7 // # ROT13
8 //
9 // Demo of the [`p/moul/x/daily/rot13`](/p/moul/x/daily/rot13/v0) library — an on-chain port of Go's classic **ROT13** cipher, the standard-library `strings.Map` / `io.Reader` teaching example. Each ASCII letter is rotated 13 places through the alphabet; everything else is left alone.
10 //
11 // Because the alphabet has 26 letters and 13 is exactly half, **ROT13 is its own inverse** — encoding twice returns the original text.
12 //
13 // ## Example
14 //
15 // | stage | text |
16 // |---|---|
17 // | input | `Hello, Gno!` |
18 // | ROT13 | `Uryyb, Tab!` |
19 // | ROT13 again | `Hello, Gno!` |
20 //
21 // ## Try it
22 //
23 // - `Render("/Uryyb, Tab!")` — decode any text (append it to the path).
24 // - `Render("/caesar/3/attack at dawn")` — a general Caesar shift.
25 //
26 // Or call the library functions directly:
27 //
28 // ```go
29 // rot13.Rot13("Hello, Gno!") // "Uryyb, Tab!"
30 // rot13.Caesar("attack", 3) // "dwwdfn"
31 // rot13.Caesar("Hello", 13) // same as Rot13: "Uryyb"
32 // ```
33}