oficina / mapa Public

Clone
git clone https://amadan.net/oficina/mapa

Plain git — no account needed to clone.

Download

Download this file

1package markup
2
3import (
4 "strings"
5 "testing"
6 "time"
7)
8
9// The link scans are linear (review M6): each body is 80,000 bytes of
10// what made them quadratic, a line of unclosed links. Before, the first
11// took over a minute to draw; now each takes milliseconds. The bound is
12// generous, for CI machines. editor/linear.test.mjs is the editor's.
13func TestTheLinkScansAreLinear(t *testing.T) {
14 const size = 80000
15 for name, body := range map[string]string{
16 "unclosed web links": strings.Repeat("[a", size/2),
17 "web links with no address": strings.Repeat("[a](", size/4),
18 "unclosed wiki links": strings.Repeat("[[a", size/3),
19 "unclosed embeds": strings.Repeat("![[", size/3),
20 } {
21 start := time.Now()
22 Spans(body)
23 Render(Parse(body), nil)
24 if took := time.Since(start); took > 750*time.Millisecond {
25 t.Errorf("%s: %v for %d bytes", name, took, size)
26 }
27 }
28}
29