Add regression tests for initialized const static properties
Check that a `const static` class property with a declaration initializer is accepted and has the initialized value. Also check that subsequent assignments through unqualified and object-member lookup are rejected. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
4ffeb748f4
commit
aa8f928ffa
|
|
@ -0,0 +1,15 @@
|
|||
// Check that a const static property cannot be assigned through an object.
|
||||
|
||||
module test;
|
||||
|
||||
class C;
|
||||
const static int value = 42;
|
||||
endclass
|
||||
|
||||
C object;
|
||||
|
||||
initial begin
|
||||
object.value = 1;
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// Check initialization of a const static class property.
|
||||
|
||||
module test;
|
||||
|
||||
class C;
|
||||
const static int value = 42;
|
||||
endclass
|
||||
|
||||
C object;
|
||||
|
||||
initial begin
|
||||
// A static property can be accessed without constructing the object.
|
||||
if (object.value !== 42) begin
|
||||
$display("FAILED: expected 42, got %0d", object.value);
|
||||
end else begin
|
||||
$display("PASSED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
// Check that a const static property cannot be assigned by local lookup.
|
||||
|
||||
module test;
|
||||
|
||||
class C;
|
||||
const static int value = 42;
|
||||
|
||||
static function void write_value;
|
||||
value = 1;
|
||||
endfunction
|
||||
endclass
|
||||
|
||||
endmodule
|
||||
|
|
@ -287,6 +287,9 @@ sv_chained_constructor4 vvp_tests/sv_chained_constructor4.json
|
|||
sv_chained_constructor5 vvp_tests/sv_chained_constructor5.json
|
||||
sv_class_const_derived vvp_tests/sv_class_const_derived.json
|
||||
sv_class_const_nested_block vvp_tests/sv_class_const_nested_block.json
|
||||
sv_class_const_static_assign_fail vvp_tests/sv_class_const_static_assign_fail.json
|
||||
sv_class_const_static_init vvp_tests/sv_class_const_static_init.json
|
||||
sv_class_const_static_local_fail vvp_tests/sv_class_const_static_local_fail.json
|
||||
sv_class_nested_method_call vvp_tests/sv_class_nested_method_call.json
|
||||
sv_class_prop_assign_op1 vvp_tests/sv_class_prop_assign_op1.json
|
||||
sv_class_prop_assign_op2 vvp_tests/sv_class_prop_assign_op2.json
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"type" : "CE",
|
||||
"source" : "sv_class_const_static_assign_fail.v",
|
||||
"iverilog-args" : [ "-g2005-sv" ],
|
||||
"vlog95" : {
|
||||
"__comment" : "Classes are not supported",
|
||||
"type" : "CE"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "sv_class_const_static_init.v",
|
||||
"iverilog-args" : [ "-g2005-sv" ],
|
||||
"vlog95" : {
|
||||
"__comment" : "Classes are not supported",
|
||||
"type" : "CE"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"type" : "CE",
|
||||
"source" : "sv_class_const_static_local_fail.v",
|
||||
"iverilog-args" : [ "-g2005-sv" ],
|
||||
"vlog95" : {
|
||||
"__comment" : "Classes are not supported",
|
||||
"type" : "CE"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue