Commit b27fa3cd authored by urbant's avatar urbant
Browse files

New tests covering changes in TTCN-3:2017

parent 01889deb
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
/***************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:5.4.1.1, verify that default value of value formal parameters cannot reference component variables
 ** @purpose  1:5.4.1.1, verify that incompatible value in default value assignment of value formal parameters causes error
 ** @verdict  pass reject
 ***************************************************/

// The following requirement is tested:
// Restriction e)
// The expression shall not refer to elements of the component type of the optional runs on clause.
// The expression of the formal parameters' default value had to be compatible with the type of the parameter.

module NegSem_05040101_parameters_of_kind_value_008 language "TTCN-3:2016" { 
module NegSem_05040101_parameters_of_kind_value_007 { 
	type component GeneralComp {
        var integer vc_int := 0;
	}	
    
    function f(in integer p_int := vc_int) runs on GeneralComp {
    function f(in integer p_int := 5.0) {
    }
    
	testcase TC_NegSem_05040101_parameters_of_kind_value_008() runs on GeneralComp {
	testcase TC_NegSem_05040101_parameters_of_kind_value_007() runs on GeneralComp {
        f();
        setverdict(pass);
	}

	control{
		execute(TC_NegSem_05040101_parameters_of_kind_value_008());
		execute(TC_NegSem_05040101_parameters_of_kind_value_007());
	}
}
+28 −0
Original line number Diff line number Diff line
/***************************************************
 ** @author   STF 548
 ** @version  0.0.2
 ** @purpose  1:5.4.1.1, verify that the default value of value formal parameters can reference component variables
 ** @verdict  pass accept, ttcn3verdict:pass
 ***************************************************/

// Background:
// Prior to the version TTCN-3:2017, the restriction 5.4.1.1.e didn't allow to refer to elements of the component type
// of the optional runs on clause in the default value expression.

module Sem_05040101_parameters_of_kind_value_023 { 
	type component GeneralComp {
        var integer vc_int := 0;
	}	
    
    function f(in integer p_int := vc_int) runs on GeneralComp {
    }
    
	testcase TC_Sem_05040101_parameters_of_kind_value_023() runs on GeneralComp {
        f();
        setverdict(pass);
	}

	control{
		execute(TC_Sem_05040101_parameters_of_kind_value_023());
	}
}
+32 −0
Original line number Diff line number Diff line
/***************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:5.4.1.1, verify that default value of value formal parameters cannot invoke functions with runs on clause
 ** @verdict  pass reject
 ** @author   STF 548
 ** @version  0.0.2
 ** @purpose  1:5.4.1.1, verify that default value of value formal parameters can invoke functions with runs on clause
 ** @verdict  pass accept, ttcn3verdict:pass
 ***************************************************/

// The following requirement is tested:
// Restriction e)
// The expression shall not contain the invocation of functions with a runs on clause.
// Background:
// Prior to the version TTCN-3:2017, the expression could not contain the invocation of functions with a runs on clause.

module NegSem_05040101_parameters_of_kind_value_010 { 
module Sem_05040101_parameters_of_kind_value_024 { 
	type component GeneralComp {
        var integer vc_int;
        var integer vc_int := 1;
	}
    
    function fx() runs on GeneralComp return integer {
@@ -22,12 +21,12 @@ module NegSem_05040101_parameters_of_kind_value_010 {
        log(p_int);
    }
    
	testcase TC_NegSem_05040101_parameters_of_kind_value_010() runs on GeneralComp {
	testcase TC_Sem_05040101_parameters_of_kind_value_024() runs on GeneralComp {
        f();
        setverdict(pass);
	}

	control{
		execute(TC_NegSem_05040101_parameters_of_kind_value_010());
		execute(TC_Sem_05040101_parameters_of_kind_value_024());
	}
}
+37 −0
Original line number Diff line number Diff line
/***************************************************
 ** @author   STF 548
 ** @version  0.0.1
 ** @purpose  1:5.4.1.1, verify that default values are evaluated in the scope of the parameterized entity
 ** @verdict  pass accept, ttcn3verdict:pass
 ***************************************************/

// The following requirement is tested:
// Restriction e
// The [default value] expression may be any expression that is well-defined at the beginning of the scope
// of the parameterized entity

module Sem_05040101_parameters_of_kind_value_025 { 
	type component GeneralComp {
        var integer vc_int := 1;
	}
       
    function f(in integer p_int := vc_int) runs on GeneralComp {
        log(p_int);
		if (p_int == vc_int) {
			setverdict(pass);
		} else { 
			setverdict(fail);
		}
    }
    
	testcase TC_Sem_05040101_parameters_of_kind_value_025() runs on GeneralComp system GeneralComp{
		var GeneralComp v_ptc := GeneralComp.create;
        vc_int := 100;
		v_ptc.start(f()); // p_int defaults to 1 (vc_int of v_ptc) and not to 100 (vc_int of self)
        v_ptc.done;
	}

	control{
		execute(TC_Sem_05040101_parameters_of_kind_value_025());
	}
}
+27 −0
Original line number Diff line number Diff line
/***************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:5.4.1.2, verify that default template instance of template formal parameters cannot reference component elements
 ** @verdict  pass reject
 ** @author   STF 548
 ** @version  0.0.2
 ** @purpose  1:5.4.1.2, verify that default template instance of template formal parameters can reference component elements
 ** @verdict  pass accept, ttcn3verdict:pass
 ***************************************************/

// The following requirement is tested:
// Restriction e)
// The template instance shall not refer to elements of the component type in a runs on clause.
// Background:
// Prior to the version TTCN-3:2017, the template instance could not refer to elements of the component type referenced in the runs on clause.

module NegSem_05040102_parameters_of_kind_template_008 language "TTCN-3:2016" { 
module Sem_05040102_parameters_of_kind_template_039 { 
	type component GeneralComp {
        var template integer vc_int := ?;
	}	
@@ -17,12 +16,12 @@ module NegSem_05040102_parameters_of_kind_template_008 language "TTCN-3:2016" {
    function f(in template integer p_int := vc_int) runs on GeneralComp {
    }
    
	testcase TC_NegSem_05040102_parameters_of_kind_template_008() runs on GeneralComp {
	testcase TC_Sem_05040102_parameters_of_kind_template_039() runs on GeneralComp {
        f();
        setverdict(pass);
	}

	control{
		execute(TC_NegSem_05040102_parameters_of_kind_template_008());
		execute(TC_Sem_05040102_parameters_of_kind_template_039());
	}
}
Loading