// @author TTF T023
// @purpose 1:6.2.1.4, Ensure embedded fields cannot be used as field names for assignment notations.
// @verdict pass reject
module NegSem_06020104_embedding_fields_002 {
type component GeneralComp {}
type record A {
B
}
type record B {
integer b
}
const A OK := { B := { b := 1 } }
const A notOK := { b := 1 }
control {
execute(TC_NegSem_06020104_embedding_fields_002());
}
}
// @author TTF T023
// @purpose 1:6.2.1.4, Ensure the unqualified type name acts as the field name.
// @verdict pass accept
module Sem_06020104_embedding_fields_001 {
type component GeneralComp {}
type record R {
integer,
R optional,
Sem_06020104_embedding_fields_001.GeneralComp
}
testcase TC_Sem_06020104_embedding_fields_001() runs on GeneralComp {
var R r := {
integer := 23,
R := {}
}
r.GeneralComp := GeneralComp.create
setverdict(pass)
}
control {
execute(TC_Sem_06020104_embedding_fields_001());
}
}
// @author TTF T023
// @purpose 1:6.2.1.4, Ensure embedded field is promoted when its name is unique.
// @verdict pass accept, ttcn3verdict:pass
module Sem_06020104_embedding_fields_002 {
type component GeneralComp {}
type record A {
B
}
type record B {
integer b;
}
testcase TC_Sem_06020104_embedding_fields_002() runs on GeneralComp {
var A a;
a.b := 1;
a.B.b := 2;
if (a.b == a.B.b) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_Sem_06020104_embedding_fields_002());
}
}
// @author TTF T023
// @purpose 1:6.2.1.4, Ensure embedded field is promoted when its name is unique.
// @verdict pass accept, ttcn3verdict:pass
module Sem_06020104_embedding_fields_003 {
type component GeneralComp {}
type record A {
B
}
type record B {
C
}
type record C {
integer c
}
testcase TC_Sem_06020104_embedding_fields_003() runs on GeneralComp {
var A a;
a.c := 1;
a.B.C.c := 2;
if (a.c == a.B.C.c) {
setverdict(pass);
} else {
setverdict(fail, "field c not promoted");
}
}
control {
execute(TC_Sem_06020104_embedding_fields_003());
}
}
// @author TTF T023
// @purpose 1:6.2.1.4, Ensure embedded field is not promoted when its name is not unique.
// @verdict pass accept, ttcn3verdict:pass
module Sem_06020104_embedding_fields_004 {
type component GeneralComp {}
type record A {
B
}
type record B {
C,
integer x
}
type record C {
integer x
}
testcase TC_Sem_06020104_embedding_fields_004() runs on GeneralComp {
var A a;
a.x := 1;
a.B.x := 2;
a.B.C.x := 3;
if (a.x == a.B.x and a.B.x != a.B.C.x) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_Sem_06020104_embedding_fields_004());
}
}
// @author TTF T023
// @purpose 1:6.2.2.4, Ensure set defintion allow embedded fields
// @verdict pass accept
module Sem_06020204_embedding_fields_001 {
type set S {
integer
}
}
// @author TTF T023
// @purpose 1:6.2.5.4, Ensure union defintions allow embedded fields and handle promotion correctly.
// @verdict pass accept, ttcn3verdict:pass
module Sem_06020504_embedding_fields_001 {
type component GeneralComp {}
type union Anytype {
integer,
boolean,
R
}
type record R {
integer,
verdicttype
}
testcase TC_Sem_06020504_embedding_fields_001() runs on GeneralComp {
var Anytype a := { boolean := false };
a.verdicttype := pass; // Equivalent to a.R.verdicttype := pass;
if (ischosen(a.R)) {
setverdict(pass)
} else {
setverdict(fail, "a.R is not chosen")
}
a.integer := 1; // Not equivalent to a.R.integer := 1;
if (ischosen(a.integer)) {
setverdict(pass)
} else {
setverdict(fail, "a.integer is not chosen")
}
}
control {
execute(TC_Sem_06020504_embedding_fields_001());
}
}
/***************************************************
** @author TTF T023
** @version 0.0.1
** @purpose 1:6.2.15.2, map template with a wildcard
** @verdict pass accept, ttcn3verdict:pass
***************************************************/
// The following requirement is tested:
// Templates of the map type can use a specific form of the mixed notation, where the first
// item is and asterisk representing the AnyElementsOrNone matching symbol, followed by one
// or more indexed assignments.
module Sem_06021502_indexed_assignment_notation_004 {
type map from charstring to charstring TMap;
type component C {}
testcase TC_Sem_06021502_indexed_assignment_notation_004() runs on C {
var template TMap v_map := { *,
["first_name"] := "John",
["surname"] := "Doe"
}
log(v_map);
setverdict(pass);
}
control {
execute(TC_Sem_06021502_indexed_assignment_notation_004());
}
}
/***************************************************
** @author TTF T023
** @version 0.0.1
** @purpose 1:6.2.15.3, unmapping AnyElementsOrNone from a map
** @verdict pass accept, ttcn3verdict:pass
***************************************************/
// The following requirement is tested:
// The unmap statement may be also used to remove the AnyElementsOrNone matching symbol from
// a map template variable. In this case, the second parameter of the statement shall be
// an asterisk literal.
module Sem_06021503_unmapping_keys_003 {
type map from charstring to charstring TMap;
type component C {}
testcase TC_Sem_06021503_unmapping_keys_003() runs on C {
var template TMap v_map := { *,
["first_name"] := "John",
["surname"] := "Doe"
}
var TMap v_val := {
["first_name"] := "John",
["surname"] := "Doe",
["city"] := "New York"
}
unmap(v_map, *);
if (not match(v_val, v_map)) { // shall not match as the city field is missing from the template and the AnyElementsOrNone symbol has been removed
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_Sem_06021503_unmapping_keys_003());
}
}
/***************************************************
** @author TTF T023
** @version 0.0.1
** @purpose 1:6.2.15.3, ignored unmapping AnyElementsOrNone from a map
** @verdict pass accept, ttcn3verdict:pass
***************************************************/
// The following requirement is tested:
// The unmap statement may be also used to remove the AnyElementsOrNone matching symbol from
// a map template variable. In this case, the second parameter of the statement shall be
// an asterisk literal. If the template variable does not contain the AnyElementsOrNone
// matching symbol, the operation has no effect.
module Sem_06021503_unmapping_keys_004 {
type map from charstring to charstring TMap;
type component C {}
testcase TC_Sem_06021503_unmapping_keys_004() runs on C {
var template TMap v_map := {
["first_name"] := ?,
["surname"] := "Doe"
}
var TMap v_val := {
["first_name"] := "John",
["surname"] := "Doe"
}
unmap(v_map, *); // ignored as the referenced template doesn't contain AnyElementsOrNone
if (match(v_val, v_map)) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_Sem_06021503_unmapping_keys_004());
}
}
/***************************************************
** @author TTF T023
** @version 0.0.1
** @purpose 1:6.2.15.4, Using asterisk as an index: RHS not a boolean value
** @verdict pass reject
***************************************************/
// The following requirement is tested:
// When the asterisk symbol is used at the left hand side of an assignment, only the presence
// of the AnyElementsOrNone within the template is changed, values and keys remain unchanged.
// The right-hand side of the assignment shall resolve into a boolean value in this case.
module NegSem_06021504_index_notation_007 {
type map from charstring to charstring TMap;
type component C {}
testcase TC_NegSem_06021504_index_notation_007() runs on C {
var template TMap v_map := {
["first_name"] := "John",
["surname"] := "Doe"
}
var TMap v_val := {
["first_name"] := "John",
["surname"] := "Doe"
}
v_map[*] := "test"; // type mismatch expected
if (match(v_val, v_map)) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_06021504_index_notation_007());
}
}
\ No newline at end of file
/***************************************************
** @author TTF T023
** @version 0.0.1
** @purpose 1:6.2.15.4, Using asterisk as an index on RHS (typing issue)
** @verdict pass reject
***************************************************/
// The following requirement is tested:
// The index notation, when used on the right-hand side, refers to the value element that the
// map value or template associates with the key given as the index or with the presence of
// the AnyElementsOrNone matching symbol if asterisk is used instead of the index.
// When used at the right-hand side of an assignment, the notation returns a boolean value
// indicating if the AnyElementsOrNone is present within the map template.
module NegSem_06021504_index_notation_008 {
type map from charstring to charstring TMap;
type component C {}
testcase TC_NegSem_06021504_index_notation_008() runs on C {
var template TMap v_map := {
["first_name"] := "John",
["surname"] := "Doe"
}
var charstring v_str := v_map[*]; // type mismatch expected, the RHS resolves to a boolean value
log (v_str);
setverdict(pass);
}
control {
execute(TC_NegSem_06021504_index_notation_008());
}
}
\ No newline at end of file
/***************************************************
** @author TTF T023
** @version 0.0.1
** @purpose 1:6.2.15.4, Using asterisk as an index on LHS
** @verdict pass accept, ttcn3verdict:pass
***************************************************/
// The following requirement is tested:
// When the asterisk symbol is used at the left hand side of an assignment, only the presence
// of the AnyElementsOrNone within the template is changed, values and keys remain unchanged.
// The right-hand side of the assignment shall resolve into a boolean value in this case.
module Sem_06021504_index_notation_007 {
type map from charstring to charstring TMap;
type component C {}
testcase TC_Sem_06021504_index_notation_007() runs on C {
var template TMap v_map := {
["first_name"] := "John",
["surname"] := "Doe"
}
var TMap v_val := {
["first_name"] := "John",
["surname"] := "Doe",
["city"] := "New York"
}
v_map[*] := true; // adding the AnyElementsOrNone field
if (match(v_val, v_map)) { // shall match as AnyElementsOrNone is active and matches the city field
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_Sem_06021504_index_notation_007());
}
}
\ No newline at end of file
/***************************************************
** @author TTF T023
** @version 0.0.1
** @purpose 1:6.2.15.4, Using asterisk as an index on RHS
** @verdict pass accept, ttcn3verdict:pass
***************************************************/
// The following requirement is tested:
// The index notation, when used on the right-hand side, refers to the value element that the
// map value or template associates with the key given as the index or with the presence of
// the AnyElementsOrNone matching symbol if asterisk is used instead of the index.
// When used at the right-hand side of an assignment, the notation returns a boolean value
// indicating if the AnyElementsOrNone is present within the map template.
module Sem_06021504_index_notation_008 {
type map from charstring to charstring TMap;
type component C {}
testcase TC_Sem_06021504_index_notation_008() runs on C {
var template TMap v_map := {
["first_name"] := "John",
["surname"] := "Doe"
}
if (not v_map[*]) { // AnyElementsOrNone isn't present
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_Sem_06021504_index_notation_008());
}
}
\ No newline at end of file
/***************************************************
** @author TTF T023
** @version 0.0.1
** @purpose 1:6.2.15.4, Using asterisk as an index in isbound
** @verdict pass accept, ttcn3verdict:pass
***************************************************/
// The following requirement is tested:
// Presence of the AnyElementsOrNone in a map template can be checked by using the isbound
// or ispresent operation with an index notation containing the asterisk symbol as its
// argument.
module Sem_06021504_index_notation_009 {
type map from charstring to charstring TMap;
type component C {}
testcase TC_Sem_06021504_index_notation_009() runs on C {
var template TMap v_map := {
*,
["first_name"] := "John",
["surname"] := "Doe"
}
if (isbound(v_map[*])) { // AnyElementsOrNone is present
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_Sem_06021504_index_notation_009());
}
}
\ No newline at end of file
/***************************************************
** @author TTF T023
** @version 0.0.1
** @purpose 1:6.2.15.4, Using asterisk as an index in ispresent
** @verdict pass accept, ttcn3verdict:pass
***************************************************/
// The following requirement is tested:
// Presence of the AnyElementsOrNone in a map template can be checked by using the isbound
// or ispresent operation with an index notation containing the asterisk symbol as its
// argument.
module Sem_06021504_index_notation_009 {
type map from charstring to charstring TMap;
type component C {}
testcase TC_Sem_06021504_index_notation_009() runs on C {
var template TMap v_map := {
*,
["first_name"] := "John",
["surname"] := "Doe"
}
if (ispresent(v_map[*])) { // AnyElementsOrNone is present
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_Sem_06021504_index_notation_009());
}
}
\ No newline at end of file
/***************************************************
** @author TTF T023
** @version 0.0.1
** @purpose 1:6.2.15.9, Using omit not allowed in map field values
** @verdict pass reject
***************************************************/
// The following requirement is tested:
// In map values, both keys and value fields associated with them are mandatory. The omit
// symbol shall not be assigned to a map key or value field.
module NegSem_06021509_optionality_of_map_element_values_001 {
type map from charstring to charstring TMap;
type component C {}
testcase TC_NegSem_06021509_optionality_of_map_element_values_001() runs on C {
var TMap v_val := {
["first_name"] := "John",
["surname"] := "Doe",
["city"] := omit
}
log(v_val);
setverdict(pass);
}
control {
execute(TC_NegSem_06021509_optionality_of_map_element_values_001());
}
}
\ No newline at end of file
/***************************************************
** @author TTF T023
** @version 0.0.1
** @purpose 1:6.2.15.9, Matching symbol not allowed as a map key
** @verdict pass reject
***************************************************/
// The following requirement is tested:
// Keys of map templates shall not contain matching symbols.
module NegSem_06021509_optionality_of_map_element_values_002 {
type map from charstring to charstring TMap;
type component C {}
testcase TC_NegSem_06021509_optionality_of_map_element_values_002() runs on C {
var template charstring mw_key := ?;
var template TMap v_map := {
["first_name"] := "John",
["surname"] := "Doe",
[mw_key] := ?
}
log(v_map);
setverdict(pass);
}
control {
execute(TC_NegSem_06021509_optionality_of_map_element_values_002());
}
}
\ No newline at end of file
/***************************************************
** @author TTF T023
** @version 0.0.1
** @purpose 1:6.2.15.9, Using omit inside map templates
** @verdict pass accept, ttcn3verdict:pass
***************************************************/
// The following requirement is tested:
// Value fields associated with keys of map templates might contain matching symbols including
// symbols for optional fields such as omit, * or ifpresent.
module Sem_06021509_optionality_of_map_element_values_001 {
type map from charstring to charstring TMap;
type component C {}
testcase TC_Sem_06021509_optionality_of_map_element_values_001() runs on C {
var template TMap v_map := {
["first_name"] := "John",
["surname"] := "Doe",
["city"] := omit
}
log(v_map);
setverdict(pass);
}
control {
execute(TC_Sem_06021509_optionality_of_map_element_values_001());
}
}
\ No newline at end of file
/***************************************************
** @author TTF T023
** @version 0.0.1
** @purpose 1:6.2.15.9, Using * inside map templates
** @verdict pass accept, ttcn3verdict:pass
***************************************************/
// The following requirement is tested:
// Value fields associated with keys of map templates might contain matching symbols including
// symbols for optional fields such as omit, * or ifpresent.
module Sem_06021509_optionality_of_map_element_values_002 {
type map from charstring to charstring TMap;
type component C {}
testcase TC_Sem_06021509_optionality_of_map_element_values_002() runs on C {
var template TMap v_map := {
["first_name"] := "John",
["surname"] := "Doe",
["city"] := *
}
log(v_map);
setverdict(pass);
}
control {
execute(TC_Sem_06021509_optionality_of_map_element_values_002());
}
}
\ No newline at end of file