183 {input, expected} cases across 10 construct files under
tests/cases/, driven by a ~180-line std-only harness (==== / ----
format). Each case asserts formatting and idempotency; #SKIP parks
known formatter bugs and fails the suite once they start passing.
Documents four real formatter bugs found while deriving expected
output (block-comment re-indent non-idempotency, comment lifted out
of expression groups, closing block labels dropped, multi-instance
declaration layout) — parked as #SKIP, to be fixed in a follow-up
feature. Also adds rustfmt.toml matching the codebase style.
Dev: Opus agent; QA: Sonnet agent; review in
docs/features/case-tables/README.md.
Co-Authored-By: Claude Fable 5 <[email protected]>
313 lines
4.2 KiB
Plaintext
313 lines
4.2 KiB
Plaintext
# leading line comment on a module
|
|
// top level comment
|
|
module m;
|
|
endmodule
|
|
----
|
|
// top level comment
|
|
module m;
|
|
endmodule
|
|
====
|
|
# leading comment on a declaration
|
|
module m;
|
|
// the data bus
|
|
wire [7:0] bus;
|
|
endmodule
|
|
----
|
|
module m;
|
|
// the data bus
|
|
wire [7:0] bus;
|
|
endmodule
|
|
====
|
|
# trailing comment on a declaration
|
|
module m;
|
|
wire [7:0] bus; // the data bus
|
|
endmodule
|
|
----
|
|
module m;
|
|
wire [7:0] bus; // the data bus
|
|
endmodule
|
|
====
|
|
# block comment before a module
|
|
/* a block comment */
|
|
module m;
|
|
endmodule
|
|
----
|
|
/* a block comment */
|
|
module m;
|
|
endmodule
|
|
====
|
|
#SKIP bug: continuation lines of a multi-line block comment gain two spaces on
|
|
#SKIP every format pass -- an unbounded idempotency violation (see feature README)
|
|
# multi-line block comment is passed through verbatim
|
|
module m;
|
|
/*
|
|
* doc block
|
|
*/
|
|
wire w;
|
|
endmodule
|
|
----
|
|
module m;
|
|
/*
|
|
* doc block
|
|
*/
|
|
wire w;
|
|
endmodule
|
|
====
|
|
# comment between statements inside a block
|
|
module m;
|
|
always_comb begin
|
|
a = 1;
|
|
// separator
|
|
b = 2;
|
|
end
|
|
endmodule
|
|
----
|
|
module m;
|
|
always_comb begin
|
|
a = 1;
|
|
// separator
|
|
b = 2;
|
|
end
|
|
endmodule
|
|
====
|
|
# trailing comment on a statement
|
|
module m;
|
|
always_comb begin
|
|
a = 1; // set a
|
|
end
|
|
endmodule
|
|
----
|
|
module m;
|
|
always_comb begin
|
|
a = 1; // set a
|
|
end
|
|
endmodule
|
|
====
|
|
# comment inside a port list forces the list to break
|
|
module m(
|
|
input a, // first
|
|
input b
|
|
);
|
|
endmodule
|
|
----
|
|
module m (
|
|
input a, // first
|
|
input b
|
|
);
|
|
endmodule
|
|
====
|
|
# comment inside a connection list forces the list to break
|
|
module m;
|
|
sub u0(
|
|
.a(x), // hook up x
|
|
.b(y)
|
|
);
|
|
endmodule
|
|
----
|
|
module m;
|
|
sub u0 (
|
|
.a(x), // hook up x
|
|
.b(y)
|
|
);
|
|
endmodule
|
|
====
|
|
# comment on a case item
|
|
module m;
|
|
always_comb begin
|
|
case (sel)
|
|
// the zero case
|
|
2'd0: y = a;
|
|
2'd1: y = b; // the one case
|
|
default: y = 0;
|
|
endcase
|
|
end
|
|
endmodule
|
|
----
|
|
module m;
|
|
always_comb begin
|
|
case (sel)
|
|
// the zero case
|
|
2'd0: y = a;
|
|
2'd1: y = b; // the one case
|
|
default: y = 0;
|
|
endcase
|
|
end
|
|
endmodule
|
|
====
|
|
# several consecutive comment lines are kept together
|
|
module m;
|
|
// line one
|
|
// line two
|
|
// line three
|
|
wire w;
|
|
endmodule
|
|
----
|
|
module m;
|
|
// line one
|
|
// line two
|
|
// line three
|
|
wire w;
|
|
endmodule
|
|
====
|
|
# blank lines around comments are collapsed to one
|
|
module m;
|
|
wire a;
|
|
|
|
|
|
|
|
// a comment after several blank lines
|
|
|
|
|
|
wire b;
|
|
endmodule
|
|
----
|
|
module m;
|
|
wire a;
|
|
|
|
// a comment after several blank lines
|
|
wire b;
|
|
endmodule
|
|
====
|
|
# comment at the very end of a module body
|
|
module m;
|
|
wire w;
|
|
// trailing note
|
|
endmodule
|
|
----
|
|
module m;
|
|
wire w;
|
|
// trailing note
|
|
endmodule
|
|
====
|
|
# comment after endmodule
|
|
module m;
|
|
endmodule
|
|
// after the module
|
|
----
|
|
module m;
|
|
endmodule
|
|
// after the module
|
|
====
|
|
# comment between two modules
|
|
module a;
|
|
endmodule
|
|
|
|
// between
|
|
|
|
module b;
|
|
endmodule
|
|
----
|
|
module a;
|
|
endmodule
|
|
|
|
// between
|
|
module b;
|
|
endmodule
|
|
====
|
|
# comment before else
|
|
module m;
|
|
always_comb begin
|
|
if (a) begin
|
|
y = 0;
|
|
// explain the else
|
|
end else begin
|
|
y = 1;
|
|
end
|
|
end
|
|
endmodule
|
|
----
|
|
module m;
|
|
always_comb begin
|
|
if (a) begin
|
|
y = 0;
|
|
// explain the else
|
|
end else begin
|
|
y = 1;
|
|
end
|
|
end
|
|
endmodule
|
|
====
|
|
# comment on a parameter port
|
|
module m #(
|
|
// the width
|
|
parameter WIDTH = 8
|
|
) ();
|
|
endmodule
|
|
----
|
|
module m #(
|
|
// the width
|
|
parameter WIDTH = 8
|
|
) ();
|
|
endmodule
|
|
====
|
|
#SKIP bug: the comment is lifted out of the concatenation to the end of the
|
|
#SKIP statement instead of forcing the group to break (see feature README)
|
|
# comment inside a concatenation
|
|
module m;
|
|
assign y = {
|
|
a, // high
|
|
b
|
|
};
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign y = {
|
|
a, // high
|
|
b
|
|
};
|
|
endmodule
|
|
====
|
|
# leading comment on an instance
|
|
module m;
|
|
// instantiate the submodule
|
|
sub u0(.a(x));
|
|
endmodule
|
|
----
|
|
module m;
|
|
// instantiate the submodule
|
|
sub u0 (.a(x));
|
|
endmodule
|
|
====
|
|
# comment in an empty module body
|
|
module m;
|
|
// nothing here yet
|
|
endmodule
|
|
----
|
|
module m;
|
|
// nothing here yet
|
|
endmodule
|
|
====
|
|
# preprocessor directives are passed through verbatim
|
|
`include "defs.svh"
|
|
`define WIDTH 8
|
|
module m;
|
|
`ifdef FAST
|
|
wire fast;
|
|
`else
|
|
wire slow;
|
|
`endif
|
|
endmodule
|
|
----
|
|
`include "defs.svh"
|
|
`define WIDTH 8
|
|
module m;
|
|
`ifdef FAST
|
|
wire fast;
|
|
`else
|
|
wire slow;
|
|
`endif
|
|
endmodule
|
|
====
|
|
# attribute instances are passed through
|
|
(* keep = "true" *)
|
|
module m;
|
|
(* dont_touch *)
|
|
wire w;
|
|
endmodule
|
|
----
|
|
(* keep = "true" *)
|
|
module m;
|
|
(* dont_touch *)
|
|
wire w;
|
|
endmodule
|