Sem_060210_ReuseofComponentTypes_003.ttcn 2.63 KB
Newer Older
kovacsa's avatar
kovacsa committed
/*****************************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:6.2.10, Ensure that extending a component with and extended component works properly
 ** @verdict  pass accept, ttcn3verdict:pass
 *****************************************************************/

/* The following requirements are tested:
 * It is allowed to have one component type extending several parent types in one definition,
 * which have to be specified as a comma-separated list of types in the definition.
 * Any of the parent types may also be defined by means of extension. 
 */

module Sem_060210_ReuseofComponentTypes_003 {

  //MyCompA has a port pt_myPortA
  type component MyCompA {
    port loopbackPort pt_myPortA;
    var integer MyInt;
  }
kovacsa's avatar
kovacsa committed
    
  //MyComp has a port pt_myPortB and inherit a port (pt_myPortA) form MyCompA
  type component MyCompB extends MyCompA {
    port loopbackPort pt_myPortB;
  }
kovacsa's avatar
kovacsa committed
    
//Component GeneralComp has a timer and inherit two ports from MyCompB (pt_myPortA and pt_myPortB)
  type component GeneralComp extends MyCompB {
    timer t;
  }
kovacsa's avatar
kovacsa committed
    
  type port loopbackPort message {
    inout integer;
    inout float;
  }
kovacsa's avatar
kovacsa committed
  

  function loopback() runs on GeneralComp {
    var integer v_i;
    var float v_f;
    while (true) {
      alt {
        [] pt_myPortA.receive(integer:?) -> value v_i { pt_myPortA.send(v_i); }
        [] pt_myPortA.receive(float:?) -> value v_f { pt_myPortA.send(v_f); }
        [] pt_myPortB.receive(integer:?) -> value v_i { pt_myPortB.send(v_i); }
        [] pt_myPortB.receive(float:?) -> value v_f { pt_myPortB.send(v_f); }
      }
    }
  }
    
  testcase TC_Sem_060210_ReuseofComponentTypes_003() runs on GeneralComp system GeneralComp {
   
    var GeneralComp v_server := GeneralComp.create;
    
    connect(mtc:pt_myPortA, v_server:pt_myPortA);
    connect(mtc:pt_myPortB, v_server:pt_myPortB);
    
    v_server.start(loopback());
kovacsa's avatar
kovacsa committed
   
kovacsa's avatar
kovacsa committed
    MyInt := 10;
        
    //Send an integer from pt_myPortA:
    pt_myPortA.send(2);
kovacsa's avatar
kovacsa committed
    alt {
kovacsa's avatar
kovacsa committed
        setverdict(pass,"Receive successful");
kovacsa's avatar
kovacsa committed
        setverdict(fail,"Unexpected result");
kovacsa's avatar
kovacsa committed
    }
        
    //Send an integer from pt_myPortB:
    pt_myPortB.send(1.0);
kovacsa's avatar
kovacsa committed
    alt {
kovacsa's avatar
kovacsa committed
        setverdict(pass,"Receive successful");
kovacsa's avatar
kovacsa committed
        setverdict(fail,"Unexpected result");
kovacsa's avatar
kovacsa committed
    }

  }

  control{
    execute(TC_Sem_060210_ReuseofComponentTypes_003());
  }
kovacsa's avatar
kovacsa committed
}