Port tools/dedupe_identical_tests.py (Python, 2 functions) to specs/port/tools/dedupe_identical_tests.t27
Context
tools/dedupe_identical_tests.py is 150 lines of hand-written Python. Re-author its logic as specs/port/tools/dedupe_identical_tests.t27 so that t27c generates the equivalent. The Python file stays where it is - this issue adds the .t27 source it should have been written in.
.t27 is the hand-authored source language. t27c compiles it out to C, Rust, Verilog and Zig. You are writing source, not compiler output, and not prose about an implementation. The goal of this project is that every hand-written file in the repository is authored in .t27 and the other languages are generated from it - this issue is one file of that migration.
Read the original first
# from the repository root
$ wc -l tools/dedupe_identical_tests.py
$ sed -n '1,120p' tools/dedupe_identical_tests.py
What to write
Create specs/port/tools/dedupe_identical_tests.t27 with one .t27 function per Python function below. Keep the names exactly as they are - the name is how the port is checked. Quoted verbatim from the original:
- line 43 -
def blocks(lines):
- line 73 -
def process(path):
Add a test block for each of the 2 functions, asserting on the behaviour you read in the original. A ported body with nothing asserting on it is a claim, not a result - and the review compiles the generated Zig and runs exactly those tests.
Acceptance criteria
-
test -f specs/port/tools/dedupe_identical_tests.t27 && echo present prints present (today the file does not exist)
-
grep -cE '^\s*(pub )?fn (blocks|process)\(' specs/port/tools/dedupe_identical_tests.t27 prints 2 - every function above is ported under its own name
-
t27c gen specs/port/tools/dedupe_identical_tests.t27 > /tmp/t27-gen.zig && grep -c 'not yet implemented' /tmp/t27-gen.zig prints 0, and t27c gen specs/port/tools/dedupe_identical_tests.t27 | wc -l prints more than 10 - an absent or empty file makes the grep print 0 on its own, so both halves are required
-
t27c spec-status specs/port/tools/dedupe_identical_tests.t27 does not print NOPARSE - the file still parses. (This replaces a parse-metrics criterion. The compiler in the container prints no such metrics, so the command printed nothing and no work could ever satisfy it.)
-
grep -cE '^[[:space:]]*test[[:space:]]+("|[A-Za-z_])' specs/port/tools/dedupe_identical_tests.t27 prints at least 2
Use t27c from the repository root, not the t27c on PATH: the PATH build prints no parse metrics at all, so criterion 4 greps nothing and an empty result reads as a pass.
Boundary
specs/port/tools/dedupe_identical_tests.t27
Port tools/dedupe_identical_tests.py (Python, 2 functions) to specs/port/tools/dedupe_identical_tests.t27
Context
tools/dedupe_identical_tests.pyis 150 lines of hand-written Python. Re-author its logic asspecs/port/tools/dedupe_identical_tests.t27so thatt27cgenerates the equivalent. The Python file stays where it is - this issue adds the.t27source it should have been written in..t27is the hand-authored source language.t27ccompiles it out to C, Rust, Verilog and Zig. You are writing source, not compiler output, and not prose about an implementation. The goal of this project is that every hand-written file in the repository is authored in.t27and the other languages are generated from it - this issue is one file of that migration.Read the original first
What to write
Create
specs/port/tools/dedupe_identical_tests.t27with one.t27function per Python function below. Keep the names exactly as they are - the name is how the port is checked. Quoted verbatim from the original:def blocks(lines):def process(path):Add a
testblock for each of the 2 functions, asserting on the behaviour you read in the original. A ported body with nothing asserting on it is a claim, not a result - and the review compiles the generated Zig and runs exactly those tests.Acceptance criteria
test -f specs/port/tools/dedupe_identical_tests.t27 && echo presentprintspresent(today the file does not exist)grep -cE '^\s*(pub )?fn (blocks|process)\(' specs/port/tools/dedupe_identical_tests.t27prints2- every function above is ported under its own namet27c gen specs/port/tools/dedupe_identical_tests.t27 > /tmp/t27-gen.zig && grep -c 'not yet implemented' /tmp/t27-gen.zigprints0, andt27c gen specs/port/tools/dedupe_identical_tests.t27 | wc -lprints more than10- an absent or empty file makes the grep print0on its own, so both halves are requiredt27c spec-status specs/port/tools/dedupe_identical_tests.t27does not printNOPARSE- the file still parses. (This replaces a parse-metrics criterion. The compiler in the container prints no such metrics, so the command printed nothing and no work could ever satisfy it.)grep -cE '^[[:space:]]*test[[:space:]]+("|[A-Za-z_])' specs/port/tools/dedupe_identical_tests.t27prints at least2Use
t27cfrom the repository root, not thet27con PATH: the PATH build prints no parse metrics at all, so criterion 4 greps nothing and an empty result reads as a pass.Boundary
specs/port/tools/dedupe_identical_tests.t27