Design: 03.04/P04

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 4: Retrieve descendant 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 6 7 8 11
      "<Retrieve paths to descendants> should retrieve all maximal
       descendant paths when path depth is zero."

Use <retrieve paths to descendants> with
     structure id = 101
     path order   = TOPFIRST
     path depth   = zero, to get:
  sadp = set of all descendant paths.

if (sadp 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) ),
      ( (101,3), (107,0) )
   )  then
   fail
   generate informative message on cause of failure
   goto check_topfirst
endif

Use <retrieve paths to descendants> with
     structure id = 103
     path order   = BOTTOMFIRST
     path depth   = zero, to get:
  sadp = set of all descendant paths.

if (sadp does not contain exactly:
      ( (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 check_topfirst
endif

Use <retrieve paths to descendants> with
     structure id = 109
     path order   = BOTTOMFIRST
     path depth   = zero, to get:
  sadp = set of all descendant paths.

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

Use <retrieve paths to descendants> with
     structure id = 108
     path order   = TOPFIRST
     path depth   = zero, to get:
  sadp = set of all descendant paths.

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

pass

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

check_topfirst:

TEST: #SR 6 7 8 11 14 17
      "<Retrieve paths to descendants> should retrieve all
       qualifying descendant paths (or portions thereof), with no
       repetition, when path depth is positive and path order is
       TOPFIRST."

Use <retrieve paths to descendants> with
     structure id = 101
     path order   = TOPFIRST
     path depth   = 2, to get:
  sadp = set of all descendant paths.

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

Use <retrieve paths to descendants> with
     structure id = 101
     path order   = TOPFIRST
     path depth   = 1, to get:
  sadp = set of all descendant paths.

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

Use <retrieve paths to descendants> with
     structure id = 104
     path order   = TOPFIRST
     path depth   = 5, to get:
  sadp = set of all descendant paths.

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

Use <retrieve paths to descendants> with
     structure id = 109
     path order   = TOPFIRST
     path depth   = 5, to get:
  sadp = set of all descendant paths.

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

pass

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

check_bottomfirst:

TEST: #SR 6 7 8 11 15 17
      "<Retrieve paths to descendants> should retrieve all
       qualifying descendant paths (or portions thereof), with no
       repetition, when path depth is positive and path order is
       BOTTOMFIRST."

Use <retrieve paths to descendants> with
     structure id = 101
     path order   = BOTTOMFIRST
     path depth   = 2, to get:
  sadp = set of all descendant paths.

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

Use <retrieve paths to descendants> with
     structure id = 103
     path order   = BOTTOMFIRST
     path depth   = 5, to get:
  sadp = set of all descendant paths.

if (sadp does not contain exactly:
      ( (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 missing_struct
endif

Use <retrieve paths to descendants> with
     structure id = 102
     path order   = BOTTOMFIRST
     path depth   = 1, to get:
  sadp = set of all descendant paths.

if (sadp does not contain exactly:
      ( (109,0) )
   )  then
   fail
   generate informative message on cause of failure
   goto missing_struct
endif

Use <retrieve paths to descendants> with
     structure id = 108
     path order   = BOTTOMFIRST
     path depth   = 1, to get:
  sadp = set of all descendant paths.

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

pass

*** *** ***   Retrieve with missing structure   *** *** ***

missing_struct:

<delete structures from archive> structure identifier 104

TEST: #SR 6 7 8 9
      "If a referenced structure T does not exist in the archive,
       then <retrieve paths to descendants> should behave as if T
       were an existing structure containing no references."
Use <retrieve paths to descendants> with
     structure id = 103
     path order   = TOPFIRST
     path depth   = 0, to get:
  sadp = set of all descendant paths.

if (sadp does not contain exactly:
      ( (103,1), (104,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 <retrieve paths to descendants> with
     structure id = 102
     path order   = BOTTOMFIRST
     path depth   = 1, to get:
  sadp = set of all descendant paths.

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

pass

done:

close archive file

END PROGRAM 4