Merge pull request #19 from nspaseski/master
[deliverable/titan.core.git] / hello / hello_world.ttcn
1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2015 Ericsson Telecom AB
3 // All rights reserved. This program and the accompanying materials
4 // are made available under the terms of the Eclipse Public License v1.0
5 // which accompanies this distribution, and is available at
6 // http://www.eclipse.org/legal/epl-v10.html
7 ///////////////////////////////////////////////////////////////////////////////
8 module hello_world
9 {
10 //====================== Data Types ======================
11 type record of charstring RoC; //unconstrained array of character strings
12
13 //====================== Port Types ======================
14 type port MYPORT message {
15 inout charstring
16 } with {extension "internal"}
17
18 //====================== Component Types ======================
19 type component MYCOMP {
20 const integer c_MyCompDummyConstant := 42;
21 var integer v_MyCompDummyVariable1, v_MyCompDummyVariable2 := 1;
22 timer T_MyCompDummyTimer;
23 port MYPORT myport
24 }
25
26 //====================== Constants ======================
27 const charstring ws0 := "(\n| )#(0,)"
28
29 //====================== Templates ======================
30 //Strings containing the words "hello" and "word", in all small, or
31 //all capital letters, or small letters with first letter capital;
32 //exclamation mark is optional; whitespaces allowed
33 template charstring t_expected :=
34 pattern "{ws0}(((h|H)ello {ws0}(w|W)orld)|HELLO {ws0}WORLD){ws0}!#(0,1){ws0}"
35
36 //====================== Functions ======================
37 function f_PTC(charstring pl_toSend) runs on MYCOMP {
38 myport.send(pl_toSend);
39 }
40
41 //====================== Testcases ======================
42 testcase TC(charstring pl_toSend) runs on MYCOMP {
43 var charstring vl_received;
44 var MYCOMP vl_PTC := MYCOMP.create alive;
45 connect (self:myport,vl_PTC:myport);
46 vl_PTC.start(f_PTC(pl_toSend));
47 T_MyCompDummyTimer.start(5.0);
48 alt {
49 [] myport.receive(t_expected)-> value vl_received {
50 setverdict(pass,"expected message received: ",vl_received)
51 }
52 [] myport.receive (charstring:?) -> value vl_received{
53 setverdict(fail,"Unexpected message received: ",vl_received)
54 }
55 [] T_MyCompDummyTimer.timeout { setverdict(inconc);}
56 }
57 }
58
59 //=========================================================================
60 // Control Part
61 //=========================================================================
62 control {
63 var RoC vl_inputs := {
64 "HELLO WORLD!",
65 "hello world",
66 "Hello World!",
67 "hello WORLD!",
68 "hELLO wORLD!",
69 "helloworld!"
70 }
71 var integer i, vl_noStrings := sizeof(vl_inputs);
72 for (i:=0; i< vl_noStrings; i:=i+1){
73 execute (TC(vl_inputs[i]),5.0)
74 }
75
76 //3 pass, 3 fail expected
77 } // end of control part
78
79 } // end of module
This page took 0.031549 seconds and 5 git commands to generate.