source: trunk/t3q-examples/checkNoOverSpecificRunsOn/checkNoOverSpecificRunsOn.ttcn3 @ 10

Last change on this file since 10 was 4, checked in by phdmakk, 15 years ago
File size: 2.2 KB
RevLine 
[4]1module checkNoOverSpecificRunsOn {
2   
3    //global const for validation
4    const someType someGlobalConst := 21;
5
6        //component in question
7    type component someComponent {
8        var someType someVarName := 2;
9        var someType someOtherVarName := 2, someAnotherVarName := 4;
10        var charstring someCharStringVar := "xyz";
11        var template someType someTemplateVarName := 3;
12        const someType someConstName := 1;
13        const integer someIntegerConstName := 42;
14        const someOtherType someConstName2 := someModuleParameterName2, someConstName3 := someModuleParameterName3;
15        timer someTimer;
16        port somePortType somePortInstance;
17    }
18
19        type component someComponent2 extends someComponent{
20        port somePortType somePortInstance2;
21               
22        }
23
24        //good
25    function someFunction ()
26    runs on someComponent {
27        //some references to component definitions here
28        someTimer.start ( 10.0 );
29    }
30
31        //bad
32    function someOverSpecificFunction ()
33    runs on someComponent {
34                //ay(); //this will make it valid
35                //wrapperfunction(); //this will make it valid
36                wrapperFunction(); //unresolvable due to a typo - proper error message provided
37    //no references to component definitions here
38    }
39
40        //irrelevant
41    function someGenericFunction () runs on someComponent{
42                somePortInstance.send("x");
43    //no relation
44    }
45
46
47
48    //good
49    //a tricky example with a referenced function that uses the relevant fields
50    //wraper function
51    function wrapperfunction ()
52    runs on someComponent {
53
54        //function that uses the component definitions
55        someFunction ();
56    }
57
58        //bad
59    testcase tcx ()
60    runs on someComponent {
61                //ay(); //this will make it valid
62    }
63
64        //good
65        //tricky wrapper example
66    altstep ax ()
67    runs on someComponent {
68        var integer a := someFunction();
69        [] ay ()
70        [] ay ()
71    }
72
73        //good
74    altstep ay ()
75    runs on someComponent {
76        var integer a := someFunction();       
77
78        [] someTimer.timeout {
79                        wrapperfunction();
80        }
81    }
82
83        //tricky cyclic call sequences
84        function f1() runs on someComponent{
85                f2();
86                f3()
87        }
88        function f2() runs on someComponent{
89                f1()
90                f4()
91        }
92        function f3() runs on someComponent{
93                f2()
94        }
95        function f4() runs on someComponent{
96       
97        }
98}
Note: See TracBrowser for help on using the repository browser.