Commit 57ae422a authored by urbant's avatar urbant
Browse files

Missing test cases for requirements specified in clause 5.4 (including several...

Missing test cases for requirements specified in clause 5.4 (including several test for requirements introduced in the version 4.7.1)
parent b1af2d17
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
The following requirements are present in 5.4.1.1 and 5.4.1.2 too and they are tested as a part of these clauses:

Formal parameters of parameterized templates, functions, altsteps, and testcases are defined in formal parameter lists. Formal parameters shall be in, inout or out parameters (see definitions in clause 3.1).

If not stated otherwise, a formal parameter is an in parameter.

Formal in parameters may have default values. This default value is used when no actual parameter is provided.
 No newline at end of file
+40 −0
Original line number Diff line number Diff line
/***************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:5.4.1, verify that error is generated for incompatible actual value of in parameter
 ** @verdict  pass reject
 ***************************************************/

// The following requirement is tested:
// If parameters are passed by value (i.e. in case of in and out parameters), type compatibility 
// rules specified in 6.3 apply.

module NegSem_050401_top_level_001 { 

	type component GeneralComp {
	}
    
    type record R1 {
        integer field1,
        integer field2
    }
    
    type record R2 {
        integer option1,
        integer option2 optional
    }
	
	function f(R2 p_rec) {
        if (p_rec.option1 == 1 and p_rec.option2 == 2) { setverdict(pass); } // reading from p_int
        else { setverdict(fail); }
	}
	
	testcase TC_NegSem_050401_top_level_001() runs on GeneralComp {
        var R1 v_rec := { field1 := 1, field2 := 2 };
		f(v_rec);
	}

	control{
		execute(TC_Sem_050401_top_level_001());
	}
}
+42 −0
Original line number Diff line number Diff line
/***************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:5.4.1, verify that error is generated for incompatible actual value of out parameter
 ** @verdict  pass reject
 ***************************************************/

// The following requirement is tested:
// If parameters are passed by value (i.e. in case of in and out parameters), type compatibility 
// rules specified in 6.3 apply.

module NegSem_050401_top_level_002 { 

	type component GeneralComp {
	}
    
    type record R1 {
        integer field1,
        integer field2
    }
    
    type record R2 {
        integer option1,
        integer option2 optional
    }
	
	function f(out R2 p_rec) {
        p_rec.option1 := 1;
        p_rec.option2 := 2; 
	}
	
	testcase TC_Sem_050401_top_level_002() runs on GeneralComp {
        var R1 v_rec;
		f(v_rec);
        if (v_rec.field1 == 1 and v_rec.field2 == 2) { setverdict(pass); } // reading from p_int
        else { setverdict(fail); }
	}

	control{
		execute(TC_Sem_050401_top_level_002());
	}
}
+40 −0
Original line number Diff line number Diff line
/***************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:5.4.1, verify that error is generated if actual inout parameter doesn't adhere to strong typing rules
 ** @verdict  pass accept, ttcn3verdict:pass
 ***************************************************/

// The following requirement is tested:
// When parameters are passed by reference, strong typing is required. Both the actual and formal 
// parameter shall be of the same type.

module NegSem_050401_top_level_003 { 

	type component GeneralComp {
	}
    
    type record R1 {
        integer field1,
        integer field2
    }
    
    type record R2 {
        integer option1,
        integer option2
    }
	
	function f(inout R2 p_rec) {
        if (p_rec.option1 == 1 and p_rec.option2 == 2) { setverdict(pass); }
        else { setverdict(fail); }
	}
	
	testcase TC_NegSem_050401_top_level_003() runs on GeneralComp {
        var R1 v_rec := { field1 := 1, field2 := 2 };
		f(v_rec); // R1 and R2 are compatible types, but not the same. Strong typing requires exactly the same types.
	}

	control{
		execute(TC_NegSem_050401_top_level_003());
	}
}
+29 −0
Original line number Diff line number Diff line
/***************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:5.4.1, verify that in parameters can be read within parametrized content
 ** @verdict  pass accept, ttcn3verdict:pass
 ***************************************************/

// The following requirement is tested:
// For all these three sorts of parameter passing, the formal parameters can both be read and set 
// (i.e. get new values being assigned) within the parametrized object.

module Sem_050401_top_level_001 { 

	type component GeneralComp {
	}	
	
	function f(in integer p_int) {
        if (p_int == 0) { setverdict(pass); } // reading from p_int
        else { setverdict(fail); }
	}
	
	testcase TC_Sem_050401_top_level_001() runs on GeneralComp {
		f(0);
	}

	control{
		execute(TC_Sem_050401_top_level_001());
	}
}
Loading