| 115 | } |
| 116 | |
| 117 | func 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 | } |