|
27 | 27 | // scala-cli run autotranslate/scratch/verify-mirror-examples.scala -- <introprog-root> |
28 | 28 | // (exit 0 = clean, exit 1 = at least one regression or an untranslated ratified code-string) |
29 | 29 |
|
30 | | -@main def verifyMirrorExamples(rootStr: String): Unit = |
| 30 | +@main def verifyMirrorExamples(args: String*): Unit = |
| 31 | + val rootStr = args.find(a => !a.startsWith("--")).getOrElse(".") |
| 32 | + val listMode = args.contains("--list") // also print the per-body phase-1 classification (file:line (env)) |
| 33 | + def lineOf(s: String, pos: Int): Int = s.substring(0, pos).count(_ == '\n') + 1 |
31 | 34 | val root = os.Path(rootStr, os.pwd) |
32 | 35 | val dir = root / "compendium" / "examples" // workspace/ is served by the hand-maintained workspace-en |
33 | 36 | val files = |
|
89 | 92 | body.replaceFirst("(?s)\\A[ \\t]*\\[[^\\]]*\\]", "") |
90 | 93 | var inChecked = 0; var inSkipped = 0; var replDeferred = 0; var nonCode = 0 |
91 | 94 | val inRegressions = collection.mutable.ArrayBuffer[String]() |
| 95 | + val inOk = collection.mutable.ArrayBuffer[String]() // file:line (env) of each OK body (for --list) |
| 96 | + val inSkip = collection.mutable.ArrayBuffer[String]() // file:line (env) of each skipped body (for --list) |
92 | 97 | for f <- texFiles do |
93 | 98 | val tex = os.read(f) |
94 | 99 | val rel = f.relativeTo(root).toString |
|
103 | 108 | if en != body then // only REWRITTEN bodies are gate-relevant |
104 | 109 | if env.startsWith("REPL") then replDeferred += 1 // rewritten transcripts -> phase 2 |
105 | 110 | else if !phase1Envs(env) then nonCode += 1 // Trace/Output — not compilable Scala |
106 | | - else if compiles(en, "Inline.scala") then inChecked += 1 |
| 111 | + else if compiles(en, "Inline.scala") then { inChecked += 1; inOk += s"$rel:${lineOf(tex, m.start)} ($env)" } |
107 | 112 | else if compiles(body, "Inline.scala") then |
108 | 113 | inRegressions += s"$rel ($env)" |
109 | 114 | println(s" INLINE REGRESSION: $rel ($env) — compiles in Swedish but NOT after rename") |
110 | | - else inSkipped += 1 |
| 115 | + else { inSkipped += 1; inSkip += s"$rel:${lineOf(tex, m.start)} ($env)" } |
111 | 116 | println(s"\n=== inline .tex compile gate (phase 1): $inChecked ok, $inSkipped skipped (not standalone), " + |
112 | 117 | s"$replDeferred REPL deferred to phase 2, $nonCode Trace/Output not gated, ${inRegressions.size} REGRESSIONS ===") |
113 | 118 | if inRegressions.nonEmpty then println("FAIL — inline translation broke compilation in: " + inRegressions.mkString(", ")) |
114 | 119 | else println("PASS — every rewritten, self-contained inline Scala-code env still compiles.") |
| 120 | + if listMode then |
| 121 | + println(s"\n--- phase-1 OK (${inOk.size}) — rewritten inline envs that compile after rename ---") |
| 122 | + inOk.foreach(s => println(s" ok $s")) |
| 123 | + println(s"--- phase-1 SKIPPED (${inSkip.size}) — rewritten inline envs that compile in NEITHER language (not standalone) ---") |
| 124 | + inSkip.foreach(s => println(s" skip $s")) |
115 | 125 |
|
116 | 126 | if regressions.nonEmpty || leaks.nonEmpty || inRegressions.nonEmpty then sys.exit(1) |
0 commit comments