Files
lucisv/crates/vlog_formatter/tests/cases/functions_tasks.cases
T
lucioandClaude Fable 5 6b95d772f1 Add case-tables: Verible-style text-in/text-out test suite
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]>
2026-08-18 23:38:58 -07:00

228 lines
3.6 KiB
Plaintext

# function with an ANSI port list
module m;
function int add(input int a, input int b);
return a + b;
endfunction
endmodule
----
module m;
function int add(input int a, input int b);
return a + b;
endfunction
endmodule
====
# function with no ports
module m;
function int zero();
return 0;
endfunction
endmodule
----
module m;
function int zero();
return 0;
endfunction
endmodule
====
# function with old-style port declarations
module m;
function [7:0] f;
input [7:0] a;
begin
f = a + 1;
end
endfunction
endmodule
----
module m;
function [7:0] f;
input [7:0] a;
begin
f = a + 1;
end
endfunction
endmodule
====
# void function
module m;
function void log(input string s);
$display(s);
endfunction
endmodule
----
module m;
function void log(input string s);
$display(s);
endfunction
endmodule
====
# automatic function with local declarations
module m;
function automatic int sum(input int n);
int acc;
acc = 0;
for (int i = 0; i < n; i++) acc = acc + i;
return acc;
endfunction
endmodule
----
module m;
function automatic int sum(input int n);
int acc;
acc = 0;
for (int i = 0; i < n; i++) acc = acc + i;
return acc;
endfunction
endmodule
====
# function whose port list is too wide
module m;
function automatic logic [31:0] compute(input logic [31:0] first_operand, input logic [31:0] second);
return first_operand + second;
endfunction
endmodule
----
module m;
function automatic logic [31:0] compute(
input logic [31:0] first_operand,
input logic [31:0] second
);
return first_operand + second;
endfunction
endmodule
====
# task with ANSI ports
module m;
task send(input logic [7:0] data, output logic done);
done = 1'b0;
@(posedge clk);
done = 1'b1;
endtask
endmodule
----
module m;
task send(input logic [7:0] data, output logic done);
done = 1'b0;
@(posedge clk);
done = 1'b1;
endtask
endmodule
====
# task with no ports and no parentheses
module m;
task reset_all;
q <= 0;
endtask
endmodule
----
module m;
task reset_all;
q <= 0;
endtask
endmodule
====
# task with old-style port declarations
module m;
task t;
input [7:0] a;
output b;
begin
b = |a;
end
endtask
endmodule
----
module m;
task t;
input [7:0] a;
output b;
begin
b = |a;
end
endtask
endmodule
====
# task with inout and ref-free defaults
module m;
task t(inout int x, input int y = 0);
x = x + y;
endtask
endmodule
----
module m;
task t(inout int x, input int y = 0);
x = x + y;
endtask
endmodule
====
# task call as a statement
module m;
initial begin
send(8'hFF, done);
reset_all;
end
endmodule
----
module m;
initial begin
send(8'hFF, done);
reset_all;
end
endmodule
====
# function call with a wide argument list
module m;
assign result = compute_the_value(first_argument_name, second_argument_name, third_argument_name);
endmodule
----
module m;
assign result = compute_the_value(first_argument_name, second_argument_name, third_argument_name);
endmodule
====
# function returning a struct-typed value
module m;
function my_type_t make(input int a);
make.field = a;
return make;
endfunction
endmodule
----
module m;
function my_type_t make(input int a);
make.field = a;
return make;
endfunction
endmodule
====
# comment on a function port
module m;
function int f(
// the operand
input int a
);
return a;
endfunction
endmodule
----
module m;
function int f(
// the operand
input int a
);
return a;
endfunction
endmodule
====
# function inside a package
package p;
function int id(input int a);
return a;
endfunction
endpackage
----
package p;
function int id(input int a);
return a;
endfunction
endpackage