Add regression tests for using `super` to access the base class
Check that it is possible to use the `super` keyword to access properties and methods of the base class that exist with the same name in current class. Also check that `this.super` is supported as an alternative to `super` and has the same behavior. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
15fa24a664
commit
295b65da2c
|
|
@ -0,0 +1,39 @@
|
|||
// Check that `super` keyword can be used to access members of the base class
|
||||
|
||||
class B;
|
||||
int x, y;
|
||||
|
||||
task set_y;
|
||||
y = 2000;
|
||||
endtask
|
||||
|
||||
function bit check_x;
|
||||
return x === 1000;
|
||||
endfunction
|
||||
endclass
|
||||
|
||||
class C extends B;
|
||||
byte x, y;
|
||||
task set_x;
|
||||
super.x = 1000;
|
||||
endtask
|
||||
|
||||
function bit check_y;
|
||||
return super.y === 2000;
|
||||
endfunction
|
||||
endclass
|
||||
|
||||
module test;
|
||||
C c;
|
||||
|
||||
initial begin
|
||||
c = new;
|
||||
c.set_x;
|
||||
c.set_y;
|
||||
if (c.check_x() && c.check_y()) begin
|
||||
$display("PASSED");
|
||||
end else begin
|
||||
$display("FAILED");
|
||||
end
|
||||
end
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
// Check that `super` keyword can be used to call tasks of the base class
|
||||
|
||||
class B;
|
||||
task t;
|
||||
$display("PASSED");
|
||||
endtask
|
||||
endclass
|
||||
|
||||
class C extends B;
|
||||
task t;
|
||||
$display("FAILED");
|
||||
endtask
|
||||
|
||||
task check;
|
||||
super.t;
|
||||
endtask
|
||||
endclass
|
||||
|
||||
module test;
|
||||
C c;
|
||||
|
||||
initial begin
|
||||
c = new;
|
||||
c.check;
|
||||
end
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
// Check that `super` keyword can be used to call functions of the base class
|
||||
|
||||
class B;
|
||||
function int f;
|
||||
return 1;
|
||||
endfunction
|
||||
endclass
|
||||
|
||||
class C extends B;
|
||||
function int f;
|
||||
return 2;
|
||||
endfunction
|
||||
|
||||
task check;
|
||||
if (super.f() === 1) begin
|
||||
$display("PASSED");
|
||||
end else begin
|
||||
$display("FAILED");
|
||||
end
|
||||
endtask
|
||||
endclass
|
||||
|
||||
module test;
|
||||
C c;
|
||||
|
||||
initial begin
|
||||
c = new;
|
||||
c.check;
|
||||
end
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
// Check that `this.super` is supported
|
||||
|
||||
class B;
|
||||
int x, y;
|
||||
|
||||
task set_y;
|
||||
y = 2000;
|
||||
endtask
|
||||
|
||||
function bit check_x;
|
||||
return x === 1000;
|
||||
endfunction
|
||||
endclass
|
||||
|
||||
class C extends B;
|
||||
byte x, y;
|
||||
task set_x;
|
||||
this.super.x = 1000;
|
||||
endtask
|
||||
|
||||
function bit check_y;
|
||||
return this.super.y === 2000;
|
||||
endfunction
|
||||
endclass
|
||||
|
||||
module test;
|
||||
C c;
|
||||
|
||||
initial begin
|
||||
c = new;
|
||||
c.set_x;
|
||||
c.set_y;
|
||||
if (c.check_x() && c.check_y()) begin
|
||||
$display("PASSED");
|
||||
end else begin
|
||||
$display("FAILED");
|
||||
end
|
||||
end
|
||||
endmodule
|
||||
|
|
@ -587,6 +587,10 @@ sv_class_static_prop2 normal,-g2009 ivltests
|
|||
sv_class_static_prop3 normal,-g2009 ivltests
|
||||
sv_class_super1 normal,-g2009 ivltests
|
||||
sv_class_super2 normal,-g2009 ivltests
|
||||
sv_class_super3 normal,-g2009 ivltests
|
||||
sv_class_super4 normal,-g2009 ivltests
|
||||
sv_class_super5 normal,-g2009 ivltests
|
||||
sv_class_super6 normal,-g2009 ivltests
|
||||
sv_class_task1 normal,-g2009 ivltests
|
||||
sv_class_virt_new_fail CE,-g2009 ivltests
|
||||
sv_darray1 normal,-g2009 ivltests
|
||||
|
|
|
|||
|
|
@ -435,6 +435,10 @@ sv_class_static_prop2 CE,-g2009 ivltests
|
|||
sv_class_static_prop3 CE,-g2009 ivltests
|
||||
sv_class_super1 CE,-g2009 ivltests
|
||||
sv_class_super2 CE,-g2009 ivltests
|
||||
sv_class_super3 CE,-g2009 ivltests
|
||||
sv_class_super4 CE,-g2009 ivltests
|
||||
sv_class_super5 CE,-g2009 ivltests
|
||||
sv_class_super6 CE,-g2009 ivltests
|
||||
sv_class_task1 CE,-g2009 ivltests
|
||||
sv_end_label CE,-g2009 ivltests # Also generate
|
||||
sv_foreach2 CE,-g2009,-pallowsigned=1 ivltests
|
||||
|
|
|
|||
Loading…
Reference in New Issue