Skip to content Search Apps Documentation Source Content Run Reset Eval Playground 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.

escape_test.gno

1.51 Kb · 19 lines
 1package levenshteindemo
 2
 3import (
 4	"testing"
 5
 6	"gno.land/p/nt/uassert/v0"
 7)
 8
 9// payload closes a one-backtick code span and opens an image. Written raw, as
10// v0 does, it renders as markup the realm appears to have authored.
11const payload = "x` ![p](https:e.io) `y"
12
13// TestRenderEscapesWords pins that both words are code spans they cannot close,
14// and that each rune in the DP table is a cell it cannot split: v0 wrote the
15// words between hand-placed backticks and every rune raw, so a "|" opened a
16// column and a backtick unbalanced the row.
17func TestRenderEscapesWords(t *testing.T) {
18	uassert.Equal(t, "# Levenshtein distance\n\nTransforming **``a`|``** → **`[b](https:e.io)`**\n\n- **Edit distance:** `15` single-character edits (insert / delete / substitute)\n- **Similarity:** `0%`\n\n## DP table\n\nEach cell `d[i][j]` is the distance between the first *i* runes of ``a`|`` and the first *j* runes of `[b](https:e.io)`. The bottom-right cell is the answer.\n\n|   | ε | \\[ | b | \\] | \\( | h | t | t | p | s | : | e | \\. | i | o | \\) |\n|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|\n| **ε** | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |\n| **a** | 1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |\n| **\\`** | 2 | 2 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |\n| **\\|** | 3 | 3 | 3 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |\n\n[← back](/r/moul/x/daily/levenshteindemo/v1)\n", Render("/a`|/[b](https:e.io)"))
19}