/******************************************************************************
 * Copyright (c) 2000-2021 Ericsson Telecom AB
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
 *
 * Contributors:
 *   Balasko, Jeno
 *   Baranyi, Botond
 *
 ******************************************************************************/
// HS41022 - Titan 2.2.pl0 Wrong value for matching for 19 digit integer

module HS41022 {

  // the number of bits this value is represented on (in this case 63) needs to be dividable by 7
  const integer BIG_NUMBER := 9223372036854775807; 

  type port PT message {
    inout integer
  } with { extension "internal" }

  type component CT {
    port PT pt
  }

  function fc_par(in integer i) runs on CT {
    if (i == BIG_NUMBER) {
      setverdict(pass);
    }
    else {
      setverdict(fail);
    }
  }

  function fc_msg() runs on CT {
    timer t := 2.0;    
    alt {
      [] pt.receive(integer:BIG_NUMBER) { setverdict(pass); }
      [] pt.receive(integer:?) { setverdict(fail); }
      [] t.timeout { setverdict(inconc); }
    }
  }
  
  // Send the number as a function parameter
  testcase tc_big_int_par_with_2_comps() runs on CT {
    var CT the_other_comp := CT.create;
    connect(self:pt, the_other_comp:pt);

    the_other_comp.start(fc_par(BIG_NUMBER));

    the_other_comp.done;
    setverdict(pass);
  }

  // Send the number as a message on a port
  testcase tc_big_int_msg_with_2_comps() runs on CT {
    var CT the_other_comp := CT.create;
    connect(self:pt, the_other_comp:pt);

    the_other_comp.start(fc_msg());
    pt.send(BIG_NUMBER);

    the_other_comp.done;
    setverdict(pass);
  }

  control {
    execute(tc_big_int_par_with_2_comps());
    execute(tc_big_int_msg_with_2_comps());
  }

}
