42 lines
1.8 KiB
Go
42 lines
1.8 KiB
Go
package checks
|
||
|
||
import (
|
||
"testing"
|
||
|
||
"textmachine/backend/internal/lang"
|
||
)
|
||
|
||
// TestTargetSeamInertness is the П1 acceptance/mutation check (D39.62): a target with NO readability data
|
||
// (→en) runs the whole of layer 7 inert BY ABSENCE of data — not by a language branch — while ru is active.
|
||
// This is what makes "a pair not in the repo passes layer 7 without a Go change" true.
|
||
func TestTargetSeamInertness(t *testing.T) {
|
||
en := CompileCheckers(nil, lang.TargetChecksFor("en"))
|
||
if en.TargetActive() {
|
||
t.Error("a target with no data must be inactive (layer 7 inert by absence)")
|
||
}
|
||
if en.TargetScriptNonLatin() {
|
||
t.Error("a target with no declared word script must not read as non-Latin")
|
||
}
|
||
if got := en.tokenizeWords("hello слово"); got != nil {
|
||
t.Errorf("a target with no word script must not tokenize, got %v", got)
|
||
}
|
||
if n, _ := en.lintBrokenWord("войть slово"); n != 0 {
|
||
t.Error("broken-word lint must be inert for a dataless target")
|
||
}
|
||
// The pattern-based sanitizer classes are inert for a dataless target (the pipeline also gates the whole
|
||
// sanitizer on TargetActive() upstream); a would-be ru preamble is not flagged for →en.
|
||
if r := en.SanitizeOutput("Вот отредактированный перевод: текст."); r.Preamble != 0 || r.TrailingNote != 0 {
|
||
t.Errorf("dataless target must not fire the pattern sanitizer classes, got %+v", r)
|
||
}
|
||
|
||
ru := CompileCheckers(nil, lang.TargetChecksFor("ru"))
|
||
if !ru.TargetActive() {
|
||
t.Error("ru ships readability data → must be active")
|
||
}
|
||
if !ru.TargetScriptNonLatin() {
|
||
t.Error("ru is a non-Latin word script")
|
||
}
|
||
if got := ru.tokenizeWords("сло́во"); len(got) != 1 || got[0] != "слово" {
|
||
t.Errorf("ru tokenizer must fold the U+0301 stress mark into one word, got %v (#11)", got)
|
||
}
|
||
}
|