Commit 750ca23f authored by Miklos Magyari's avatar Miklos Magyari
Browse files

OOP: tests for object method override semantic checks; abstract override check


Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent d43c0a7c
......@@ -473,6 +473,21 @@ function f_with_exception(integer pl_int) return integer exception(integer) {
raise integer:0; // invalid, raise cannot be used in a finally block
}
type class ObjClass1 {
public function toString(in universal charstring pl_prefix) return universal charstring { // mismatch
return pl_prefix & "ObjectClass1";
}
public function equals(object pl_obj, integer pl_x) return boolean { // mismatch
return false;
}
}
type class @abstract ObjClass2 {
private var boolean equals; // shadows object equals()
public function @abstract toString() return universal charstring; // mismatch because of @abstract
}
testcase tc_basicSyntax() runs on CT {
var GrandSubClass vl_gsc := GrandSubClass.create(1, 1, 1, { a := 10 });
......
......@@ -54,7 +54,8 @@ public class DefinitionContainer implements Iterable<Definition> {
final IsIdenticalResult inres = funclist.isIdentical(timestamp, fplist);
if (fplist != null) {
if (funclist != null && inres != IsIdenticalResult.RES_DIFFERS &&
func.getType(timestamp).isIdentical(timestamp, ClassTypeBody.getObjectMethodReturnType(name))) {
func.getType(timestamp).isIdentical(timestamp, ClassTypeBody.getObjectMethodReturnType(name)) &&
! func.isAbstract()) {
if (inres == IsIdenticalResult.RES_NAME_DIFFERS) {
funclist.getLocation().reportSemanticWarning(FormalParameterList.ONEORMORENAMESDIFER);
}
......
......@@ -181,7 +181,7 @@ public class OOP_Semantic_tests {
private ArrayList<MarkerToCheck> oopNegative_ttcn_initializer() {
//oopNegativeSemanticTest.ttcn
ArrayList<MarkerToCheck> markersToCheck = new ArrayList<MarkerToCheck>(102);
ArrayList<MarkerToCheck> markersToCheck = new ArrayList<MarkerToCheck>(106);
int lineNum = 33;
markersToCheck.add(new MarkerToCheck("class type expected", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 10;
......@@ -340,6 +340,13 @@ public class OOP_Semantic_tests {
markersToCheck.add(new MarkerToCheck("octetstring value was expected", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 17;
markersToCheck.add(new MarkerToCheck("Raise statement cannot be used in a finally block", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 4;
markersToCheck.add(new MarkerToCheck("The prototype of method `toString is not identical to that of the method inherited from the object class", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 4;
markersToCheck.add(new MarkerToCheck("The prototype of method `equals is not identical to that of the method inherited from the object class", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 6;
markersToCheck.add(new MarkerToCheck("`variable `@classesNegativeSemantic.ObjClass2' shadows a method inherited from the object class", lineNum, IMarker.SEVERITY_ERROR));
markersToCheck.add(new MarkerToCheck("The prototype of method `toString is not identical to that of the method inherited from the object class", ++lineNum, IMarker.SEVERITY_ERROR));
lineNum += 10;
markersToCheck.add(new MarkerToCheck("Unknown field reference", lineNum, IMarker.SEVERITY_ERROR));
markersToCheck.add(new MarkerToCheck("Type mismatch: a value of type `charstring' was expected instead of `integer'", ++lineNum, IMarker.SEVERITY_ERROR));
......@@ -360,7 +367,7 @@ public class OOP_Semantic_tests {
lineNum += 3;
markersToCheck.add(new MarkerToCheck("Too few parameters: 5 was expected instead of 3", lineNum, IMarker.SEVERITY_ERROR));
markersToCheck.add(new MarkerToCheck("float value was expected", ++lineNum, IMarker.SEVERITY_ERROR));
return markersToCheck;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment