Design: 02.01/P02

This is an abstract, language-independent design. Grim details may be found in the corresponding source code. You may return to the documentation for the module containing this program design, or to the entire hierarchical table of topics covered by the PVT.


PROGRAM 2: Inquiring about ancestor paths

CHARACTERISTICS: nnnn

OPERATOR SCRIPT: passive test.

DESIGN:

Use <open structure> and <execute structure> to set up
the CSS as follows:

                 101        106       108
                / | \       /
               /  |  \    1/
             1/  2|  3\   /
             /    |    \ /
            /     |    107
           /      |
        102      103
        | \      / \\
        |  \   1/   \\
       1|  2\  /    2\\3
        |    \/       \\
        |    104      105
        |     |      /
        |    1|    1/
         \    |    /
          \   |   /
           \  |  /
            \ | /
             109

The nodes of the graph (101-109) represent structures, and the
labelled edges are references to invoked (lower) structures.
The labels (1-3) represent the element position of the <execute
structure> function within the calling structure.  Eg, an element
reference path from 101 to 109 would be: (101, 2), (103, 3),
(105, 1), (109, 0).

*** *** *** *** ***   No truncation   *** *** *** *** ***

TEST: #SR 1 3 5 6 7
      "<Inquire paths to ancestors> should retrieve all maximal
       ancestor paths when path depth is zero."

Use <inquire paths to ancestors> with
     structure id = 109
     path order   = TOPFIRST
     path depth   = zero, to get:
  saap = set of all ancestor paths.

if (saap does not contain exactly:
      ( (101,1), (102,1), (109,0) ),
      ( (101,1), (102,2), (104,1), (109,0) ),
      ( (101,2), (103,1), (104,1), (109,0) ),
      ( (101,2), (103,2), (105,1), (109,0) ),
      ( (101,2), (103,3), (105,1), (109,0) )
   )  then
   fail
   generate informative message on cause of failure
   goto check_topfirst
endif

Use <inquire paths to ancestors> with
     structure id = 107
     path order   = BOTTOMFIRST
     path depth   = zero, to get:
  saap = set of all ancestor paths.

if (saap does not contain exactly:
      ( (101,3), (107,0) ),
      ( (106,1), (107,0) )
   )  then
   fail
   generate informative message on cause of failure
   goto check_topfirst
endif

Use <inquire paths to ancestors> with
     structure id = 106
     path order   = BOTTOMFIRST
     path depth   = zero, to get:
  saap = set of all ancestor paths.

if (saap not empty) then
   fail
   generate informative message on cause of failure
   goto check_topfirst
endif

Use <inquire paths to ancestors> with
     structure id = 108
     path order   = TOPFIRST
     path depth   = zero, to get:
  saap = set of all ancestor paths.

if (saap not empty) then
   fail
   generate informative message on cause of failure
   goto check_topfirst
endif

pass

*** *** ***   Truncating via TOPFIRST   *** *** ***

check_topfirst:

TEST: #SR 1 3 5 6 9 13
      "<Inquire paths to ancestors> should retrieve all
       qualifying ancestor paths (or portions thereof), with no
       repetition, when path depth is positive and path order is
       TOPFIRST."

Use <inquire paths to ancestors> with
     structure id = 109
     path order   = TOPFIRST
     path depth   = 3, to get:
  saap = set of all ancestor paths.

if (saap does not contain exactly:
      ( (101,1), (102,1), (109,0) ),
      ( (101,1), (102,2), (104,1) ),
      ( (101,2), (103,1), (104,1) ),
      ( (101,2), (103,2), (105,1) ),
      ( (101,2), (103,3), (105,1) )
   )  then
   fail
   generate informative message on cause of failure
   goto check_bottomfirst
endif

Use <inquire paths to ancestors> with
     structure id = 105
     path order   = TOPFIRST
     path depth   = 1, to get:
  saap = set of all ancestor paths.

if (saap does not contain exactly:
      ( (101,2) )
   )  then
   fail
   generate informative message on cause of failure
   goto check_bottomfirst
endif

Use <inquire paths to ancestors> with
     structure id = 101
     path order   = TOPFIRST
     path depth   = 5, to get:
  saap = set of all ancestor paths.

if (saap not empty)  then
   fail
   generate informative message on cause of failure
   goto check_bottomfirst
endif

pass

*** *** ***   Truncating via BOTTOMFIRST   *** *** ***

check_bottomfirst:

TEST: #SR 1 3 5 6 10 13
      "<Inquire paths to ancestors> should retrieve all
       qualifying ancestor paths (or portions thereof), with no
       repetition, when path depth is positive and path order is
       BOTTOMFIRST."

Use <inquire paths to ancestors> with
     structure id = 109
     path order   = BOTTOMFIRST
     path depth   = 3, to get:
  saap = set of all ancestor paths.

if (saap does not contain exactly:
      ( (101,1), (102,1), (109,0) ),
      ( (102,2), (104,1), (109,0) ),
      ( (103,1), (104,1), (109,0) ),
      ( (103,2), (105,1), (109,0) ),
      ( (103,3), (105,1), (109,0) )
   )  then
   fail
   generate informative message on cause of failure
   goto done
endif

Use <inquire paths to ancestors> with
     structure id = 109
     path order   = BOTTOMFIRST
     path depth   = 2, to get:
  saap = set of all ancestor paths.

if (saap does not contain exactly:
      ( (102,1), (109,0) ),
      ( (104,1), (109,0) ),
      ( (105,1), (109,0) )
   )  then
   fail
   generate informative message on cause of failure
   goto done
endif

Use <inquire paths to ancestors> with
     structure id = 107
     path order   = BOTTOMFIRST
     path depth   = 5, to get:
  saap = set of all ancestor paths.

if (saap does not contain exactly:
      ( (101,3), (107,0) ),
      ( (106,1), (107,0) )
   )  then
   fail
   generate informative message on cause of failure
   goto done
endif

Use <inquire paths to ancestors> with
     structure id = 107
     path order   = BOTTOMFIRST
     path depth   = 1, to get:
  saap = set of all ancestor paths.

if (saap does not contain exactly:
      ( (107,0) )
   )  then
   fail
   generate informative message on cause of failure
   goto done
endif

Use <inquire paths to ancestors> with
     structure id = 106
     path order   = BOTTOMFIRST
     path depth   = 1, to get:
  saap = set of all ancestor paths.

if (saap not empty)  then
   fail
   generate informative message on cause of failure
   goto done
endif

pass

done:

END PROGRAM 2