Next / Previous / Contents / Shipman's homepage

14. Truths._inputCheck(): Check one input set

tracecase
# - - -   T r u t h s . _ i n p u t C h e c k

    def _inputCheck(self, inputList):
        '''Check one set of input conditions.

          [ inputList is a list of (self._caseCount) bool values ->
              if inputList matches exactly one of the cases in self ->
                return None
              else ->
                return an error message string ]
        '''

We'll accumulate a list matchList of the case indices that match this set of inputs. For the logic that checks one case, see Section 15, “Truths._caseCheck(): Check one case”.

tracecase
        #-- 1
        # [ matchList  :=  list of numbers (k) such that the inputs
        #       in inputList all match case [k] ]
        matchList = [ k
                      for k in range(self._caseCount)
                      if self._caseCheck(inputList, k) ]

If matchCount doesn't have exactly one value, it's an error. For the uncovered case, see Section 17, “Truths._uncovered(): Message for an uncovered input set”; for the over-covered case, see Section 19, “Truths._overcovered(): Message for an over-covered input set”.

tracecase
        #-- 2
        # [ if len(matchList) == 1 ->
        #     return None
        #   else len(matchList) < 1 ->
        #     return an "uncovered" message showing inputList
        #   else ->
        #     return a "covers N cases" message showing inputList
        #     and the cases whose indices are in matchList ]
        if len(matchList) == 1:
            return None
        elif len(matchList) < 1:
            return self._uncovered(inputList)
        else:
            return self._overcovered(inputList, matchList)