Re: test for default history content

Zjnue,
   You're right about getTargetStates. It even gets called when 
computing the exit set, and the defaultHistoryContent variable doesn't 
exist yet.  One inelegant aspect of this solution is that since it gets 
called multiple times, the defaultContent gets added multiple times.  
That's not a problem, but it might be confusing. I'll have more time to 
look at this next week, and I will create new tests on <history> as 
well.  (It occurs to me that we can use the 'in()' predicate to test 
that the history state never becomes part of the configuration.)

- Jim
On 4/1/2014 5:51 AM, Zjnue Brzavi wrote:
> [...]
>
>     what if we define
>
>     getTargetStates(stateList, defaultEntryContent)
>         allTargets = newOrderedSet
>         for state in stateList:
>              if isHistoryState(state):
>                   if historyValue[state.id <http://state.id>]:
>                        allTargets.union(historyValue[state.id
>     <http://state.id>])
>                   else:
>     allTargets.union(getTargetStates(state.transition.target))
>                       defaultHistoryContent[state.parent.id
>     <http://state.parent.id>] = state.transition.content
>              else:
>                  allTargets.add(state)
>
>     If we do this, addDescendentStatesToEnter should never see a
>     history state, so it can be simplified to:
>
>     procedure addDescendantStatesToEnter(state,statesToEnter,statesForDefaultEntry, defaultHistoryContent):
>          if isCompoundState(state):
>              statesForDefaultEntry.add(state)
>              for s in getTargetStates(state.initial):
>                 statesToEnter.add(s)
>                 addDescendantStatesToEnter(s,statesToEnter,statesForDefaultEntry)
>                 addAncestorStatesToEnter(s, state, statesToEnter, statesForDefaultEntry, defaultHistoryContent)
>          elif isParallelState(state):
>               for child in getChildStates(state):
>                   if not statesToEnter.some(lambda s: isDescendant(s,child)):
>                      statesToEnter.add(child)
>                      addDescendantStatesToEnter(child,statesToEnter,statesForDefaultEntry, defaultHistoryContent)
>
> Hi,
>
> Please excuse the wait - only just found time this morning to test the 
> suggested changes.
> After two small alterations, they work well.
>
> It is important to remember that we call getTargetStates from several 
> places where we don't have a reference to defaultHistoryContent. 
> Therefore, the argument is optional and we need to test whether 
> defaultHistoryContent is null before trying to populate it.
>
> Secondly, addDescendantStatesToEnter should call 
> statesToEnter.add(state); at the start and not do the 
> statesToEnter.add() calls as per suggestion. The way it is written 
> above causes test 403c, 504 and 533 to fail. So the final 
> addDescendantStatesToEnter definition looks like this [1].
>
> Best regards,
> Zjnue
>
> [1]
> procedure addDescendantStatesToEnter(state,statesToEnter,statesForDefaultEntry, defaultHistoryContent):
>      statesToEnter.add(child)
>
>      if isCompoundState(state):
>          statesForDefaultEntry.add(state)
>          for s in getTargetStates(state.initial):
>             addDescendantStatesToEnter(s,statesToEnter,statesForDefaultEntry)
>             addAncestorStatesToEnter(s, state, statesToEnter, statesForDefaultEntry, defaultHistoryContent)
>      elif isParallelState(state):
>           for child in getChildStates(state):
>               if not statesToEnter.some(lambda s: isDescendant(s,child)):
>                  addDescendantStatesToEnter(child,statesToEnter,statesForDefaultEntry, defaultHistoryContent)

-- 
Jim Barnett
Genesys

Received on Tuesday, 1 April 2014 13:27:56 UTC