USE 3.0.4 Generator problem

Help
2012-10-29
2013-04-29
  • Stefan Mijatov
    Stefan Mijatov
    2012-10-29

    I have a problem when I execute a procedure in ASSL for generating multiple objects from my model.
    What happens is that as soon USE creates objects, it checks the state validity, and issues undo actions for creation of each object, so that I end up with an empty state. What could be the problem, and am I doing something wrong?

    Here is the relevant source:

    model.use:

    model Airline

    class Passenger
    attributes
        name : String
    end
    

    model.assl:

    procedure generatePassengers(count:Integer)
    var thePassengers:Sequence(Passenger);
    begin
    thePassengers := CreateN(Passenger, [count]);
    for p:Passenger in [thePassengers]
        begin
        [p].name := Any([Sequence{'Ann', 'Bob', 'Cecil', 'Demian', 'Faith', 'Glen'}
        ->reject(n1|Passenger.allInstances.name->exists(n2|n1=n2))]);
        end;
    end;
    

    command:

    gen start -b model.assl generatePassengers(1)

    result:

    Added Barrier for invariant `Payment::paymentCodeUnique' before statement `thePassengers := CreateN(Passenger, )'
    Added Barrier for invariant `Flight::flightNumberUnique' before statement `thePassengers := CreateN(Passenger, )'
    Added Barrier for invariant `Reservation::reservationCodeUnique' before statement `thePassengers := CreateN(Passenger, )'
    !new Passenger('Passenger1')
    !@Passenger1.name := 'Ann'
    check state (1): valid state.
    undo: !@Passenger1.name := 'Ann'
    undo: !new Passenger('Passenger1')

    So basically I see that tool does 'undo' actions at the end, leaving an empty state. Why? And how can I prevent this?
    It makes impossible to proceed with other commands in a test case file I am trying to run..

    Thanks in advance,
    Stefan

     
  • Lars Hamann
    Lars Hamann
    2012-10-29

    Hi Stefa,
    you just need to accept the found state with the command:

    gen result accept
    

    Best regards!
    Lars

     
  • Stefan Mijatov
    Stefan Mijatov
    2012-10-29

    Great, it works, thanks!!!

    Best regards,
    Stefan