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]>
272 lines
5.2 KiB
Plaintext
272 lines
5.2 KiB
Plaintext
# binary operators get single spaces
|
|
module m;
|
|
assign y=a+b*c-d/e%f;
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign y = a + b * c - d / e % f;
|
|
endmodule
|
|
====
|
|
# unary operators bind tightly
|
|
module m;
|
|
assign y = ~a & -b | !c ^ +d;
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign y = ~a & -b | !c ^ +d;
|
|
endmodule
|
|
====
|
|
# reduction operators
|
|
module m;
|
|
assign y = &a | |b ^ ^c;
|
|
assign z = ~&a & ~|b & ~^c;
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign y = &a | |b ^ ^c;
|
|
assign z = ~&a & ~|b & ~^c;
|
|
endmodule
|
|
====
|
|
# comparison and equality operators
|
|
module m;
|
|
assign y = (a<b)&&(c>=d)||(e==f)&&(g!==h);
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign y = (a < b) && (c >= d) || (e == f) && (g !== h);
|
|
endmodule
|
|
====
|
|
# shift and power operators
|
|
module m;
|
|
assign y = (a << 2) + (b >>> 1) + (c ** 2);
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign y = (a << 2) + (b >>> 1) + (c ** 2);
|
|
endmodule
|
|
====
|
|
# redundant parentheses are preserved
|
|
module m;
|
|
assign y = ((a + b));
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign y = ((a + b));
|
|
endmodule
|
|
====
|
|
# nested ternary
|
|
module m;
|
|
assign y = a ? b : c ? d : e;
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign y = a ? b : c ? d : e;
|
|
endmodule
|
|
====
|
|
# ternary that must wrap
|
|
module m;
|
|
assign output_signal_name = condition_signal_name_x ? first_alternative_value : second_alternative;
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign output_signal_name =
|
|
condition_signal_name_x ? first_alternative_value : second_alternative;
|
|
endmodule
|
|
====
|
|
# concatenation and replication
|
|
module m;
|
|
assign y={a,b,c};
|
|
assign z={4{a}};
|
|
assign w={2{a,b}};
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign y = {a, b, c};
|
|
assign z = {4{a}};
|
|
assign w = {2{a, b}};
|
|
endmodule
|
|
====
|
|
# nested concatenation
|
|
module m;
|
|
assign y = {{4{a}}, {2{b, c}}, d};
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign y = {{4{a}}, {2{b, c}}, d};
|
|
endmodule
|
|
====
|
|
# part selects and indexed part selects
|
|
module m;
|
|
assign y = bus[7:0];
|
|
assign z = bus[base+:8];
|
|
assign w = bus[base-:8];
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign y = bus[7:0];
|
|
assign z = bus[base+:8];
|
|
assign w = bus[base-:8];
|
|
endmodule
|
|
====
|
|
# chained selects on a hierarchical name
|
|
module m;
|
|
assign y = top.u_sub.mem[3][7:0];
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign y = top.u_sub.mem[3][7:0];
|
|
endmodule
|
|
====
|
|
# casts
|
|
module m;
|
|
assign y = int'(a);
|
|
assign z = 8'(b);
|
|
assign w = signed'(c);
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign y = int'(a);
|
|
assign z = 8'(b);
|
|
assign w = signed'(c);
|
|
endmodule
|
|
====
|
|
# assignment patterns
|
|
module m;
|
|
always_comb begin
|
|
s = '{a: 1, b: 2};
|
|
v = '{default: 0};
|
|
t = '{1, 2, 3};
|
|
end
|
|
endmodule
|
|
----
|
|
module m;
|
|
always_comb begin
|
|
s = '{a: 1, b: 2};
|
|
v = '{default: 0};
|
|
t = '{1, 2, 3};
|
|
end
|
|
endmodule
|
|
====
|
|
# inside operator
|
|
module m;
|
|
assign y = a inside {1, 2, 3};
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign y = a inside {1, 2, 3};
|
|
endmodule
|
|
====
|
|
# package-scoped and hierarchical names
|
|
module m;
|
|
assign y = pkg::CONST + top.inst.sig;
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign y = pkg::CONST + top.inst.sig;
|
|
endmodule
|
|
====
|
|
# function call in an expression
|
|
module m;
|
|
assign y = compute(a, b) + 1;
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign y = compute(a, b) + 1;
|
|
endmodule
|
|
====
|
|
# system function call
|
|
module m;
|
|
localparam W = $clog2(DEPTH);
|
|
endmodule
|
|
----
|
|
module m;
|
|
localparam W = $clog2(DEPTH);
|
|
endmodule
|
|
====
|
|
# macro usage in expression position
|
|
module m;
|
|
assign y = `MY_MACRO(a, b) + 1;
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign y = `MY_MACRO(a, b) + 1;
|
|
endmodule
|
|
====
|
|
# numeric literal forms
|
|
module m;
|
|
localparam A = 8'hFF;
|
|
localparam B = 4'b1010;
|
|
localparam C = 32'd42;
|
|
localparam D = 'x;
|
|
localparam E = 1.5e3;
|
|
endmodule
|
|
----
|
|
module m;
|
|
localparam A = 8'hFF;
|
|
localparam B = 4'b1010;
|
|
localparam C = 32'd42;
|
|
localparam D = 'x;
|
|
localparam E = 1.5e3;
|
|
endmodule
|
|
====
|
|
# string literal
|
|
module m;
|
|
initial $display("a string with, commas and (parens)");
|
|
endmodule
|
|
----
|
|
module m;
|
|
initial $display("a string with, commas and (parens)");
|
|
endmodule
|
|
====
|
|
# long boolean expression breaks at the top-level operator
|
|
module m;
|
|
assign ready_signal = first_condition_name && second_condition_name && third_condition_name && xyzw;
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign ready_signal =
|
|
first_condition_name && second_condition_name && third_condition_name && xyzw;
|
|
endmodule
|
|
====
|
|
# an expression that fits in exactly 100 columns is left on one line
|
|
module m;
|
|
assign ready_signal = first_condition_name && second_condition_name && third_condition_name && xy;
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign ready_signal = first_condition_name && second_condition_name && third_condition_name && xy;
|
|
endmodule
|
|
====
|
|
# a very long operator chain breaks one operand per line
|
|
module m;
|
|
assign ready_signal = first_condition_name && second_condition_name && third_condition_name && fourth_condition_name && fifth_condition_name;
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign ready_signal =
|
|
first_condition_name &&
|
|
second_condition_name &&
|
|
third_condition_name &&
|
|
fourth_condition_name &&
|
|
fifth_condition_name;
|
|
endmodule
|
|
====
|
|
# a long concatenation that fits once wrapped stays on one line
|
|
module m;
|
|
assign bus_value = {first_source_word, second_source_word, third_source_word, fourth_source_word, fifth};
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign bus_value =
|
|
{first_source_word, second_source_word, third_source_word, fourth_source_word, fifth};
|
|
endmodule
|
|
====
|
|
# streams of mixed precedence stay unparenthesized
|
|
module m;
|
|
assign y = a + b == c - d;
|
|
endmodule
|
|
----
|
|
module m;
|
|
assign y = a + b == c - d;
|
|
endmodule
|