@@ -2325,8 +2325,8 @@ func TestProcessFileDocUsesFieldLevelFrontmatterTranslation(t *testing.T) {
23252325 if ! strings .Contains (text , "在 Fly.io 上部署 OpenClaw" ) {
23262326 t .Fatalf ("expected translated read_when entry in output:\n %s" , text )
23272327 }
2328- if ! strings .Contains (text , "prompt_version: 24 " ) {
2329- t .Fatalf ("expected prompt version 24 in output metadata:\n %s" , text )
2328+ if ! strings .Contains (text , "prompt_version: 25 " ) {
2329+ t .Fatalf ("expected prompt version 25 in output metadata:\n %s" , text )
23302330 }
23312331}
23322332
@@ -2375,3 +2375,85 @@ func TestProcessFileDocRejectsSuspiciousFrontmatterScalarExpansion(t *testing.T)
23752375 t .Fatalf ("expected read_when translation to survive fallback:\n %s" , text )
23762376 }
23772377}
2378+
2379+ func TestValidateDocChunkTranslationRejectsChangedCompositeLiteral (t * testing.T ) {
2380+ t .Parallel ()
2381+
2382+ tests := [][2 ]string {
2383+ {"Supports 1:1 conversations.\n " , "आमने-सामने की बातचीत को सपोर्ट करता है।\n " },
2384+ {"Use mask 0xFF.\n " , "Use mask 0xAA.\n " },
2385+ {"Use 1e-3.\n " , "Use 1e -3.\n " },
2386+ }
2387+ for _ , pair := range tests {
2388+ err := validateDocChunkTranslation (pair [0 ], pair [1 ])
2389+ if err == nil || ! strings .Contains (err .Error (), "numeric value mismatch" ) {
2390+ t .Fatalf ("expected composite-literal mismatch, got %v" , err )
2391+ }
2392+ }
2393+ }
2394+
2395+ func TestValidateDocBodyRejectsChangedCompositeLiteral (t * testing.T ) {
2396+ t .Parallel ()
2397+
2398+ err := validateDocBodyFencedLiterals ("Supports 1:1 conversations.\n " , "आमने-सामने की बातचीत को सपोर्ट करता है।\n " )
2399+ if err == nil || ! strings .Contains (err .Error (), "numeric value mismatch" ) {
2400+ t .Fatalf ("expected final-document numeric mismatch, got %v" , err )
2401+ }
2402+ }
2403+
2404+ func TestExtractNumericValuesKeepsLowAmbiguityComposites (t * testing.T ) {
2405+ t .Parallel ()
2406+
2407+ got := strings .Join (extractNumericValues ("0xFF 0b101 0o755 1.5:1 1e-3 v1.2.3" ), "," )
2408+ if want := "0xFF,0b101,0o755,1.5:1,1e-3" ; got != want {
2409+ t .Fatalf ("unexpected composite literals: got=%q want=%q" , got , want )
2410+ }
2411+ if err := validateDocChunkTranslation ("Supports 1:1 conversations.\n " , "Unterstützt 1:1-Unterhaltungen.\n " ); err != nil {
2412+ t .Fatalf ("expected locale compound after exact ratio to pass: %v" , err )
2413+ }
2414+ }
2415+
2416+ func TestValidateDocChunkTranslationRejectsDroppedDuplicateLink (t * testing.T ) {
2417+ t .Parallel ()
2418+
2419+ source := "Deploy on [Render](https://render.com), then open [account](https://render.com).\n "
2420+ translated := "Auf [Render](https://render.com) bereitstellen, dann das Konto öffnen.\n "
2421+ err := validateDocChunkTranslation (source , translated )
2422+ if err == nil || ! strings .Contains (err .Error (), "link destination mismatch" ) {
2423+ t .Fatalf ("expected duplicate-link mismatch, got %v" , err )
2424+ }
2425+ }
2426+
2427+ func TestValidateDocBodyRejectsDroppedLinkMarkup (t * testing.T ) {
2428+ t .Parallel ()
2429+
2430+ err := validateDocBodyFencedLiterals ("Read [guide](/setup).\n " , "Lesen Sie guide](/setup).\n " )
2431+ if err == nil || ! strings .Contains (err .Error (), "link destination mismatch" ) {
2432+ t .Fatalf ("expected final-document link mismatch, got %v" , err )
2433+ }
2434+ }
2435+
2436+ func TestExtractMarkdownLinkDestinationsUsesParsedNodes (t * testing.T ) {
2437+ t .Parallel ()
2438+
2439+ source := "[docs](https://host/a_(b)) [guide](/setup \" Setup guide\" ) [angle](<https://host/a b>)"
2440+ got := strings .Join (extractMarkdownLinkDestinations (source ), "," )
2441+ want := "link:https://host/a_(b),link:/setup,link:https://host/a b"
2442+ if got != want {
2443+ t .Fatalf ("unexpected parsed destinations: got=%q want=%q" , got , want )
2444+ }
2445+ if got := extractMarkdownLinkDestinations ("`[inline](https://example.com)`" ); len (got ) != 0 {
2446+ t .Fatalf ("expected code-context link to be ignored, got %q" , got )
2447+ }
2448+ }
2449+
2450+ func TestValidateDocChunkTranslationChecksLinkInsideMDX (t * testing.T ) {
2451+ t .Parallel ()
2452+
2453+ source := "<Card>\n Read [guide](/setup).\n </Card>\n "
2454+ translated := "<Card>\n Lesen Sie guide](/setup).\n </Card>\n "
2455+ err := validateDocChunkTranslation (source , translated )
2456+ if err == nil || ! strings .Contains (err .Error (), "link destination mismatch" ) {
2457+ t .Fatalf ("expected MDX-contained link mismatch, got %v" , err )
2458+ }
2459+ }
0 commit comments