Unverified Commit 8b6b3f58 authored by Elemer Lelik's avatar Elemer Lelik Committed by GitHub
Browse files

Merge pull request #119 from eadrkir/master

 Added new tests from etsi and updated SoC document
parents d2f16dfb 43a3324d
......@@ -746,6 +746,287 @@ error: Right operand of operation `&' should be a string, `record of' or `set of
:h2. 08_modules folder
.*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
:h3. NegSem_080201_ModuleParameters_001 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - 080201_001 Ensure that a port, default or component types cannot be module parameters. >
<COMPILE>
<MODULE TTCN NegSem_080201_ModuleParameters_001 NegSem_080201_ModuleParameters_001.ttcn >
/*****************************************************************
** @version 0.0.1
** @purpose 1:8.2.1, Ensure that a port, default or component types cannot be module parameters.
** @verdict pass reject
*****************************************************************/
// The following requirements are tested:
/* Restriction B: Module parameters shall not be of port type,
* default type or component type and shall not be of a structured type that contains a sub-element of
* port type at any level of nesting.*/
module NegSem_080201_ModuleParameters_001 {
type port MyMessagePortType message {
inout integer
} with {extension "internal"}
modulepar MyMessagePortType MY_PORT; // not allowed
type component GeneralComp {
}
testcase TC_NegSem_080201_ModuleParameters_001() runs on GeneralComp {
if (MY_PORT.checkstate("Started")) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control{
execute(TC_NegSem_080201_ModuleParameters_001());
}
}
<END_MODULE>
<RESULT COUNT 1>
error: Type of module parameter cannot be or embed port type `@NegSem_080201_ModuleParameters_001.MyMessagePortType'
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_080201_ModuleParameters_004 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - 080201_004 Ensure that module parameters remain constant. >
<COMPILE>
<MODULE TTCN NegSem_080201_ModuleParameters_004 NegSem_080201_ModuleParameters_004.ttcn >
/*****************************************************************
** @version 0.0.1
** @purpose 1:8.2.1, Ensure that module parameters remain constant.
** @verdict pass reject
*****************************************************************/
// The following requirements are tested:
/* Restriction B: Module parameters shall not be of port type,
* default type or component type and shall not be of a structured type that contains a sub-element of
* port type at any level of nesting.*/
module NegSem_080201_ModuleParameters_004 {
modulepar integer MY_INT := 2;
type component GeneralComp {
}
testcase TC_NegSem_080201_ModuleParameters_004() runs on GeneralComp {
MY_INT := 3; // not allowed to change module parameter
if (MY_INT == 2) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control{
execute(TC_NegSem_080201_ModuleParameters_004());
}
}
<END_MODULE>
<RESULT COUNT 1>
error: Reference to a variable or template variable was expected instead of module parameter `@NegSem_080201_ModuleParameters_004.MY_INT'
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_080201_ModuleParameters_005 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - 080201_005 Ensure that a reference to plain module parameter with a default value delivers the default value unless it is overwritten. >
<COMPILE>
<MODULE TTCN NegSem_080201_ModuleParameters_005 NegSem_080201_ModuleParameters_005.ttcn >
/*****************************************************************
** @version 0.0.1
** @purpose 1:8.2.1, Ensure that a reference to plain module parameter with a default value delivers the default value unless it is overwritten.
** @verdict pass reject
*****************************************************************/
// A module parameter shall only be of type address if the address type is explicitly defined within the associated module
module NegSem_080201_ModuleParameters_005 {
modulepar address MY_ADDRESS_MODULE_PARAMETER := 2; // error: address type not defined
type component GeneralComp {
}
testcase TC_NegSem_080201_ModuleParameters_005() runs on GeneralComp {
if (MY_ADDRESS_MODULE_PARAMETER == 2) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control{
execute(TC_NegSem_080201_ModuleParameters_005());
}
}
<END_MODULE>
<RESULT COUNT 1>
error: Type `address' is not defined in this module
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_080201_ModuleParameters_006 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - 080201_006 Ensure that a module parameter is not allowed to be used in arrays >
<COMPILE>
<MODULE TTCN NegSem_080201_ModuleParameters_006 NegSem_080201_ModuleParameters_006.ttcn >
/*****************************************************************
** @version 0.0.1
** @purpose 1:8.2.1, Ensure that a module parameter is not allowed to be used in arrays
** @verdict pass reject
*****************************************************************/
//Module parameters shall not be used in type or array definitions.
module NegSem_080201_ModuleParameters_006 {
modulepar integer MY_INT_MODULE_PARAMETER := 2;
type component GeneralComp {
}
type integer MyArrayType[MY_INT_MODULE_PARAMETER];
// error: Module parameters shall not be used in type or array definitions.
testcase TC_NegSem_080201_ModuleParameters_006() runs on GeneralComp {
var MyArrayType v_arr := {2,3};
if (v_arr[0] == 2) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control{
execute(TC_NegSem_080201_ModuleParameters_006());
}
}
<END_MODULE>
<RESULT COUNT 1>
error: Reference to an \(evaluable\) constant value was expected instead of module parameter `@NegSem_080201_ModuleParameters_006.MY_INT_MODULE_PARAMETER'
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSyn_080201_ModuleParameters_001 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - 080201_001 Ensure that module parameter can be declared within the module definition part only. >
<COMPILE>
<MODULE TTCN NegSyn_080201_ModuleParameters_001 NegSyn_080201_ModuleParameters_001.ttcn >
/*****************************************************************
** @version 0.0.1
** @purpose 1:8.2.1, Ensure that module parameter can be declared within the module definition part only.
** @verdict pass reject, noexecution
*****************************************************************/
module NegSyn_080201_ModuleParameters_001 {
type component GeneralComp {
}
testcase TC_NegSyn_080201_ModuleParameters_001() runs on GeneralComp {
modulepar integer MY_MODULE_PAR := 1; // not allowed to declared here
setverdict(fail);
}
control {
execute(TC_NegSyn_080201_ModuleParameters_001());
}
}
<END_MODULE>
<RESULT COUNT 1>
error: at or before token `modulepar': syntax error, unexpected ModuleParKeyword
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSyn_080201_ModuleParameters_002 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - 080201_002 Ensure that module parameter can be declared within the module definition part only. >
<COMPILE>
<MODULE TTCN NegSyn_080201_ModuleParameters_002 NegSyn_080201_ModuleParameters_002.ttcn >
/*****************************************************************
** @version 0.0.1
** @purpose 1:8.2.1, Ensure that module parameter can be declared within the module definition part only.
** @verdict pass reject, noexecution
*****************************************************************/
module NegSyn_080201_ModuleParameters_002 {
modulepar integer MY_MODULE_PAR := 1;
modulepar integer MY_MODULE_PAR := 2; //error: not allowed to redeclare
type component GeneralComp {
}
testcase TC_NegSyn_080201_ModuleParameters_002() runs on GeneralComp {
setverdict(fail);
}
control {
execute(TC_NegSyn_080201_ModuleParameters_002());
}
}
<END_MODULE>
<RESULT COUNT 1>
error: Duplicate definition with name `MY_MODULE_PAR'
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_08020301_GeneralFormatOfImport_002 negative test
.*---------------------------------------------------------------------*
......@@ -2274,6 +2555,49 @@ error: any value is not allowed in this context
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_1101_ValueVars_005 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - 1101_005 Variables should be assigned only by initialized variables >
<COMPILE>
<EXECUTE_PARALLEL>
<MODULE TTCN NegSem_1101_ValueVars_005 NegSem_1101_ValueVars_005.ttcn >
/***************************************************
** @version 0.0.1
** @purpose 1:11.1, Variables should be assigned only by initialized variables
** @verdict pass reject
***************************************************/
// The expression shall evaluate to a value, which is at least partially initialized.
module NegSem_1101_ValueVars_005 {
type component GeneralComp {}
testcase TC_NegSem_1101_ValueVars_005() runs on GeneralComp {
var integer v_i;
var integer v_j := v_i + 2; // error: v_i is uninitialized
setverdict(pass);
}
control {
execute(TC_NegSem_1101_ValueVars_005());
}
}
<END_MODULE>
<RESULT COUNT 1>
Dynamic test case error: Unbound left operand of integer addition.
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSyn_1101_ValueVars_001 negative test
.*---------------------------------------------------------------------*
......@@ -2367,6 +2691,49 @@ error: at or before token `var': syntax error, unexpected VarKeyword
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSyn_1102_TemplateVars_002 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - 1102_002 Template variables should be assigned with unitialized variables >
<COMPILE>
<MODULE TTCN NegSyn_1102_TemplateVars_002 NegSyn_1102_TemplateVars_002.ttcn >
/***************************************************
** @version 0.0.1
** @purpose 1:11.2, Template variables should be assigned with unitialized variables
** @verdict pass reject
***************************************************/
/* The following requirements are tested:
Restriction l) The template body at the right-hand side of the assignment symbol shall evaluate to a value or template, which is type compatible with the variable being declared.
*/
module NegSyn_1102_TemplateVars_002 {
type component GeneralComp {}
testcase TC_NegSyn_1102_TemplateVars_002() runs on GeneralComp {
var integer v_i1 := 1;
var template float v_i2 := v_i1; // error: v_i1 is integer, meanwhile template type is float
setverdict(pass);
}
control {
execute(TC_NegSyn_1102_TemplateVars_002());
}
}
<END_MODULE>
<RESULT COUNT 1>
error: Type mismatch: a value or template of type `float' was expected instead of `integer'
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h2. 12_timers folder
.*---------------------------------------------------------------------*
......
......@@ -282,6 +282,34 @@ error
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. Syn_0801_DefinitionOfAModule_010 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - 0801_010 Ensure that a module definition with ed4.8.1 language and package is accepted. >
<COMPILE>
<MODULE TTCN Syn_0801_DefinitionOfAModule_010 Syn_0801_DefinitionOfAModule_010.ttcn >
/*****************************************************************
** @version 0.0.1
** @purpose 1:8.1, Ensure that a module definition with ed4.8.1 language and package is accepted.
** @verdict pass accept, noexecution
*****************************************************************/
module Syn_0801_DefinitionOfAModule_010 language "TTCN-3:2016" {
}
<END_MODULE>
<RESULT IF_PASS NEGATIVE>
error
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. Syn_0803_ModuleControlPart_003 negative test
.*---------------------------------------------------------------------*
......
......@@ -56,6 +56,47 @@ This TD contains negative tests from ETSI TTCN3 Conformance Test's 15_templates
:h1.REQUIREMENT-BASED TESTS
.*---------------------------------------------------------------------*
.*---------------------------------------------------------------------*
:h2. 15_top_level folder
.*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
:h3. NegSyn_15_TopLevel_001 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - 15_001 Ensure that the expression or template body initializing a template shall evaluate to a value or template, which is type compatible with the template being declared. >
<COMPILE>
<MODULE TTCN NegSyn_15_TopLevel_001 NegSyn_15_TopLevel_001.ttcn >
/*****************************************************************
** @version 0.0.1
** @purpose 1:15, Ensure that the expression or template body initializing a template shall evaluate to a value or template, which is type compatible with the template being declared.
** @verdict pass reject, noexecution
*****************************************************************/
// The following requirement is tested:
//Restriction C: the expression or template body initializing a template shall evaluate to a value or template, which is type compatible with the template being declared.
module NegSyn_15_TopLevel_001 {
type record MyRecord {
integer myInt
}
template MyRecord mw_myRecord := {
myInt := 2.1 // error: incompatible type (int req., float is given)
}
}
<END_MODULE>
<RESULT COUNT 1>
error: integer value was expected
<END_RESULT>
<END_TC>
:exmp
.*---------------------------------------------------------------------*
:h2. 1503_global_and_local_templates folder
.*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
......@@ -3589,7 +3630,7 @@ error: Formal parameter with template restriction `present' not allowed here
<MODULE TTCN NegSem_1508_TemplateRestrictions_043 NegSem_1508_TemplateRestrictions_043.ttcn >
/******************************************************************************
** @version 0.0.1
** @purpose 1:15.8, Ensure that template(present) can be parameter to template(omit)
** @purpose 1:15.8, Ensure that template cannot be parameter to template(omit)
** @verdict pass reject
*****************************************************************/
......@@ -4202,6 +4243,55 @@ error: Reference to a value was expected instead of template `@NegSem_1509_Match
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_1509_MatchOperation_003 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - 1509_003 Ensure that the match operation works correctly with enums. >
<COMPILE>
<MODULE TTCN NegSem_1509_MatchOperation_003 NegSem_1509_MatchOperation_003.ttcn >
/*****************************************************************
** @version 0.0.1
** @purpose 1:15.9, Ensure that the match operation works correctly with enums.
** @verdict pass reject
*****************************************************************/
module NegSem_1509_MatchOperation_003 {
type component GeneralComp { }
type enumerated A_enum { A, B, C, D, E };
type enumerated B_enum { A, F, G };
testcase TC_NegSem_1509_MatchOperation_003() runs on GeneralComp {
var A_enum v_value := A;
if (match(v_value, B_enum:G)) { // error: different enum type
setverdict(pass);
} else {
setverdict(fail);
}
}
control{
execute(TC_NegSem_1509_MatchOperation_003());
}
}
<END_MODULE>
<RESULT COUNT 1>
error: Type mismatch: a value of type `@NegSem_1509_MatchOperation_003.B_enum' was expected instead of `@NegSem_1509_MatchOperation_003.A_enum'
<END_RESULT>
<END_TC>
:exmp
.*---------------------------------------------------------------------*
:h2. 1510_valueof_operation folder
.*---------------------------------------------------------------------*
......
......@@ -2802,6 +2802,68 @@ error: The 'intOption' is already present in the 1. branch of select union
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_190302_select_union_statement_006 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - 190302_006 verify that it is possible to use a select union statement with several branches >
<COMPILE>
<MODULE TTCN NegSem_190302_select_union_statement_006 NegSem_190302_select_union_statement_006.ttcn >
/******************************************************************************
** @version 0.0.1
** @purpose 1:19.3.2, verify that it is possible to use a select union statement with several branches
** @verdict pass accept, ttcn3verdict:pass
***************************************************/
// The following requirement is tested:
// c) No two cases in a select union statement shall have the same caseIdentifier or TypeIdentifier.
module NegSem_190302_select_union_statement_006 {
type component GeneralComp {
}
testcase TC_NegSem_190302_select_union_statement_006() runs on GeneralComp {
var anytype v_any;
v_any.integer := 2;
v_any.charstring := "abc";
v_any.float := 1.2;
select union (v_any) {
case (charstring) {
if(match(v_any.charstring,"abc"))
{setverdict(pass, v_any.charstring);}
} case (integer) {
if(match(v_any.integer,2))
{setverdict(pass, v_any.integer);}
} case (charstring) { // error
if(match(v_any.charstring,"abc"))
{setverdict(fail, v_any.charstring);}
}
case else {
setverdict(fail);
}
}
}
control {
execute(TC_NegSem_190302_select_union_statement_006());
}
}
with {
extension "anytype integer, charstring, float"
}
<END_MODULE>
<RESULT COUNT 1>
error: The 'charstring' is already present in the 1. branch of select union
<END_RESULT>