MCPcopy
hub / github.com/lmorg/murex / TestSpellcheckVariable

Function TestSpellcheckVariable

utils/spellcheck/spellcheck_test.go:117–147  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

115}
116
117func TestSpellcheckVariable(t *testing.T) {
118 count.Tests(t, 1)
119 lang.InitEnv()
120 defaults.Config(lang.ShellProcess.Config, false)
121
122 err := lang.ShellProcess.Config.Set("shell", "spellcheck-enabled", true, nil)
123 if err != nil {
124 t.Fatalf("Unable to set spellcheck-enabled config: %s", err)
125 }
126
127 err = lang.ShellProcess.Config.Set("shell", "spellcheck-func", `{ -> jsplit ' ' -> suffix "\n" }`, nil)
128 if err != nil {
129 t.Fatalf("Unable to set spellcheck-func config: %s", err)
130 }
131
132 os.Setenv("MUREX_TEST_SPELLCHECK_TEST", "quick")
133
134 line := "$the $MUREX_TEST_SPELLCHECK_TEST $brown $fox"
135 newLine, err := spellcheck.String(line)
136 ansiLine := ansi.ExpandConsts("{UNDERLINE}$the{UNDEROFF} {UNDERLINE}$MUREX_TEST_SPELLCHECK_TEST{UNDEROFF} {UNDERLINE}$brown{UNDEROFF} {UNDERLINE}$fox{UNDEROFF}")
137
138 if newLine != ansiLine {
139 t.Error("spellcheck output doesn't match expected:")
140 t.Logf(" Expected: '%s'", ansiLine)
141 t.Logf(" Actual: '%s'", newLine)
142 }
143
144 if err != nil {
145 t.Errorf("spellcheck produced an error: %s", err.Error())
146 }
147}

Callers

nothing calls this directly

Calls 7

TestsFunction · 0.92
InitEnvFunction · 0.92
ConfigFunction · 0.92
StringFunction · 0.92
ExpandConstsFunction · 0.92
SetMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected