Commit b27fa3cd authored by urbant's avatar urbant
Browse files

New tests covering changes in TTCN-3:2017

parent 01889deb
/***************************************************
** @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());
}
}
/***************************************************
** @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());
}
}
/***************************************************
** @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());
}
}
/***************************************************
** @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());
}
}
/***************************************************
** @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());
}
}
/***************************************************
** @author STF 487
** @version 0.0.1
** @purpose 1:5.4.1.2, verify that default template instance of template formal parameters cannot invoke functions with runs on clause
** @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 invoke functions with runs on clause
** @verdict pass accept, ttcn3verdict:pass
***************************************************/
// The following requirement is tested:
// Restriction e)
// The template instance shall not contain the invocation of functions with a runs on clause.
// Background:
// Prior to the version TTCN-3:2017, the template instance could not contain invocation of functions with a runs on clause.
module NegSem_05040101_parameters_of_kind_value_010 {
module Sem_05040101_parameters_of_kind_value_040 {
type component GeneralComp {
var integer vc_int;
var integer vc_int := 1;
}
function fx() runs on GeneralComp return integer {
return vc_int + 1;
function fx() runs on GeneralComp return template integer {
return (vc_int..100);
}
function f(in template integer p_int := fx()) runs on GeneralComp {
log(p_int);
}
testcase TC_NegSem_05040101_parameters_of_kind_value_010() runs on GeneralComp {
testcase TC_Sem_05040101_parameters_of_kind_value_040() runs on GeneralComp {
f();
setverdict(pass);
}
control{
execute(TC_NegSem_05040101_parameters_of_kind_value_010());
execute(TC_Sem_05040101_parameters_of_kind_value_040());
}
}
/***************************************************
** @author STF 548
** @version 0.0.1
** @purpose 1:5.4.1.2, verify that default template instance of template formal parameters is resolved in the scope of the parameterized entity
** @verdict pass accept, ttcn3verdict:pass
***************************************************/
// The following requirement is tested:
// If a default template is used, it is evaluated in the scope of the parameterized entity, not the scope of the actual parameter list.
module Sem_05040102_parameters_of_kind_template_041 {
type component GeneralComp {
var template integer vc_int := ?;
}
function f(in template integer p_int := vc_int) runs on GeneralComp {
if (match(10, p_int)) {
setverdict(pass);
} else {
setverdict(fail);
}
}
testcase TC_Sem_05040102_parameters_of_kind_template_041() runs on GeneralComp system GeneralComp {
var GeneralComp v_ptc := GeneralComp.create;
vc_int := (1, 2, 3);
v_ptc.start(f()); // p_int default to ? (vc_int of v_ptc) and not to (1, 2, 3) (vc_int of self)
v_ptc.done;
setverdict(pass);
}
control{
execute(TC_Sem_05040102_parameters_of_kind_template_041());
}
}
/***************************************************
** @author STF 548
** @version 0.0.1
** @purpose 1:5.4.2, verify that parameter reuse is not allowed in the mixed notation
** @verdict pass reject
***************************************************/
// The following requirement is tested:
// Restriction o
// If the mixed notation is used, ... the parameters given in assignment notation shall not assign parameters
// that already have an actual parameter given in list notation.
module NegSem_050402_actual_parameters_183 {
type component GeneralComp {
}
function f_mixed (out integer p_par1, in integer p_par2 := 2, inout integer p_par3) {
p_par1 := 1 + p_par2;
if (p_par2 == 2 and p_par3 == 0) {
setverdict(pass);
} else {
setverdict(fail);
}
}
testcase TC_NegSem_050402_actual_parameters_183() runs on GeneralComp {
var integer v := 0;
f_mixed(-, 5, p_par3 := v, p_par2 := 2);
setverdict(pass);
}
control {
execute(TC_NegSem_050402_actual_parameters_183());
}
}
/***************************************************
** @author STF 548
** @version 0.0.1
** @purpose 1:5.4.2, verify that in mixed notation, no value list notation can be used following the first assignment notation
** @verdict pass reject
***************************************************/
// The following requirement is tested:
// Restriction o
// If the mixed notation is used, no value list notation shall be used following the first assignment notation
module NegSyn_050402_actual_parameters_001 {
type component GeneralComp {
}
function f_mixed (out integer p_par1, in integer p_par2 := 2, inout integer p_par3) {
p_par1 := 1 + p_par2;
if (p_par2 == 2 and p_par3 == 0) {
setverdict(pass);
} else {
setverdict(fail);
}
}
testcase TC_NegSyn_050402_actual_parameters_001() runs on GeneralComp {
var integer v := 0;
f_mixed(-,p_par2 := 2, v);
setverdict(pass);
}
control {
execute(TC_NegSyn_050402_actual_parameters_001());
}
}
/***************************************************
** @author STF 548
** @version 0.0.1
** @purpose 1:5.4.2, verify that mixed notation can be used
** @verdict pass accept, ttcn3verdict:pass
***************************************************/
// The following requirement is tested:
// Actual parameters can be provided ... in a mixed notation where the first parameters are given in list notation
// and additional parameters in assignment notation.
// The test is based on modified example 11
module Sem_050402_actual_parameters_227 {
type component GeneralComp {
}
function f_mixed (out integer p_par1, in integer p_par2 := 2, inout integer p_par3) {
p_par1 := 1 + p_par2;
if (p_par2 == 2 and p_par3 == 0) {
setverdict(pass);
} else {
setverdict(fail);
}
}
testcase TC_Sem_050402_actual_parameters_227() runs on GeneralComp {
var integer v := 0;
// the following statements all have the same semantics:
f_mixed(-,2,v);
f_mixed(-,p_par2 := 2, p_par3 := v);
f_mixed(-,-,p_par3 := v);
f_mixed(-,p_par3 := v, p_par2 := 2);
setverdict(pass);
}
control {
execute(TC_Sem_050402_actual_parameters_227());
}
}
/*****************************************************************
** @author STF 409
** @version 0.0.1
** @purpose 1:15.9, Ensure that the match operation works correctly if the types are incompatible.
** @verdict pass accept, ttcn3verdict:pass
*****************************************************************/
module Sem_1509_MatchOperation_005 {
type component GeneralComp { }
type record MyRecord {
charstring field1,
boolean field2
}
template MyRecord m_receiveTemplate := {
field1 := "ab*de",
field2 := ?
}
testcase TC_Sem_1509_MatchOperation_005() runs on GeneralComp {
var integer v_value := 20;
if (match(v_value, m_receiveTemplate)) {
setverdict(fail);
} else {
setverdict(pass);
}
}
control{
execute(TC_Sem_1509_MatchOperation_005());
}
}
\ No newline at end of file
/*****************************************************************
** @author STF 470
** @version 0.0.1
** @purpose 1:15.9, Ensure that the match operation works correctly if the set types are incompatible.
** @verdict pass accept, ttcn3verdict:pass
*****************************************************************/
module Sem_1509_MatchOperation_009 language "TTCN-3:2016"{
type component GeneralComp { }
type set MySet {
charstring field1,
boolean field2
}
template MySet mw_receiveTemplate := {
field1 := "ab*de",
field2 := ?
}
testcase TC_Sem_1509_MatchOperation_009() runs on GeneralComp {
var integer v_value := 20;
if (match(v_value, mw_receiveTemplate)) {
setverdict(fail);
} else {
setverdict(pass);
}
}
control{
execute(TC_Sem_1509_MatchOperation_009());
}
}
\ No newline at end of file
/***************************************************
** @author STF 548
** @version 0.0.1
** @purpose 1:16.1.2, Verify that the encvalue function supports the dynamic_encoding parameter
** @verdict pass accept, noexecution
***************************************************/
// The following requirements are tested:
// The optional dynamic_encoding parameter is used for dynamic selection of encode
// attribute of the inpar value for this single encvalue call. The rules for dynamic
// selection of the encode attribute are described in clause 27.9.
// NOTE: the test is not executed as it would require dedicated codec support
module Sem_160102_predefined_functions_101 {
type component GeneralComp {
}
type integer I with {
encode "Codec 1";
encode "Codec 2"
};
testcase TC_Sem_160102_predefined_functions_101 () runs on GeneralComp {
var template I v_test := 0;
var bitstring v_res := encvalue(v_test, -, "Codec 1");
setverdict(pass);
}
//control{
// execute(TC_Sem_160102_predefined_functions_101());
//}
}
\ No newline at end of file
/***************************************************
** @author STF 548
** @version 0.0.1
** @purpose 1:16.1.2, Verify that the dynamic_encoding parameter of the encvalue function can be explicitly skipped
** @verdict pass accept, noexecution
***************************************************/
// The following requirements are tested:
// The optional dynamic_encoding parameter is used for dynamic selection of encode
// attribute of the inpar value for this single encvalue call. The rules for dynamic
// selection of the encode attribute are described in clause 27.9.
module Sem_160102_predefined_functions_102 {
type component GeneralComp {
}
type integer I with { variant "32 bit"};
testcase TC_Sem_160102_predefined_functions_102 () runs on GeneralComp {
var template I v_test := 0;
var bitstring v_res := encvalue(v_test, "encoding_info_text", -);
if (lengthof(v_res) == 32) {
setverdict(pass,v_res);
} else {
setverdict(fail, "Invalid encoding length");
}
}
control{
execute(TC_Sem_160102_predefined_functions_102());
}
}
\ No newline at end of file
/***************************************************
** @author STF 548
** @version 0.0.1
** @purpose 1:16.1.2, Verify that the decvalue function supports the dynamic_encoding parameter
** @verdict pass accept, noexecution
***************************************************/
// The following requirements are tested:
// The optional dynamic_encoding parameter is used for dynamic selection of encode