Add regression tests for shadowing class properties
Check that class properties can be shadowed by local symbols in class methods and also check that a package scoped identifier with the same name as class property can be accessed in a class method. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
07e20376d7
commit
4cc3c7b08f
|
|
@ -0,0 +1,25 @@
|
|||
// Check that class properties can be shadowed by a local symbol
|
||||
|
||||
module test;
|
||||
|
||||
class C;
|
||||
int x = 0;
|
||||
|
||||
task check;
|
||||
int x; // This should shadow the class property
|
||||
x = 10;
|
||||
if (this.x == 0 && x === 10) begin
|
||||
$display("PASSED");
|
||||
end else begin
|
||||
$display("FAILED");
|
||||
end
|
||||
endtask
|
||||
endclass
|
||||
|
||||
initial begin
|
||||
C c;
|
||||
c = new;
|
||||
c.check;
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
// Check that it is possible to access a package scoped identifier of the same
|
||||
// name of a class property inside a class method
|
||||
|
||||
package P;
|
||||
int x = 10;
|
||||
endpackage
|
||||
|
||||
module test;
|
||||
|
||||
class C;
|
||||
int x = 0;
|
||||
|
||||
task check;
|
||||
if (P::x === 10) begin
|
||||
$display("PASSED");
|
||||
end else begin
|
||||
$display("FAILED");
|
||||
end
|
||||
endtask
|
||||
endclass
|
||||
|
||||
initial begin
|
||||
C c;
|
||||
c = new;
|
||||
c.check;
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -584,6 +584,8 @@ sv_class_method_lt_static2 CE,-g2009 ivltests
|
|||
sv_class_method_signed1 normal,-g2009 ivltests
|
||||
sv_class_method_signed2 normal,-g2009 ivltests
|
||||
sv_class_method_var_init normal,-g2009 ivltests
|
||||
sv_class_prop_shadow1 normal,-g2009 ivltests
|
||||
sv_class_prop_shadow2 normal,-g2009 ivltests
|
||||
sv_class_property_signed1 normal,-g2009 ivltests
|
||||
sv_class_property_signed2 normal,-g2009 ivltests
|
||||
sv_class_property_signed3 normal,-g2009 ivltests
|
||||
|
|
|
|||
|
|
@ -432,6 +432,8 @@ sv_class_method_default2 CE,-g2009 ivltests
|
|||
sv_class_method_signed1 CE,-g2009,-pallowsigned=1 ivltests
|
||||
sv_class_method_signed2 CE,-g2009,-pallowsigned=1 ivltests
|
||||
sv_class_method_var_init CE,-g2009,-pallowsigned=1 ivltests
|
||||
sv_class_prop_shadow1 CE,-g2009 ivltests
|
||||
sv_class_prop_shadow2 CE,-g2009 ivltests
|
||||
sv_class_property_signed1 CE,-g2009,-pallowsigned=1 ivltests
|
||||
sv_class_property_signed2 CE,-g2009,-pallowsigned=1 ivltests
|
||||
sv_class_property_signed3 CE,-g2009,-pallowsigned=1 ivltests
|
||||
|
|
|
|||
Loading…
Reference in New Issue