Design: 03.04/P03

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 3: Retrieving ancestor paths

CHARACTERISTICS: nnnn

OPERATOR SCRIPT: passive test.

DESIGN:

open new archive file, with arid = archive identifier
Set up archive 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 5 7 8 10
      "<Retrieve paths to ancestors> should retrieve all maximal
       ancestor paths when path depth is zero."

Use <retrieve 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 <retrieve 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 <retrieve 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 <retrieve 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 5 7 8 10 12 16
      "<Retrieve 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 <retrieve 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 <retrieve paths to ancestors> with
     structure id = 104
     path order   = TOPFIRST
     path depth   = 5, to get:
  saap = set of all ancestor paths.

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

Use <retrieve 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 <retrieve 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 5 7 8 10 13 16
      "<Retrieve 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 <retrieve 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 <retrive 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 <retrieve 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 <retrieve 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 <retrieve 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:
close archive file

END PROGRAM 3