-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression tests for binding task/function arguments by name
Check that binding task and function arguments by name works as expected. Also check that is works for the various variations of invoking a class constructor. Signed-off-by: Lars-Peter Clausen <[email protected]>
- Loading branch information
1 parent
f6a51bc
commit 250c456
Showing
80 changed files
with
1,009 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Check that binding task arguments by name is supported. | ||
|
||
module test; | ||
|
||
class B; | ||
integer val; | ||
|
||
function new(integer a, integer b); | ||
val = a + b * 10; | ||
endfunction | ||
endclass | ||
|
||
class C extends B(.b(2), .a(1)); | ||
endclass | ||
|
||
initial begin | ||
C c; | ||
c = new; | ||
if (c.val == 21) begin | ||
$display("PASSED"); | ||
end else begin | ||
$display("FAILED"); | ||
end | ||
end | ||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Check that binding task arguments by name is supported and that a mix of | ||
// positional and named arguments is supported. | ||
|
||
module test; | ||
|
||
class B; | ||
integer val; | ||
|
||
function new(integer a, integer b, integer c); | ||
val = a + b * 10 + c * 100; | ||
endfunction | ||
endclass | ||
|
||
class C extends B(1, .c(3), .b(2)); | ||
endclass | ||
|
||
initial begin | ||
C c; | ||
c = new; | ||
if (c.val == 321) begin | ||
$display("PASSED"); | ||
end else begin | ||
$display("FAILED"); | ||
end | ||
end | ||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Check that binding task arguments by name is supported and that an empty | ||
// value can be bound to the name, in which case the default argument value | ||
// should be used. | ||
|
||
module test; | ||
|
||
class B; | ||
integer val; | ||
|
||
function new(integer a, integer b = 2); | ||
val = a + b * 10; | ||
endfunction | ||
endclass | ||
|
||
class C extends B(.a(1), .b()); | ||
endclass | ||
|
||
initial begin | ||
C c; | ||
c = new; | ||
if (c.val == 21) begin | ||
$display("PASSED"); | ||
end else begin | ||
$display("FAILED"); | ||
end | ||
end | ||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Check that an error is reported when trying to bind an argument by nae that | ||
// does not exist | ||
|
||
module test; | ||
|
||
class B; | ||
function new(integer a, integer b); | ||
$display("FAILED"); | ||
endfunction | ||
endclass | ||
|
||
class C extends B(.b(2), .c(1)); // This should fail. `c` is not an arugment | ||
// of the base constructor. | ||
endclass | ||
|
||
initial begin | ||
C c; | ||
c = new; | ||
end | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Check that an error is reported when trying to bind the same argument by name | ||
// multiple times. | ||
|
||
module test; | ||
|
||
class B; | ||
function new(integer a, integer b); | ||
$display("FAILED"); | ||
endfunction | ||
endclass | ||
|
||
class C extends B(.a(1), .a(2)); // This should fail. `a` is provided twice | ||
// as a named argument. | ||
endclass | ||
|
||
initial begin | ||
C c; | ||
c = new; | ||
end | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Check that an error is reported when trying to bind an argument by name that | ||
// is also provided as a positional argument. | ||
|
||
module test; | ||
|
||
class B; | ||
function new(integer a, integer b); | ||
$display("FAILED"); | ||
endfunction | ||
endclass | ||
|
||
class C extends B(1, .a(2)); // This should fail. `a` is provided both as a | ||
// positional and named argument. | ||
endclass | ||
|
||
initial begin | ||
C c; | ||
c = new; | ||
end | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Check that an error is reported trying to provide a positional argument to a | ||
// function after a named argument. | ||
|
||
module test; | ||
|
||
class B; | ||
function new(integer a, integer b); | ||
$display("FAILED"); | ||
endfunction | ||
endclass | ||
|
||
class C extends B(.a(2), 1); // This should fail. Positional arguments must | ||
// precede named arguments. | ||
endclass | ||
|
||
initial begin | ||
C c; | ||
c = new; | ||
end | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Check that an error is reported when binding an empty value to an argument by | ||
// name and the argument does not have a default value. | ||
|
||
module test; | ||
|
||
class B; | ||
function new(integer a); | ||
$display("FAILED"); | ||
endfunction | ||
endclass | ||
|
||
class C extends B(.a()); // This should fail. `a` has no default value. | ||
endclass | ||
|
||
initial begin | ||
C c; | ||
c = new; | ||
end | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Check that binding task arguments by name is supported. | ||
|
||
module test; | ||
|
||
class B; | ||
integer val; | ||
|
||
function new(integer a, integer b); | ||
val = a + b * 10; | ||
endfunction | ||
endclass | ||
|
||
class C extends B; | ||
function new; | ||
super.new(.b(2), .a(1)); | ||
endfunction | ||
endclass | ||
|
||
initial begin | ||
C c; | ||
c = new; | ||
if (c.val == 21) begin | ||
$display("PASSED"); | ||
end else begin | ||
$display("FAILED"); | ||
end | ||
end | ||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Check that binding task arguments by name is supported and that a mix of | ||
// positional and named arguments is supported. | ||
|
||
module test; | ||
|
||
class B; | ||
integer val; | ||
|
||
function new(integer a, integer b, integer c); | ||
val = a + b * 10 + c * 100; | ||
endfunction | ||
endclass | ||
|
||
class C extends B; | ||
function new; | ||
super.new(1, .c(3), .b(2)); | ||
endfunction | ||
endclass | ||
|
||
initial begin | ||
C c; | ||
c = new; | ||
if (c.val == 321) begin | ||
$display("PASSED"); | ||
end else begin | ||
$display("FAILED"); | ||
end | ||
end | ||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Check that binding task arguments by name is supported and that an empty | ||
// value can be bound to the name, in which case the default argument value | ||
// should be used. | ||
|
||
module test; | ||
|
||
class B; | ||
integer val; | ||
|
||
function new(integer a, integer b = 2); | ||
val = a + b * 10; | ||
endfunction | ||
endclass | ||
|
||
class C extends B; | ||
function new; | ||
super.new(.a(1), .b()); | ||
endfunction | ||
endclass | ||
|
||
initial begin | ||
C c; | ||
c = new; | ||
if (c.val == 21) begin | ||
$display("PASSED"); | ||
end else begin | ||
$display("FAILED"); | ||
end | ||
end | ||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Check that an error is reported when trying to bind an argument by nae that | ||
// does not exist | ||
|
||
module test; | ||
|
||
class B; | ||
function new(integer a, integer b); | ||
$display("FAILED"); | ||
endfunction | ||
endclass | ||
|
||
class C extends B; | ||
function new; | ||
super.new(.b(2), .c(1)); // This should fail. `c` is not an arugment of | ||
// the base constructor. | ||
endfunction | ||
endclass | ||
|
||
initial begin | ||
C c; | ||
c = new; | ||
end | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Check that an error is reported when trying to bind the same argument by name | ||
// multiple times. | ||
|
||
module test; | ||
|
||
class B; | ||
function new(integer a, integer b); | ||
$display("FAILED"); | ||
endfunction | ||
endclass | ||
|
||
class C extends B; | ||
function new; | ||
super.new(.a(1), .a(2)); // This should fail. `a` is provided twice as a | ||
// named argument. | ||
endfunction | ||
endclass | ||
|
||
initial begin | ||
C c; | ||
c = new; | ||
end | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Check that an error is reported when trying to bind an argument by name that | ||
// is also provided as a positional argument. | ||
|
||
module test; | ||
|
||
class B; | ||
function new(integer a, integer b); | ||
$display("FAILED"); | ||
endfunction | ||
endclass | ||
|
||
class C extends B; | ||
function new; | ||
super.new(1, .a(2)); // This should fail. `a` is provided both as a | ||
// positional and named argument. | ||
endfunction | ||
endclass | ||
|
||
initial begin | ||
C c; | ||
c = new; | ||
end | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Check that an error is reported trying to provide a positional argument to a | ||
// function after a named argument. | ||
|
||
module test; | ||
|
||
class B; | ||
function new(integer a, integer b); | ||
$display("FAILED"); | ||
endfunction | ||
endclass | ||
|
||
class C extends B; | ||
function new; | ||
super.new(.a(2), 1); // This should fail. Positional arguments must | ||
// precede named arguments. | ||
endfunction | ||
endclass | ||
|
||
initial begin | ||
C c; | ||
c = new; | ||
end | ||
|
||
endmodule |
Oops, something went wrong.