home *** CD-ROM | disk | FTP | other *** search
/ Programmer's ROM - The Computer Language Library / programmersrom.iso / ada / cais / caistst.src < prev    next >
Encoding:
Text File  |  1988-05-03  |  376.8 KB  |  12,378 lines

  1. --::::::::::::::
  2. --caistest.pro
  3. --::::::::::::::
  4.  
  5.  
  6. -------- SIMTEL20 Ada Software Repository Prologue ------------
  7. --                                                           -*
  8. -- Unit name    : CAISTEST
  9. -- Version      : 860307
  10. -- Author       : Mitre Corp.
  11. --              : Rebecca Bowerman    Helen Gill
  12. --              : Chuck Howell        Robbie Hutchison
  13. --              : Mike McClimens
  14. -- DDN Address  : cig-info at mitre
  15. -- Date created : 07 MAR 86
  16. -- Release date : 07 MAR 86
  17. -- Last update  : 07 MAR 86
  18. -- Machine/System Compiled/Run on : Vax 8600
  19. --                                  UNIX
  20. --                                  Verdix Ada Development Sys
  21. --                                                           -*
  22. ---------------------------------------------------------------
  23. --                                                           -*
  24. -- Keywords     :  Tool Interfaces, Portability, Stoneman,
  25. --                 Operating System Calls, Host-Dependencies,
  26. --                 MIL-STD-CAIS, APSE, Programming Support Environment,
  27. --                 Regression Tests
  28. ----------------:
  29. --
  30. -- Abstract     :  
  31. --         This set of tests exercises a wide range of the
  32. -- implemented CAIS interfaces.  In general the results of the
  33. -- tests are self-documenting.  However they are programmer-
  34. -- developed tests and are not as rigorous as might be
  35. -- expected for acceptance testing.  They also vary in style.
  36. -- In some instances dependencies upon the state of the node
  37. -- model remain in these tests and thus may require the
  38. -- existence (or non-existence) of nodes and/or attributes.
  39. --
  40. -- The tests are:
  41. --   attribute_ex.a               => Test Exceptions on Attribute Com
  42. --   cais_commandos.a             => Set of Interactive CAIS Commands
  43. --   copytree_test.a              => Tests Copy_Tree(+Node), Rename
  44. --   existree_ex.a                => Same as Nodetree_ex sans Creates
  45. --   io_ex_create_test.a          => Test Exceptions on Text_Io.Create
  46. --   io_ex_open_test.a            => Test Exceptions on Text_Io.Open
  47. --   io_ex_delete_test.a          => Test Exceptions on Text_Io.Delete
  48. --   list_test_02_12.a            => Tests List_Utilities 5.4.2 - 12
  49. --   list_test_13_ss.a            => Tests List_Utilities 5.4.13 - 23
  50. --   list_tstex.a                 => Tests Exceptions on List_Utilities
  51. --   listutst.a                   => Five Quick List_Utilities Tests
  52. --   list_utilities_tests-body.a        => Part of Above
  53. --   list_utilities_tests-spec.a        => Part of Above
  54. --   natt_tst_all.a               => Test Node Attribute Commands
  55. --   natt_tst_it.a                => Test Node Attribute Iterators
  56. --   new_user.a                   => Adds New_Users
  57. --   node_mgnt.a                  => Tests some of Node-Management
  58. --   node_management_tests-body.a       => Part of Above
  59. --   node_management_tests-body.a       => Part of Above
  60. --   nodetree_ex.a                => Tests some Node_Management Excep.
  61. --   nodetree_cleanup.a                 => Deletes Nodes from Above
  62. --   patt_tst_all.a               => Test Path Attribute Commands
  63. --   patt_tst_it.a                => Test Path Attribute Iterators
  64. --   struct_nodes.a               => Main for Structural_Nodes test
  65. --   structural_nodes_tests-body.a      => Part of Above
  66. --   structural_nodes_tests-spec.a      => Part of Above
  67. --   test_internals.a             => Test Window into Cais Insides
  68. --   test_node_iterate.a          => Tests Node Iterate
  69. --   text_test.a                  => Tests some of Text_Io
  70. --   text_io_tests-body.a               => Part of Above
  71. --   text_io_tests-spec.a               => Part of Above
  72. --
  73. --         The tests should be run when the CAIS is installed
  74. -- and users have been added.  They can also be run as
  75. -- regression tests, if the CAIS code is modified.  They may
  76. -- be helpful as supplementary (though rudimentary) examples
  77. -- to MIL-STD-CAIS
  78. ----------------:  
  79. --                                                           -*
  80. ------------------ Revision history ---------------------------
  81. --                                                           -*
  82. -- DATE      VERSION AUTHOR        HISTORY
  83. -- 03/07/85  860307  Mitre Corp    Initial Release
  84. --                                                           -*
  85. ------------------ Distribution and Copyright -----------------
  86. --                                                           -*
  87. -- This prologue must be included in all copies of this software.
  88. --
  89. -- This software is released to the Public Domain (note:
  90. --   software released to the Public Domain is not subject
  91. --   to copyright protection).
  92. --
  93. -- Restrictions on use or distribution:  Although there are
  94. --      no current plans to provide maintenance for this set of
  95. --      CAIS tests, further modifications are planned. We would
  96. --      appreciate your reporting problems and experiences to:
  97. --              
  98. --                cig-info at mitre    (net address)
  99. --
  100. --      or call at:
  101. --
  102. --                (703)  883-7858
  103. --                                                           -*
  104. ------------------ Disclaimer ---------------------------------
  105. --                                                           -*
  106. -- This software and its documentation are provided "AS IS" and
  107. -- without any expressed or implied warranties whatsoever.
  108. -- No warranties as to performance, merchantability, or fitness
  109. -- for a particular purpose exist.
  110. --
  111. -- Because of the diversity of conditions and hardware under
  112. -- which this software may be used, no warranty of fitness for
  113. -- a particular purpose is offered.  The user is advised to
  114. -- test the software thoroughly before relying on it.  The user
  115. -- must assume the entire risk and liability of using this
  116. -- software.
  117. --
  118. -- In no event shall any person or organization of people be
  119. -- held responsible for any direct, indirect, consequential
  120. -- or inconsequential damages or lost profits.
  121. --                                                           -*
  122. -------------------END-PROLOGUE--------------------------------
  123.  
  124. --::::::::::::::
  125. --testscript.log
  126. --::::::::::::::
  127. Script started on Fri Mar  7 16:30:02 1986
  128.  
  129.  
  130.  
  131. ***************************************************************
  132. * This file contains sample outputs from CAIS tests.  The style
  133. * of reporting tests varies greatly among the test.  It may be
  134. * advisable to read the test source.  However, an attempt was
  135. * made in all tests to self-check and explicitly indicate
  136. * failures.        Good Luck
  137. **************************************************************
  138.  
  139. *************************************************************
  140. * Several tests run under this test driver.  You should
  141. * determine the number of tests available (14 in this case).
  142. * The level of test output must be: status or none.
  143. * Tests may or may not issue status information.  Test failures
  144. * are reported at the end.  All other tests pass.
  145. **************************************************************
  146. % text_test.out
  147. Enter the highest test number to be run: 15
  148. PLEASE ENTER AN INTEGER 0 ..  14
  149. Enter the highest test number to be run: 14
  150. Abort the test upon an unexpected exception? (Yes or No): no
  151. Enter the level of test output to be printed: status
  152. Do you want output redirected to a file? (yes or no): no
  153.  
  154. **** Beginning Execution of Text_Test ****
  155.     TEST_OUTPUT is set to STATUS
  156.     ABORT_ON_EXCEPTION is set to FALSE
  157.     TEST_COUNT is set to  14
  158.  
  159.  
  160. **** End of Text_Test ****
  161.  
  162.  
  163.  
  164. NO TESTS FAILED. 
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171. ***********************************************************
  172. * Cais_commandos is a set of interactive CAIS commands
  173. * which allows simple creation, deletion, and listing of
  174. * the node system.   QUIT is used in some cases, in others
  175. * ! is required to quit. Don't be confused and be wary of
  176. * naming a node to be QUIT.
  177. **********************************************************
  178. % cais_commandos.out
  179.  
  180.  
  181. 1. Add_Attributes  2. Change_Attributes   3. Create_File_Nodes
  182. 4. Delete_Nodes    5. Import_Export       6. Create_Struc_Nodes
  183. 7. Directory       8. Delete_Attributes   9. List_Attributes
  184. ENTER COMMAND NUMBER (0 to QUIT): 7
  185.  
  186. DIRECTORY:
  187.  
  188. Give NODE (or QUIT):  'current_node
  189. Give PRIMARY or SECONDARY:  primary
  190. Give FILE or STRUCTURAL:  file
  191.  
  192.     DOT(HOWELL)
  193.     DOT(MIKE)
  194.  
  195. Give NODE (or QUIT):  quit
  196.  
  197. COMPLETED.
  198.  
  199.  
  200.  
  201. 1. Add_Attributes  2. Change_Attributes   3. Create_File_Nodes
  202. 4. Delete_Nodes    5. Import_Export       6. Create_Struc_Nodes
  203. 7. Directory       8. Delete_Attributes   9. List_Attributes
  204. ENTER COMMAND NUMBER (0 to QUIT): 6
  205.  
  206. CREATING STRUCTURAL NODES
  207. Give PATH (or QUIT):  test
  208.  
  209. Give PATH (or QUIT):  test1
  210.  
  211. Give PATH (or QUIT):  quit
  212.  
  213.  
  214. COMPLETED.
  215.  
  216.  
  217.  
  218. 1. Add_Attributes  2. Change_Attributes   3. Create_File_Nodes
  219. 4. Delete_Nodes    5. Import_Export       6. Create_Struc_Nodes
  220. 7. Directory       8. Delete_Attributes   9. List_Attributes
  221. ENTER COMMAND NUMBER (0 to QUIT): 7
  222.  
  223. DIRECTORY:
  224.  
  225. Give NODE (or QUIT):  'current_node
  226. Give PRIMARY or SECONDARY:  primary
  227. Give FILE or STRUCTURAL:  structural
  228.  
  229.     DOT(TEST)
  230.     DOT(TEST1)
  231.  
  232. Give NODE (or QUIT):  quit
  233.  
  234. COMPLETED.
  235.  
  236.  
  237.  
  238. 1. Add_Attributes  2. Change_Attributes   3. Create_File_Nodes
  239. 4. Delete_Nodes    5. Import_Export       6. Create_Struc_Nodes
  240. 7. Directory       8. Delete_Attributes   9. List_Attributes
  241. ENTER COMMAND NUMBER (0 to QUIT): 9
  242.  
  243. LISTING ATTRIBUTES
  244.  
  245. NODE, PATH, or QUIT?  node
  246. Give NODE (or QUIT):  howell
  247.  
  248.     ACCESS_METHOD => (TEXT)
  249.     FILE_KIND => (SECONDARY_STORAGE)
  250.  
  251. NODE, PATH, or QUIT?  path
  252. Give PATH (or QUIT):  'current_node.howell
  253.  
  254.     KIND => (("FILE"))
  255.  
  256. NODE, PATH, or QUIT?  quit
  257.  
  258. COMPLETED.
  259.  
  260.  
  261.  
  262. 1. Add_Attributes  2. Change_Attributes   3. Create_File_Nodes
  263. 4. Delete_Nodes    5. Import_Export       6. Create_Struc_Nodes
  264. 7. Directory       8. Delete_Attributes   9. List_Attributes
  265. ENTER COMMAND NUMBER (0 to QUIT): 0
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275. *******************************************************************
  276. * Several I/O and List_Utility tests are of the following form.
  277. * Pass/Fail messages are printed for each test.  Diagnostic
  278. * information is interspersed with the messages and may be ignored.
  279. * This output should be able to be quickly scanned for correctness
  280. * or compared with previous runs for character_by_character
  281. * consistency.
  282. ******************************************************************
  283. % io_ex_create_test.out
  284.  
  285.  1. OK -- Create raises Io_Definitions.Name_Error when file exists
  286.  
  287.  
  288.  2. OK -- Create raises Io_Definitions.Name_Error when key is bad
  289.  
  290.  
  291.  3. OK -- Create raises Io_Definitions.Name_Error when relation is bad
  292.  
  293.  
  294. CAIS Use_Error: Bad attribute value in Cais.Text_Io.Create
  295.  
  296.  
  297.  4. OK -- Create raises Io_Definitions.Use_Error when attribute syntax illegal
  298.  
  299.  
  300. CAIS Use_Error: Invalid Access_Method in Cais.Text_Io.Create
  301.  
  302.  
  303.  5. OK -- Create raises Io_Definitions.Use_Error when attribute semantics illegal
  304.  
  305.  
  306. CAIS Use_Error: Invalid File_Kind in Cais.Text_Io.Create
  307.  
  308.  
  309.  6. OK -- Create raises Io_Definitions.Use_Error when predefined attribute
  310.  
  311.  
  312.  7. OK -- Create raises Io_Definitions.Use_Error when predefined relation
  313.  
  314.  
  315.  8. OK -- Create raises Io_Definitions.Status_Error when base not open
  316.  
  317.  
  318.  9. OK -- Create raises Io_Definitions.Status_Error when file handle open
  319.  
  320.  
  321.  10. OK -- Create raises Io_Definitions.Intent_Violation when base intent not Append_Relationships
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332. *********************************************************************
  333. * Several Exception tests have this style, quickly listing the no. of
  334. * passing tests.  Failed tests will be reported on a separate line.
  335. * For this test, inaccessibility test are skipped unless a 'Y' is
  336. * entered as a response. If they are to be run the tester must
  337. * interrupt this process and move the node's "shadow file".  Don't
  338. * lose it because it is hard to clean up unless you put it back
  339. ********************************************************************
  340. % nodetree_ex.out
  341. CREATE --TREE
  342. CREATE --Nowalk.john
  343. CREATE --Nowalk.john.johnjr
  344. CREATE --Nowalk.john.johnjr.mark
  345. CREATE --Nowalk.john.will
  346. CREATE --Nowalk.john.will.kitty
  347. NOW YOU must make the node dot(will) inaccessible
  348. It should be the 2nd from last node created.
  349. Should Inaccessibility tests be run (Y/N)
  350. n
  351.  
  352. PASSES TEST:  2   3   5   6   8   9   10   12   13   14  
  353. PASSES TEST:  15   16   17   18   19   20   21   22   23   24  
  354. PASSES TEST:  25   26   27   28   29   30   31   32   33   34  
  355. PASSES TEST:  35   36   37   38   39   40   41   42   43   44  
  356. PASSES TEST:  45   48   49   50  
  357. ****************************T O T A L S***********************
  358. Number of tests run:  50
  359. Number of failures :  0
  360. *** NOTE 6 TESTS ARE SKIPPED IF INACCESSIBILITY NOT CHECKED***
  361. **************************************************************
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371. *************************************************************
  372. * Some attribute tests tell you what to expect and then show
  373. * you whar is there ( and maybe a little bit more). As long
  374. * as the extra attributes are system'types or can reasonably
  375. * be expected, they can be ignored.  Unfortunately, this
  376. * style of test reporting really should be read to be
  377. * verified, but could be compared automatically against
  378. * previous test results.
  379. ************************************************************
  380. % patt_tst.all.out
  381.  
  382. TESTING CREATE
  383. TST_NODE1 EXPECTS: time, verified
  384.     KIND                            => (("FILE"))
  385.     TIME                            => (HOUR=>12,MINUTE=>30,SECONDS=>49)
  386.     VERIFIED                        => (TRUE)
  387. TST_NODE2 EXPECTS: time
  388.     KIND                            => (("FILE"))
  389.     TIME                            => (HOUR=>12,MINUTE=>30,SECONDS=>49)
  390.  
  391. TESTING GET
  392. TEST PASSES: FOUND (HOUR=>12,MINUTE=>30,SECONDS=>49)
  393. TEST PASSES: FOUND (TRUE)
  394. TEST PASSES: FOUND (HOUR=>12,MINUTE=>30,SECONDS=>49)
  395.  
  396. TESTING SET
  397. TST_NODE1 EXPECTS: time=101517, verified=false
  398.     KIND                            => (("FILE"))
  399.     TIME                            => (HOUR=>10,MINUTE=>15,SECONDS=>17)
  400.     VERIFIED                        => (FALSE)
  401. TST_NODE2 EXPECTS: time=101517
  402.     KIND                            => (("FILE"))
  403.     TIME                            => (HOUR=>10,MINUTE=>15,SECONDS=>17)
  404.  
  405. TESTING DELETE
  406. ONLY VERIFIED EXPECTED: 
  407.     KIND                            => (("FILE"))
  408.     VERIFIED                        => (FALSE)
  409. NOTHING EXPECTED  : 
  410.     KIND                            => (("FILE"))
  411. NOTHING EXPECTED  : 
  412.     KIND                            => (("FILE"))
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424. *************************************************************
  425. * In this test there are only 7 tests and only the 1st 5
  426. * print out STATUS information.  Unfortunately, the test
  427. * will accept up to 15 as the number of tests to be run.
  428. * Tests 6 and 7 do not report their success and any test
  429. * higher than 8 always shows as a failure.  The test
  430. * results look much better when NONE is entered for level
  431. * and 7 is entered for # of tests.
  432. ************************************************************
  433. % node_mgmt.out
  434. Enter the highest test number to be run: 10
  435. Abort the test upon an unexpected exception? (Yes or No): no
  436. Enter the level of test output to be printed: status
  437. Do you want output redirected to a file? (yes or no): no
  438.  
  439. **** Beginning Execution of Node_Management_Tests ****
  440.     TEST_OUTPUT is set to STATUS
  441.     ABORT_ON_EXCEPTION is set to FALSE
  442.     TEST_COUNT is set to  10
  443.  
  444. Test 001: Bad Pathname raised  NAME_ERROR correctly
  445. Test 002: Node_Management.Open with Open node handle raised STATUS_ERROR correctly
  446. Test 003 Is_Equal is OK
  447. Test 004: Different Node_Management.Open interfaces are equivalant.
  448. Test 005: Node_Management.Close worked as advertised.
  449.  
  450. **** End of Node_Management_Tests ****
  451.  
  452. A total of   3 Test(s) failed.
  453. The following test(s) failed:
  454. Test number   8
  455. Test number   9
  456. Test number  10
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467. script done on Fri Mar  7 17:11:14 1986
  468. *******************************************************************
  469. ********E N D   O F   S A M P L E   T E S T   O U T P U T**********
  470. *******************************************************************
  471. --::::::::::::::
  472. --attribute_ex.a
  473. --::::::::::::::
  474. ----------------------------------------------------------------------------
  475. --NOTE!  SETUP IS DIFFICULT.  THIS TEST ASSUMES THAT THE TOP_NODE FOR THE --
  476. --       USER HAS A PATH FOR DOT(HOWELL).  ALSO MAKE SURE THAT ATTRIBUTES --
  477. --       ADDED BY THIS TEST ARE DELETED BEFORE TRYING TO RUN THE TEST     --
  478. --       AGAIN.                                                           --
  479. --                 G O O D   L U C K !                                    --
  480. ----------------------------------------------------------------------------
  481. with Cais; use Cais;
  482. with Text_Io;          use Text_Io;
  483. procedure Attribute_Ex is
  484.  
  485. use Attributes;
  486. use List_Utilities;
  487. use Node_Management;
  488. use Node_Definitions;
  489.  
  490.   Exceptions_Tested : constant := 48;
  491.   Failures   : integer := 0;
  492.   Line_Count : integer;
  493.   Expected   : string(1..3);
  494.  
  495.     Impotent_Node : Cais.Node_Type;
  496.     Closed_Node   : Cais.Node_Type;
  497.     Node          : Cais.Node_Type;
  498.     Key          : Relationship_Key(1..6) := "howell";
  499.     Relation      : Relation_Name(1..3)    := "dot";
  500.     Null_List     : List_Type;
  501.  
  502.  
  503.  
  504.   procedure Wrong_Exception(II: integer;
  505.                 SS: string) is
  506.  
  507.   begin
  508.     Failures := Failures + 1;
  509.     Line_Count := 10;
  510.     new_line;
  511.     put(
  512.          integer'image(II)   &
  513.          ":**ERROR**"     &
  514.          " Received: "       &
  515.              SS                  &
  516.              " Expected: "       &
  517.              Expected            );
  518.   end Wrong_Exception;
  519.  
  520.  
  521.   procedure No_Ex(Error: in string) is
  522.   begin
  523.     new_line;
  524.     put(Error);
  525.     Line_Count := 10;
  526.     Failures := Failures + 1;
  527.   end No_Ex;
  528.  
  529.  
  530.  
  531.  
  532.  
  533.   procedure Raise_Exception(II: integer ) is
  534.     Text    : Natural;
  535.     String1 : string(1..3);
  536.     Name1   : NameString(1..3);
  537.     Iterator      : Attribute_Iterator;
  538.     Attribute     : Attribute_Name(1..32);
  539.   begin
  540.  
  541.     case II is
  542.                             --MIL STD 5.1.3.1
  543.                               --not applicable
  544.                             --MIL STD 5.1.3.2
  545.                               --no exceptions
  546.  
  547.                             --MIL STD 5.1.3.4
  548.                               --no exceptions
  549.  
  550.                             --MIL STD 5.1.3.5
  551.                               --no exceptions
  552.  
  553.     when  1 =>                    --MIL STD 5.1.3.1
  554.         Expected := "Use";    --Use_Error Expected
  555.         Create_Node_Attribute(Node,"aaa",Null_List);
  556.         No_Ex(" 1:**ERROR**CREATE_NODE_ATT: attribute exists");
  557.     when  2 =>
  558.         Expected := "Use";    --Use_Error Expected
  559.         Create_Node_Attribute(Node,"aa_",Null_List);
  560.         No_Ex(" 2:**ERROR**CREATE_NODE_ATT: illegal attribute");
  561.     when  3 =>
  562.         Expected := "Use";    --Use_Error Expected
  563.         Create_Node_Attribute(Node,"access_method",Null_List);
  564.         No_Ex(" 3:**ERROR**CREATE_NODE_ATT: predefined attribute");
  565.     when  4 =>
  566.         Expected := "Sta";    --Status_Error Expected
  567.         Create_Node_Attribute(Closed_Node,"aaa",Null_List);
  568.         No_Ex(" 4:**ERROR**CREATE_NODE_ATT: unopened node");
  569.     when  5 =>
  570.         Expected := "Int";    --Intent_Error Expected
  571.         Create_Node_Attribute(Impotent_Node,"aaa",Null_List);
  572.         No_Ex(" 5:**ERROR**CREATE_NODE_ATT: Impotent node");
  573.     --***************************************************************
  574.     --***************************************************************
  575.     --********SECURITY_VIOLATIONS ARE NOT TESTED BECAUSE*************
  576.     --***********ACCESS_CONTROL IS NOT IMPLEMENTED*******************
  577.     --***************************************************************
  578.     --***************************************************************
  579.  
  580.     when  6 =>                    --MIL STD 5.1.3.2
  581.         Expected := "Use";    --Use_Error Expected
  582.         Create_Path_Attribute(Node,Key,Relation,"aaa",Null_List);
  583.         No_Ex(" 6:**ERROR**CREATE_Path_ATT: attribute exists");
  584.     when  7 =>
  585.         Expected := "Use";    --Use_Error Expected
  586.         Create_Path_Attribute(Node,Key,Relation,"aa_",Null_List);
  587.         No_Ex(" 7:**ERROR**CREATE_Path_ATT: illegal attribute");
  588.     when  8 =>
  589.       Expected := "Use";    --Use_Error Expected
  590.       Create_Path_Attribute(Node,Key,Relation,"access_method",Null_List);
  591.         No_Ex(" 8:**ERROR**CREATE_Path_ATT: predefined attribute");
  592.     when  9 =>
  593.         Expected := "Sta";    --Status_Error Expected
  594.         Create_Path_Attribute(Closed_Node,Key,Relation,"aaa",Null_List);
  595.         No_Ex(" 9:**ERROR**CREATE_Path_ATT: unopened Node");
  596.     when 10 =>
  597.       Expected := "Int";    --Intent_Error Expected
  598.       Create_Path_Attribute(Impotent_Node,Key,Relation,"aaa",Null_List);
  599.         No_Ex("10:**ERROR**CREATE_Path_ATT: Impotent Node");
  600.     --***************************************************************
  601.     --***************************************************************
  602.     --********SECURITY_VIOLATIONS ARE NOT TESTED BECAUSE*************
  603.     --***********ACCESS_CONTROL IS NOT IMPLEMENTED*******************
  604.     --***************************************************************
  605.     --***************************************************************
  606.  
  607.  
  608.                             
  609.     when 11 =>                    ---MIL STD 5.1.3.4
  610.         Expected := "Use";    --Use_Error Expected
  611.         Delete_Node_Attribute(Node,"xxx");
  612.         No_Ex("11:**ERROR**Delete_NODE_ATT: attribute undefined");
  613.     when 12 =>
  614.         Expected := "Use";    --Use_Error Expected
  615.         Delete_Node_Attribute(Node,"access_method");
  616.         No_Ex("12:**ERROR**Delete_NODE_ATT: predefined attribute");
  617.     when 13 =>
  618.         Expected := "Sta";    --Status_Error Expected
  619.         Delete_Node_Attribute(Closed_Node,"aaa");
  620.         No_Ex("13:**ERROR**Delete_NODE_ATT: unopened node");
  621.     when 14 =>
  622.         Expected := "Int";    --Intent_Error Expected
  623.         Delete_Node_Attribute(Impotent_Node,"aaa");
  624.         No_Ex("14:**ERROR**Delete_NODE_ATT: Impotent node");
  625.     --***************************************************************
  626.     --***************************************************************
  627.     --********SECURITY_VIOLATIONS ARE NOT TESTED BECAUSE*************
  628.     --***********ACCESS_CONTROL IS NOT IMPLEMENTED*******************
  629.     --***************************************************************
  630.     --***************************************************************
  631.  
  632.     when 15 =>                    --MIL STD 5.1.3.4
  633.         Expected := "Use";    --Use_Error Expected
  634.         Delete_Path_Attribute(Node,Key,Relation,"xxx");
  635.         No_Ex("15:**ERROR**Delete_Path_ATT: attribute undefined");
  636.     when 16 =>
  637.       Expected := "Use";    --Use_Error Expected
  638.       Delete_Path_Attribute(Node,Key,Relation,"access_method");
  639.         No_Ex("16:**ERROR**Delete_Path_ATT: predefined attribute");
  640.     when 17 =>
  641.         Expected := "Sta";    --Status_Error Expected
  642.         Delete_Path_Attribute(Closed_Node,Key,Relation,"aaa");
  643.         No_Ex("17:**ERROR**Delete_Path_ATT: unopened Node");
  644.     when 18 =>
  645.       Expected := "Int";    --Intent_Error Expected
  646.       Delete_Path_Attribute(Impotent_Node,Key,Relation,"aaa");
  647.         No_Ex("18:**ERROR**Delete_Path_ATT: Impotent Node");
  648.     --***************************************************************
  649.     --***************************************************************
  650.     --********SECURITY_VIOLATIONS ARE NOT TESTED BECAUSE*************
  651.     --***********ACCESS_CONTROL IS NOT IMPLEMENTED*******************
  652.     --***************************************************************
  653.     --***************************************************************
  654.  
  655.  
  656.     when 19 =>                    --MIL STD 5.1.3.5
  657.         Expected := "Use";    --Use_Error Expected
  658.         Set_Node_Attribute(Node,"xxx",Null_List);
  659.         No_Ex("19:**ERROR**Set_NODE_ATT: attribute undefined");
  660.     when 20 =>
  661.         Expected := "Use";    --Use_Error Expected
  662.         Set_Node_Attribute(Node,"aa_",Null_List);
  663.         No_Ex("20:**ERROR**Set_NODE_ATT: illegal attribute");
  664.     when 21 =>
  665.         Expected := "Use";    --Use_Error Expected
  666.         Set_Node_Attribute(Node,"access_method",Null_List);
  667.         No_Ex("21:**ERROR**Set_NODE_ATT: predefined attribute");
  668.     when 22 =>
  669.         Expected := "Sta";    --Status_Error Expected
  670.         Set_Node_Attribute(Closed_Node,"aaa",Null_List);
  671.         No_Ex("22:**ERROR**Set_NODE_ATT: unopened node");
  672.     when 23 =>
  673.         Expected := "Int";    --Intent_Error Expected
  674.         Set_Node_Attribute(Impotent_Node,"aaa",Null_List);
  675.         No_Ex("23:**ERROR**Set_NODE_ATT: Impotent node");
  676.     --***************************************************************
  677.     --***************************************************************
  678.     --********SECURITY_VIOLATIONS ARE NOT TESTED BECAUSE*************
  679.     --***********ACCESS_CONTROL IS NOT IMPLEMENTED*******************
  680.     --***************************************************************
  681.     --***************************************************************
  682.  
  683.     when 24 =>                    --MIL STD 5.1.3.6
  684.         Expected := "Use";    --Use_Error Expected
  685.         Set_Path_Attribute(Node,Key,Relation,"xxx",Null_List);
  686.         No_Ex("24:**ERROR**Set_Path_ATT: attribute undefined");
  687.     when 25 =>
  688.         Expected := "Use";    --Use_Error Expected
  689.         Set_Path_Attribute(Node,Key,Relation,"aa_",Null_List);
  690.         No_Ex("25:**ERROR**Set_Path_ATT: illegal attribute");
  691.     when 26 =>
  692.       Expected := "Use";    --Use_Error Expected
  693.       Set_Path_Attribute(Node,Key,Relation,"access_method",Null_List);
  694.         No_Ex("26:**ERROR**Set_Path_ATT: predefined attribute");
  695.     when 27 =>
  696.         Expected := "Sta";    --Status_Error Expected
  697.         Set_Path_Attribute(Closed_Node,Key,Relation,"aaa",Null_List);
  698.         No_Ex("27:**ERROR**Set_Path_ATT: unopened Node");
  699.     when 28 =>
  700.       Expected := "Int";    --Intent_Error Expected
  701.       Set_Path_Attribute(Impotent_Node,Key,Relation,"aaa",Null_List);
  702.         No_Ex("28:**ERROR**Set_Path_ATT: Impotent Node");
  703.     --***************************************************************
  704.     --***************************************************************
  705.     --********SECURITY_VIOLATIONS ARE NOT TESTED BECAUSE*************
  706.     --***********ACCESS_CONTROL IS NOT IMPLEMENTED*******************
  707.     --***************************************************************
  708.     --***************************************************************
  709.  
  710.  
  711.     when 29 =>                    --MIL STD 5.1.3.7
  712.         Expected := "Use";    --Use_Error Expected
  713.         Get_Node_Attribute(Node,"xxx",Null_List);
  714.         No_Ex("29:**ERROR**Get_NODE_ATT: attribute undefined");
  715.     when 30 =>
  716.         Expected := "Use";    --Use_Error Expected
  717.         Get_Node_Attribute(Node,"aa_",Null_List);
  718.         No_Ex("30:**ERROR**Get_NODE_ATT: illegal attribute");
  719.     when 31 =>
  720.         Expected := "Use";    --Use_Error Expected
  721.         Get_Node_Attribute("'current_node","aaaaaa",Null_List);
  722.         No_Ex("31:**ERROR**Get_NODE_ATT: attribute undefined");
  723.     when 32 =>
  724.         Expected := "Sta";    --Status_Error Expected
  725.         Get_Node_Attribute(Closed_Node,"aaa",Null_List);
  726.         No_Ex("32:**ERROR**Get_NODE_ATT: unopened node");
  727.     when 33 =>
  728.         Expected := "Int";    --Intent_Error Expected
  729.         Get_Node_Attribute(Impotent_Node,"aaa",Null_List);
  730.         No_Ex("33:**ERROR**Get_NODE_ATT: Impotent node");
  731.     --***************************************************************
  732.     --***************************************************************
  733.     --********SECURITY_VIOLATIONS ARE NOT TESTED BECAUSE*************
  734.     --***********ACCESS_CONTROL IS NOT IMPLEMENTED*******************
  735.     --***************************************************************
  736.     --***************************************************************
  737.  
  738.     when 34 =>                    --MIL STD 5.1.3.8
  739.         Expected := "Use";    --Use_Error Expected
  740.         Get_Path_Attribute(Node,Key,Relation,"xxx",Null_List);
  741.         No_Ex("34:**ERROR**Get_Path_ATT: attribute undefined");
  742.     when 35 =>
  743.         Expected := "Use";    --Use_Error Expected
  744.         Get_Path_Attribute(Node,Key,Relation,"aa_",Null_List);
  745.         No_Ex("35:**ERROR**Get_Path_ATT: illegal attribute");
  746.     when 36 =>
  747.       Expected := "Use";    --Use_Error Expected
  748.       Get_Path_Attribute("'current_node.howell","aaaaaa",Null_List);
  749.         No_Ex("36:**ERROR**Get_Path_ATT: attribute undefined");
  750.     when 37 =>
  751.         Expected := "Sta";    --Status_Error Expected
  752.         Get_Path_Attribute(Closed_Node,Key,Relation,"aaa",Null_List);
  753.         No_Ex("37:**ERROR**Get_Path_ATT: unopened Node");
  754.     when 38 =>
  755.       Expected := "Int";    --Intent_Error Expected
  756.       Get_Path_Attribute(Impotent_Node,Key,Relation,"aaa",Null_List);
  757.         No_Ex("38:**ERROR**Get_Path_ATT: Impotent Node");
  758.     --***************************************************************
  759.     --***************************************************************
  760.     --********SECURITY_VIOLATIONS ARE NOT TESTED BECAUSE*************
  761.     --***********ACCESS_CONTROL IS NOT IMPLEMENTED*******************
  762.     --***************************************************************
  763.     --***************************************************************
  764.  
  765.                             --MIL STD 5.1.3.9
  766.                               --only definitions
  767.  
  768.     when 39 =>                    --MIL STD 5.1.3.10
  769.         Expected := "Use";    --Use_Error Expected
  770.         Node_Attribute_Iterate(Iterator,Node,"aa_");
  771.         No_Ex("39:**ERROR**NODE_ATT_ITERATE: illegal attribute");
  772.     when 40 =>
  773.         Expected := "Use";    --Use_Error Expected
  774.         Node_Attribute_Iterate(Iterator,Node,"a__a");
  775.         No_Ex("40:**ERROR**NODE_ATT_ITERATE: illegal attribute");
  776.     when 41 =>
  777.         Expected := "Sta";    --Status_Error Expected
  778.         Node_Attribute_Iterate(Iterator,Closed_Node,"aaa");
  779.         No_Ex("41:**ERROR**NODE_ATT_ITERATE: unopened node");
  780.     when 42 =>
  781.         Expected := "Int";    --Intent_Error Expected
  782.         Node_Attribute_Iterate(Iterator,Impotent_Node,"aaa");
  783.         No_Ex("42:**ERROR**NODE_ATT_ITERATE: Impotent node");
  784.     --***************************************************************
  785.     --***************************************************************
  786.     --********SECURITY_VIOLATIONS ARE NOT TESTED BECAUSE*************
  787.     --***********ACCESS_CONTROL IS NOT IMPLEMENTED*******************
  788.     --***************************************************************
  789.     --***************************************************************
  790.  
  791.     when 43 =>                    --MIL STD 5.1.3.12
  792.         Expected := "Use";    --Use_Error Expected
  793.         Path_Attribute_Iterate(Iterator,Node,Key,Relation,"aa_");
  794.         No_Ex("44:**ERROR**Path_ATT_ITERATE: illegal attribute");
  795.     when 44 =>
  796.         Expected := "Use";    --Use_Error Expected
  797.         Path_Attribute_Iterate(Iterator,Node,Key,Relation,"aa__a");
  798.         No_Ex("44:**ERROR**Path_ATT_ITERATE: illegal attribute");
  799.     when 45 =>
  800.         Expected := "Sta";    --Status_Error Expected
  801.         Path_Attribute_Iterate(Iterator,Closed_Node,Key,Relation,"aaa");
  802.         No_Ex("45:**ERROR**Path_ATT_ITERATE: unopened Node");
  803.     when 46 =>
  804.       Expected := "Int";    --Intent_Error Expected
  805.       Path_Attribute_Iterate(Iterator,Impotent_Node,Key,Relation,"aaa");
  806.         No_Ex("46:**ERROR**Path_ATT_ITERATE: Impotent Node");
  807.  
  808.  
  809.     when 47 =>                    --MIL STD 5.1.3.12
  810.         Expected := "Use";    --Use_Error Expected
  811.         if More(Iterator) then
  812.           No_Ex("47:**ERROR**MORE: iterator undefined");
  813.         end if;
  814.  
  815.  
  816.     when 48 =>                    --MIL STD 5.1.3.13
  817.         Expected := "Use";    --Use_Error Expected
  818.         Get_Next(Iterator,Attribute,Null_List);
  819.         No_Ex("48:**ERROR**GET_NEXT: iterator undefined");
  820.  
  821.  
  822.                 --*******************************
  823.                 --ERROR, SHOULD NEVER BE EXECUTED
  824.                 --*******************************
  825.     when others =>
  826.         put_line( "******No test for: " & integer'image(II) );
  827.     end case;
  828.   end Raise_Exception;
  829.  
  830.  
  831.   begin
  832.     Open(Node,"'current_node",(1=>read_relationships,  2 => read_attributes,
  833.                    3=>write_relationships, 4 => write_attributes,
  834.              5=>append_relationships,6 => append_attributes));
  835.     Open(Impotent_Node,"'current_user",(1=>read_contents));
  836.     Create_Node_Attribute(Node,"aaa",Null_List);
  837.     Create_Path_Attribute(Node,Key,Relation,"aaa",Null_List);
  838.  
  839.     Line_Count := 10;
  840.     for I in 1..Exceptions_Tested loop
  841.     begin
  842.         if Line_Count = 10 then
  843.         new_line;
  844.         put("PASSES TEST: ");
  845.         Line_Count := 0;
  846.         end if;
  847.         Raise_Exception(I);
  848.         exception
  849.       when Node_Definitions.Use_Error     =>
  850.                 if Expected /= "Use" then
  851.                   Wrong_Exception(I,"Use_Error");
  852.                 else
  853.                   Line_Count := Line_Count+1;
  854.                   put( integer'image(I));
  855.                   put("  ");
  856.                 end if;
  857.  
  858.       when Node_Definitions.Status_Error     =>
  859.                 if Expected /= "Sta" then
  860.                   Wrong_Exception(I,"Status_Error");
  861.                 else
  862.                   Line_Count := Line_Count+1;
  863.                   put( integer'image(I));
  864.                   put("  ");
  865.                 end if;
  866.  
  867.       when Intent_Violation =>
  868.                 if Expected /= "Int" then
  869.                   Wrong_Exception(I,"Intent_Error");
  870.                 else
  871.                   Line_Count := Line_Count+1;
  872.                   put( integer'image(I));
  873.                   put("  ");
  874.                 end if;
  875.  
  876.       when Security_Violation =>
  877.                 if Expected /= "Sec" then
  878.                   Wrong_Exception(I,"Security_Violation");
  879.                 else
  880.                   Line_Count := Line_Count+1;
  881.                   put( integer'image(I));
  882.                   put("  ");
  883.                 end if;
  884.  
  885.       when Node_Definitions.Name_Error =>
  886.                 if Expected /= "Nam" then
  887.                   Wrong_Exception(I,"Name_Error");
  888.                 else
  889.                   Line_Count := Line_Count+1;
  890.                   put( integer'image(I));
  891.                   put("  ");
  892.                 end if;
  893.     end;
  894.   end loop;
  895.  
  896.   new_line;
  897.   put_line("****************************T O T A L S***********************");
  898.   put_line("Number of tests run: " & integer'image(Exceptions_Tested));
  899.   put_line("Number of failures : " & integer'image(Failures) );
  900.   put_line("**************************************************************");
  901. end Attribute_Ex;
  902. --::::::::::::::
  903. --cais_commandos.a
  904. --::::::::::::::
  905.  
  906.  
  907. with Cais; use Cais;
  908. with Character_Set; use Character_Set;
  909. with Text_IO;  use Text_IO;
  910.  
  911. procedure Cais_Commandos is
  912.  
  913.     Last    : natural;
  914.     Line    : string(1..255);
  915.  
  916.  
  917.  
  918. ----------------------------------------------------------------------
  919. --                           ADD_ATTRIBUTES
  920. --
  921. --
  922. --           CAIS tool to add attributes to a node or path
  923. --
  924. --
  925. --
  926. --
  927. --                   Ada Software Engineering Group
  928. --                       The MITRE Corporation
  929. --                          McLean, VA 22102
  930. --
  931. --
  932. --                    Wed Jun 19 13:57:23 EDT 1985
  933. --
  934. --                  (Unclassified and uncopyrighted)
  935. --
  936. ----------------------------------------------------------------------
  937.  
  938. -- This tool adds any number of user-specified attributes to given
  939. -- nodes or paths.  The tool loops through nodes/paths and attributes
  940. -- until the user enters "quit."  This tool does NOT change the values
  941. -- of existing attributes.
  942.  
  943. procedure Add_Attributes is 
  944.  
  945. use Attributes;
  946. use List_Utilities;
  947. use Node_Definitions;
  948. use Node_Management;
  949.     
  950.     type Response is (NODE, PATH, QUIT);
  951.  
  952.     Node_or_Path        : Response;
  953.     Valid_Response      : Boolean := False;
  954.     Node_Handle         : Node_Definitions.Node_Type;
  955.     NodePath_Str        : Node_Definitions.Name_String (1..80);  -- Arbitrary #
  956.     Attrib_Name         : Attributes.Attribute_Name (1..80);  -- Arbitrary #
  957.     Attrib_Val_Str      : String (1..80);  -- Arbitrary #
  958.     Last1, Last2, Last3 : Natural;
  959.     Temp_Lst_Item       : List_Utilities.List_Type;
  960.     Attrib_Val_Lst      : List_Utilities.List_Type;
  961.  
  962.     package Response_IO is new Enumeration_IO (Response);  Use Response_IO;
  963.  
  964.     procedure String_To_Simple_List (
  965.     Str      : String;
  966.     List     : in out List_Type) is
  967.  
  968.     Offset   : Integer;
  969.     Tmp_List : List_Type;
  970.     begin
  971.     Offset := Last_Non_Space (Str);
  972.     Copy (List, EMPTY_LIST);
  973.     Copy (Tmp_List, EMPTY_LIST);
  974.     String_Items.Insert (List => Tmp_List, 
  975.         List_Item => Str (Str'first .. Offset),  Position => 0);
  976.     Insert (List => List, List_Item => Tmp_List, Position => 0);
  977.     end String_To_Simple_List;
  978.  
  979.  
  980. begin
  981.     New_Line;
  982.     Put_Line ("ADDING ATTRIBUTES"); 
  983.  
  984.     -- Loop for each node or path until user enters "quit."
  985.     EACH_NODE_OR_PATH:
  986.     loop
  987.         -- Determine whether user wants to add node or path attributes.
  988.         New_Line;
  989.         while not Valid_Response loop
  990.             Put("NODE, PATH, or QUIT?  ");
  991.             GET_RESPONSE:
  992.             begin
  993.                 Get(Node_or_Path);
  994.                 Skip_Line (Standard_Input);
  995.                 exit EACH_NODE_OR_PATH when (Node_or_Path = QUIT);
  996.                 Valid_Response := True;
  997.             exception
  998.                 when Data_Error =>
  999.                     Skip_Line (Standard_Input);
  1000.                     Put(Ascii.Bel);
  1001.                     Put_Line("Valid responses are NODE, PATH, or QUIT.");
  1002.                     New_Line;
  1003.             end GET_RESPONSE;
  1004.         end loop;
  1005.         Valid_Response := False;
  1006.  
  1007.         -- Get Node or Path string.
  1008.         if Node_or_Path = NODE then
  1009.             Put ("Give NODE (or QUIT):  ");
  1010.         else 
  1011.             Put("Give PATH (or QUIT):  ");
  1012.         end if;
  1013.         Get_Line (NodePath_Str, Last1);
  1014.         exit EACH_NODE_OR_PATH when 
  1015.             (NodePath_Str(1..4) = "quit") or (NodePath_Str(1..4) = "QUIT");
  1016.  
  1017.         CAIS_EXCEPTIONS:
  1018.         begin
  1019.             -- Obtain an open node handle.
  1020.             if Node_or_Path = NODE then
  1021.                 Node_Management.Open 
  1022.                     (Node_Handle, 
  1023.                     NodePath_Str(1..Last1), 
  1024.                     (1=> Append_Attributes));
  1025.             else 
  1026.                 Node_Management.Open
  1027.                     (Node_Handle, 
  1028.                     Node_Management.Base_Path(NodePath_Str(1..Last1)), 
  1029.                     (1=> Write_Relationships));
  1030.             end if;
  1031.  
  1032.             -- Get attribute names and values repeatedly
  1033.             -- and create either node or path attributes.
  1034.             ADD_ATTRIB:
  1035.             loop
  1036.                 New_Line;
  1037.                 Put ("    Give NAME (or QUIT):  ");
  1038.                 Get_Line (Attrib_Name, Last2);
  1039.                 exit ADD_ATTRIB when 
  1040.                     (Attrib_Name(1..4) = "quit") or 
  1041.                     (Attrib_Name(1..4) = "QUIT");
  1042.  
  1043.                 Put ("    Give VALUE:           ");
  1044.                 Get_Line (Attrib_Val_Str, Last3);
  1045.                 -- Convert attribute value from string to list type.
  1046.                 List_Utilities.Copy (Attrib_Val_Lst, List_Utilities.Empty_List);
  1047.                 String_To_Simple_List(Attrib_Val_Str(1..Last3), Temp_Lst_Item);
  1048.                 List_Utilities.Insert (Attrib_Val_Lst, Temp_Lst_Item,
  1049.                     Attrib_Name(1..Last2), Position => 0);
  1050.  
  1051.                 -- Now have all parameters to create an attribute.
  1052.                 if Node_or_Path = NODE then
  1053.                     Attributes.Create_Node_Attribute
  1054.                         (Node_Handle, Attrib_Name(1..Last2), Attrib_Val_Lst);
  1055.                 else 
  1056.                     Attributes.Create_Path_Attribute
  1057.                         (Node_Handle,
  1058.                         Node_Management.Last_Key(NodePath_Str(1..Last1)),
  1059.                         Node_Management.Last_Relation(NodePath_Str(1..Last1)),
  1060.                         Attrib_Name(1..Last2), Attrib_Val_Lst);
  1061.                 end if; 
  1062.             end loop ADD_ATTRIB;
  1063.  
  1064.         exception
  1065.             when Node_Definitions.Status_Error => 
  1066.                 New_Line;
  1067.                 if Node_Management.Is_Open(Node_Handle) then
  1068.                     Put_Line("*** Status error raised while creating   ***");
  1069.                     Put_Line("*** attributes; node handle is not open. ***");
  1070.                 else
  1071.                     Put_Line("*** Status error raised while opening ***");
  1072.                     Put_Line("*** a node handle; node handle is     ***");
  1073.                     Put_Line("*** already open or base is not an    ***");
  1074.                     Put_Line("*** open node handle.                 ***");
  1075.                 end if;
  1076.  
  1077.             when Node_Definitions.Use_Error =>
  1078.                 New_Line;
  1079.                 if Node_Management.Is_Open(Node_Handle) then
  1080.                     Put_Line("*** Use error raised while creating      ***");
  1081.                     Put_Line("*** attributes; attribute is predefined, ***");
  1082.                     Put_Line("*** already exists, or is syntactically  ***");
  1083.                     Put_Line("*** illegal.                             ***");
  1084.                     New_Line;
  1085.                     Put_Line("Note:  Use Change_Attributes tool if ");
  1086.                     Put_Line("       attribute already exists.");
  1087.                 else
  1088.                     Put_Line("*** Use error raised while opening  ***");
  1089.                     Put_Line("*** a node handle; specified intent ***");
  1090.                     Put_Line("*** is an empty array.              ***");
  1091.                 end if;
  1092.  
  1093.             when Node_Definitions.Intent_Violation =>
  1094.                 New_Line;
  1095.                 if Node_Management.Is_Open(Node_Handle) then
  1096.                     Put_Line("*** Intent violation raised while creating  ***");
  1097.                     Put_Line("*** attributes; node not opened with the    ***");
  1098.                     Put_Line("*** intent to append attributes or          ***");
  1099.                     Put_Line("*** write relationships.                    ***");
  1100.                 else
  1101.                     Put_Line("*** Intent violation raised while opening ***");
  1102.                     Put_Line("*** a node handle; base is not open with  ***");
  1103.                     Put_Line("*** the intent to read relationships.     ***");
  1104.                 end if;
  1105.  
  1106.             when Node_Definitions.Name_Error =>
  1107.                 New_Line;
  1108.                 Put_Line("*** Name error raised while opening a node    ***");
  1109.                 Put_Line("*** handle; pathname is syntactically illegal ***");
  1110.                 Put_Line("*** or some node in path is unobtainable,     ***");
  1111.                 Put_Line("*** inaccessible or non-existent.             ***");
  1112.                 New_Line;
  1113.  
  1114.             when Node_Definitions.Security_Violation =>
  1115.                 New_Line;
  1116.                 if Node_Management.Is_Open(Node_Handle) then
  1117.                     Put_Line("*** Security violation raised while ***");
  1118.                     Put_Line("*** creating attributes.            ***");
  1119.                 else
  1120.                     Put_Line("*** Security violation raised while ***");
  1121.                     Put_Line("*** opening a node handle.          ***");
  1122.                 end if;
  1123.  
  1124.             when Node_Definitions.Lock_Error |
  1125.                 Node_Definitions.Access_Violation =>
  1126.                     New_Line;
  1127.                     Put_Line("*** Lock error or access violation      ***");
  1128.                     Put_Line("*** raised while opening a node handle. ***");
  1129.         end CAIS_EXCEPTIONS;
  1130.  
  1131.         Node_Management.Close(Node_Handle);
  1132.  
  1133.     end loop EACH_NODE_OR_PATH;
  1134.  
  1135.     New_Line;
  1136.     Put_Line ("COMPLETED.");
  1137.     New_Line;
  1138.  
  1139. exception
  1140.     when others =>
  1141.         New_Line;
  1142.         Put_Line ("*** Unhandled exception ***");
  1143.         New_Line;
  1144.         raise;
  1145. end Add_Attributes;     
  1146.  
  1147.  
  1148.  
  1149. ----------------------------------------------------------------------
  1150. --                        CHANGE_ATTRIBUTES
  1151. --
  1152. --
  1153. --           CAIS tool to change attributes of a node or path
  1154. --
  1155. --
  1156. --
  1157. --
  1158. --                   Ada Software Engineering Group
  1159. --                       The MITRE Corporation
  1160. --                          McLean, VA 22102
  1161. --
  1162. --
  1163. --                    Wed Jul 10 15:20:23 EDT 1985
  1164. --
  1165. --                  (Unclassified and uncopyrighted)
  1166. --
  1167. ----------------------------------------------------------------------
  1168.  
  1169. -- This tool changes any number of user-specified attributes of given
  1170. -- nodes or paths.  The tool loops through nodes/paths and attributes
  1171. -- until the user enters "quit."
  1172.  
  1173. procedure Change_Attributes is 
  1174. use Attributes;
  1175. use List_Utilities;
  1176. use Node_Definitions;
  1177. use Node_Management;
  1178.     
  1179.     type Response is (NODE, PATH, QUIT);
  1180.  
  1181.     Node_or_Path        : Response;
  1182.     Valid_Response      : Boolean := False;
  1183.     Node_Handle         : Node_Definitions.Node_Type;
  1184.     NodePath_Str        : Node_Definitions.Name_String (1..80);  -- Arbitrary #
  1185.     Attrib_Name         : Attributes.Attribute_Name (1..80);  -- Arbitrary #
  1186.     Attrib_Val_Str      : String (1..80);  -- Arbitrary #
  1187.     Last1, Last2, Last3 : Natural;
  1188.     Temp_Lst_Item       : List_Utilities.List_Type;
  1189.     Attrib_Val_Lst      : List_Utilities.List_Type;
  1190.  
  1191.     package Response_IO is new Enumeration_IO (Response);  Use Response_IO;
  1192.  
  1193.     procedure String_To_Simple_List (
  1194.     Str      : String;
  1195.     List     : in out List_Type) is
  1196.  
  1197.     Offset   : Integer;
  1198.     Tmp_List : List_Type;
  1199.     begin
  1200.     Offset := Last_Non_Space (Str);
  1201.     Copy (List, EMPTY_LIST);
  1202.     Copy (Tmp_List, EMPTY_LIST);
  1203.     String_Items.Insert (List => Tmp_List, 
  1204.         List_Item => Str (Str'first .. Offset),  Position => 0);
  1205.     Insert (List => List, List_Item => Tmp_List, Position => 0);
  1206.     end String_To_Simple_List;
  1207.  
  1208.  
  1209. begin
  1210.     New_Line;
  1211.     Put_Line ("CHANGING ATTRIBUTES"); 
  1212.  
  1213.     -- Loop for each node or path until user enters "quit."
  1214.     EACH_NODE_OR_PATH:
  1215.     loop
  1216.         -- Determine whether user wants to add node or path attributes.
  1217.         New_Line;
  1218.         while not Valid_Response loop
  1219.             Put("NODE, PATH, or QUIT?  ");
  1220.             GET_RESPONSE:
  1221.             begin
  1222.                 Get(Node_or_Path);
  1223.                 Skip_Line (Standard_Input);
  1224.                 exit EACH_NODE_OR_PATH when (Node_or_Path = QUIT);
  1225.                 Valid_Response := True;
  1226.             exception
  1227.                 when Data_Error =>
  1228.                     Skip_Line (Standard_Input);
  1229.                     Put(Ascii.Bel);
  1230.                     Put_Line("Valid responses are NODE, PATH, or QUIT.");
  1231.                     New_Line;
  1232.             end GET_RESPONSE;
  1233.         end loop;
  1234.         Valid_Response := False;
  1235.  
  1236.         -- Get Node or Path string.
  1237.         if Node_or_Path = NODE then
  1238.             Put ("Give NODE (or QUIT):  ");
  1239.         else 
  1240.             Put("Give PATH (or QUIT):  ");
  1241.         end if;
  1242.         Get_Line (NodePath_Str, Last1);
  1243.         exit EACH_NODE_OR_PATH when 
  1244.             (NodePath_Str(1..4) = "quit") or (NodePath_Str(1..4) = "QUIT");
  1245.  
  1246.         CAIS_EXCEPTIONS:
  1247.         begin
  1248.             -- Obtain an open node handle.
  1249.             if Node_or_Path = NODE then
  1250.                 Node_Management.Open 
  1251.                     (Node_Handle, 
  1252.                     NodePath_Str(1..Last1), 
  1253.                     (1=> Write_Attributes));
  1254.             else 
  1255.                 Node_Management.Open
  1256.                     (Node_Handle, 
  1257.                     Node_Management.Base_Path(NodePath_Str(1..Last1)), 
  1258.                     (1=> Write_Relationships));
  1259.             end if;
  1260.  
  1261.             -- Get attribute names and values repeatedly
  1262.             -- and set either node or path attributes.
  1263.             CHG_ATTRIB:
  1264.             loop
  1265.                 New_Line;
  1266.                 Put ("    Give NAME (or QUIT):  ");
  1267.                 Get_Line (Attrib_Name, Last2);
  1268.                 exit CHG_ATTRIB when 
  1269.                     (Attrib_Name(1..4) = "quit") or 
  1270.                     (Attrib_Name(1..4) = "QUIT");
  1271.  
  1272.                 Put ("    Give VALUE:           ");
  1273.                 Get_Line (Attrib_Val_Str, Last3);
  1274.                 -- Convert attribute value from string to list type.
  1275.                 List_Utilities.Copy (Attrib_Val_Lst, List_Utilities.Empty_List);
  1276.                 String_To_Simple_List(Attrib_Val_Str(1..Last3), Temp_Lst_Item);
  1277.                 List_Utilities.Insert (Attrib_Val_Lst, Temp_Lst_Item,
  1278.                     Attrib_Name(1..Last2), Position => 0);
  1279.  
  1280.                 -- Now have all parameters to set an attribute.
  1281.                 if Node_or_Path = NODE then
  1282.                     Attributes.Set_Node_Attribute
  1283.                         (Node_Handle, Attrib_Name(1..Last2), Attrib_Val_Lst);
  1284.                 else 
  1285.                     Attributes.Set_Path_Attribute
  1286.                         (Node_Handle,
  1287.                         Node_Management.Last_Key(NodePath_Str(1..Last1)),
  1288.                         Node_Management.Last_Relation(NodePath_Str(1..Last1)),
  1289.                         Attrib_Name(1..Last2), Attrib_Val_Lst);
  1290.                 end if; 
  1291.             end loop CHG_ATTRIB;
  1292.  
  1293.         exception
  1294.             when Node_Definitions.Status_Error => 
  1295.                 New_Line;
  1296.                 if Node_Management.Is_Open(Node_Handle) then
  1297.                     Put_Line("*** Status error raised while setting    ***");
  1298.                     Put_Line("*** attributes; node handle is not open. ***");
  1299.                 else
  1300.                     Put_Line("*** Status error raised while opening ***");
  1301.                     Put_Line("*** a node handle; node handle is     ***");
  1302.                     Put_Line("*** already open or base is not an    ***");
  1303.                     Put_Line("*** open node handle.                 ***");
  1304.                 end if;
  1305.  
  1306.             when Node_Definitions.Use_Error =>
  1307.                 New_Line;
  1308.                 if Node_Management.Is_Open(Node_Handle) then
  1309.                     Put_Line("*** Use error raised while setting          ***");
  1310.                     Put_Line("*** attributes; attribute does not exist    ***");
  1311.                     Put_Line("*** or is predefined and cannot be modified ***");
  1312.                     Put_Line("*** by user.                                ***");
  1313.                     New_Line;
  1314.                 else
  1315.                     Put_Line("*** Use error raised while opening  ***");
  1316.                     Put_Line("*** a node handle; specified intent ***");
  1317.                     Put_Line("*** is an empty array.              ***");
  1318.                 end if;
  1319.  
  1320.             when Node_Definitions.Intent_Violation =>
  1321.                 New_Line;
  1322.                 if Node_Management.Is_Open(Node_Handle) then
  1323.                     Put_Line("*** Intent violation raised while setting   ***");
  1324.                     Put_Line("*** attributes; node not opened with the    ***");
  1325.                     Put_Line("*** intent to write attributes or           ***");
  1326.                     Put_Line("*** relationships.                          ***");
  1327.                 else
  1328.                     Put_Line("*** Intent violation raised while opening ***");
  1329.                     Put_Line("*** a node handle; base is not open with  ***");
  1330.                     Put_Line("*** the intent to read relationships.     ***");
  1331.                 end if;
  1332.  
  1333.             when Node_Definitions.Name_Error =>
  1334.                 New_Line;
  1335.                 Put_Line("*** Name error raised while opening a node    ***");
  1336.                 Put_Line("*** handle; pathname is syntactically illegal ***");
  1337.                 Put_Line("*** or some node in path is unobtainable,     ***");
  1338.                 Put_Line("*** inaccessible or non-existent.             ***");
  1339.  
  1340.             when Node_Definitions.Security_Violation =>
  1341.                 New_Line;
  1342.                 if Node_Management.Is_Open(Node_Handle) then
  1343.                     Put_Line("*** Security violation raised while ***");
  1344.                     Put_Line("*** setting attributes.             ***");
  1345.                 else
  1346.                     Put_Line("*** Security violation raised while ***");
  1347.                     Put_Line("*** opening a node handle.          ***");
  1348.                 end if;
  1349.  
  1350.             when Node_Definitions.Lock_Error |
  1351.                 Node_Definitions.Access_Violation =>
  1352.                     New_Line;
  1353.                     Put_Line("*** Lock error or access violation      ***");
  1354.                     Put_Line("*** raised while opening a node handle. ***");
  1355.         end CAIS_EXCEPTIONS;
  1356.  
  1357.         Node_Management.Close(Node_Handle);
  1358.  
  1359.     end loop EACH_NODE_OR_PATH;
  1360.  
  1361.     New_Line;
  1362.     Put_Line ("COMPLETED.");
  1363.     New_Line;
  1364.  
  1365. exception
  1366.     when others =>
  1367.         New_Line;
  1368.         Put_Line ("*** Unhandled exception ***");
  1369.         New_Line;
  1370.         raise;
  1371. end Change_Attributes;     
  1372.  
  1373.  
  1374.  
  1375.  
  1376. -----------------------------------------------------------------
  1377. --                      Create_file_nodes 
  1378. --
  1379. --       This procedure creates the primary relationship to
  1380. --       a file node identified by NODE.  
  1381. --
  1382. --
  1383. --
  1384. --        Ada Software Engineering Group
  1385. --             The MITRE Corporation
  1386. --              McLean, VA  22102
  1387. --
  1388. --        Mon Jul 29 16:02:45 EDT 1985
  1389. --
  1390. --             (Unclassified and Uncopyrighted)
  1391. --
  1392. -----------------------------------------------------------------
  1393. procedure Create_File_Nodes is
  1394.  
  1395. use Node_Definitions;
  1396. use Node_Management;
  1397. use List_Utilities; 
  1398.  
  1399.     Node                     : Node_Definitions.Node_Type;
  1400.     File             : Io_Definitions.File_Type;
  1401.     Node_Str                 : Node_Definitions.Name_String(1..100);
  1402.     Intents                  : Node_Definitions.Intention(1..2)
  1403.                                  := (1 => Exclusive_Write,
  1404.                      2 => Read_Relationships);
  1405.     Last                     : Natural;
  1406.  
  1407.     Attr_String             : Name_String(1..Pragmatics.Max_Name_String);
  1408.     Last_Attr             : Natural;
  1409.     Attr_List             : List_Type;
  1410.  
  1411. begin
  1412.     New_Line;
  1413.     Put_Line ("CREATING FILE NODES");
  1414.  
  1415.     GET_NODE:
  1416.     loop
  1417.         New_Line;
  1418.         Put ("Give NODE (or ! to quit) =>");
  1419.         Get_Line (Node_Str, Last);
  1420.  
  1421.         exit GET_NODE when (Last = 1 and Node_Str(1) = '!');
  1422.  
  1423.  
  1424.     Put_Line ("Enter Node Attributes (One Line, <= 256 characters);");
  1425.     Put_Line ("  Include File_Kind and Access_Method to change defaults.");
  1426.     Put ("> ");
  1427.     Get_Line (Attr_String, Last_Attr);
  1428.     To_List (Attr_String(1..Last_Attr), Attr_List);
  1429.  
  1430.  
  1431.         CAIS_CALLS:
  1432.         begin
  1433.             Cais.Text_Io.Create (File, Node_Str(1..Last), 
  1434.                     Attributes => Attr_List);
  1435.         Cais.Text_Io.Close (File);
  1436. exception
  1437.             when Node_Definitions.Name_Error =>
  1438.                 New_Line;
  1439.                 Put_Line("*** Node is inaccessible ***");
  1440.                 New_Line;
  1441.             when Node_Definitions.Status_Error =>
  1442.                 New_Line;
  1443.                 Put_Line("*** Open status is incorrect ***");
  1444.                 New_Line;           
  1445.             when Security_Violation =>
  1446.                 New_Line;
  1447.                 Put_Line("*** SECURITY VIOLATION ***");
  1448.                 New_Line;
  1449.         end CAIS_CALLS;
  1450.     end loop GET_NODE;
  1451.  
  1452.     New_Line;
  1453.     Put_Line("CREATE_FILE_NODES COMPLETE");
  1454.     New_Line;
  1455.  
  1456. exception
  1457.     when others =>
  1458.         New_Line;
  1459.         Put_Line("*** UNHANDLED EXCEPTION ***");
  1460.         New_Line;
  1461.         raise;
  1462. end Create_File_Nodes;
  1463.  
  1464.  
  1465.  
  1466.  
  1467. ----------------------------------------------------------------------
  1468. --                         CREATE_STRUC_NODES
  1469. --
  1470. --
  1471. --               CAIS tool to create structural nodes
  1472. --
  1473. --
  1474. --
  1475. --
  1476. --                  Ada Software Engineering Group
  1477. --                      The MITRE Corporation
  1478. --                         McLean, VA 22102
  1479. --
  1480. --
  1481. --                   Fri Jun 21 14:27:35 EDT 1985
  1482. --
  1483. --                 (Unclassified and uncopyrighted)
  1484. --
  1485. ----------------------------------------------------------------------
  1486.  
  1487. -- This tool creates structural nodes as specified
  1488. -- by the user.  Any number of nodes can be created until the user
  1489. -- enters "quit."  This tool does not set attributes, access control,
  1490. -- or level.
  1491.  
  1492. procedure Create_Struc_Nodes is 
  1493.  
  1494. use Node_Definitions;
  1495. use Node_Management;
  1496. use Structural_Nodes;
  1497.  
  1498.     Path_Str             : Node_Definitions.Name_String (1..80); -- Arbitrary #
  1499.     Last                 : Natural;
  1500.  
  1501. begin
  1502.     New_Line;
  1503.     Put_Line ("CREATING STRUCTURAL NODES");
  1504.  
  1505.     -- Loop for each node until user enters "quit."
  1506.     EACH_NODE:
  1507.     loop
  1508.  
  1509.         -- Get node's pathname string.
  1510.         Put("Give PATH (or QUIT):  ");
  1511.         Get_Line (Path_Str, Last);
  1512.         New_Line;
  1513.         exit EACH_NODE when 
  1514.             (Path_Str(1..4) = "quit") or (Path_Str(1..4) = "QUIT");
  1515.  
  1516.         CAIS_EXCEPTIONS:
  1517.         begin
  1518.             Structural_Nodes.Create_Node(Path_Str(1..Last));
  1519.         exception
  1520.             when Node_Definitions.Status_Error => 
  1521.                 New_Line;
  1522.                 Put_Line("*** Status error raised while creating ***");
  1523.                 Put_Line("*** a node; base is not open or node   ***");
  1524.                 Put_Line("*** is already open.                   ***");
  1525.  
  1526.             when Node_Definitions.Use_Error =>
  1527.                 New_Line;
  1528.                 Put_Line("*** Use error raised while creating    ***");
  1529.                 Put_Line("*** a node; parameters are illegal,    ***");
  1530.                 Put_Line("*** attributes are predefined, or      ***");
  1531.                 Put_Line("*** relation cannot be created by user.***");
  1532.  
  1533.             when Node_Definitions.Intent_Violation =>
  1534.                 New_Line;
  1535.                 Put_Line("*** Intent violation raised while  ***");
  1536.                 Put_Line("*** creating a node; base not open ***");
  1537.                 Put_Line("*** with intent to append          ***");
  1538.                 Put_Line("*** relationships.                 ***");
  1539.  
  1540.             when Node_Definitions.Name_Error =>
  1541.                 New_Line;
  1542.                 Put_Line("*** Name error raised while creating    ***");
  1543.                 Put_Line("*** a node; node already exists, is     ***");
  1544.                 Put_Line("*** syntactically illegal as specified, ***");
  1545.                 Put_Line("*** or is unobtainable due to access    ***");
  1546.                 Put_Line("*** control.                            ***");
  1547.  
  1548.             when Node_Definitions.Security_Violation =>
  1549.                 New_Line;
  1550.                 Put_Line("*** Security violation raised while ***");
  1551.                 Put_Line("*** creating a node.                ***");
  1552.         end CAIS_EXCEPTIONS;
  1553.  
  1554.     end loop EACH_NODE;
  1555.    
  1556.     New_Line;
  1557.     Put_Line ("COMPLETED.");
  1558.     New_Line;
  1559.  
  1560. exception
  1561.     when others =>
  1562.         New_Line;
  1563.         Put_Line ("*** Unhandled exception ***");
  1564.         New_Line;
  1565.         raise;
  1566. end Create_Struc_Nodes;
  1567.  
  1568.  
  1569.  
  1570.  
  1571. -----------------------------------------------------------------------------
  1572. --                          DELETE_ATTRIBUTES
  1573. --  
  1574. --   
  1575. --        CAIS tool to delete selected attributes of a node or path.
  1576. --
  1577. -- 
  1578. --   
  1579. -- 
  1580. --                   Ada Software Engineering Group
  1581. --                       The MITRE Corporation
  1582. --                          McLean, VA  22102
  1583. -- 
  1584. -- 
  1585. --                   Wed Jun 19 15:44:40 EDT 1985    
  1586. -- 
  1587. --                 (Unclassified and Uncopyrighted)
  1588. --  
  1589. --
  1590. ------------------------------------------------------------------------------
  1591. procedure Delete_Attributes is
  1592.  
  1593. use Attributes;
  1594. use Node_Definitions;
  1595. use Node_Management;
  1596.  
  1597.     type Response is (NODE, PATH, QUIT);
  1598.  
  1599.     Node_or_Path       : Response;
  1600.     Valid_Response     : Boolean := False;
  1601.     Node_Handle        : Node_Definitions.Node_Type;
  1602.     NodePath_Str       : Node_Definitions.Name_String(1..80);  --Arbitrary
  1603.     Attrib_Name        : Attributes.Attribute_Name(1..80);  --Arbitrary
  1604.     Last1, Last2       : Natural;
  1605.       
  1606.     package Response_IO is new Enumeration_IO(Response);  Use Response_IO;
  1607.  
  1608. begin
  1609.     New_Line;
  1610.     Put_Line("DELETING ATTRIBUTES");
  1611.  
  1612.     -- Loop  for each node or path until user enters "quit."
  1613.     EACH_NODE_OR_PATH:
  1614.     loop
  1615.         -- Determine whether user wants to delete node or path attributes.
  1616.         New_Line;
  1617.         while not Valid_Response loop
  1618.             Put("NODE, PATH, or QUIT?  ");
  1619.             GET_RESPONSE:
  1620.             begin
  1621.                 Get(Node_or_Path);
  1622.                 Skip_Line(Standard_Input);
  1623.                 exit EACH_NODE_OR_PATH when (Node_or_Path = QUIT);
  1624.                 Valid_Response := True;
  1625.             exception
  1626.                 when Data_Error => 
  1627.                     Skip_Line(Standard_Input);
  1628.                     Put(Ascii.Bel);
  1629.                     Put_Line("Valid responses are NODE, PATH, or QUIT");
  1630.             New_Line;
  1631.             end GET_RESPONSE;
  1632.         end loop;
  1633.         Valid_Response := False;
  1634.         
  1635.         -- Get node or path string.
  1636.         if Node_or_Path = NODE then
  1637.             Put("Give NODE (or QUIT):  ");
  1638.         else
  1639.             Put("Give PATH (or QUIT):  ");
  1640.         end if;
  1641.         Get_Line(NodePath_Str, Last1);
  1642.         exit EACH_NODE_OR_PATH when 
  1643.             (NodePath_Str(1..4) = "quit") or (NodePath_Str(1..4) = "QUIT");
  1644.         New_Line;
  1645.  
  1646.         CAIS_EXCEPTIONS:
  1647.         begin
  1648.             -- Obtain an open node handle.
  1649.             if Node_or_Path = NODE then
  1650.                 Node_Management.Open
  1651.                     (Node_Handle, 
  1652.                     NodePath_Str(1..Last1), 
  1653.                     (1=> Write_Attributes));
  1654.             else
  1655.                 Node_Management.Open
  1656.                     (Node_Handle, 
  1657.                     Node_Management.Base_Path(NodePath_Str(1..Last1)),
  1658.                     (1=> Write_Relationships));
  1659.             end if;
  1660.  
  1661.             -- Loop through attributes to be deleted.
  1662.             DEL_ATTRIB:
  1663.             loop 
  1664.                 Put("    Give NAME (or QUIT):  ");
  1665.                 Get_Line(Attrib_Name, Last2);
  1666.                 exit DEL_ATTRIB when 
  1667.                     (Attrib_Name(1..4) = "quit") or 
  1668.                     (Attrib_Name(1..4) = "QUIT");
  1669.  
  1670.                 if Node_or_Path = NODE then
  1671.                     Attributes.Delete_Node_Attribute
  1672.                         (Node_Handle, Attrib_Name(1..Last2));
  1673.                 else
  1674.                     Attributes.Delete_Path_Attribute
  1675.                         (Node_Handle,
  1676.                         Last_Key(NodePath_Str(1..Last1)), 
  1677.                         Last_Relation(NodePath_Str(1..Last1)), 
  1678.                         Attrib_Name(1..Last2));
  1679.                 end if;
  1680.             end loop DEL_ATTRIB;
  1681.  
  1682.  
  1683.         exception
  1684.             when Node_Definitions.Status_Error => 
  1685.                 New_Line;
  1686.                 if Node_Management.Is_Open(Node_Handle) then
  1687.                     Put_Line("*** Status error raised while deleting   ***");
  1688.                     Put_Line("*** attributes; node handle is not open. ***");
  1689.                 else
  1690.                     Put_Line("*** Status error raised while opening ***");
  1691.                     Put_Line("*** a node handle; node handle is     ***");
  1692.                     Put_Line("*** already open or base is not an    ***");
  1693.                     Put_Line("*** open node handle.                 ***");
  1694.                 end if;
  1695.                 New_Line;
  1696.  
  1697.             when Node_Definitions.Use_Error =>
  1698.                 New_Line;
  1699.                 if Node_Management.Is_Open(Node_Handle) then
  1700.                     Put_Line("*** Use error raised while deleting      ***");
  1701.                     Put_Line("*** attributes; attribute does not exist ***");
  1702.                     Put_Line("*** or is predefined and can not be      ***");
  1703.                     Put_Line("*** modified by user.                    ***");
  1704.                     New_Line;
  1705.                 else
  1706.                     Put_Line("*** Use error raised while opening  ***");
  1707.                     Put_Line("*** a node handle; specified intent ***");
  1708.                     Put_Line("*** is an empty array.              ***");
  1709.                 end if;
  1710.                 New_Line;
  1711.  
  1712.             when Node_Definitions.Intent_Violation =>
  1713.                 New_Line;
  1714.                 if Node_Management.Is_Open(Node_Handle) then
  1715.                     Put_Line("*** Intent violation raised while deleting  ***");
  1716.                     Put_Line("*** attributes; node not opened with the    ***");
  1717.                     Put_Line("*** intent to write attributes or           ***");
  1718.                     Put_Line("*** relationships.                          ***");
  1719.                 else
  1720.                     Put_Line("*** Intent violation raised while opening ***");
  1721.                     Put_Line("*** a node handle; base is not open with  ***");
  1722.                     Put_Line("*** the intent to read relationships.     ***");
  1723.                 end if;
  1724.                 New_Line;
  1725.  
  1726.             when Node_Definitions.Name_Error =>
  1727.                 New_Line;
  1728.                 Put_Line("*** Name error raised while opening a node    ***");
  1729.                 Put_Line("*** handle; pathname is syntactically illegal ***");
  1730.                 Put_Line("*** or some node in path is unobtainable,     ***");
  1731.                 Put_Line("*** inaccessible or non-existent.             ***");
  1732.                 New_Line;
  1733.  
  1734.             when Node_Definitions.Security_Violation =>
  1735.                 New_Line;
  1736.                 if Node_Management.Is_Open(Node_Handle) then
  1737.                     Put_Line("*** Security violation raised while ***");
  1738.                     Put_Line("*** deleting attributes.            ***");
  1739.                 else
  1740.                     Put_Line("*** Security violation raised while ***");
  1741.                     Put_Line("*** opening a node handle.          ***");
  1742.                 end if;
  1743.                 New_Line;
  1744.  
  1745.             when Node_Definitions.Lock_Error |
  1746.                 Node_Definitions.Access_Violation =>
  1747.                     New_Line;
  1748.                     Put_Line("*** Lock error or access violation      ***");
  1749.                     Put_Line("*** raised while opening a node handle. ***");
  1750.                     New_line;
  1751.         end CAIS_EXCEPTIONS;
  1752.  
  1753.         Node_Management.Close(Node_Handle);
  1754.  
  1755.     end loop EACH_NODE_OR_PATH; 
  1756.  
  1757.     New_Line;
  1758.     Put_Line("COMPLETED.");
  1759.     New_Line;
  1760.  
  1761. exception
  1762.     when others =>
  1763.         New_Line;
  1764.         Put_Line("*** Unhandled exception ***");
  1765.         raise;
  1766.  
  1767. end Delete_Attributes;
  1768.  
  1769.  
  1770.  
  1771. ----------------------------------------------------------------------
  1772. --                         DELETE_NODES
  1773. --
  1774. --
  1775. --             CAIS tool to delete structural or file nodes
  1776. --
  1777. --
  1778. --
  1779. --
  1780. --                  Ada Software Engineering Group
  1781. --                      The MITRE Corporation
  1782. --                         McLean, VA 22102
  1783. --
  1784. --
  1785. --                   Fri Jun 21 14:27:35 EDT 1985
  1786. --
  1787. --                 (Unclassified and uncopyrighted)
  1788. --
  1789. ----------------------------------------------------------------------
  1790.  
  1791. -- This tool deletes either structural or file nodes as specified
  1792. -- by the user.  Any number of nodes can be deleted until the user
  1793. -- enters "quit."  
  1794.  
  1795. procedure Delete_Nodes is 
  1796.  
  1797. use Node_Definitions;
  1798. use Node_Management;
  1799.  
  1800.     Node     : Node_Definitions.Node_Type;
  1801.     Node_Str : Node_Definitions.Name_String (1..80); -- Arbitrary #
  1802.     Last     : Natural;
  1803.  
  1804. begin
  1805.     New_Line;
  1806.     Put_Line ("DELETING NODES");
  1807.     New_Line;
  1808.  
  1809.     -- Loop for each node until user enters "quit."
  1810.     EACH_NODE:
  1811.     loop
  1812.         -- Get node string.
  1813.         Put("Give NODE (or QUIT):  ");
  1814.         Get_Line (Node_Str, Last);
  1815.         New_Line;
  1816.         exit EACH_NODE when 
  1817.             (Node_Str(1..4) = "quit") or (Node_Str(1..4) = "QUIT");
  1818.  
  1819.         CAIS_EXCEPTIONS:
  1820.         begin
  1821.             Node_Management.Open
  1822.             (Node, Node_Str(1..Last), 
  1823.             (Exclusive_Write, Read_Relationships));
  1824.  
  1825.             Node_Management.Delete_Node(Node);
  1826.             -- Do not have to distinguish between a structural vs. 
  1827.             -- file node since either can be deleted this way.  Do 
  1828.             -- not have an open file handle so do not need to use 
  1829.             -- Cais_Text_IO.Delete.
  1830.         exception
  1831.             when Node_Definitions.Name_Error =>
  1832.                 New_Line;
  1833.                 Put_Line("*** Name error raised while deleting ***");
  1834.                 Put_Line("*** a node; parent of node is        ***");
  1835.                 Put_Line("*** inaccessible.                    ***");
  1836.  
  1837.             when Node_Definitions.Status_Error => 
  1838.                 New_Line;
  1839.                 Put_Line("*** Status error raised while deleting ***");
  1840.                 Put_Line("*** a node; node handle is not open.   ***");
  1841.  
  1842.             when Node_Definitions.Use_Error =>
  1843.                 New_Line;
  1844.                 Put_Line("*** Use error raised while deleting    ***");
  1845.                 Put_Line("*** a node; primary relationships      ***");
  1846.                 Put_Line("*** emanate from node.                 ***");
  1847.  
  1848.             when Node_Definitions.Intent_Violation =>
  1849.                 New_Line;
  1850.                 Put_Line("*** Intent violation raised while   ***");
  1851.                 Put_Line("*** deleting a node; node not open  ***");
  1852.                 Put_Line("*** with intent exclusive write and ***");
  1853.                 Put_Line("*** read relationships.             ***");
  1854.  
  1855.             when Node_Definitions.Lock_Error =>
  1856.                 New_Line;
  1857.                 Put_Line("*** Lock error raised while deleting ***");
  1858.                 Put_Line("*** a node.                          ***");
  1859.  
  1860.             when Node_Definitions.Security_Violation =>
  1861.                 New_Line;
  1862.                 Put_Line("*** Security violation raised while ***");
  1863.                 Put_Line("*** deleting a node.                ***");
  1864.  
  1865.             when Node_Definitions.Access_Violation =>
  1866.                 New_Line;
  1867.                 Put_Line("*** Access violation raised while ***");
  1868.                 Put_Line("*** deleting a node.              ***");
  1869.         end CAIS_EXCEPTIONS;
  1870.  
  1871.     end loop EACH_NODE;
  1872.    
  1873.     New_Line;
  1874.     Put_Line ("COMPLETED.");
  1875.     New_Line;
  1876.  
  1877. exception
  1878.     when others =>
  1879.         New_Line;
  1880.         Put_Line ("*** Unhandled exception ***");
  1881.         New_Line;
  1882.         raise;
  1883. end Delete_Nodes;
  1884.  
  1885.  
  1886.  
  1887.  
  1888. ----------------------------------------------------------------------
  1889. --                            DIRECTORY
  1890. --
  1891. --
  1892. --            CAIS tool to list all targets of relationships
  1893. --                     emanating from a given node.
  1894. --
  1895. --
  1896. --
  1897. --
  1898. --                  Ada Software Engineering Group
  1899. --                      The MITRE Corporation
  1900. --                         McLean, VA 22102
  1901. --
  1902. --
  1903. --                   Tue Jun 25 11:23:07 EDT 1985
  1904. --
  1905. --                 (Unclassified and uncopyrighted)
  1906. --
  1907. ----------------------------------------------------------------------
  1908.  
  1909. procedure Directory is 
  1910.  
  1911. use Node_Definitions;
  1912. use Node_Management;
  1913.  
  1914.     Node, Next_Node     : Node_Definitions.Node_Type;
  1915.     Node_Str            : Node_Definitions.Name_String(1..100);  -- Arbitrary #.
  1916.     Relationship_Str    : String(1..80);
  1917.     Relationship_Flag   : Boolean;
  1918.     Kind                : Node_Kind;
  1919.     Last1, Last2, Last3 : Natural;
  1920.     Iterator            : Node_Management.Node_Iterator;
  1921.  
  1922.     package Enum_Io is new Enumeration_IO(Node_Kind);
  1923.     use Enum_Io;
  1924.  
  1925. begin
  1926.     New_Line;
  1927.     Put_Line ("DIRECTORY:");
  1928.  
  1929.     -- Loop for each node until user enters "quit."
  1930.     EACH_NODE:
  1931.     loop
  1932.         New_Line;
  1933.         Put ("Give NODE (or QUIT):  ");
  1934.         Get_Line (Node_Str, Last1);
  1935.         exit EACH_NODE when 
  1936.             (Node_Str(1..4) = "quit") or (Node_Str(1..4) = "QUIT");
  1937.  
  1938.     Put("Give PRIMARY or SECONDARY:  ");
  1939.     Get_Line(Relationship_Str, Last2);
  1940.     if Relationship_Str(1..Last2) = "SECONDARY" or 
  1941.         Relationship_Str(1..Last2) = "secondary" then 
  1942.         Relationship_Flag := False;
  1943.     else
  1944.         Relationship_Flag := True;
  1945.     end if;
  1946.  
  1947.     Put("Give FILE or STRUCTURAL:  ");
  1948.     Enum_Io.Get(Kind);
  1949.     Skip_Line(Standard_Input);
  1950.         New_Line;
  1951.  
  1952.         CAIS_EXCEPTIONS:
  1953.         begin
  1954.             Node_Management.Open 
  1955.                 (Node, Node_Str(1..Last1), 
  1956.                 (1=> Read_Relationships));
  1957.  
  1958.             Node_Management.Iterate 
  1959.         (Iterator, Node, Kind, 
  1960.         Primary_Only=> Relationship_Flag); 
  1961.             while Node_Management.More (Iterator) loop  
  1962.                 Node_Management.Get_Next  
  1963.                     (Iterator, Next_Node);  
  1964.                 Put("    " & Path_Relation(Next_Node));  
  1965.                 Put("(");  
  1966.                 Put(Path_Key(Next_Node));  
  1967.                 Put_Line(")");  
  1968.             end loop;  
  1969.  
  1970.         exception
  1971.             when Node_Definitions.Status_Error => 
  1972.                 New_Line;
  1973.                 if Node_Management.Is_Open(Node) then
  1974.                     Put_Line("*** Status error raised while iterating ***");
  1975.                     Put_Line("*** nodes or finding relations/keys;    ***");
  1976.                     Put_Line("*** node handle is not open.            ***");
  1977.                 else
  1978.                     Put_Line("*** Status error raised while opening ***");
  1979.                     Put_Line("*** a node handle; node handle is     ***");
  1980.                     Put_Line("*** already open or base is not an    ***");
  1981.                     Put_Line("*** open node handle.                 ***");
  1982.                 end if;
  1983.                 New_Line;
  1984.  
  1985.             when Node_Definitions.Use_Error =>
  1986.                 New_Line;
  1987.                 if Node_Management.Is_Open(Node) then
  1988.                     Put_Line("*** Use error raised while iterating nodes; ***");
  1989.                     Put_Line("*** relation/key are syntactically illegal. ***");
  1990.                     New_Line;
  1991.                 else
  1992.                     Put_Line("*** Use error raised while opening  ***");
  1993.                     Put_Line("*** a node handle; specified intent ***");
  1994.                     Put_Line("*** is an empty array.              ***");
  1995.                 end if;
  1996.                 New_Line;
  1997.  
  1998.             when Node_Definitions.Intent_Violation =>
  1999.                 New_Line;
  2000.                 if Node_Management.Is_Open(Node) then
  2001.                     Put_Line("*** Intent violation raised while iterating ***");
  2002.                     Put_Line("*** nodes; node not opened with the intent  ***");
  2003.                     Put_Line("*** to read relationships.                  ***");
  2004.                 else
  2005.                     Put_Line("*** Intent violation raised while opening ***");
  2006.                     Put_Line("*** a node handle; base is not open with  ***");
  2007.                     Put_Line("*** the intent to read relationships.     ***");
  2008.                 end if;
  2009.                 New_Line;
  2010.  
  2011.             when Node_Definitions.Name_Error =>
  2012.                 New_Line;
  2013.                 if Node_Management.Is_Open(Node) then
  2014.                     Put_Line("*** Name error raised while iterating ***");
  2015.                     Put_Line("*** nodes; next node is unobtainable  ***");
  2016.                     Put_Line("*** and intent is not existence.      ***");
  2017.                 else
  2018.                     Put_Line("*** Name error raised while opening a  ***");
  2019.                     Put_Line("*** node handle; pathname is syntac-   ***");
  2020.                     Put_Line("*** tically illegal or some node in    ***");
  2021.                     Put_Line("*** path is unobtainable, inaccessible ***");
  2022.                     Put_Line("*** or non-existent.                   ***");
  2023.                 end if;
  2024.                 New_Line;
  2025.  
  2026.             when Node_Definitions.Security_Violation =>
  2027.                 New_Line;
  2028.                 if Node_Management.Is_Open(Node) then
  2029.                     Put_Line("*** Security violation raised while ***");
  2030.                     Put_Line("*** iterating nodes.                ***");
  2031.                 else
  2032.                     Put_Line("*** Security violation raised while ***");
  2033.                     Put_Line("*** opening a node handle.          ***");
  2034.                 end if;
  2035.                 New_Line;
  2036.  
  2037.             when Node_Definitions.Lock_Error =>
  2038.                 New_Line;
  2039.                 if Node_Management.Is_Open(Node) then
  2040.                     Put_Line("*** Lock error raised while iterating nodes.***");
  2041.                 else
  2042.                     Put_Line("*** Lock error raised while opening a ***");
  2043.                     Put_Line("*** node handle.                      ***");
  2044.                 end if;
  2045.                 New_Line;
  2046.  
  2047.             when Node_Definitions.Access_Violation =>
  2048.                 New_Line;
  2049.                 if Node_Management.Is_Open(Node) then
  2050.                     Put_Line("*** Access violation raised while ***");
  2051.                     Put_Line("*** iterating nodes.              ***");
  2052.                 else
  2053.                     Put_Line("*** Lock error raised while opening a ***");
  2054.                     Put_Line("*** node handle.                      ***");
  2055.                 end if;
  2056.                 New_Line;
  2057.  
  2058.         end CAIS_EXCEPTIONS;
  2059.  
  2060.         Node_Management.Close (Node);
  2061.  
  2062.     end loop EACH_NODE;
  2063.  
  2064.     New_Line;
  2065.     Put_Line ("COMPLETED.");
  2066.     New_Line;
  2067. exception
  2068.     when others =>
  2069.         New_Line;
  2070.         Put_Line ("*** Unhandled exception ***");
  2071.         New_Line;
  2072.         raise;
  2073. end Directory;
  2074.  
  2075.  
  2076.  
  2077.  
  2078. procedure Import_Export is 
  2079.  
  2080. use Node_Management;
  2081. use Io_Definitions;
  2082. use Node_Definitions;
  2083. use File_Import_Export;
  2084. use Pragmatics;
  2085.     
  2086.     type Response is (IMPORT, EXPORT, QUIT);
  2087.  
  2088.     Import_or_Export            : Response;
  2089.     Valid_Response              : Boolean :=False;
  2090.  
  2091.     Cais_File                   : Cais.Text_IO.File_Type;
  2092.     Node                        : Node_Definitions.Node_Type;
  2093.     Node_Name                   : Node_Definitions.Name_String 
  2094.                     (1..Pragmatics.Max_Name_String);
  2095.     Node_Last                   : Natural;
  2096.  
  2097.     Host_File                   : Cais.Text_IO.File_Type;
  2098.     File_Name                   : String(1..80);
  2099.     File_Last                   : Natural;
  2100.  
  2101.     Text_Line                   : String(1..256);
  2102.     Line_Length                 : Natural;
  2103.  
  2104.     package Response_IO is new Enumeration_IO(Response); 
  2105.     use Response_IO;
  2106.  
  2107.  
  2108. begin
  2109.     New_Line;
  2110.     Put_Line("TESTING FILE IMPORT AND EXPORT");
  2111.  
  2112.     EACH_FILE_IO:
  2113.     loop
  2114.         New_Line;
  2115.         Valid_Response := False;
  2116.         while not Valid_Response loop
  2117.             Put("IMPORT, EXPORT, OR QUIT:  ");
  2118.             GET_RESPONSE:
  2119.             begin
  2120.                 Get(Import_or_Export);
  2121.                 exit EACH_FILE_IO when (Import_or_Export = Quit);
  2122.                 Valid_Response := True; 
  2123.             exception
  2124.                 when Text_Io.Data_Error =>
  2125.                     Put(Ascii.Bel);
  2126.                     Put_Line("You may IMPORT, EXPORT or QUIT");
  2127.                     New_Line;
  2128.             end GET_RESPONSE;
  2129.         end loop;
  2130.     Skip_Line(Standard_Input);
  2131.  
  2132.     Put("Give NODE (or QUIT):   ");
  2133.     Get_Line(Node_Name,Node_Last);
  2134.     New_Line;
  2135.     exit EACH_FILE_IO when
  2136.         (Node_Name(1..4) = "quit") or (Node_Name(1..4) = "QUIT");
  2137.  
  2138.     Put("Give FILE (or QUIT):   ");
  2139.     Get_Line(File_Name,File_Last);
  2140.     New_Line;
  2141.     exit EACH_FILE_IO when
  2142.         (File_Name(1..4) = "quit") or (File_Name(1..4) = "QUIT");
  2143.  
  2144.     CAIS_EXCEPTIONS:
  2145.     begin 
  2146.         if Import_or_Export = Import then
  2147.         Node_Management.Open(Node, Node_Name(1..Node_Last), 
  2148.                     (1 => Write_Contents));
  2149.         Import (Node, File_Name(1..File_Last));
  2150.         Node_Management.Close (Node);
  2151.         end if;
  2152.         if Import_or_Export = Export then
  2153.         Node_Management.Open(Node, Node_Name(1..Node_Last), 
  2154.                     (1 => Read_Contents));
  2155.         Export (Node, File_Name(1..File_Last));
  2156.         Node_Management.Close (Node);
  2157.         end if;
  2158.     
  2159.     exception 
  2160.         when Node_Definitions.Name_Error =>
  2161.             New_Line;
  2162.             if not Node_Management.Is_Obtainable(Node) then
  2163.                 Put_Line("*** Name error raised while file import/    ***");
  2164.                 Put_Line("*** export; node identified by NODE is      ***");
  2165.                 Put_Line("*** inaccessible.                           ***");
  2166.             end if;
  2167.             New_Line;
  2168.  
  2169.         when Node_Definitions.Use_Error =>
  2170.             New_Line;
  2171.             Put_Line("*** Use error raised while file import/export ***");
  2172.             Put_Line("*** Host File Name does not adhere to the     ***");
  2173.             Put_Line("*** required syntax for file names in the     ***");
  2174.             Put_Line("*** host file system or the Host File Name    ***");
  2175.             Put_Line("*** does not exist in the Host File System.   ***");
  2176.             Put_Line("*** Also, FILE may not be the value of the    ***");
  2177.             Put_Line("*** attribute KIND of the node identified     ***");
  2178.             Put_Line("*** by NODE.                                  ***");
  2179.             New_Line;
  2180.  
  2181.         when Node_Definitions.Status_Error =>
  2182.             New_Line;
  2183.             if not Node_Management.Is_Open(Node) then
  2184.                 Put_Line("*** Status error raised while file import/ ***");
  2185.                 Put_Line("*** export; node handle is not open.      ***");
  2186.             end if;
  2187.             New_Line;
  2188.  
  2189.         when Node_Definitions.Intent_Violation =>
  2190.             New_Line;
  2191.             Put_Line("*** Intent violation raised while file import/ ***");
  2192.             Put_Line("*** export; NODE was not opened with an intent ***");
  2193.             Put_Line("*** establishing the right to write contents.  ***");
  2194.             New_Line;
  2195.  
  2196.         when Node_Definitions.Lock_Error|Node_Definitions.Access_Violation|
  2197.             Node_Definitions.Security_Violation =>
  2198.             New_Line;
  2199.             Put_Line("*** Lock error, access violation or security ***");
  2200.             Put_Line("*** violation raised while opening a node    ***");
  2201.             Put_Line("*** handle.                                  ***");
  2202.             New_Line;
  2203.  
  2204.         end CAIS_EXCEPTIONS;
  2205.     end loop EACH_FILE_IO;
  2206.       
  2207.     Put_Line("*** File Import/Export => Complete ***");
  2208.     New_Line;
  2209.  
  2210. exception
  2211.     when others =>
  2212.     New_Line;
  2213.     Put_Line("*** Unhandled exception ***");
  2214.     New_Line;
  2215.     raise;
  2216. end Import_Export; 
  2217.  
  2218.  
  2219.  
  2220.  
  2221. ----------------------------------------------------------------------
  2222. --                          LIST_ATTRIBUTES
  2223. --
  2224. --
  2225. --         CAIS tool to list all attributes of a node or path
  2226. --
  2227. --
  2228. --
  2229. --
  2230. --                  Ada Software Engineering Group
  2231. --                      The MITRE Corporation
  2232. --                         McLean, VA 22102
  2233. --
  2234. --
  2235. --                   Wed Jun 19 09:59:37 EDT 1985
  2236. --
  2237. --                 (Unclassified and uncopyrighted)
  2238. --
  2239. ----------------------------------------------------------------------
  2240.  
  2241. -- This tool lists all attribute names and values for user-specified 
  2242. -- nodes or paths.  The tool loops through nodes/paths until the user 
  2243. -- enters "quit."
  2244.  
  2245. procedure List_Attributes is 
  2246.  
  2247. use Attributes;
  2248. use List_Utilities;
  2249. use Node_Definitions;
  2250. use Node_Management;
  2251.  
  2252.     type Response is (NODE, PATH, QUIT);
  2253.  
  2254.     Node_or_Path         : Response;
  2255.     Valid_Response       : Boolean := False;
  2256.     Node_Handle          : Node_Definitions.Node_Type;
  2257.     NodePath_Str         : Node_Definitions.Name_String (1..80); -- Arbitrary #
  2258.     Last                 : Natural;
  2259.     Attrib_Iterator      : Attributes.Attribute_Iterator;
  2260.     Attrib_Name          : Attributes.Attribute_Name(1..80);  -- Arbitrary #
  2261.     Attrib_Val           : List_Utilities.List_Type;
  2262.     Attrib_Val_Item      : List_Utilities.List_Type;
  2263.  
  2264.     package Response_IO is new Enumeration_IO(Response);  use Response_IO;
  2265.  
  2266. begin
  2267.     New_Line;
  2268.     Put_Line ("LISTING ATTRIBUTES");
  2269.  
  2270.     -- Loop for each node or path until user enters "quit."
  2271.     EACH_NODE_OR_PATH:
  2272.     loop
  2273.         -- Determine whether user wants to add node or path attributes.
  2274.         New_Line;
  2275.         while not Valid_Response loop
  2276.             Put("NODE, PATH, or QUIT?  ");
  2277.             GET_RESPONSE:
  2278.             begin
  2279.                 Get(Node_or_Path);
  2280.                 Skip_Line(Standard_Input);
  2281.                 exit EACH_NODE_OR_PATH when (Node_or_Path = QUIT);
  2282.                 Valid_Response := True;
  2283.             exception
  2284.                 when Data_Error =>
  2285.                     Skip_Line(Standard_Input);
  2286.                     Put(Ascii.Bel);
  2287.                     Put_Line("Valid responses are NODE, PATH, or QUIT.");
  2288.                     New_Line;
  2289.             end GET_RESPONSE;
  2290.         end loop;
  2291.         Valid_Response := False;
  2292.  
  2293.         -- Get node or path string.
  2294.         if Node_or_Path = NODE then
  2295.             Put("Give NODE (or QUIT):  ");
  2296.         else
  2297.             Put("Give PATH (or QUIT):  ");
  2298.         end if;
  2299.         Get_Line (NodePath_Str, Last);
  2300.         New_Line;
  2301.         exit EACH_NODE_OR_PATH when 
  2302.             (NodePath_Str(1..4) = "quit") or (NodePath_Str(1..4) = "QUIT");
  2303.  
  2304.         CAIS_EXCEPTIONS:
  2305.         begin
  2306.             -- Obtain an open node handle and attribute iterator.
  2307.             if Node_or_Path = NODE then
  2308.                 Node_Management.Open 
  2309.                     (Node_Handle, 
  2310.                     NodePath_Str(1..Last), 
  2311.                     (1=> Read_Attributes));
  2312.                 Attributes.Node_Attribute_Iterate 
  2313.                     (Attrib_Iterator, Node_Handle);
  2314.             else
  2315.                 Node_Management.Open
  2316.                     (Node_Handle, 
  2317.                     Base_Path(NodePath_Str(1..Last)),
  2318.                     (1=> Read_Relationships));
  2319.                 Attributes.Path_Attribute_Iterate
  2320.                     (Attrib_Iterator, 
  2321.                     Node_Handle,
  2322.                     Last_Key(NodePath_Str(1..Last)), 
  2323.                     Last_Relation(NodePath_Str(1..Last)));
  2324.             end if;
  2325.  
  2326.             -- Loop through attributes printing names and values.
  2327.             while Attributes.More (Attrib_Iterator) loop
  2328.                 Attributes.Get_Next 
  2329.                     (Attrib_Iterator, Attrib_Name, Attrib_Val);
  2330.                 Last := Character_Set.Last_Non_Space(Attrib_Name);
  2331.                 Put ("    ");  Put (Attrib_Name (1..Last));  Put (" => ");  
  2332.                 if List_Utilities.Get_List_Kind(Attrib_Val) = Named then
  2333.                     -- Pull attribute value item from list.
  2334.                     List_Utilities.Extract
  2335.                         (Attrib_Val, Attrib_Name(1..Last), Attrib_Val_Item);
  2336.                     Put (List_Utilities.To_Text (Attrib_Val_Item));  
  2337.                 else
  2338.                     Put(List_Utilities.To_Text(Attrib_Val));
  2339.                 end if;
  2340.                 New_Line;
  2341.             end loop;
  2342.  
  2343.         exception
  2344.             when Node_Definitions.Status_Error => 
  2345.                 New_Line;
  2346.                 if Node_Management.Is_Open(Node_Handle) then
  2347.                     Put_Line("*** Status error raised while iterating  ***");
  2348.                     Put_Line("*** attributes; node handle is not open. ***");
  2349.                 else
  2350.                     Put_Line("*** Status error raised while opening ***");
  2351.                     Put_Line("*** a node handle; node handle is     ***");
  2352.                     Put_Line("*** already open or base is not an    ***");
  2353.                     Put_Line("*** open node handle.                 ***");
  2354.                 end if;
  2355.  
  2356.             when Node_Definitions.Use_Error =>
  2357.                 New_Line;
  2358.                 if Node_Management.Is_Open(Node_Handle) then
  2359.                     Put_Line("*** Use error raised while iterating     ***");
  2360.                     Put_Line("*** attributes; probably a syntactically ***");
  2361.                     Put_Line("*** illegal pattern.                     ***");
  2362.                 else
  2363.                     Put_Line("*** Use error raised while opening  ***");
  2364.                     Put_Line("*** a node handle; specified intent ***");
  2365.                     Put_Line("*** is an empty array.              ***");
  2366.                 end if;
  2367.  
  2368.             when Node_Definitions.Intent_Violation =>
  2369.                 New_Line;
  2370.                 if Node_Management.Is_Open(Node_Handle) then
  2371.                     Put_Line("*** Intent violation raised while iterating ***");
  2372.                     Put_Line("*** attributes; node not opened with the    ***");
  2373.                     Put_Line("*** intent to read attributes/relationships.***");
  2374.                 else
  2375.                     Put_Line("*** Intent violation raised while opening ***");
  2376.                     Put_Line("*** a node handle; base is not open with  ***");
  2377.                     Put_Line("*** the intent to read relationships.     ***");
  2378.                 end if;
  2379.  
  2380.             when Node_Definitions.Name_Error =>
  2381.                 New_Line;
  2382.                 Put_Line("*** Name error raised while opening a node    ***");
  2383.                 Put_Line("*** handle; pathname is syntactically illegal ***");
  2384.                 Put_Line("*** or some node in path is unobtainable,     ***");
  2385.                 Put_Line("*** inaccessible or non-existent.             ***");
  2386.  
  2387.             when Node_Definitions.Lock_Error|Node_Definitions.Access_Violation|
  2388.                 Node_Definitions.Security_Violation =>
  2389.                 New_Line;
  2390.                 Put_Line("*** Lock error, access violation, or security ***");
  2391.                 Put_Line("*** violation raised while opening a node     ***");
  2392.                 Put_Line("*** handle.                                   ***");
  2393.         end CAIS_EXCEPTIONS;
  2394.  
  2395.         Node_Management.Close (Node_Handle);
  2396.  
  2397.     end loop EACH_NODE_OR_PATH;
  2398.    
  2399.     New_Line;
  2400.     Put_Line ("COMPLETED.");
  2401.     New_Line;
  2402.  
  2403. exception
  2404.     when others =>
  2405.         New_Line;
  2406.         Put_Line ("*** Unhandled exception ***");
  2407.         New_Line;
  2408.         raise;
  2409. end List_Attributes;          
  2410.  
  2411.  
  2412.  
  2413.  
  2414. begin
  2415.  
  2416.     loop
  2417.     New_Line; 
  2418.     New_Line;
  2419.     Put_Line("1. Add_Attributes  2. Change_Attributes   3. Create_File_Nodes");
  2420.     Put_Line("4. Delete_Nodes    5. Import_Export       6. Create_Struc_Nodes");
  2421.     Put_Line("7. Directory       8. Delete_Attributes   9. List_Attributes");
  2422.     Put("ENTER COMMAND NUMBER (0 to QUIT): ");
  2423.  
  2424.     Get_Line(Line, Last);
  2425.     if Last > 0 and then Line(1) in '0'..'9' then
  2426.     case Line(1) is
  2427.         when '0' => exit;
  2428.         when '1' => Add_Attributes;
  2429.         when '2' => Change_Attributes;
  2430.         when '3' => Create_File_Nodes;
  2431.         when '4' => Delete_Nodes;
  2432.         when '5' => Import_Export;
  2433.         when '6' => Create_Struc_Nodes;
  2434.         when '7' => Directory;
  2435.         when '8' => Delete_Attributes;
  2436.         when '9' => List_Attributes;
  2437.         when others => exit;
  2438.     end case;
  2439.     else
  2440.     exit;
  2441.     end if;
  2442. end loop;
  2443.  
  2444. end Cais_Commandos;
  2445. --::::::::::::::
  2446. --copytree_test.a
  2447. --::::::::::::::
  2448.  
  2449. with Cais; Use Cais;
  2450. with Text_Io; use Text_Io;
  2451. procedure Copytree_Test is
  2452.  
  2453. use Node_Definitions;
  2454. use Node_Management;
  2455.  
  2456.     Node    : Cais.Node_Type;
  2457.     Node1    : Cais.Node_Type;
  2458.     Node2    : Cais.Node_Type;
  2459.     Node3    : Cais.Node_Type;
  2460.  
  2461.  
  2462.  
  2463. procedure Myplant is
  2464.  
  2465. use Cais.node_management;
  2466. use Cais.node_definitions;
  2467.  
  2468.     Node    : Cais.Node_Type;
  2469.     Node1    : Cais.Node_Type;
  2470.     Node2    : Cais.Node_Type;
  2471.     Node3    : Cais.Node_Type;
  2472.     Node4    : Cais.Node_Type;
  2473.     Node5    : Cais.Node_Type;
  2474.     Node6    : Cais.Node_Type;
  2475.     File    : Cais.Text_Io.File_Type;
  2476.  
  2477.     begin
  2478.     Put_Line("CREATE --TREE");
  2479.     Cais.Structural_Nodes.Create_Node(Node, Name=>"'current_user.Nowalk");
  2480.     Close(Node);
  2481.     Open(Node, "'current_user.Nowalk",
  2482.             (1=>read_relationships, 2=>append_relationships));
  2483.  
  2484.     Put_Line("CREATE --Nowalk.john");
  2485.     Cais.Structural_Nodes.Create_Node(Node1, Node, "john", "dot"  );
  2486.     Close(Node1);
  2487.     Open(Node1, Node, "john","dot", 
  2488.             (1=>read_relationships, 2=>append_relationships));
  2489.     Put_Line("huzzah");
  2490.  
  2491.     Put_Line("CREATE --Nowalk.john.johnjr");
  2492.     Cais.Text_Io.Create(File, Node1, "johnjr", "dot" );
  2493.     Cais.Text_Io.Close(File);
  2494.     Open(Node2, Node1, "johnjr","dot", 
  2495.             (1=>read_relationships, 2=>append_relationships));
  2496.  
  2497.     Put_Line("CREATE --Nowalk.john.will");
  2498.     Cais.Text_Io.Create(File, Node1, "will", "dot"  );
  2499.     Cais.Text_Io.Close(File);
  2500.     Open(Node6, Node1, "will","dot", 
  2501.             (1=>read_relationships, 2=>append_relationships));
  2502.  
  2503.     Put_Line("CREATE --Nowalk.john.johnjr.mike");
  2504.     Cais.Text_Io.Create(File, Node2, "mike", "dot"  );
  2505.     Cais.Text_Io.Close(File);
  2506.     Open(Node5, Node2, "mike","dot", 
  2507.             (1=>read_relationships, 2=>append_relationships));
  2508.  
  2509.     Put_Line("CREATE --Nowalk.john.johnjr.mark");
  2510.     Cais.Text_Io.Create(File, Node2, "mark", "dot" );
  2511.     Cais.Text_Io.Close(File);
  2512.     Open(Node3, Node2, "mark","dot", 
  2513.             (1=>read_relationships, 2=>append_relationships));
  2514.     Put_Line("CREATE --Nowalk.john.johnjr.mark.mary");
  2515.     Cais.Text_Io.Create(File, Node3, "mary", "dot" );
  2516.     Cais.Text_Io.Close(File);
  2517.     Open(Node4, Node3, "mary","dot", 
  2518.             (1=>read_relationships, 2=>append_relationships));
  2519.  
  2520.  
  2521.     --Put in Secondary Uncle Links
  2522.     Link(Node5, Node4, "Mike", "uncle");
  2523.     Link(Node6, Node3, "Will", "uncle");
  2524.     Link(Node6, Node5, "Will", "uncle");
  2525.  
  2526.     --Put in Secondary Sibling Links
  2527.     Link(Node5, Node3, "Mark", "sibling");
  2528.     Link(Node3, Node5, "Mike", "sibling");
  2529.     Link(Node6, Node2, "Will", "sibling");
  2530.     Link(Node2, Node6, "Johnjr", "sibling");
  2531.  
  2532.     --Put in Secondary Sibling Links
  2533.     Link(Node, Node1, "Nowalk", "clan");
  2534.     Link(Node, Node2, "Nowalk", "clan");
  2535.     Link(Node, Node3, "Nowalk", "clan");
  2536.     Link(Node, Node4, "Nowalk", "clan");
  2537.     Link(Node, Node5, "Nowalk", "clan");
  2538.     Link(Node, Node6, "Nowalk", "clan");
  2539.  
  2540.     --Put in Self Reference
  2541.     Link(Node4, Node4, "Me", "Self");
  2542.  
  2543.     Put_Line("--TEST SETUP COMPLETED");
  2544.  
  2545. end Myplant;
  2546. begin
  2547.     Myplant;
  2548.  
  2549.     Open(Node,"'current_user.Nowalk", 
  2550.             (1=>read, 2=>append_relationships));
  2551.     Put_Line("Nowalk is Open");
  2552.     Open(Node1,"'current_user.Nowalk.john.johnjr.mark.mary", 
  2553.             (1=>read, 2=>append_relationships));
  2554.     Put_Line("Mary is Open");
  2555.     Open(Node2,"'current_user.Nowalk.john", 
  2556.             (1=>read, 2=>append_relationships));
  2557.     Put_Line("john is Open");
  2558.     Open(Node3,"'current_user.Nowalk.john.johnjr.mark", 
  2559.         (1=>read, 2=>append_relationships, 3=>write_relationships));
  2560.     Put_Line("Mark is Open");
  2561.  
  2562.     Copy_Node(Node1, Node, "marie", "dot");
  2563.     put_line("Nowalk.John.Johnjr.Mark.Mary COPIED TO Nowalk.Marie");
  2564.  
  2565.     Copy_Tree(Node2, Node, "johann", "dot");
  2566.     put_line("The TREE  Nowalk.John COPIED TO Nowalk.Johann");
  2567.  
  2568.     Rename(Node3, Node2, "mark", "dot");
  2569.     put_line("The TREE  Nowalk.John.Johnjr.Mark RENAMED TO Nowalk.John.Mark");
  2570.  
  2571.     put_line("Verify by examining the resulting node files.");
  2572.     put_line("Then cleanup by running Nodetree_Cleanup!!!  ");
  2573. end Copytree_Test;
  2574. --::::::::::::::
  2575. --existree_ex.a
  2576. --::::::::::::::
  2577.  
  2578. -----------------------------N O D E T R E E _ E X---------------------------
  2579. -- Purpose:
  2580. -- -------
  2581. --    This program runs exception tests for the subprogams in sections
  2582. --    7,8,9,17,18,19,20, and 22 of MIL-STD-CAIS 5.1.2.  These routines
  2583. --      provide information on the primary_name, provide access to the
  2584. --    parent node, provide for copying and deleting trees, and provide
  2585. --    for copying and renaming nodes.
  2586. --
  2587. --    Tests for Lock_Error, Access_Violation, and Security_Violation
  2588. --    are not included because these features are not yet implemented.
  2589. --
  2590. --    In order to perform these tests, several nodes are created. Several
  2591. --    nodes have strange properties, such as inaccessibility.  The
  2592. --    manner in which these properties have been created likely violates
  2593. --    rules enforced by access_methods or locking_checks.  Therefore,
  2594. --    this program must be updated once these features are implemented.
  2595. --
  2596. ------------------------------------------------------------------------------
  2597. with Cais;    use Cais;
  2598. with Text_Io; use Text_Io;
  2599. procedure Existree_Ex is
  2600.  
  2601. use Attributes;
  2602. use List_Utilities;
  2603. use Node_Management;
  2604. use Node_Definitions;
  2605.  
  2606.   Exceptions_Tested : constant := 50;
  2607.   Failures   : integer := 0;
  2608.   Line_Count : integer;
  2609.   Expected   : string(1..3);
  2610.   Check_Inaccessibility : boolean;
  2611.  
  2612.     Inaccessible_Node : Cais.Node_Type;
  2613.     In_Traversed_Node : Cais.Node_Type;
  2614.     Closed_Node       : Cais.Node_Type;
  2615.     Open_Node      : Cais.Node_Type;
  2616.     Locked_Node      : Cais.Node_Type;
  2617.     Impotent_Node      : Cais.Node_Type;
  2618.     Hidden_Node      : Cais.Node_Type;
  2619.     Process_Node      : Cais.Node_Type;
  2620.     Top_Node      : Cais.Node_Type;
  2621.     Living_Node      : Cais.Node_Type;
  2622.     Offspring_Node      : Cais.Node_Type;
  2623.     Parent           : Cais.Node_Type;
  2624.     Temp_File      : Cais.Text_Io.File_Type;
  2625.  
  2626.     Node      : Cais.Node_Type;
  2627.     Node1     : Cais.Node_Type;
  2628.  
  2629.     Wait      : string(1..100);
  2630.     Last      : natural;
  2631.     No_Intent : Intention(1..2) := (Existence, read);
  2632.     Key       : Relationship_Key(1..6) := "howell";
  2633.     Relation  : Relation_Name(1..4)    := "user";
  2634.     Null_List : List_Type;
  2635.  
  2636.  
  2637.  
  2638.   procedure Wrong_Exception(II: integer;
  2639.                 SS: string) is
  2640.  
  2641.   begin
  2642.     Failures := Failures + 1;
  2643.     Line_Count := 10;
  2644.     new_line;
  2645.     put(
  2646.          integer'image(II)   &
  2647.          ":**ERROR**"     &
  2648.          " Received: "       &
  2649.              SS                  &
  2650.              " Expected: "       &
  2651.              Expected            );
  2652.   end Wrong_Exception;
  2653.  
  2654.  
  2655.   procedure No_Ex(Error: in string) is
  2656.   begin
  2657.     new_line;
  2658.     put(Error);
  2659.     Line_Count := 10;
  2660.     Failures := Failures + 1;
  2661.   end No_Ex;
  2662.  
  2663.  
  2664.  
  2665.  
  2666.  
  2667.   procedure Raise_Exception(II: integer ) is
  2668.     Text    : Natural;
  2669.     String1 : string(1..3);
  2670.     Name1   : NameString(1..3);
  2671.     Iterator      : Attribute_Iterator;
  2672.     Attribute     : Attribute_Name(1..32);
  2673.   begin
  2674.  
  2675.     case II is
  2676.                             --MIL STD 5.1.3.1
  2677.                               --not applicable
  2678.  
  2679.                         --Access_Violation not checked
  2680.                         --Lock_Error not checked
  2681.     when  1 =>                    --MIL STD 5.1.2.7
  2682.       if check_inaccessibility then
  2683.         Expected := "Nam";
  2684.         Put_Line (Primary_Name(In_Traversed_Node) );
  2685.         No_Ex(" 1***ERROR***Primary_Name: inaccessible");
  2686.       end if;
  2687.     when  2 =>
  2688.         Expected := "Sta";
  2689.         Put_Line (Primary_Name(Closed_Node) );
  2690.         No_Ex(" 2***ERROR***Primary_Name: not open");
  2691.     when  3 =>
  2692.         Expected := "Int";
  2693.         Put_Line (Primary_Name(Impotent_Node) );
  2694.         No_Ex(" 3***ERROR***Primary_Name: bad intent");
  2695.                         --Access_Violation not checked
  2696.                         --Lock_Error not checked
  2697.     when  4 =>                    --MIL STD 5.1.2.8
  2698.       if check_inaccessibility then
  2699.         Expected := "Nam";
  2700.         Put_Line (Primary_Key(In_Traversed_Node) );
  2701.         No_Ex(" 4***ERROR***Primary_Key: inaccessible");
  2702.       end if;
  2703.     when  5 =>
  2704.         Expected := "Sta";
  2705.         Put_Line (Primary_Key(Closed_Node) );
  2706.         No_Ex(" 5***ERROR***Primary_Key: not open");
  2707.     when  6 =>
  2708.         Expected := "Int";
  2709.         Put_Line (Primary_Key(Impotent_Node) );
  2710.         No_Ex(" 6***ERROR***Primary_Key: bad intent");
  2711.                         --Access_Violation not checked
  2712.                         --Lock_Error not checked
  2713.     when  7 =>                    --MIL STD 5.1.2.9
  2714.       if check_inaccessibility then
  2715.         Expected := "Nam";
  2716.         Put_Line (Primary_Relation(In_Traversed_Node) );
  2717.         No_Ex(" 7***ERROR***Primary_Relation: inaccessible");
  2718.       end if;
  2719.     when  8 =>
  2720.         Expected := "Sta";
  2721.         Put_Line (Primary_Relation(Closed_Node) );
  2722.         No_Ex(" 8***ERROR***Primary_Relation: not open");
  2723.     when  9 =>
  2724.         Expected := "Int";
  2725.         Put_Line (Primary_Relation(Impotent_Node) );
  2726.         No_Ex(" 9***ERROR***Primary_Relation: bad intent");
  2727.  
  2728.                         --Security_Violation not checked
  2729.                         --Access_Violation not checked
  2730.                         --Lock_Error not checked
  2731.     when  10 =>                    --MIL STD 5.1.2.17
  2732.         Expected := "Nam";
  2733.         Get_Parent(Parent, Top_Node);
  2734.         No_Ex(" 10***ERROR***Get_Parent: top-level");
  2735.         Close(Parent);
  2736.     when  11 =>
  2737.       if check_inaccessibility then
  2738.         Expected := "Nam";
  2739.         Get_Parent(Parent, In_Traversed_Node);
  2740.         No_Ex(" 11***ERROR***Get_Parent: inaccessible parent");
  2741.         Close(Parent);
  2742.       end if;
  2743.     when  12 =>                    
  2744.         Expected := "Use";
  2745.         Get_Parent(Parent, Offspring_Node, No_Intent(2..1) );
  2746.         No_Ex(" 12***ERROR***Get_Parent: null intention");
  2747.         Close(Parent);
  2748.     when  13 =>
  2749.         Expected := "Sta";
  2750.         Get_Parent(Open_Node, Offspring_Node);
  2751.         No_Ex(" 13***ERROR***Get_Parent: open parent");
  2752.         Close(Parent);
  2753.     when  14 =>    
  2754.         Expected := "Sta";
  2755.         Get_Parent(Parent, Closed_Node);
  2756.         No_Ex(" 14***ERROR***Get_Parent: closed node");
  2757.         Close(Parent);
  2758.     when  15 =>
  2759.         Expected := "Int";
  2760.         Get_Parent(Parent, Impotent_Node);
  2761.         No_Ex(" 15***ERROR***Get_Parent: bad intent");
  2762.         Close(Parent);
  2763.                         --Security_Violation not checked
  2764.     when  16 =>                    --MIL STD 5.1.2.18
  2765.         Expected := "Nam";
  2766.         Copy_Node(Impotent_Node,Living_Node, "Bad__Key");
  2767.         No_Ex(" 16***ERROR***Copy_Node: illegal key");
  2768.     when  17 =>
  2769.         Expected := "Nam";
  2770.         Copy_Node(Impotent_Node,Living_Node, "OK", "Bad__Rel");
  2771.         No_Ex(" 17***ERROR***Copy_Node: illegal relation");
  2772.     when  18 =>                    
  2773.         Expected := "Nam";
  2774.         Copy_Node(Impotent_Node,Living_Node, "johnjr", "dot" );
  2775.         No_Ex(" 18***ERROR***Copy_Node: existing node");
  2776.     when  19 =>
  2777.         Expected := "Use";
  2778.         Copy_Node(Process_Node,Living_Node, "dan", "dot" );
  2779.         No_Ex(" 19***ERROR***Copy_Node: wrong node kind");
  2780.     when  20 =>    
  2781.         Expected := "Use";
  2782.         Copy_Node(Living_Node, Living_Node, "jim", "dot");
  2783.         No_Ex(" 20***ERROR***Copy_Node: primary relationships");
  2784.     when  21 =>
  2785.         Expected := "Use";
  2786.         Copy_Node(Offspring_Node,Living_Node, "dummy", "access");
  2787.         No_Ex(" 21***ERROR***Copy_Node: predefined relation");
  2788.     when  22 =>                    
  2789.         Expected := "Sta";
  2790.         Copy_Node(Closed_Node,Living_Node, "dummy", "link" );
  2791.         No_Ex(" 22***ERROR***Copy_Node: from closed");
  2792.     when  23 =>
  2793.         Expected := "Sta";
  2794.         Copy_Node(Living_Node,Closed_Node,"dummy", "link" );
  2795.         No_Ex(" 23***ERROR***Copy_Node: to closed");
  2796.     when  24 =>    
  2797.         Expected := "Int";
  2798.         Copy_Node(Impotent_Node,Living_Node, "dummy", "link" );
  2799.         No_Ex(" 24***ERROR***Copy_Node: from bad intent");
  2800.     when  25 =>
  2801.         Expected := "Int";
  2802.         Copy_Node(Living_Node,Impotent_Node, "dummy", "link" );
  2803.         No_Ex(" 25***ERROR***Copy_Node: to bad intent");
  2804.  
  2805.                         --Security_Violation not checked
  2806.                         --Access_Violation not checked
  2807.                         --Lock_Error not checked
  2808.     when  26 =>                    --MIL STD 5.1.2.19
  2809.         Expected := "Nam";
  2810.         Copy_Tree(Impotent_Node,Living_Node, "Bad__Key");
  2811.         No_Ex(" 26***ERROR***Copy_Tree: illegal key");
  2812.     when  27 =>
  2813.         Expected := "Nam";
  2814.         Copy_Tree(Impotent_Node,Living_Node, "OK", "Bad__Rel");
  2815.         No_Ex(" 27***ERROR***Copy_Tree: illegal relation");
  2816.     when  28 =>                    
  2817.         Expected := "Nam";
  2818.         Copy_Tree(Impotent_Node,Living_Node, "johnjr", "dot" );
  2819.         No_Ex(" 28***ERROR***Copy_Tree: existing node");
  2820.     when  29 =>
  2821.         Expected := "Use";
  2822.         Copy_Tree(Process_Node,Living_Node, "dan", "dot" );
  2823.         No_Ex(" 29***ERROR***Copy_Tree: wrong node kind");
  2824.     when  30 =>
  2825.         Expected := "Use";
  2826.         Copy_Tree(Offspring_Node,Living_Node, "dummy", "access");
  2827.         No_Ex(" 30***ERROR***Copy_Tree: predefined relation");
  2828.     when  31 =>                    
  2829.         Expected := "Sta";
  2830.         Copy_Tree(Closed_Node,Living_Node, "dummy", "link" );
  2831.         No_Ex(" 31***ERROR***Copy_Tree: from closed");
  2832.     when  32 =>
  2833.         Expected := "Sta";
  2834.         Copy_Tree(Living_Node,Closed_Node,"dummy", "link" );
  2835.         No_Ex(" 32***ERROR***Copy_Tree: to closed");
  2836.     when  33 =>    
  2837.         Expected := "Int";
  2838.         Copy_Tree(Impotent_Node,Living_Node, "dummy", "link" );
  2839.         No_Ex(" 33***ERROR***Copy_Tree: from bad intent");
  2840.     when  34 =>
  2841.         Expected := "Int";
  2842.         Copy_Tree(Offspring_Node,Hidden_Node, "dummy", "link" );
  2843.         No_Ex(" 34***ERROR***Copy_Tree: to bad intent");
  2844.                      --Security_Violation not checked
  2845.                         --Access_Violation not checked
  2846.                         --Lock_Error not checked
  2847.     when  35 =>                    --MIL STD 5.1.2.20
  2848.         Expected := "Nam";
  2849.         Rename(Hidden_Node,Living_Node, "Bad__Key");
  2850.         No_Ex(" 35***ERROR***Rename: illegal key");
  2851.     when  36 =>
  2852.         Expected := "Nam";
  2853.         Rename(Hidden_Node,Living_Node, "OK", "Bad__Rel");
  2854.         No_Ex(" 36***ERROR***Rename: illegal relation");
  2855.     when  37 =>                    
  2856.         Expected := "Nam";
  2857.         Rename(Hidden_Node,Living_Node, "johnjr", "dot" );
  2858.         No_Ex(" 37***ERROR***Rename: existing node");
  2859.     when  38 =>
  2860.         Expected := "Use";
  2861.         Rename(Process_Node,Living_Node, "dan", "dot" );
  2862.         No_Ex(" 38***ERROR***Rename: wrong node kind");
  2863.     when  39 =>
  2864.         Expected := "Use";
  2865.         Rename(Living_Node,Offspring_Node, "dummy", "dot");
  2866.         No_Ex(" 39***ERROR***Rename: acircularity test");
  2867.     when  40 =>
  2868.         Expected := "Use";
  2869.         Rename(Offspring_Node,Living_Node, "dummy", "access");
  2870.         No_Ex(" 40***ERROR***Rename: predefined relation");
  2871.     when  41 =>
  2872.         Expected := "Use";
  2873.         Rename(Top_Node,Living_Node, "dummy", "dot");
  2874.         No_Ex(" 41***ERROR***Rename: parent relation is predefined");
  2875.     when  42 =>                    
  2876.         Expected := "Sta";
  2877.         Rename(Closed_Node,Living_Node, "dummy", "link" );
  2878.         No_Ex(" 42***ERROR***Rename: from closed");
  2879.     when  43 =>
  2880.         Expected := "Sta";
  2881.         Rename(Living_Node,Closed_Node,"dummy", "link" );
  2882.         No_Ex(" 43***ERROR***Rename: to closed");
  2883.     when  44 =>    
  2884.         Expected := "Int";
  2885.         Rename(Hidden_Node,Living_Node, "dummy", "link" );
  2886.         No_Ex(" 44***ERROR***Rename: from bad intent");
  2887.     when  45 =>
  2888.         Expected := "Int";
  2889.         Rename(Living_Node,Impotent_Node, "dummy", "link" );
  2890.         No_Ex(" 45***ERROR***Rename: to bad intent");
  2891.                          --Security_Violation not checked
  2892.                         --Access_Violation not checked
  2893.                         --Lock_Error not checked
  2894.     when  46 =>                    --MIL STD 5.1.2.22
  2895.       if check_inaccessibility then
  2896.         Expected := "Nam";
  2897.         Delete_Tree(In_Traversed_Node);
  2898.         No_Ex(" 46***ERROR***Delete_Tree: inaccessible parent");
  2899.       end if;
  2900.     when  47 =>                    --MIL STD 5.1.2.22
  2901.       if check_inaccessibility then
  2902.         Expected := "Nam";
  2903.         Delete_Tree(Living_Node);
  2904.         No_Ex(" 47***ERROR***Delete_Tree: inaccessible subtree");
  2905.       end if;
  2906.     when  48 =>                    --MIL STD 5.1.2.22
  2907.         Expected := "Use";
  2908.         Delete_Tree(Top_Node);
  2909.         No_Ex(" 48***ERROR***Delete_Tree: parent relation is predefined");
  2910.     when  49 =>                    --MIL STD 5.1.2.22
  2911.         Expected := "Sta";
  2912.         Delete_Tree(Closed_Node);
  2913.         No_Ex(" 49***ERROR***Delete_Tree: unopened node");
  2914.     when  50 =>                    --MIL STD 5.1.2.22
  2915.         Expected := "Int";
  2916.         Delete_Tree(Hidden_Node);
  2917.         No_Ex(" 50***ERROR***Delete_Tree: bad intent");
  2918.     when others =>
  2919.         Put_Line("***TEST SET-UP ERROR*** " & integer'image(II) &
  2920.              " NOT EXPECTED!!");
  2921.     end case;
  2922.   end Raise_Exception;
  2923.  
  2924.  
  2925.   begin
  2926.         Open(Top_Node,"'current_user",(1=>Exclusive_Write, 2=>Read));
  2927.         Open(Impotent_Node,"'current_user",(1=>read_contents));
  2928.  
  2929.     Put_Line("CREATE --TREE");
  2930.     --Structural_Nodes.Create_Node(Node, Name=>"'current_user.Nowalk");
  2931.     --Close(Node);
  2932.     Open(Node1, "'current_user.Nowalk",
  2933.             (1=>read, 2=>append_relationships));
  2934.  
  2935.     Put_Line("CREATE --Nowalk.john");
  2936.     --Structural_Nodes.Create_Node(Living_Node, Node1, "john", "dot"  );
  2937.     --Close(Living_Node);
  2938.     Open(Living_Node, Node1, "john","dot", 
  2939.             (1=>read, 2=>append_relationships));
  2940.  
  2941.     Put_Line("CREATE --Nowalk.john.johnjr");
  2942.     --Cais.Text_Io.Create(Temp_File, Living_Node, "johnjr", "dot" );
  2943.     --Cais.Text_Io.Close(Temp_File);
  2944.     Open(Offspring_Node,Living_Node, "johnjr","dot", 
  2945.             (1=>read, 2=>Exclusive_Write, 3=>append_relationships));
  2946.  
  2947.     Put_Line("CREATE --Nowalk.john.johnjr.mark");
  2948.     --Cais.Text_Io.Create(Temp_File, Offspring_Node, "Mark", "dot" );
  2949.     --Cais.Text_Io.Close(Temp_File);
  2950.  
  2951.     Put_Line("CREATE --Nowalk.john.will");
  2952.     --Cais.Text_Io.Create(Temp_File, Living_Node, "will", "dot"  );
  2953.     --Cais.Text_Io.Close(Temp_File);
  2954.     Open(Node, Living_Node, "will","dot", 
  2955.         (1=>Exclusive_write, 2=>append_relationships,3=>read));
  2956.  
  2957.     Put_Line("CREATE --Nowalk.john.will.kitty");
  2958.     --Cais.Text_Io.Create(Temp_File, Node, "kitty", "dot"  );
  2959.     --Cais.Text_Io.Close(Temp_File);
  2960.  
  2961.     Open(Inaccessible_Node, Living_Node, "will","dot", (1=>write, 2=>read));
  2962.     Open(In_traversed_Node,Node,"kitty","dot",(1=>exclusive_write,2=>read));
  2963.  
  2964.  
  2965.     Put_Line("NOW YOU must make the node dot(will) inaccessible");
  2966.     Put_Line("It should be the 2nd from last node created.");
  2967.     Put_Line("Should Inaccessibility tests be run (Y/N)");
  2968.     Get_Line(Wait, Last);
  2969.     if Last = 1 and then Wait(1) = 'Y' then
  2970.         Check_Inaccessibility := true;
  2971.     else
  2972.         Check_Inaccessibility := false;
  2973.     end if;
  2974.  
  2975.         Open(Process_Node,"'current_job",(1=>Existence));
  2976.     Open(Hidden_Node, Living_Node, "johnjr","dot", (1=>existence));
  2977.     Open(Open_Node, Living_Node, "johnjr","dot", (1=>write, 2=>read));
  2978.  
  2979. --========================================================================
  2980. --===================S E T U P   C O M P L E T E D========================
  2981. --========================================================================
  2982.  
  2983.     Line_Count := 10;
  2984.     for I in 1..Exceptions_Tested loop
  2985.     begin
  2986.         if Line_Count = 10 then
  2987.         new_line;
  2988.         put("PASSES TEST: ");
  2989.         Line_Count := 0;
  2990.         end if;
  2991.         Raise_Exception(I);
  2992.         exception
  2993.       when Node_Definitions.Use_Error     =>
  2994.                 if Expected /= "Use" then
  2995.                   Wrong_Exception(I,"Use_Error");
  2996.                 else
  2997.                   Line_Count := Line_Count+1;
  2998.                   put( integer'image(I));
  2999.                   put("  ");
  3000.                 end if;
  3001.  
  3002.       when Node_Definitions.Status_Error     =>
  3003.                 if Expected /= "Sta" then
  3004.                   Wrong_Exception(I,"Status_Error");
  3005.                 else
  3006.                   Line_Count := Line_Count+1;
  3007.                   put( integer'image(I));
  3008.                   put("  ");
  3009.                 end if;
  3010.  
  3011.       when Intent_Violation =>
  3012.                 if Expected /= "Int" then
  3013.                   Wrong_Exception(I,"Intent_Error");
  3014.                 else
  3015.                   Line_Count := Line_Count+1;
  3016.                   put( integer'image(I));
  3017.                   put("  ");
  3018.                 end if;
  3019.  
  3020.       when Lock_Error         =>
  3021.                 if Expected /= "Loc" then
  3022.                   Wrong_Exception(I,"Lock_Error");
  3023.                 else
  3024.                   Line_Count := Line_Count+1;
  3025.                   put( integer'image(I));
  3026.                   put("  ");
  3027.                 end if;
  3028.  
  3029.       when Security_Violation =>
  3030.                 if Expected /= "Sec" then
  3031.                   Wrong_Exception(I,"Security_Violation");
  3032.                 else
  3033.                   Line_Count := Line_Count+1;
  3034.                   put( integer'image(I));
  3035.                   put("  ");
  3036.                 end if;
  3037.  
  3038.       when Node_Definitions.Name_Error =>
  3039.                 if Expected /= "Nam" then
  3040.                   Wrong_Exception(I,"Name_Error");
  3041.                 else
  3042.                   Line_Count := Line_Count+1;
  3043.                   put( integer'image(I));
  3044.                   put("  ");
  3045.                 end if;
  3046.     end;
  3047.   end loop;
  3048.  
  3049.   new_line;
  3050.   put_line("****************************T O T A L S***********************");
  3051.   put_line("Number of tests run: " & integer'image(Exceptions_Tested));
  3052.   put_line("Number of failures : " & integer'image(Failures) );
  3053.   put_line("*** NOTE 6 TESTS ARE SKIPPED IF INACCESSIBILITY NOT CHECKED***");
  3054.   put_line("**************************************************************");
  3055. end Existree_Ex;
  3056. --::::::::::::::
  3057. --io_ex_create_test.a
  3058. --::::::::::::::
  3059. with Cais; use Cais;
  3060. with Trace;
  3061.  
  3062. procedure Create_Test is
  3063.     use Node_Definitions;
  3064.     use Node_Management;
  3065.     use Cais.Text_Io;
  3066.     use List_Utilities;
  3067.  
  3068.     Test_Max: constant Natural := 20;
  3069.     type Test_Result is  (Succeed, Fail);
  3070.     type Test_Vec is Array (1..Test_Max) of Test_Result;
  3071.  
  3072.     Test_Outcomes : Test_Vec := (others => Succeed);
  3073.     Tests_Executed : Natural;
  3074.  
  3075.     File1 : File_Type;
  3076.     File2 : File_Type;
  3077.     Base  : Cais.Node_Type;
  3078.  
  3079.     Unopened_File  : File_Type;
  3080.     Unopened_Base  : Cais.Node_Type;
  3081.  
  3082.     Attr_List : List_Type;
  3083.  
  3084.     procedure Name_Trap ( 
  3085.              File           :in out File_Type;
  3086.            Base        :in out Cais.Node_Type;
  3087.            Key        :    Relationship_Key := Latest_Key;
  3088.            Relation    :    Relation_Name     := Default_Relation;
  3089.            Mode        :    File_Mode     := Inout_File;
  3090.            Form        :    List_Type     := Empty_List;
  3091.            Attributes    :    List_Type     := Empty_List;
  3092.            Access_Control :    List_Type     := Empty_List;
  3093.            Level        :    List_Type     := Empty_List;
  3094.                  -- parameters not used in Create call
  3095.          Results    :in out Test_Vec;
  3096.          Test_Number    :    Natural;
  3097.          Situation    :    String) is
  3098.  
  3099.     begin
  3100.         Create (File, Base, Key, Relation, Mode, Form, Attributes,
  3101.             Access_Control, Level);
  3102.         Trace.Report (Natural'image(Test_Number) & ". Create fails to raise " &
  3103.             "Io_Definitions.Name_Error when "
  3104.             & Situation (Situation'range));
  3105.         Results (Test_Number) := Fail;
  3106.     exception
  3107.         when Io_Definitions.Name_Error =>
  3108.             Trace.Report (Natural'image(Test_Number) &
  3109.             ". OK -- Create raises " &
  3110.             "Io_Definitions.Name_Error when "
  3111.             & Situation (Situation'range));
  3112.         when others =>
  3113.         Trace.Report (Natural'image(Test_Number) &
  3114.         ". Unexpected exception in Create when "
  3115.         & Situation (Situation'range));
  3116.              Results (Test_Number) := Fail;
  3117.  
  3118.     end Name_Trap; 
  3119.  
  3120.  
  3121.  
  3122.     procedure Status_Trap ( 
  3123.              File           :in out File_Type;
  3124.            Base        :in out Cais.Node_Type;
  3125.            Key        :    Relationship_Key := Latest_Key;
  3126.            Relation    :    Relation_Name     := Default_Relation;
  3127.            Mode        :    File_Mode     := Inout_File;
  3128.            Form        :    List_Type     := Empty_List;
  3129.            Attributes    :    List_Type     := Empty_List;
  3130.            Access_Control :    List_Type     := Empty_List;
  3131.            Level        :    List_Type     := Empty_List;
  3132.                  -- parameters not used in Create call
  3133.          Results    :in out Test_Vec;
  3134.          Test_Number    :    Natural;
  3135.          Situation    :    String) is
  3136.  
  3137.     begin
  3138.         Create (File, Base, Key, Relation, Mode, Form, Attributes,
  3139.             Access_Control, Level);
  3140.         Trace.Report (Natural'image(Test_Number) & ". Create fails to raise " &
  3141.             "Io_Definitions.Status_Error when "
  3142.             & Situation (Situation'range));
  3143.         Results (Test_Number) := Fail;
  3144.     exception
  3145.         when Io_Definitions.Status_Error =>
  3146.             Trace.Report (Natural'image(Test_Number) &
  3147.             ". OK -- Create raises " &
  3148.             "Io_Definitions.Status_Error when "
  3149.             & Situation (Situation'range));
  3150.         when others =>
  3151.         Trace.Report (Natural'image(Test_Number) &
  3152.         ". Unexpected exception in Create when "
  3153.         & Situation (Situation'range));
  3154.              Results (Test_Number) := Fail;
  3155.  
  3156.     end Status_Trap; 
  3157.  
  3158.  
  3159.     procedure Use_Trap ( 
  3160.              File           :in out File_Type;
  3161.            Base        :in out Cais.Node_Type;
  3162.            Key        :    Relationship_Key := Latest_Key;
  3163.            Relation    :    Relation_Name     := Default_Relation;
  3164.            Mode        :    File_Mode     := Inout_File;
  3165.            Form        :    List_Type     := Empty_List;
  3166.            Attributes    :    List_Type     := Empty_List;
  3167.            Access_Control :    List_Type     := Empty_List;
  3168.            Level        :    List_Type     := Empty_List;
  3169.                  -- parameters not used in Create call
  3170.          Results    :in out Test_Vec;
  3171.          Test_Number    :    Natural;
  3172.          Situation    :    String) is
  3173.  
  3174.     begin
  3175.         Create (File, Base, Key, Relation, Mode, Form, Attributes,
  3176.             Access_Control, Level);
  3177.         Trace.Report (Natural'image(Test_Number) & ". Create fails to raise " &
  3178.             "Io_Definitions.Use_Error when "
  3179.             & Situation (Situation'range));
  3180.         Results (Test_Number) := Fail;
  3181.     exception
  3182.         when Io_Definitions.Use_Error =>
  3183.             Trace.Report (Natural'image(Test_Number) &
  3184.             ". OK -- Create raises " &
  3185.             "Io_Definitions.Use_Error when "
  3186.             & Situation (Situation'range));
  3187.         when others =>
  3188.         Trace.Report (Natural'image(Test_Number) &
  3189.         ". Unexpected exception in Create when "
  3190.         & Situation (Situation'range));
  3191.              Results (Test_Number) := Fail;
  3192.  
  3193.     end Use_Trap; 
  3194.  
  3195.  
  3196.     procedure Intent_Trap ( 
  3197.              File           :in out File_Type;
  3198.            Base        :in out Cais.Node_Type;
  3199.            Key        :    Relationship_Key := Latest_Key;
  3200.            Relation    :    Relation_Name     := Default_Relation;
  3201.            Mode        :    File_Mode     := Inout_File;
  3202.            Form        :    List_Type     := Empty_List;
  3203.            Attributes    :    List_Type     := Empty_List;
  3204.            Access_Control :    List_Type     := Empty_List;
  3205.            Level        :    List_Type     := Empty_List;
  3206.                  -- parameters not used in Create call
  3207.          Results    :in out Test_Vec;
  3208.          Test_Number    :    Natural;
  3209.          Situation    :    String) is
  3210.  
  3211.     begin
  3212.         Create (File, Base, Key, Relation, Mode, Form, Attributes,
  3213.             Access_Control, Level);
  3214.         Trace.Report (Natural'image(Test_Number) & ". Create fails to raise " &
  3215.             "Io_Definitions.Intent_Violation when "
  3216.             & Situation (Situation'range));
  3217.         Results (Test_Number) := Fail;
  3218.     exception
  3219.         when Node_Definitions.Intent_Violation =>
  3220.             Trace.Report (Natural'image(Test_Number) &
  3221.             ". OK -- Create raises " &
  3222.             "Io_Definitions.Intent_Violation when "
  3223.             & Situation (Situation'range));
  3224.         when others =>
  3225.         Trace.Report (Natural'image(Test_Number) &
  3226.         ". Unexpected exception in Create when "
  3227.         & Situation (Situation'range));
  3228.              Results (Test_Number) := Fail;
  3229.  
  3230.     end Intent_Trap; 
  3231.  
  3232.  
  3233. begin
  3234.     Trace.Enable_All;
  3235.  
  3236.     Open (Base, "'current_node", (1 => append_relationships));
  3237.     Create (File1, Base, "test1", "Exceptions", Inout_File);
  3238.  
  3239.     Name_Trap (File2, Base, "test1", "Exceptions", Inout_File,
  3240.             Results    => Test_Outcomes,
  3241.             Test_Number => 1,
  3242.             Situation => "file exists");
  3243.  
  3244.     Name_Trap (File2, Base, ".test2", "Exceptions", Inout_File,
  3245.             Results    => Test_Outcomes,
  3246.             Test_Number => 2,
  3247.             Situation => "key is bad");
  3248.  
  3249.     Name_Trap (File2, Base, "test3", "'Exceptions", Inout_File,
  3250.             Results    => Test_Outcomes,
  3251.             Test_Number => 3,
  3252.             Situation => "relation is bad");
  3253.  
  3254.     To_List ("(A=>Avalue)", Attr_List);
  3255.     Use_Trap (File2, Base, "test4", "Exceptions", Inout_File,
  3256.             Attributes => Attr_List,
  3257.             Results    => Test_Outcomes,
  3258.             Test_Number => 4,
  3259.             Situation => "attribute syntax illegal");
  3260.  
  3261.     To_List ("(Access_Method=>(Direct))", Attr_List);
  3262.     Use_Trap (File2, Base, "test5", "Exceptions", Inout_File,
  3263.             Attributes => Attr_List,
  3264.             Results    => Test_Outcomes,
  3265.             Test_Number => 5,
  3266.             Situation => "attribute semantics illegal");
  3267.  
  3268.     To_List ("(File_Kind=>(Avalue))", Attr_List);
  3269.     Use_Trap (File2, Base, "test6", "Exceptions", Inout_File,
  3270.             Attributes => Attr_List,
  3271.             Results    => Test_Outcomes,
  3272.             Test_Number => 6,
  3273.             Situation => "predefined attribute");
  3274.  
  3275.  
  3276.     Use_Trap (File2, Base, "test7", "Adopted_Role", Inout_File,
  3277.             Results    => Test_Outcomes,
  3278.             Test_Number => 7,
  3279.             Situation => "predefined relation");
  3280.  
  3281.     Status_Trap (Unopened_File, Unopened_Base, "test8", "Exceptions",
  3282.             Inout_File,
  3283.             Results    => Test_Outcomes,
  3284.             Test_Number => 8,
  3285.             Situation => "base not open");
  3286.  
  3287.     Status_Trap (File1, Base, "test9", "Exceptions",
  3288.             Inout_File,
  3289.             Results    => Test_Outcomes,
  3290.             Test_Number => 9,
  3291.             Situation => "file handle open");
  3292.  
  3293.     Close (Base);
  3294.     Delete (File1);
  3295.  
  3296.     Open (Base, "'current_node", (1 => existence));
  3297.     Intent_Trap (File2, Base, "test10", "Exceptions",
  3298.             Inout_File,
  3299.             Results    => Test_Outcomes,
  3300.             Test_Number => 10,
  3301.             Situation => "base intent not Append_Relationships");
  3302.  
  3303. end Create_Test;
  3304. --::::::::::::::
  3305. --io_ex_delete_test.a
  3306. --::::::::::::::
  3307.  
  3308. with Cais; use Cais;
  3309. with Trace;
  3310.  
  3311. procedure Delete_Test is
  3312.     use Node_Definitions;
  3313.     use Node_Management;
  3314.     use Cais.Text_Io;
  3315.     use List_Utilities;
  3316.  
  3317.     Test_Max: constant Natural := 20;
  3318.     type Test_Result is  (Succeed, Fail);
  3319.     type Test_Vec is Array (1..Test_Max) of Test_Result;
  3320.  
  3321.     Test_Outcomes : Test_Vec := (others => Succeed);
  3322.     Tests_Executed : Natural;
  3323.  
  3324.     File1 : File_Type;
  3325.     File2 : File_Type;
  3326.  
  3327.     Unopened_File  : File_Type;
  3328.     Unopened_Base  : Cais.Node_Type;
  3329.  
  3330.     Attr_List : List_Type;
  3331.  
  3332.     procedure Name_Trap ( 
  3333.              File           :in out File_Type;
  3334.                  -- parameters not used in Delete call
  3335.          Results    :in out Test_Vec;
  3336.          Test_Number    :    Natural;
  3337.          Situation    :    String) is
  3338.  
  3339.     begin
  3340.         Delete (File);
  3341.         Trace.Report (Natural'image(Test_Number) & ". Delete fails to raise " &
  3342.             "Io_Definitions.Name_Error when "
  3343.             & Situation (Situation'range));
  3344.         Results (Test_Number) := Fail;
  3345.     exception
  3346.         when Io_Definitions.Name_Error =>
  3347.             Trace.Report (Natural'image(Test_Number) &
  3348.             ". OK -- Delete raises " &
  3349.             "Io_Definitions.Name_Error when "
  3350.             & Situation (Situation'range));
  3351.         when others =>
  3352.         Trace.Report (Natural'image(Test_Number) &
  3353.         ". Unexpected exception in Delete ");
  3354.              Results (Test_Number) := Fail;
  3355.  
  3356.     end Name_Trap; 
  3357.  
  3358.  
  3359.  
  3360.     procedure Status_Trap ( 
  3361.              File           :in out File_Type;
  3362.                  -- parameters not used in Delete call
  3363.          Results    :in out Test_Vec;
  3364.          Test_Number    :    Natural;
  3365.          Situation    :    String) is
  3366.  
  3367.     begin
  3368.         Delete (File);
  3369.         Trace.Report (Natural'image(Test_Number) & ". Delete fails to raise " &
  3370.             "Io_Definitions.Status_Error when "
  3371.             & Situation (Situation'range));
  3372.         Results (Test_Number) := Fail;
  3373.     exception
  3374.         when Io_Definitions.Status_Error =>
  3375.             Trace.Report (Natural'image(Test_Number) &
  3376.             ". OK -- Delete raises " &
  3377.             "Io_Definitions.Status_Error when "
  3378.             & Situation (Situation'range));
  3379.         when others =>
  3380.         Trace.Report (Natural'image(Test_Number) &
  3381.         ". Unexpected exception in Delete ");
  3382.              Results (Test_Number) := Fail;
  3383.  
  3384.     end Status_Trap; 
  3385.  
  3386.  
  3387.     procedure Use_Trap ( 
  3388.              File           :in out File_Type;
  3389.                  -- parameters not used in Delete call
  3390.          Results    :in out Test_Vec;
  3391.          Test_Number    :    Natural;
  3392.          Situation    :    String) is
  3393.  
  3394.     begin
  3395.         Delete (File);
  3396.         Trace.Report (Natural'image(Test_Number) & ". Delete fails to raise " &
  3397.             "Io_Definitions.Use_Error when "
  3398.             & Situation (Situation'range));
  3399.         Results (Test_Number) := Fail;
  3400.     exception
  3401.         when Io_Definitions.Use_Error =>
  3402.             Trace.Report (Natural'image(Test_Number) &
  3403.             ". OK -- Delete raises " &
  3404.             "Io_Definitions.Use_Error when "
  3405.             & Situation (Situation'range));
  3406.         when others =>
  3407.         Trace.Report (Natural'image(Test_Number) &
  3408.         ". Unexpected exception in Delete ");
  3409.              Results (Test_Number) := Fail;
  3410.  
  3411.     end Use_Trap; 
  3412.  
  3413.  
  3414.     procedure Intent_Trap ( 
  3415.              File           :in out File_Type;
  3416.                  -- parameters not used in Delete call
  3417.          Results    :in out Test_Vec;
  3418.          Test_Number    :    Natural;
  3419.          Situation    :    String) is
  3420.  
  3421.     begin
  3422.         Delete (File);
  3423.         Trace.Report (Natural'image(Test_Number) & ". Delete fails to raise " &
  3424.             "Io_Definitions.Intent_Violation when "
  3425.             & Situation (Situation'range));
  3426.         Results (Test_Number) := Fail;
  3427.     exception
  3428.         when Node_Definitions.Intent_Violation =>
  3429.             Trace.Report (Natural'image(Test_Number) &
  3430.             ". OK -- Delete raises " &
  3431.             "Io_Definitions.Intent_Violation when "
  3432.             & Situation (Situation'range));
  3433.         when others =>
  3434.         Trace.Report (Natural'image(Test_Number) &
  3435.         ". Unexpected exception in Delete ");
  3436.              Results (Test_Number) := Fail;
  3437.  
  3438.     end Intent_Trap; 
  3439.  
  3440.  
  3441. begin
  3442.     Trace.Enable_All;
  3443.  
  3444.  
  3445.     -- Cannot test for Name_Error on inaccessible parent until
  3446.     --   discretionary access control is in place.
  3447.     Trace.Report ("1. OK -- test for Name_Error is stubbed.");
  3448.  
  3449.  
  3450.     Create (File1, "'current_node'del_exc(test2_parent)",Inout_File);
  3451.     Create (File2, "'current_node'del_exc(test2_parent).child",Inout_File);
  3452.     Use_Trap (File1,
  3453.             Results    => Test_Outcomes,
  3454.             Test_Number => 2,
  3455.             Situation => "primary relationships emanate from " &
  3456.                 "node to be deleted");
  3457.     Delete (File2);
  3458.     Delete (File1);
  3459.  
  3460.  
  3461.     Status_Trap (Unopened_File,
  3462.             Results    => Test_Outcomes,
  3463.             Test_Number => 3,
  3464.             Situation => "file handle is not open");
  3465.  
  3466.  
  3467. end Delete_Test;
  3468. --::::::::::::::
  3469. --io_ex_open_test.a
  3470. --::::::::::::::
  3471.  
  3472. with Cais; use Cais;
  3473. with Trace;
  3474.  
  3475. procedure Open_Test is
  3476.     use Node_Definitions;
  3477.     use Node_Management;
  3478.     use Cais.Text_Io;
  3479.     use List_Utilities;
  3480.  
  3481.     Test_Max: constant Natural := 20;
  3482.     type Test_Result is  (Succeed, Fail);
  3483.     type Test_Vec is Array (1..Test_Max) of Test_Result;
  3484.  
  3485.     Test_Outcomes : Test_Vec := (others => Succeed);
  3486.     Tests_Executed : Natural;
  3487.  
  3488.     package Dir_Io is new Cais.Direct_Io (Integer);
  3489.     package Dir_Defs renames Dir_Io.Dir_Io_Definitions;
  3490.      
  3491.     File1 : File_Type;
  3492.     File2 : File_Type;
  3493.     FileX : Dir_Io.File_Type;
  3494.  
  3495.     Node1 : Cais.Node_Type;
  3496.     Node2 : Cais.Node_Type; -- Not a text file
  3497.  
  3498.     Unopened_File  : File_Type;
  3499.     Unopened_Node  : Cais.Node_Type;
  3500.  
  3501.     Attr_List : List_Type;
  3502.  
  3503.  
  3504.     procedure Status_Trap ( 
  3505.              File           :in out File_Type;
  3506.          Node        :    Cais.Node_Type;
  3507.            Mode        :    File_Mode     := Inout_File;
  3508.                  -- parameters not used in Open call
  3509.          Results    :in out Test_Vec;
  3510.          Test_Number    :    Natural;
  3511.          Situation    :    String) is
  3512.  
  3513.     begin
  3514.         Open (File, Node, Mode);
  3515.         Trace.Report (Natural'image(Test_Number) & ". Open fails to raise " &
  3516.             "Io_Definitions.Status_Error when "
  3517.             & Situation (Situation'range));
  3518.         Results (Test_Number) := Fail;
  3519.     exception
  3520.         when Io_Definitions.Status_Error =>
  3521.             Trace.Report (Natural'image(Test_Number) &
  3522.             ". OK -- Open raises " &
  3523.             "Io_Definitions.Status_Error when "
  3524.             & Situation (Situation'range));
  3525.         when others =>
  3526.         Trace.Report (Natural'image(Test_Number) &
  3527.         ". Unexpected exception in Open ");
  3528.              Results (Test_Number) := Fail;
  3529.  
  3530.     end Status_Trap; 
  3531.  
  3532.  
  3533.     procedure Use_Trap ( 
  3534.              File           :in out File_Type;
  3535.          Node        :    Cais.Node_Type;
  3536.            Mode        :    File_Mode     := Inout_File;
  3537.                  -- parameters not used in Open call
  3538.          Results    :in out Test_Vec;
  3539.          Test_Number    :    Natural;
  3540.          Situation    :    String) is
  3541.  
  3542.     begin
  3543.         Open (File, Node, Mode);
  3544.         Trace.Report (Natural'image(Test_Number) & ". Open fails to raise " &
  3545.             "Io_Definitions.Use_Error when "
  3546.             & Situation (Situation'range));
  3547.         Results (Test_Number) := Fail;
  3548.     exception
  3549.         when Io_Definitions.Use_Error =>
  3550.             Trace.Report (Natural'image(Test_Number) &
  3551.             ". OK -- Open raises " &
  3552.             "Io_Definitions.Use_Error when "
  3553.             & Situation (Situation'range));
  3554.         when others =>
  3555.         Trace.Report (Natural'image(Test_Number) &
  3556.         ". Unexpected exception in Open ");
  3557.              Results (Test_Number) := Fail;
  3558.  
  3559.     end Use_Trap; 
  3560.  
  3561.  
  3562.     procedure Intent_Trap ( 
  3563.              File           :in out File_Type;
  3564.          Node        :    Cais.Node_Type;
  3565.            Mode        :    File_Mode     := Inout_File;
  3566.                  -- parameters not used in Open call
  3567.          Results    :in out Test_Vec;
  3568.          Test_Number    :    Natural;
  3569.          Situation    :    String) is
  3570.  
  3571.     begin
  3572.         Open (File, Node, Mode);
  3573.         Trace.Report (Natural'image(Test_Number) & ". Open fails to raise " &
  3574.             "Io_Definitions.Intent_Violation when "
  3575.             & Situation (Situation'range));
  3576.         Results (Test_Number) := Fail;
  3577.     exception
  3578.         when Node_Definitions.Intent_Violation =>
  3579.             Trace.Report (Natural'image(Test_Number) &
  3580.             ". OK -- Open raises " &
  3581.             "Io_Definitions.Intent_Violation when "
  3582.             & Situation (Situation'range));
  3583.         when others =>
  3584.         Trace.Report (Natural'image(Test_Number) &
  3585.         ". Unexpected exception in Open ");
  3586.              Results (Test_Number) := Fail;
  3587.  
  3588.     end Intent_Trap; 
  3589.  
  3590.  
  3591. begin
  3592.     Trace.Enable_All;
  3593.  
  3594.  
  3595.     Structural_Nodes.Create_Node (Node => Node1,
  3596.         Name => "'Current_Node'Open_Exc(test1)");
  3597.     Use_Trap (File1, Node1, Out_File,
  3598.             Results    => Test_Outcomes,
  3599.             Test_Number => 1,
  3600.             Situation => "not a file node");
  3601.     Close (Node1);
  3602.     Open (Node => Node1,
  3603.         Name => "'Current_Node'Open_Exc(test1)",
  3604.         Intent => (1 => Exclusive_Write, 2 => Read_Relationships));
  3605.     Delete_Node (Node1);
  3606.  
  3607.  
  3608.     Dir_Io.Create (FileX, "'Current_Node'Open_Exc(test2)",
  3609.                     Dir_Defs.Inout_File);
  3610.     Dir_Io.Close (FileX);
  3611.     Open (Node2, "'Current_Node'Open_Exc(test2)",
  3612.         (1=> Read, 2 => Exclusive_Write));
  3613.     Use_Trap (File2, Node2, In_File,
  3614.             Results    => Test_Outcomes,
  3615.             Test_Number => 2,
  3616.             Situation => "not Text Access_Method");
  3617.     Delete_Node (Node2);
  3618.  
  3619.  
  3620.     Status_Trap (Unopened_File, Unopened_Node, Inout_File,
  3621.             Results    => Test_Outcomes,
  3622.             Test_Number => 3,
  3623.             Situation => "node handle not open");
  3624.  
  3625.  
  3626.     Create (File2, "'Current_Node'Open_Exc(test4)", Inout_File);
  3627.     Open (Node2, "'Current_Node'Open_Exc(test4) ", (1 => Write));
  3628.     Status_Trap (File2, Node2, Out_File,
  3629.             Results    => Test_Outcomes,
  3630.             Test_Number => 4,
  3631.             Situation => "file handle open");
  3632.     Close (Node2);
  3633.     Delete (File2);
  3634.  
  3635.  
  3636.     Create (File1, "'Current_Node'Open_Exc(test5)", Inout_File);
  3637.     Open (Node2, "'Current_Node'Open_Exc(test5)", (1 => Existence));
  3638.     Intent_Trap (File2, Node2, Append_File,
  3639.             Results    => Test_Outcomes,
  3640.             Test_Number => 5,
  3641.             Situation => " intent disallows mode");
  3642.     Close (Node2);
  3643.     Delete (File1);
  3644.  
  3645. end Open_Test;
  3646. --::::::::::::::
  3647. --list_test_02_12.a
  3648. --::::::::::::::
  3649. with Cais; use Cais;
  3650. with Text_Io;        use Text_Io;
  3651. procedure List_Test_02_12 is
  3652.  
  3653.  
  3654. procedure Test2 is
  3655.  
  3656. use List_Utilities; 
  3657. use String_Items;
  3658.  
  3659.     List2       : List_Type;
  3660.     List1       : List_Type;
  3661.     String_Item : string(1..24);
  3662.  
  3663.  
  3664.    procedure Show(L1 : List_Type;
  3665.               L2 : List_Type;
  3666.               L3 : String;
  3667.           II : Positive) is
  3668.         XX : string(1..35) := "                                   ";
  3669.    begin
  3670.     put_line(         L3  );
  3671.     if To_Text(L1) = To_Text(L2) then
  3672.       put_line(XX & "**************PASSES TEST " & Positive'Image(II) );
  3673.     else
  3674.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  3675.     end if;
  3676.    exception
  3677.      when others =>
  3678.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  3679.    end Show;
  3680. begin
  3681.     To_List("(1,01,1234567890,1.,1_1,1_1.1_1,1.45,1E+01,1E-24)",List2);--numbers
  3682.     Copy   (List1,List2);
  3683.     Show(List1, List2, "(1,01,1234567890,1.,1_1,1_1.1_1,1.45,1E+01,1E-24)",1);
  3684.  
  3685.  
  3686.     To_List("(""1"",""embedded"""""",""in""""middle"")",List2);--strings
  3687.     Copy   (List1,List2);
  3688.     Show(List1, List2, "(""1"",""embedded"""""",""in""""middle"")",2);--strings
  3689.  
  3690.     To_List("(""Name"",""ID001"",""ada_name"")",List2);--identifiers
  3691.     Copy   (List1,List2);
  3692.     Show(List1, List2, "(""Name"",""ID001"",""ada_name"")",3);
  3693.  
  3694. To_List("((list),(list,(sublist),(sublist)),((sub1list,(sub2list))))",List2);
  3695. Copy   (List1,List2);
  3696. Show(List1,List2,"((list),(list,(sublist),(sublist)),((sub1list,(sub2list))))",4);
  3697.  
  3698.     To_List("( I=>1, you=>2, We=>3, Them_Guys=>4)", List2);
  3699.     Copy(List1, List2);
  3700.     Show(List1, List2, "( I=>1, you=>2, We=>3, Them_Guys=>4)",5);
  3701. end Test2;
  3702.  
  3703. procedure Test3 is
  3704.  
  3705. use List_Utilities; 
  3706. use String_Items;
  3707.  
  3708.     List2       : List_Type;
  3709.     String_Item : string(1..24);
  3710.  
  3711.    procedure Test(L1 : String;
  3712.               L2 : List_Type;
  3713.           II : Positive) is
  3714.         XX : string(1..35) := "                                   ";
  3715.    begin
  3716.     put_line(L1);
  3717.     put_line(To_Text(L2));
  3718.     if To_Text(L2) = L1 then
  3719.       put_line(XX & "**************PASSES TEST " & Positive'Image(II) );
  3720.     else
  3721.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  3722.     end if;
  3723.    exception
  3724.      when others =>
  3725.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  3726.    end Test;
  3727.  
  3728. begin
  3729.     To_List("(1,01,1234567890,1.,1_1,1_1.1_1,1.45,1E+01,1E-24)",List2);--numbers
  3730.     Test("(1,01,1234567890,1.,1_1,1_1.1_1,1.45,1E+01,1E-24)",List2,1);--numbers
  3731.  
  3732.     To_List("(""1"",""embedded"""""",""in""""middle"")",List2);--strings
  3733.     Test("(""1"",""embedded"""""",""in""""middle"")",List2,2);--strings
  3734.  
  3735.     To_List("(""Name"",""ID001"",""ada_name"")",List2);--identifiers
  3736.     Test("(""Name"",""ID001"",""ada_name"")",List2,3);--identifiers
  3737.  
  3738.     To_List("((list), (list,(sublist),(sublist)), ((sub1list,(sub2list))) )",
  3739.                        List2);--lists
  3740.     Test("((LIST),(LIST,(SUBLIST),(SUBLIST)),((SUB1LIST,(SUB2LIST))))",
  3741.                        List2,4);--lists
  3742.  
  3743. end Test3;
  3744.  
  3745.  
  3746.  
  3747. procedure Test4 is
  3748.  
  3749. use List_Utilities; 
  3750. use String_Items;
  3751.  
  3752.     List2       : List_Type;
  3753.     String_Item : string(1..24);
  3754.  
  3755.    procedure Test(L1 : String;
  3756.               L2 : List_Type;
  3757.           II : Positive) is
  3758.         XX : string(1..35) := "                                   ";
  3759.    begin
  3760.     put_line(L1);
  3761.     if To_Text(L2) = L1 then
  3762.       put_line(XX & "**************PASSES TEST " & Positive'Image(II) );
  3763.     else
  3764.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  3765.     end if;
  3766.    exception
  3767.      when others =>
  3768.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  3769.    end Test;
  3770.  
  3771. begin
  3772.     To_List("(1,01,1234567890,1.,1_1,1_1.1_1,1.45,1E+01,1E-24)",List2);--numbers
  3773.     Test("(1,01,1234567890,1.,1_1,1_1.1_1,1.45,1E+01,1E-24)", List2, 1);
  3774.     
  3775.  
  3776.     To_List("(""1"",""embedded"""""",""in""""middle"")",List2);--strings
  3777.     Test( "(""1"",""embedded"""""",""in""""middle"")", List2, 2);
  3778.  
  3779.     To_List("(""Name"",""ID001"",""ada_name"")",List2);--identifiers
  3780.     Test( "(""Name"",""ID001"",""ada_name"")", List2, 3);
  3781.  
  3782.     To_List("((list), (list,(sublist),(sublist)), ((sub1list,(sub2list))) )",
  3783.                        List2);--lists
  3784.     Test("((LIST),(LIST,(SUBLIST),(SUBLIST)),((SUB1LIST,(SUB2LIST))))",List2,4);
  3785.  
  3786. end Test4;
  3787.  
  3788.  
  3789.  
  3790. procedure Test5 is
  3791.  
  3792. use List_Utilities; 
  3793. use String_Items;
  3794.     List2       : List_Type;
  3795.     List1       : List_Type;
  3796.     String_Item : string(1..24);
  3797.  
  3798.    procedure Show(L1 : List_Type;
  3799.               L2 : List_Type;
  3800.               L3 : String;
  3801.           II : Positive) is
  3802.         XX : string(1..35) := "                                   ";
  3803.    begin
  3804.     put_line(         L3  );
  3805.     if Is_Equal(L1, L2) then
  3806.       put_line(XX & "**************PASSES TEST " & Positive'Image(II) );
  3807.     else
  3808.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  3809.     end if;
  3810.    exception
  3811.      when others =>
  3812.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  3813.    end Show;
  3814. begin
  3815.     To_List("(1,01,1234567890,1.,1_1,1_1.1_1,1.45,1E+01,1E-24)",List2);--numbers
  3816.     Copy   (List1,List2);
  3817.     Show(List1, List2, "(1,01,1234567890,1.,1_1,1_1.1_1,1.45,1E+01,1E-24)",1);
  3818.  
  3819.  
  3820.     To_List("(""1"",""embedded"""""",""in""""middle"")",List2);--strings
  3821.     Copy   (List1,List2);
  3822.     Show(List1, List2, "(""1"",""embedded"""""",""in""""middle"")",2);--strings
  3823.  
  3824.     To_List("(""Name"",""ID001"",""ada_name"")",List2);--identifiers
  3825.     Copy   (List1,List2);
  3826.     Show(List1, List2, "(""Name"",""ID001"",""ada_name"")",3);
  3827.  
  3828. To_List("((list),(list,(sublist),(sublist)),((sub1list,(sub2list))))",List2);
  3829. Copy   (List1,List2);
  3830. Show(List1,List2,"((list),(sublist)),((sublist)),((sublist,(sub2list))))",4);
  3831.  
  3832.     To_List("( I=>1, you=>2, We=>3, Them_Guys=>4)", List2);
  3833.     Copy(List1, List2);
  3834.     Show(List1, List2, "( I=>1, you=>2, We=>3, Them_Guys=>4)",5);
  3835. end Test5;
  3836.  
  3837.  
  3838. ------------------------------------------------------------------------
  3839. --Tests the DELETE operation on any item type within a list    5.4.1.6--
  3840. ------------------------------------------------------------------------
  3841. procedure Test6 is
  3842. use List_Utilities; 
  3843. use String_Items;
  3844. use Identifier_Items;
  3845.     List2       : List_Type;
  3846.     List1       : List_Type;
  3847.     Tok_You     : Token_Type;
  3848.     Tok_I        : Token_Type;
  3849.     Tok_We      : Token_Type;
  3850.     Tok_Them_G  : Token_Type;
  3851.     Tok_UPPER   : Token_Type;
  3852.     Tok_Low        : Token_Type;
  3853.     String_Item : string(1..24);
  3854.  
  3855.    procedure Show(L1 : List_Type;
  3856.               L2 : List_Type;
  3857.               L3 : String;
  3858.           II : Positive) is
  3859.         XX : string(1..35) := "                                   ";
  3860.    begin
  3861.     put_line(         L3  );
  3862.     if Is_Equal(L1,L2) then
  3863.       put_line(XX & "**************PASSES TEST " & Positive'Image(II) );
  3864.     else
  3865.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  3866.     end if;
  3867.    exception
  3868.      when others =>
  3869.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  3870.    end Show;
  3871. begin
  3872. put_line("-------------------------------------------------------------");
  3873. put_line("Tests the DELETE operation   5.4.1.6");
  3874. put_line("-------------------------------------------------------------");
  3875.     To_List("(1,2,3,4,5,6)",List2);
  3876.     To_List("(1,2,4,5)",List1);
  3877.     Delete(List2,3);
  3878.     Delete(List2,5);
  3879.     Show(List1, List2, "*** 3 AND 6 *** SHOULD BE DELETED",1);
  3880.  
  3881.  
  3882.  
  3883. To_List("((list),(list,(sublist),(sublist)),((sub1list,(sub2list))))",List2);
  3884. To_List("((list),((sub1list,(sub2list))))",List1);
  3885. Delete (List2,2);
  3886. Show(List1,List2,"MIDDLE LIST DELETED (list,(sublist),(sublist)) ****",2);
  3887.  
  3888.     To_List("( I=>1, you=>2, We=>3, Them_Guys=>4)", List2);
  3889.     To_List("( you=>2 )", List1);
  3890.     Delete (List2,"We ");
  3891.     Delete (List2,1);
  3892.     Delete (List2,2);
  3893.     Show(List1, List2, "ONLY ""YOU"" SHOULD REMAIN",3);
  3894.  
  3895.     To_Token("You",      Tok_You);
  3896.     To_Token("I",        Tok_I);
  3897.     To_Token("We",       Tok_We);
  3898.     To_Token("Them_Guys",Tok_Them_G);
  3899.     To_Token("YOU",      Tok_UPPER);
  3900.     To_Token("we",       Tok_Low);
  3901.     To_List("( I=>1, you=>2, We=>3, Them_Guys=>4)", List2);
  3902.     To_List("( Them_Guys=>4)", List1);
  3903.     Delete(List2, Tok_You);
  3904.     Delete(List2, "I    ");
  3905.     Delete(List2, Tok_We);
  3906.     Show(List1, List2, "ONLY ""THEM_GUYS"" SHOULD REMAIN",4);
  3907.  
  3908.     To_List("( I=>1, you=>2, We=>3, Them_Guys=>4)", List2);
  3909.     To_List("( I=>1 )", List1);
  3910.     Delete(List2, Tok_Them_G);
  3911.     Delete(List2, Tok_UPPER);
  3912.     Delete(List2, Tok_Low);
  3913.     Show(List1, List2, "ONLY ""I"" SHOULD REMAIN",5);
  3914. end Test6;
  3915.  
  3916.  
  3917.  
  3918.  
  3919. ------------------------------------------------------------------------
  3920. --Tests the GET_LIST_KIND operation on any list               5.4.1.7--
  3921. ------------------------------------------------------------------------
  3922. procedure Test7 is
  3923. use List_Utilities; 
  3924.  
  3925.     List2       : List_Type;
  3926. begin
  3927.     To_List("(ONE=>1,TWO=>2)",List2);
  3928.     if Get_List_Kind(List2) = Named then
  3929.     put_line("NAMED   List OK.  TEST 1 PASSES");
  3930.     else
  3931.     put_line("NAMED error*******TEST 1 FAILS*************");
  3932.     end if;
  3933.  
  3934.     Delete(List2,2);
  3935.     Delete(List2,1);
  3936.     if Get_List_Kind(List2) = Empty then
  3937.     put_line("EMPTY   List OK.  TEST 2 PASSES");
  3938.     else
  3939.     put_line("EMPTY error*******TEST 2 FAILS*************");
  3940.     end if;
  3941.  
  3942.     To_List("(1,2,3)",List2);
  3943.     if Get_List_Kind(List2) = Unnamed then
  3944.     put_line("UNNAMED List OK.  TEST 3 PASSES");
  3945.     else
  3946.     put_line("UNNAMED error*******TEST 3 FAILS*************");
  3947.     end if;
  3948.  
  3949. end Test7;
  3950.  
  3951.  
  3952.  
  3953.  
  3954. ------------------------------------------------------------------------
  3955. --Tests the GET_ITEM_KIND operation on any item type in a list 5.4.1.8--
  3956. ------------------------------------------------------------------------
  3957. procedure Test8 is
  3958. use List_Utilities;
  3959.     List2 : List_Type;
  3960. begin
  3961.     To_List("(1, 3.14, ID_NAME, ""string"", (1,2) )", List2);
  3962.     if Get_Item_Kind(List2,1) = Integer_Item then
  3963.     put_line("Integer_Item       OK.       TEST 1 PASSES");
  3964.     else
  3965.     put_line("Integer_Item     error*******TEST 1 FAILS*****");
  3966.     end if;
  3967.  
  3968.     if Get_Item_Kind(List2,2) = Float_Item   then
  3969.     put_line("Float_Item         OK.       TEST 2 PASSES");
  3970.     else
  3971.     put_line("Float_Item       error*******TEST 2 FAILS*****");
  3972.     end if;
  3973.  
  3974.     if Get_Item_Kind(List2,3) = Identifier_Item then
  3975.     put_line("Identifier_Item    OK.       TEST 3 PASSES");
  3976.     else
  3977.     put_line("Identifier_Item  error*******TEST 3 FAILS*****");
  3978.     end if;
  3979.  
  3980.     if Get_Item_Kind(List2,5) = List_Item    then
  3981.     put_line("List_Item          OK.       TEST 4 PASSES");
  3982.     else
  3983.     put_line("List_Item        error*******TEST 4 FAILS*****");
  3984.     end if;
  3985.  
  3986.     if Get_Item_Kind(List2,4) = String_Item  then
  3987.     put_line("String_Item        OK.       TEST 5 PASSES");
  3988.     else
  3989.     put_line("String_Item      error*******TEST 5 FAILS*****");
  3990.     end if;
  3991.  
  3992.  
  3993.  
  3994.  
  3995.     To_List("(aa=>1, bb=>3.14, cc=>ID_NAME, dd=>""string"", ee=>(1,2) )",List2);
  3996.     if Get_Item_Kind(List2,"aa") = Integer_Item then
  3997.     put_line("Integer_Item       OK.       TEST 6 PASSES");
  3998.     else
  3999.     put_line("Integer_Item     error*******TEST 6 FAILS*****");
  4000.     end if;
  4001.  
  4002.     if Get_Item_Kind(List2,"bb") = Float_Item   then
  4003.     put_line("Float_Item         OK.       TEST 7 PASSES");
  4004.     else
  4005.     put_line("Float_Item       error*******TEST 7 FAILS*****");
  4006.     end if;
  4007.  
  4008.     if Get_Item_Kind(List2,3) = Identifier_Item then
  4009.     put_line("Identifier_Item    OK.       TEST 8 PASSES");
  4010.     else
  4011.     put_line("Identifier_Item  error*******TEST 8 FAILS*****");
  4012.     end if;
  4013.  
  4014.     if Get_Item_Kind(List2,"ee") = List_Item    then
  4015.     put_line("List_Item          OK.       TEST 9 PASSES");
  4016.     else
  4017.     put_line("List_Item        error*******TEST 9 FAILS*****");
  4018.     end if;
  4019.  
  4020.     if Get_Item_Kind(List2,4) = String_Item  then
  4021.     put_line("String_Item        OK.       TEST 10 PASSES");
  4022.     else
  4023.     put_line("String_Item      error*******TEST 10 FAILS*****");
  4024.     end if;
  4025.  
  4026. end Test8;
  4027.  
  4028.  
  4029.  
  4030.  
  4031. ------------------------------------------------------------------------
  4032. --Tests the SPLICE operation on any two lists               5.4.1.9--
  4033. ------------------------------------------------------------------------
  4034. procedure Test9 is
  4035. use List_Utilities;
  4036.     List1 : List_Type;
  4037.     List2 : List_Type;
  4038.     List3 : List_Type;
  4039.         List4 : List_Type;
  4040.         List5 : List_Type;
  4041.  
  4042.    procedure Test(L1 : List_Type;
  4043.               L2 : List_Type;
  4044.           II : Positive) is
  4045.         XX : string(1..35) := "                                   ";
  4046.    begin
  4047.     put_line(To_Text(L1));
  4048.     if Is_Equal(L2,L1) then
  4049.       put_line(XX & "**************PASSES TEST " & Positive'Image(II) );
  4050.     else
  4051.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4052.     end if;
  4053.    exception
  4054.      when others =>
  4055.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4056.    end Test;
  4057.  
  4058. begin
  4059.     To_List     ("( ""3"" )",                List1);
  4060.     To_List     (" (""1"", ""2"", ""4"") ",  List2);
  4061.     To_List     (" (""1"", ""2"", ""3"", ""4"") ",  List5);
  4062.     Splice      (List2,2,List1);
  4063.     Test(List2,List5,1);
  4064.  
  4065.     To_List     ("(1,2,3,4)", List1);
  4066.     To_List     (" (""1"", ""2"", ""3"", ""4"",1,2,3,4) ",  List5);
  4067.     Splice      (List2,4,List1);
  4068.     Test(List2,List5,2);
  4069.  
  4070.     To_List     ("(A=>Mike, A_1=>Mary)",List3);
  4071.     To_List     ("(B=>Mark)",           List4);
  4072.     To_List     ("(A=>Mike, B=>Mark, A_1=>Mary)",List5);
  4073.     Splice      (List3,1,List4);
  4074.     Test(List3,List5,3);
  4075.  
  4076.     begin
  4077.       Splice    (List3,0,List4);
  4078.       Put_line  ("ZERO POSITION SPLICE IS SUPPORTED **ERR** FAILS TEST 4");
  4079.     exception   
  4080.       when others =>
  4081.       Put_line  ("ZERO POSITION SPLICE IS CORRECTLY FLAGGED PASSES TEST 4");
  4082.     end;
  4083.  
  4084. end Test9;
  4085.  
  4086.  
  4087.  
  4088. ------------------------------------------------------------------------
  4089. --Tests the MERGE operation on any two lists              5.4.1.10--
  4090. ------------------------------------------------------------------------
  4091. procedure Test10 is
  4092.  
  4093. use List_Utilities;
  4094.  
  4095.     List1 : List_Type;
  4096.     List2 : List_Type;
  4097.     List3 : List_Type;
  4098.         List4 : List_Type;
  4099.     List5 : List_type;
  4100.     List6 : List_type;
  4101.     List7 : List_type;
  4102.  
  4103.    procedure Test(L1 : List_Type;
  4104.               L2 : List_Type;
  4105.           II : Positive) is
  4106.         XX : string(1..35) := "                                   ";
  4107.    begin
  4108.     put_line(To_Text(L1));
  4109.     if Is_Equal(L1,L2) then
  4110.       put_line(XX & "**************PASSES TEST " & Positive'Image(II) );
  4111.     else
  4112.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4113.     end if;
  4114.    exception
  4115.      when others =>
  4116.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4117.    end Test;
  4118.  
  4119. begin
  4120.     To_List     ("( ""3"" )",                List1);
  4121.     To_List     (" (""1"", ""2"", ""4"") ",  List2);
  4122.     Merge       (List1,List2,List5);
  4123.     To_List     (" (""3"", ""1"", ""2"", ""4"") ",  List7);
  4124.     Test(List5,List7,1);
  4125.  
  4126.     To_List     ("(1,2,3,4)", List1);
  4127.     Merge       (List1,List2,List5);
  4128.     To_List     (" (1,2,3,4,""1"", ""2"", ""4"") ",  List7);
  4129.     Test(List5,List7,2);
  4130.  
  4131.     To_List     ("(A=>Mike, A_1=>Mary)",List3);
  4132.     To_List     ("(B=>Mark)",           List4);
  4133.     Merge       (List3,List4,List5);
  4134.     To_List     ("(A=>Mike, A_1=>Mary,B=>Mark)",List7);
  4135.     Test(List5,List7,3);
  4136.  
  4137.     To_List     ("()", List6);                      --test null lists
  4138.     Merge       (List1,List6,List5);
  4139.     To_List     ("(1,2,3,4)", List7);
  4140.     Test(List5,List7,4);
  4141.  
  4142.     Merge       (List6,List2,List5);
  4143.     To_List     (" (""1"", ""2"", ""4"") ",  List7);
  4144.     Test(List5,List7,5);
  4145.  
  4146.     Merge       (List3,List6,List5);
  4147.     To_List     ("(A=>Mike, A_1=>Mary)",List7);
  4148.     Test(List5,List7,6);
  4149.  
  4150.     Merge       (List6,List4,List5);
  4151.     To_List     ("(B=>Mark)",           List7);
  4152.     Test(List5,List7,7);
  4153.  
  4154. end Test10;
  4155.  
  4156.  
  4157. ------------------------------------------------------------------------
  4158. --Tests the SET_EXTRACT operation on any sublist of a list    5.4.1.11--
  4159. ------------------------------------------------------------------------
  4160. procedure Test11 is
  4161.  
  4162. use List_Utilities; 
  4163. use String_Items;
  4164.  
  4165.     List2       : List_Type;
  4166.     String_Item : string(1..24);
  4167.  
  4168.    procedure Test(L1 : String;
  4169.               L2 : String;
  4170.               L3 : String;
  4171.           II : Positive) is
  4172.         XX : string(1..35) := "                                   ";
  4173.         L4 : List_Type;
  4174.         L5 : List_Type;
  4175.    begin
  4176.     put_line(         L3  );
  4177.     To_List(L1, L4);
  4178.     To_List(L2, L5);
  4179.     if Is_Equal(L4,L5) then
  4180.       put_line(XX & "**************PASSES TEST " & Positive'Image(II) );
  4181.     else
  4182.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4183.     end if;
  4184.    exception
  4185.      when others =>
  4186.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4187.    end Test;
  4188. begin
  4189.     To_List("(1,01,1234567890,1.,1_1,1_1.1_1,1.45,1E+01,1E-24)",List2);--numbers
  4190.     put_line("(1,01,1234567890,1.,1_1,1_1.1_1,1.45,1E+01,1E-24)  --numbers");
  4191.     Test( "(1234567890,1.,1_1,1_1.1_1,1.45,1E+01)",
  4192.          Set_Extract(List2,3,6), "TOKENS 3-6", 1);
  4193.  
  4194.     Test( "(1234567890,1.,1_1,1_1.1_1,1.45,1E+01,1E-24)",
  4195.          Set_Extract(List2,3,9), "TOKENS 3-9", 2);
  4196.  
  4197.     To_List("(""1"",""embedded"""""",""in""""middle"")",List2);--strings
  4198.     put_line("(""1"",""embedded"""""",""in""""middle"") --strings");
  4199.     Test( "(""1"",""embedded"""""")", Set_Extract(List2,1,2), "TOKENS 1-2", 3);
  4200.     Test( "(""1"")", Set_Extract(List2,1,1), "TOKENS 1-1", 4);
  4201.  
  4202.     To_List("(""Name"",""ID001"",""ada_name"")",List2);--identifiers
  4203.     put_line("(""Name"",""ID001"",""ada_name"")  --identifiers");
  4204.     Test( "(""ada_name"")", Set_Extract(List2,3,1), "TOKENS 3-3", 5);
  4205.  
  4206.     To_List("((list), (list,(sublist),(sublist)), ((sub1list,(sub2list))) )",
  4207.                        List2);--lists
  4208.     put_line("((list), (list,(sublist),(sublist)), ((sub1list,(sub2list))) )" &
  4209.          "--lists");
  4210.     Test("((list),(list,(sublist),(sublist)),((sub1list,(sub2list))))",
  4211.          Set_Extract(List2,1,3), "TOKENS 1-3", 6);
  4212.     Test("((list),(list,(sublist),(sublist)))",
  4213.          Set_Extract(List2,1,2), "TOKENS 1-2", 7);
  4214.  
  4215. end Test11;
  4216.  
  4217.  
  4218.  
  4219.  
  4220. ------------------------------------------------------------------------
  4221. --Tests the LENGTH operation on any list              5.4.1.12--
  4222. ------------------------------------------------------------------------
  4223. procedure Test12 is
  4224.  
  4225. use List_Utilities; 
  4226. use String_Items;
  4227.     List1 : List_Type;
  4228.     List2 : List_Type;
  4229.     List3 : List_Type;
  4230.         List4 : List_Type;
  4231.     List5 : List_type;
  4232.     List6 : List_type;
  4233.     String_Item : string(1..24);
  4234.  
  4235.    procedure Test(L1 : List_Utilities.Count;
  4236.               L2 : List_Utilities.Count;
  4237.           II : Positive) is
  4238.     XX : String(1..35) := "                                   ";
  4239.    begin
  4240.     put_line("EXPECT" & List_Utilities.Count'image(L1) & " => GET " 
  4241.               & List_Utilities.Count'image(L2));
  4242.     if L1 = L2 then
  4243.       put_line(XX & "**************PASSES TEST " & Positive'Image(II) );
  4244.     else
  4245.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4246.     end if;
  4247.    exception
  4248.      when others =>
  4249.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4250.    end Test;
  4251.  
  4252. begin
  4253.     To_List("(1,01,1234567890,1.,1_1,1_1.1_1,1.45,1E+01,1E-24)",List2);--numbers
  4254.     put_line( "(1,01,1234567890,1.,1_1,1_1.1_1,1.45,1E+01,1E-24)" );
  4255.     Test(9, Length(List2), 1);
  4256.  
  4257.     To_List("(""1"",""embedded"""""",""in""""middle"")",List2);--strings
  4258.     put_line( "(""1"",""embedded"""""",""in""""middle"")" );
  4259.     Test(3, Length(List2), 2);
  4260.  
  4261.     To_List("(""Name"",""ID001"",""ada_name"")",List2);--identifiers
  4262.     put_line( "(""Name"",""ID001"",""ada_name"")" );
  4263.     Test(3, Length(List2), 3);
  4264.  
  4265.     To_List("((list), (list,(sublist),(sublist)), ((sub1list,(sub2list))) )",
  4266.                        List2);--lists
  4267.     Test(3, Length(List2), 4);
  4268.  
  4269.     To_List     ("( ""3"" )",                List1);
  4270.     To_List     (" (""1"", ""2"", ""4"") ",  List2);
  4271.     Merge       (List1,List2,List5);
  4272.     Test(4, Length(List5), 5);
  4273.  
  4274.     To_List     ("(1,2,3,4)", List1);
  4275.     Merge       (List1,List2,List5);
  4276.     Test(7, Length(List5), 6);
  4277.  
  4278.     To_List     ("(A=>Mike, A_1=>Mary)",List3);
  4279.     To_List     ("(B=>Mark)",           List4);
  4280.     Merge       (List3,List4,List5);
  4281.     Test(3, Length(List5), 7);
  4282.  
  4283.     To_List     ("()", List6);                      --test null lists
  4284.     Merge       (List1,List6,List5);
  4285.     Test(4, Length(List5), 8);
  4286.  
  4287.     Test(0, Length(List6), 9);
  4288.  
  4289. end Test12;
  4290.  
  4291.  
  4292.  
  4293. begin
  4294.     Test2;
  4295.     Test3;
  4296.     Test4;
  4297.     Test5;
  4298.     Test6;
  4299.     Test7;
  4300.     Test8;
  4301.     Test9;
  4302.     Test10;
  4303.     Test11;
  4304.     Test12;
  4305. end List_Test_02_12;
  4306. --::::::::::::::
  4307. --list_test_13_ss.a
  4308. --::::::::::::::
  4309.  
  4310. with Cais; use Cais;
  4311. with Text_Io;        use Text_Io;
  4312. procedure List_Test_13_ss is
  4313.  
  4314.  
  4315. ---------------------------------------------------------------------------
  4316. --Tests the LENGTH operation on strings representing a list_item 5.4.1.13--
  4317. ---------------------------------------------------------------------------
  4318. procedure Test13 is
  4319.  
  4320. use List_Utilities;
  4321. use String_Items; use Identifier_Items;
  4322.     List1 : List_Type;
  4323.     List2 : List_Type;
  4324.     List3 : List_Type;
  4325.         List4 : List_Type;
  4326.     List5 : List_type;
  4327.     List6 : List_type;
  4328.         Token_Form  : Token_Type;
  4329.     String_Item : string(1..24);
  4330.  
  4331.    procedure Test(L1 : Integer;
  4332.               L2 : Integer;
  4333.           II : Positive) is
  4334.     XX : String(1..35) := "                                   ";
  4335.    begin
  4336.     put_line("EXPECT" & integer'image(L1) & " => GET " & integer'image(L2));
  4337.     if L1 = L2 then
  4338.       put_line(XX & "**************PASSES TEST " & Positive'Image(II) );
  4339.     else
  4340.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4341.     end if;
  4342.    exception
  4343.      when others =>
  4344.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4345.    end Test;
  4346.  
  4347. begin
  4348.     new_line;
  4349.     put_line("123456789012345678901234567890123456789012345678901234567890");
  4350.     put_line("         +         +         +         +         +         +");
  4351.     To_List("(1,01,1234567890,1.,1_1,1_1.1_1,1.45,1E+01,1E-24)",List2);--numbers
  4352.     put_line( "(1,01,1234567890,1.,1_1,1_1.1_1,1.45,1E+01,1E-24)" );
  4353.     Test(49, Text_Length(List2), 1);
  4354.     Test(2, Text_Length(List2,2), 2);
  4355.     Test(7, Text_Length(List2,6), 3);
  4356.  
  4357.     To_List("(""1"",""embedded"""""",""in""""middle"")",List2);--strings
  4358.     put_line("(""1"",""embedded"""""",""in""""middle"")");
  4359.     Test(31, Text_Length(List2), 4);
  4360.     Test(9, Text_Length(List2,3), 5);
  4361.  
  4362.     To_List("(""Name"",""ID001"",""ada_name"")",List2);--identifiers
  4363.     put_line( "(""Name"",""ID001"",""ada_name"")" );
  4364.     Test(27, Text_Length(List2), 6);
  4365.     Test(8, Text_Length(List2,3), 7);
  4366.  
  4367.     To_List("((list), (list,(sublist),(sublist)), ((sub1list,(sub2list))) )",
  4368.                        List2);--lists
  4369.     put_line("((list),(list,(sublist),(sublist)),((sub1list,(sub2list))))");
  4370.     Test(59, Text_Length(List2), 8);
  4371.     Test(26, Text_Length(List2,2), 9);
  4372.     Test(23, Text_Length(List2,3), 10);
  4373.  
  4374.     To_List     ("( ""3"" )",                List1);
  4375.     To_List     (" (""1"", ""2"", ""4"") ",  List2);
  4376.     Merge       (List1,List2,List5);
  4377.     put_line(To_Text(List5));
  4378.     Test(17, Text_Length(List5), 11);
  4379.     Test(1, Text_Length(List5,4), 12);
  4380.     Test(1, Text_Length(List5,1), 13);
  4381.  
  4382.     To_List     ("(1,2,3,4)", List1);
  4383.     Merge       (List1,List2,List5);
  4384.     new_line; new_line;
  4385.     put_line("123456789012345678901234567890123456789012345678901234567890");
  4386.     put_line("         +         +         +         +         +         +");
  4387.     put_line(To_Text(List5));
  4388.     Test(21, Text_Length(List5), 14);
  4389.  
  4390.     To_List     ("(A=>Mike, A_1=>Mary)",List3);
  4391.     To_List     ("(B=>Mark)",           List4);
  4392.     Merge       (List3,List4,List5);
  4393.     put_line(To_Text(List5));
  4394.     Test(27, Text_Length(List5), 15);
  4395.  
  4396.     Test(4, Text_Length(List5,"a"), 16);
  4397.     To_Token("b",Token_Form);
  4398.     Test(4, Text_Length(List5,Token_Form), 17);
  4399.  
  4400.     To_List     ("()", List6);                      --test null lists
  4401.     Merge       (List1,List6,List5);
  4402.     put_line(To_Text(List5));
  4403.     Test(9, Text_Length(List5), 18);
  4404.  
  4405.     put_line(To_Text(List6));
  4406.     Test(2, Text_Length(List6), 19);
  4407.  
  4408.     To_List ("("""")", List2);
  4409.     Test(0, Text_Length(List2,1), 20);
  4410. end Test13;
  4411.  
  4412.  
  4413.  
  4414.  
  4415. ------------------------------------------------------------------------
  4416. --Tests the ITEM_NAME operation on positions within a list    5.4.1.14--
  4417. ------------------------------------------------------------------------
  4418. procedure Test14 is
  4419.  
  4420. use List_Utilities;
  4421. use String_Items; use Identifier_Items;
  4422.  
  4423.         List3 : List_Type;
  4424.         List4 : List_Type;
  4425.     List5 : List_type;
  4426.         Pos1  : Token_Type;
  4427.         Pos2  : Token_Type;
  4428.         Pos3  : Token_Type;
  4429.  
  4430.    procedure Test(L1 : String;
  4431.               L2 : Token_Type;
  4432.           II : Positive) is
  4433.         XX : string(1..35) := "                                   ";
  4434.         L3 : Token_Type;
  4435.    begin
  4436.     To_Token(L1, L3);
  4437.     if Is_Equal(L3,L2) then
  4438.       put_line(XX & "**************PASSES TEST " & Positive'Image(II) );
  4439.     else
  4440.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4441.     end if;
  4442.    exception
  4443.      when others =>
  4444.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4445.    end Test;
  4446.  
  4447. begin
  4448.  
  4449.     To_List     ("(A=>Mike, A_1=>Mary)",List3);
  4450.     To_List     ("(B=>Mark)",           List4);
  4451.     Merge       (List3,List4,List5);
  4452.     put_line(To_Text(List5));
  4453.     Item_Name(List5,1,Pos1);  Test("A", Pos1, 1);
  4454.     Item_Name(List5,2,Pos2);  Test("A_1", Pos2, 2);
  4455.     Item_Name(List5,3,Pos3);  Test("B", Pos3, 3);
  4456.  
  4457.     To_List("(Name=>1, MiXeD_Name=>ID, llllllllllooooooooooonnnnng_name=>1.)",
  4458.                                                                         List5);
  4459.     put_line(To_Text(List5));
  4460.     Item_Name(List5,1,Pos1);  Test("NAME", Pos1, 4);
  4461.     Item_Name(List5,2,Pos2);  Test("MIXED_NAME", Pos2, 5);
  4462.     Item_Name(List5,3,Pos3);
  4463.     Test("llllllllllooooooooooonnnnng_name", Pos3, 6);
  4464. end Test14;
  4465.  
  4466.  
  4467.  
  4468.  
  4469. ------------------------------------------------------------------------
  4470. --Tests the POSITION_BY_NAME operation on named lists          5.4.1.15--
  4471. ------------------------------------------------------------------------
  4472. procedure Test15 is
  4473.  
  4474. use List_Utilities;
  4475. use String_Items; use Identifier_Items;
  4476.         List3 : List_Type;
  4477.         List4 : List_Type;
  4478.     List5 : List_type;
  4479.         Pos1  : Position_Count;
  4480.         Pos2  : Position_Count;
  4481.         Pos3  : Position_Count;
  4482.         Tok1  : Token_Type;
  4483.  
  4484.    procedure Test(L1 : Position_Count;
  4485.               L2 : Position_Count;
  4486.           II : Positive) is
  4487.         XX : string(1..35) := "                                   ";
  4488.    begin
  4489.     put_line("EXPECT" & List_Utilities.Count'image(L1) & " => GET " 
  4490.               & List_Utilities.Count'image(L2));
  4491.     if L1 = L2 then
  4492.       put_line(XX & "**************PASSES TEST " & Positive'Image(II) );
  4493.     else
  4494.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4495.     end if;
  4496.    exception
  4497.      when others =>
  4498.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4499.    end Test;
  4500.  
  4501. begin
  4502.  
  4503.     To_List     ("(A=>Mike, A_1=>Mary)",List3);
  4504.     To_List     ("(B=>Mark)",           List4);
  4505.     Merge       (List3,List4,List5);
  4506.     put_line(To_Text(List5));
  4507.     Pos1 := Position_By_Name(List5,"a");    Test(1, Pos1, 1);
  4508.     Pos2 := Position_By_Name(List5,"A_1");    Test(2, Pos2, 2);
  4509.     Pos3 := Position_By_Name(List5,"b");    Test(3, Pos3, 3);
  4510.  
  4511.     To_List("(Name=>1, MiXeD_Name=>ID, llllllllllooooooooooonnnnng_name=>1.)",
  4512.                                                                         List5);
  4513.     put_line(To_Text(List5));
  4514.     Pos1 := Position_By_Name(List5,"NAME");        Test(1, Pos1, 4);
  4515.     Pos2 := Position_By_Name(List5,"mixed_nAME");    Test(2, Pos2, 5);
  4516.     Pos3 := Position_By_Name(List5,"llllllllllooooooooooonnnnng_name");
  4517.                             Test(3, Pos3, 6);
  4518.  
  4519.  
  4520.     To_List("(Name=>1, MiXeD_Name=>ID, llllll_o_o_oooonnnnng_name=>1.)", List5);
  4521.     put_line(To_Text(List5));
  4522.  
  4523.     To_Token("NAME",Tok1);
  4524.     Pos1 := Position_By_Name(List5,Tok1);    Test(1, Pos1, 7);
  4525.     To_Token("mixed_nAME",Tok1);
  4526.     Pos2 := Position_By_Name(List5,Tok1);    Test(2, Pos2, 8);
  4527.     To_Token("llllll_o_o_oooonnnnng_name",Tok1);
  4528.     Pos3 := Position_By_Name(List5,Tok1);    Test(3, Pos3, 9);
  4529. end Test15;
  4530.  
  4531.  
  4532.  
  4533.  
  4534. ------------------------------------------------------------------------
  4535. --Tests the EXTRACT operation on any list_items in a list     5.4.1.16--
  4536. ------------------------------------------------------------------------
  4537. procedure Test16 is
  4538.  
  4539. use List_Utilities;
  4540. use  Identifier_Items;
  4541.     List1 : List_Type;
  4542.     List2 : List_Type;
  4543.     List3 : List_Type;
  4544.         Toke  : Token_Type;
  4545.  
  4546.    procedure Show(L1 : List_Type;
  4547.               L2 : String;
  4548.           II : Positive) is
  4549.         XX : string(1..35) := "                                   ";
  4550.         L3 : List_Type;
  4551.    begin
  4552.     put_line(To_Text(L1));
  4553.     To_List(L2,L3);
  4554.     if Is_Equal(L1,L3) then
  4555.       put_line(XX & "**************PASSES TEST " & Positive'Image(II) );
  4556.     else
  4557.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4558.     end if;
  4559.    exception
  4560.      when others =>
  4561.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4562.    end Show;
  4563. begin
  4564.     To_List     (" ((1), ((2)), (4,5)) ",  List2);
  4565.     put_line(To_Text(List2));
  4566.     Extract(List2,1,List3); Show(List3,"(1)",1);
  4567.     Extract(List2,2,List3); Show(List3,"((2))",2);
  4568.     Extract(List2,3,List3); Show(List3,"(4,5)",3);
  4569.      
  4570.  
  4571.     To_List     ("( (""3"") )",                List1);
  4572.     put_line(To_Text(List1));
  4573.     Extract(List1,1,List3);  Show(List3,"(""3"")",4);
  4574.  
  4575. To_List("(SIMPLE=>(list), NESTED=>(list,(sublist),(sublist)), TWICEN=>((sub1list ,(sub2list))))",List2);
  4576.  put_line(To_Text(List2));
  4577.  Extract(List2,"simple",List3);  Show(List3,"(list)",5);
  4578.  Extract(List2,"nEsTed",List3);  Show(List3,"(list,(sublist),(sublist))",6);
  4579.  Extract(List2,"TWICEN",List3);  Show(List3,"((sub1list,(sub2list)))",7);
  4580.  
  4581.  To_Token("simple",Toke);
  4582.  Extract(List2,Toke,List3);  Show(List3,"(list)",8);
  4583.  
  4584.  To_Token("NeStEd",Toke);
  4585.  Extract(List2,Toke,List3);   Show(List3,"(list,(sublist),(sublist))",9);
  4586.  
  4587.  To_Token("twiceN",Toke);
  4588.  Extract(List2,Toke,List3);   Show(List3,"((sub1list,(sub2list)))",10);
  4589.  
  4590.  Extract(List2,1,List3);  Show(List3,"(list)",11);
  4591.  Extract(List2,2,List3);  Show(List3,"(list,(sublist),(sublist))",12);
  4592.  Extract(List2,3,List3);  Show(List3,"((sub1list,(sub2list)))",13);
  4593.  
  4594. end Test16;
  4595.  
  4596.  
  4597.  
  4598. ------------------------------------------------------------------------
  4599. --Tests the REPLACE operation on list_items within a list     5.4.1.17--
  4600. ------------------------------------------------------------------------
  4601. procedure Test17 is
  4602.  
  4603. use List_Utilities;
  4604. use  Identifier_Items;
  4605.     List1 : List_Type;
  4606.     List2 : List_Type;
  4607.     List3 : List_Type;
  4608.     List4 : List_Type;
  4609.         Toke  : Token_Type;
  4610.  
  4611.    procedure Test(L1 : List_Type;
  4612.               L2 : List_Type;
  4613.           II : Positive) is
  4614.         XX : string(1..35) := "                                   ";
  4615.    begin
  4616.     put_line(To_Text(L1));
  4617.     if Is_Equal(L1,L2) then
  4618.       put_line(XX & "**************PASSES TEST " & Positive'Image(II) );
  4619.     else
  4620.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4621.     end if;
  4622.    exception
  4623.      when others =>
  4624.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4625.    end Test;
  4626.  
  4627. begin
  4628.     To_List     (" ((1), ((2)), (4,5)) ",  List2);
  4629.     To_List     ("( ""NEW"" )",                List3);
  4630.     put_line(To_Text(List2));
  4631.     Replace(List2,List3,1);
  4632.     To_List("((""NEW""),((2)),(4,5))",List4);
  4633.     Test(List2,List4,1);
  4634.     Replace(List2,List3,2);
  4635.     To_List("((""NEW""),(""NEW""),(4,5))",List4);
  4636.     Test(List2,List4,2);
  4637.     Replace(List2,List3,3);
  4638.     To_List("((""NEW""),(""NEW""),(""NEW""))",List4);
  4639.     Test(List2,List4,3);
  4640.     new_line;
  4641.  
  4642.     To_List     ("( (""OLD"") )",                List1);
  4643.     put_line(To_Text(List1));
  4644.     Replace(List1,List3,1);
  4645.     To_List("((""NEW""))",List4);
  4646.     Test(List1,List4,4);
  4647.     new_line;
  4648.  
  4649. To_List("(SIMPLE=>(list), NESTED=>(list,(sub),(sub)), TWICEN=>((sub1,(sub2))))",
  4650.                 List2);
  4651.  put_line(To_Text(List2));
  4652.  Replace(List2,List3,"simple");  put_line(To_Text(List2));
  4653.     To_List("(SIMPLE=>(""NEW""),NESTED=>(list,(sub),(sub))," &
  4654.                 "TWICEN=>((sub1,(sub2))))",List4);
  4655.     Test(List2,List4,5);
  4656.  Replace(List2,List3,"nEsTed");
  4657.  To_List("(SIMPLE=>(""NEW""),NESTED=>(""NEW""),TWICEN=>((sub1,(sub2))))",List4);
  4658.     Test(List2,List4,6);
  4659.  Replace(List2,List3,"TWICEN");
  4660.  To_List("(SIMPLE=>(""NEW""),NESTED=>(""NEW""),TWICEN=>(""NEW""))",List4);
  4661.     Test(List2,List4,7);
  4662.  new_line;
  4663.  
  4664.  To_List     ("( NEW_Token )",                List3);
  4665.  To_Token("simple",Toke);
  4666.  Replace(List2,List3,Toke);
  4667.  To_List("(SIMPLE=>(New_Token),NESTED=>(""NEW""),TWICEN=>(""NEW""))",List4);
  4668.     Test(List2,List4,8);
  4669.  
  4670.  To_Token("NeStEd",Toke);
  4671.  Replace(List2,List3,Toke);
  4672.  To_List("(SIMPLE=>(New_Token),NESTED=>(New_Token),TWICEN=>(""NEW""))",List4);
  4673.     Test(List2,List4,9);
  4674.  
  4675.  To_Token("twiceN",Toke);
  4676.  Replace(List2,List3,Toke);
  4677.  To_List("(SIMPLE=>(New_Token),NESTED=>(New_Token),TWICEN=>(New_Token))",List4);
  4678.     Test(List2,List4,10);
  4679.  new_line;
  4680.  
  4681.     To_List     ("( NEW_POSITION )",                List3);
  4682.     Replace(List2,List3,1);
  4683.     To_List("(SIMPLE=>(New_Position),NESTED=>(New_Token),TWICEN=>(New_Token))", 
  4684.         List4);
  4685.     Test(List2,List4,11);
  4686.  
  4687.     Replace(List2,List3,2);
  4688.     To_List("(SIMPLE=>(New_Position),NESTED=>(New_Position)," &
  4689.                 "TWICEN=>(New_Token))",List4);
  4690.     Test(List2,List4,12);
  4691.     Replace(List2,List3,3);
  4692.     To_List("(SIMPLE=>(New_Position),NESTED=>(New_Position)," &
  4693.                 "TWICEN=>(New_Position))",List4);
  4694.     Test(List2,List4,13);
  4695.  
  4696. end Test17;
  4697.  
  4698.  
  4699.  
  4700. ------------------------------------------------------------------------
  4701. --Tests the INSERT operation on list_items within a list      5.4.1.18--
  4702. ------------------------------------------------------------------------
  4703. procedure Test18 is
  4704.  
  4705. use List_Utilities;
  4706. use  Identifier_Items;
  4707.     List1 : List_Type;
  4708.     List2 : List_Type;
  4709.     List3 : List_Type;
  4710.         Toke  : Token_Type;
  4711.  
  4712.    procedure Test(L1 : String;
  4713.               L2 : List_Type;
  4714.           II : Positive) is
  4715.         XX : string(1..35) := "                                   ";
  4716.         L3 : List_Type;
  4717.    begin
  4718.     put_line(To_Text(L2));
  4719.     To_List(L1, L3);
  4720.     put_line(To_Text(L3));
  4721.     if Is_Equal(L3,L2) then
  4722.       put_line(XX & "**************PASSES TEST " & Positive'Image(II) );
  4723.     else
  4724.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4725.     end if;
  4726.    exception
  4727.      when others =>
  4728.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4729.    end Test;
  4730.  
  4731. begin
  4732.     To_List     (" ((1), ((2)), (4,5)) ",  List2);
  4733.     To_List     ("( NEW )",                List3);
  4734.     put_line(To_Text(List2));
  4735.     Insert(List2,List3,3);
  4736.     Test( "((1), ((2)), (4,5), (NEW))",        List2, 1);
  4737.     Insert(List2,List3,2);
  4738.     Test( "((1), ((2)), (NEW), (4,5), (NEW))",    List2, 2);
  4739.     Insert(List2,List3,1);
  4740.     Test( "((1), (NEW), ((2)), (NEW), (4,5), (NEW))",    List2, 3);
  4741.     Insert(List2,List3,0);
  4742.     new_line;
  4743.  
  4744.     To_List     ("(  )",                List1);
  4745.     put_line(To_Text(List1));
  4746.     Insert(List1,List3,0); put_line(To_Text(List1));
  4747.     Test( "((NEW))", List1, 4);
  4748.     new_line;
  4749.  
  4750. To_List("(SIMPLE=>(ll), NESTED=>(ll,(sub),(sub)), TWICEN=>((sub1,(sub2))))",
  4751.             List2);
  4752.  put_line(To_Text(List2));
  4753.  Insert(List2,List3,"Isimple",0);
  4754.  Test("(ISIMPLE=>(NEW), SIMPLE=>(ll), NESTED=>(ll,(sub),(sub))," &
  4755.             "TWICEN=>((sub1,(sub2))))",
  4756.             List2, 5);
  4757.  Insert(List2,List3,"InEsTed",2);
  4758.  Test("(ISIMPLE=>(NEW), SIMPLE=>(ll), INESTED=>(NEW),NESTED=>(ll,(sub),(sub)),"&
  4759.             "TWICEN=>((sub1,(sub2))))",
  4760.             List2, 6);
  4761.  Insert(List2,List3,"ITWICEN",4);
  4762.  Test("(ISIMPLE=>(NEW), SIMPLE=>(ll), INESTED=>(NEW),NESTED=>(ll,(sub),(sub)),"&
  4763.             "ITWICEN=>(NEW), TWICEN=>((sub1,(sub2))))",
  4764.             List2, 7);
  4765.  new_line;
  4766.  
  4767. To_List("(SIMPLE=>(ll), NESTED=>(ll,(sub),(sub)), TWICEN=>((sub1,(sub2))))",List2);
  4768.  To_List     ("( NEW_Token )",                List3);
  4769.  To_Token("Tsimple",Toke);
  4770.  Insert(List2,List3,Toke,0);  put_line(To_Text(List2));
  4771.  Test("(TSIMPLE=>(NEW_TOKEN), SIMPLE=>(ll), NESTED=>(ll,(sub),(sub))," &
  4772.             "TWICEN=>((sub1,(sub2))))",
  4773.             List2, 8);
  4774.  
  4775.  To_Token("TNeStEd",Toke);
  4776.  Insert(List2,List3,Toke,2);  put_line(To_Text(List2));
  4777.  Test("(TSIMPLE=>(NEW_TOKEN), SIMPLE=>(ll), TNESTED=>(NEW_TOKEN)," &
  4778.             "NESTED=>(ll,(sub),(sub))," &
  4779.             "TWICEN=>((sub1,(sub2))))",
  4780.             List2, 9);
  4781.  
  4782.  To_Token("TtwiceN",Toke);
  4783.  Insert(List2,List3,Toke,4);  put_line(To_Text(List2));
  4784.  Test("(TSIMPLE=>(NEW_TOKEN), SIMPLE=>(ll),TNESTED=>(NEW_TOKEN)," &
  4785.             "NESTED=>(ll,(sub),(sub))," &
  4786.             "TTWICEN=>(NEW_TOKEN), TWICEN=>((sub1,(sub2))))",
  4787.             List2, 10);
  4788.  
  4789. end Test18;
  4790.  
  4791.  
  4792.  
  4793. ------------------------------------------------------------------------
  4794. --Tests the POSITION_BY_VALUE operation on list_items in list 5.4.1.19--
  4795. ------------------------------------------------------------------------
  4796. procedure Test19 is
  4797.  
  4798. use List_Utilities;
  4799. use  Identifier_Items;
  4800.     List1 : List_Type;
  4801.     List2 : List_Type;
  4802.     List3 : List_Type;
  4803.         Toke  : Token_Type;
  4804.         XX    : Position_Count;
  4805.         First : Position_Count;
  4806.         Last  : Position_Count;
  4807.  
  4808.    procedure Test(L1 : Position_Count;
  4809.               L2 : Position_Count;
  4810.           II : Positive) is
  4811.         XX : string(1..35) := "                                   ";
  4812.    begin
  4813.     put_line("EXPECT" & List_Utilities.Count'image(L1) & " => GET " 
  4814.               & List_Utilities.Count'image(L2));
  4815.     if L1 = L2 then
  4816.       put_line(XX & "**************PASSES TEST " & Positive'Image(II) );
  4817.     else
  4818.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4819.     end if;
  4820.    exception
  4821.      when others =>
  4822.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4823.    end Test;
  4824.  
  4825. begin
  4826.     To_List     (" ((1), ((2)), (4,5)) ",  List2);
  4827.     put_line(To_Text(List2));
  4828.  
  4829.     First := 1; Last  := 1;
  4830.     To_List     ("(1)",                List3);
  4831.     Test(1, Position_By_Value(List2,List3,First,Last), 1);
  4832.  
  4833.     First := 2; Last  := 3;
  4834.     To_List     ("((2))",                List3);
  4835.     Test(2, Position_By_Value(List2,List3,First,Last), 2);
  4836.  
  4837.     First := 2; Last  := 3;
  4838.     To_List     ("(4,5)",                List3);
  4839.     Test(3, Position_By_Value(List2,List3,First,Last), 3);
  4840.  
  4841.     To_List     ("(4,5)",                List3);
  4842.     Test(3, Position_By_Value(List2,List3,First), 4);
  4843.  
  4844.     To_List     ("(4,5)",                List3);
  4845.     Test(3, Position_By_Value(List2,List3), 5);
  4846.     new_line;
  4847.  
  4848. To_List("(SIMPLE=>(ll),NESTED=>(ll,(sub),(sub)),TWICEN=>((sub1,(sub2))))",List2);
  4849.  put_line(To_Text(List2));
  4850.  
  4851.     First := 2; Last  := 9;
  4852.     To_List     (" (ll,(sub),(sub))",               List3);
  4853.     Test(2, Position_By_Value(List2,List3,First,Last), 6);
  4854.  
  4855.     First := 3; Last  := 3;
  4856.     To_List     ("((sub1,(sub2)))",                List3);
  4857.     Test(3, Position_By_Value(List2,List3,First,Last), 7);
  4858.  
  4859.     First := 1; Last  := 9;
  4860.     To_List     ("(ll)",                List3);
  4861.     Test(1, Position_By_Value(List2,List3,First,Last), 8);
  4862.  
  4863.     First := 1; Last  := 9;
  4864.     To_List     ("(  ll )",                List3);
  4865.     Test(1, Position_By_Value(List2,List3,First,Last), 9);
  4866.  
  4867.     First := 3; Last  := 3;
  4868.     To_List     ("(( sub1,  (sub2  )))",                List3);
  4869.     Test(3, Position_By_Value(List2,List3,First,Last), 10);
  4870.  
  4871.  
  4872. end Test19;
  4873.  
  4874. ------------------------------------------------------------------------
  4875. --Quick test of list operations.  Very quick.              5.4.1.23...--
  4876. ------------------------------------------------------------------------
  4877. procedure Testll is
  4878.  
  4879. use List_Utilities; 
  4880.  
  4881.     List1 : List_Type;
  4882.     List2 : List_Type;
  4883.     List3 : List_Type;
  4884.  
  4885.    procedure Test(L1 : List_Type;
  4886.               L2 : List_Type;
  4887.           II : Positive) is
  4888.         XX : string(1..35) := "                                   ";
  4889.    begin
  4890.     put_line(To_Text(L1));
  4891.     if Is_Equal(L1,L2) then
  4892.       put_line(XX & "**************PASSES TEST " & Positive'Image(II) );
  4893.     else
  4894.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4895.     end if;
  4896.    exception
  4897.      when others =>
  4898.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4899.    end Test;
  4900.  
  4901. begin
  4902.     To_List     (" (""1"", ""2"", ""4"") ",  List2);
  4903.     To_List     ("( ""3"" )",                List1);
  4904.  
  4905.     Insert      (List2, List1, 2);
  4906.     To_List     (" (""1"", ""2"", (""3""), ""4"") ",  List3);
  4907.     Test        (List2, List3, 1);
  4908.  
  4909.     Extract     (List2, 3, List3);
  4910.     Test        (List1, List3, 2);
  4911. end Testll;
  4912.  
  4913.  
  4914. ------------------------------------------------------------------------
  4915. --Quick test of string operations.  Very quick.            5.4.1.23...--
  4916. ------------------------------------------------------------------------
  4917. procedure Testss is
  4918.  
  4919. use List_Utilities; 
  4920. use String_Items;
  4921.     List2       : List_Type;
  4922.     List3       : List_Type;
  4923.     List4       : List_Type;
  4924.     List5       : List_Type;
  4925.     XX : string(1..35) := "                                   ";
  4926.  
  4927.  
  4928.    procedure Test(L1 : List_Type;
  4929.               L2 : List_Type;
  4930.           II : Positive) is
  4931.         XX : string(1..35) := "                                   ";
  4932.    begin
  4933.     put_line(To_Text(L1));
  4934.     if Is_Equal(L1,L2) then
  4935.       put_line(XX & "**************PASSES TEST " & Positive'Image(II) );
  4936.     else
  4937.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4938.     end if;
  4939.    exception
  4940.      when others =>
  4941.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(II) );
  4942.    end Test;
  4943.  
  4944. begin
  4945.     To_List     (" (""1"", ""2"") ",  List2);
  4946.     To_List     (" (44, Id_44) ",  List3);
  4947.     To_List     (" (""1"", ""2"", 44, Id_44) ",  List5);
  4948.     Merge(List2, List3, List4);
  4949.     Test(List4,List5,1);
  4950.  
  4951.     Insert    (List4,"String Insertion Works",2);
  4952.     To_List     (" (""1"", ""2"",""String Insertion Works"",44, Id_44) ",List5);
  4953.     Test(List4,List5,2);
  4954.  
  4955.     
  4956.    begin
  4957.     if "String Insertion Works" = Extract(List4,3) then
  4958.       put_line(XX & "**************PASSES TEST " & Positive'Image(3) );
  4959.     else
  4960.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(3) );
  4961.     end if;
  4962.    exception
  4963.      when others =>
  4964.       put_line(XX & "!!!!!!!!!!!!!!!!!FAILS! TEST " & Positive'Image(3) );
  4965.    end;
  4966.  
  4967.     Insert    (List4,"",2);
  4968.     To_List("(""1"", ""2"", """", ""String Insertion Works"",44, Id_44)",List5);
  4969.     Test(List4,List5,4);
  4970.     Put_Line(Extract(List4,3) & "!!Even when null");
  4971. end Testss;
  4972.  
  4973. begin
  4974.     Test13;
  4975.     Test14;
  4976.     Test15;
  4977.     Test16;
  4978.     Test17;
  4979.     Test18;
  4980.     Test19;
  4981.     Testll;
  4982.     Testss;
  4983. end List_Test_13_ss;
  4984. --::::::::::::::
  4985. --list_tstex.a
  4986. --::::::::::::::
  4987.  
  4988.  
  4989. ------------------------------------------------------------------------
  4990. ----------------L I S T _ U T   E X C E P T I O N   T E S T-------------
  4991. --These tests raise each of the possible exceptions specified in the  --
  4992. --package of List_Utilities.                                          --
  4993. ------------------------------------------------------------------------
  4994. ------------------------------------------------------------------------
  4995. with Cais; use Cais;
  4996. with Text_Io;        use Text_Io;
  4997. procedure Test_Ex is
  4998.  
  4999. use List_Utilities;
  5000.  
  5001.   use Identifier_Items;
  5002.   use String_Items;
  5003.   Package LU renames List_Utilities;
  5004.  
  5005.  
  5006.   Exceptions_Tested : constant := 90;
  5007.   Failures   : integer := 0;
  5008.   Line_Count : integer;
  5009.   Expected   : string(1..3);
  5010.  
  5011.  
  5012.  
  5013.  
  5014.   procedure Wrong_Exception(II: integer;
  5015.                 SS: string) is
  5016.  
  5017.   begin
  5018.     Failures := Failures + 1;
  5019.     Line_Count := 10;
  5020.     new_line;
  5021.     put(
  5022.          integer'image(II)   &
  5023.          ":**ERROR**"     &
  5024.          " Received: "       &
  5025.              SS                  &
  5026.              " Expected: "       &
  5027.              Expected            );
  5028.   end Wrong_Exception;
  5029.  
  5030.  
  5031.   procedure No_Exception(Error: in string) is
  5032.   begin
  5033.     new_line;
  5034.     put(Error);
  5035.     Line_Count := 10;
  5036.     Failures := Failures + 1;
  5037.   end No_exception;
  5038.  
  5039.  
  5040.  
  5041.  
  5042.  
  5043.   procedure Raise_Exception(II: integer ) is
  5044.     Text    : Natural;
  5045.     Token1  : Token_Type;
  5046.     String1 : string(1..3);
  5047.     Name1   : NameString(1..3);
  5048.     Posit1  : Position_Count;
  5049.     List1   : List_Type;
  5050.     List2   : List_Type;
  5051.     List3   : List_Type;
  5052.     Listtext: List_Text(1..10);
  5053.     Kind1   : Item_Kind;
  5054.   begin
  5055.     case II is
  5056.                             --MIL STD 5.4.1.1
  5057.                               --not applicable
  5058.                             --MIL STD 5.4.1.2
  5059.                               --no exceptions
  5060.  
  5061.     when  1 =>                    --MIL STD 5.4.1.3
  5062.         Expected := "Use";    --Use_Error Expected
  5063.         To_List("error", List1);
  5064.         No_Exception(" 1:**ERROR**TO_LIST: no ()");
  5065.     when  2 =>
  5066.         Expected := "Use";    --Use_Error Expected
  5067.         To_List("(error,,)", List1);
  5068.         No_Exception(" 2:**ERROR**TO_LIST: two ,,");
  5069.     when  3 =>
  5070.         Expected := "Use";    --Use_Error Expected
  5071.         To_List("(error,id_)", List1);
  5072.         No_Exception(" 3:**ERROR**TO_LIST: trailing _");
  5073.     when  4 =>
  5074.         Expected := "Use";    --Use_Error Expected
  5075.         To_List("(error,name=>""zz"")", List1);
  5076.         No_Exception(" 4:**ERROR**TO_LIST: mixed pos/name");
  5077.     when  5 =>
  5078.         Expected := "Use";    --Use_Error Expected
  5079.         To_List("(name=>1,1.1)", List1);
  5080.         No_Exception(" 5:**ERROR**TO_LIST: mixed name/pos");
  5081.                             --MIL STD 5.4.1.4
  5082.                               --no exceptions
  5083.  
  5084.                             --MIL STD 5.4.1.5
  5085.                               --no exceptions
  5086.  
  5087.  
  5088.  
  5089.     when  6 =>                    --MIL STD 5.4.1.6
  5090.         Expected := "Use";    --Use_Error Expected
  5091.         To_List("(1,2)", List1);
  5092.         Delete(List1,3);
  5093.         No_Exception(" 6:**ERROR**DELETE: position too high");
  5094.     when  7 =>
  5095.         Expected := "Use";    --Use_Error Expected
  5096.         To_List("()", List1);
  5097.         Delete(List1,1);
  5098.         No_Exception(" 7:**ERROR**DELETE: null list");
  5099.     when  8 =>
  5100.         Expected := "Use";    --Use_Error Expected
  5101.         To_List("(1,2)", List1);
  5102.         Delete(List1,"No_Name");
  5103.         No_Exception(" 8:**ERROR**DELETE: mixed pos/name");
  5104.     when  9 =>
  5105.         Expected := "Use";    --Use_Error Expected
  5106.         To_List("(1,2)", List1);
  5107.         To_Token("No_Name",Token1);
  5108.         Delete(List1,Token1);
  5109.         No_Exception(" 9:**ERROR**DELETE: mixed pos/token");
  5110.     when 10 =>
  5111.         Expected := "Use";    --Use_Error Expected
  5112.         To_List("(TWO=>2)", List1);
  5113.         To_Token("No_Name",Token1);
  5114.         new_line;
  5115.         put("*****AT ISSUE WITH MIL STD CAIS, FAILURE EXPECTED ON 10");
  5116.         Delete(List1,Token1);
  5117.         No_Exception("**STD ISSUE**10:**ERROR**DELETE: bad name");
  5118.                             --MIL STD 5.4.1.7
  5119.                               --no exceptions
  5120.  
  5121.  
  5122.                             --MIL STD 5.4.1.8
  5123.     when 11 =>
  5124.         Expected := "Sea";    --Search_Error Expected
  5125.         
  5126.         To_List("(TWO=>2)", List1);
  5127.         Kind1 := Get_Item_Kind(List1,"No_Name");
  5128.         No_Exception("11:**ERROR**GET_ITEM_KIND: bad name");
  5129.     when 12 =>
  5130.         Expected := "Sea";    --Search_Error Expected
  5131.         To_List("(TWO=>2)", List1);
  5132.         To_Token("No_Name",Token1);
  5133.         Kind1 := Get_Item_Kind(List1,Token1);
  5134.         No_Exception("12:**ERROR**GET_ITEM_KIND: bad token");
  5135.     when 13 =>
  5136.         Expected := "Use";    --Use_Error Expected
  5137.         To_List("()", List1);
  5138.         Kind1 := Get_Item_Kind(List1,2);
  5139.         No_Exception("13:**ERROR**GET_ITEM_KIND: null list");
  5140.     when 14 =>
  5141.         Expected := "Use";    --Use_Error Expected
  5142.         To_List("(TWO=>2)", List1);
  5143.         Delete(List1,3);
  5144.         No_Exception("14:**ERROR**GET_ITEM_KIND: position high");
  5145.  
  5146.  
  5147.  
  5148.     when 15 =>                    --MIL STD 5.4.1.9
  5149.         Expected := "Use";    --Use_Error Expected
  5150.         To_List("(1,3)", List1);
  5151.         To_List("( 2 )", List2);
  5152.         Splice(List1,5,List2);
  5153.         No_Exception("15:**ERROR**SPLICE: position high");
  5154.     when 16 =>
  5155.         Expected := "Use";    --Use_Error Expected
  5156.         To_List("(1,3)", List1);
  5157.         Splice(List1,3,"(2,,)");
  5158.         No_Exception("16:**ERROR**SPLICE: bad list");
  5159.     when 17 =>
  5160.         Expected := "Use";    --Use_Error Expected
  5161.         To_List("(1,3)", List1);
  5162.         Splice(List1,3,"(I=>2)");
  5163.         No_Exception("17:**ERROR**SPLICE: mixed pos/name");
  5164.     when 18 =>
  5165.         Expected := "Use";    --Use_Error Expected
  5166.         To_List("(I=>1,J=>3)", List1);
  5167.         Splice(List1,3,"(I=>2)");
  5168.         No_Exception("18:**ERROR**SPLICE: duplicate names");
  5169.  
  5170.  
  5171.  
  5172.     when 19 =>                    --MIL STD 5.4.1.10
  5173.         Expected := "Use";    --Use_Error Expected
  5174.         To_List("(I=>1,J=>3)", List1);
  5175.         To_List("(I=>1,J=>3)", List2);
  5176.         Merge(List1,List2,List3);
  5177.         No_Exception("19:**ERROR**MERGE: duplicate names");
  5178.     when 20 =>
  5179.         Expected := "Use";    --Use_Error Expected
  5180.         To_List("(I=>1,J=>3)", List1);
  5181.         To_List("(1,3)", List2);
  5182.         Merge(List1,List2,List3);
  5183.         No_Exception("20:**ERROR**MERGE: mixed name/pos");
  5184.  
  5185.  
  5186.     when 21 =>                    --MIL STD 5.4.1.11
  5187.         Expected := "Use";    --Use_Error Expected
  5188.         To_List("(I=>1,J=>3)", List1);
  5189.         Listtext := Set_Extract(List1,4,4);
  5190.         No_Exception("21:**ERROR**SET_EXTRACT: position too high");
  5191.     when 22 =>
  5192.         Expected := "Use";    --Use_Error Expected
  5193.         To_List("(1,3)", List2);
  5194.         Listtext := Set_Extract(List2,4,4);
  5195.         No_Exception("22:**ERROR**SET_EXTRACT: position too high");
  5196.  
  5197.                             --MIL STD 5.4.1.12
  5198.                               --no exceptions
  5199.  
  5200.  
  5201.     when 23 =>                    --MIL STD 5.4.1.13
  5202.         Expected := "Use";    --Use_Error Expected
  5203.         To_List("(I=>1,J=>3)", List1);
  5204.         Text := Text_Length(List1,10);
  5205.         No_Exception("23:**ERROR**TEXT_LENGTH: position too high");
  5206.     when 24 =>
  5207.         Expected := "Use";    --Use_Error Expected
  5208.         To_List("(1,3)", List2);
  5209.         Text := Text_Length(List2, "No_Name");
  5210.         No_Exception("24:**ERROR**TEXT_LENGTH: mixed name/pos");
  5211. --*****NOTE************
  5212. --see test 90 also
  5213. --for Text_Length
  5214. --*********************
  5215.  
  5216.  
  5217.     when 25 =>                    --MIL STD 5.4.1.14
  5218.         Expected := "Use";    --Use_Error Expected
  5219.         To_List("(""I""=>1,""J""=>3)", List2);
  5220.         Item_Name(List2, 2, Token1);
  5221.         No_Exception("25:**ERROR**ITEM_NAME: mixed name/pos");
  5222.     when 26 =>
  5223.         Expected := "Use";    --Use_Error Expected
  5224.         To_List("(I=>1,J=>3)", List1);
  5225.         Item_Name(List1, 4, Token1);
  5226.         No_Exception("26:**ERROR**ITEM_NAME: position too high");
  5227.  
  5228.  
  5229.     when 27 =>                    --MIL STD 5.4.1.15
  5230.         Expected := "Use";    --Use_Error Expected
  5231.         To_List("(1,3)", List2);
  5232.         Posit1 := Position_By_Name(List2, "No_Name");
  5233.         No_Exception("27:**ERROR**POSITION_BY_NAME: mixed name/pos");
  5234.     when 28 =>
  5235.         Expected := "Sea";    --Search_Error Expected
  5236.         To_List("(I=>1,J=>3)", List1);
  5237.         Posit1 := Position_By_Name(List1, "No_Name");
  5238.         No_Exception("28:**ERROR**POSITION_BY_NAME: bad name");
  5239.     when 29 =>
  5240.         Expected := "Use";    --Use_Error Expected
  5241.         To_List("()", List1);
  5242.         Posit1 := Position_By_Name(List1, "No_Name");
  5243.         No_Exception("29:**ERROR**POSITION_BY_NAME: empty list");
  5244.  
  5245.  
  5246.     when 30 =>                    --MIL STD 5.4.1.16
  5247.         Expected := "Use";    --Use_Error Expected
  5248.         To_List("()", List1);
  5249.         Extract(List1, "No_Name", List2);
  5250.         No_Exception("30:**ERROR**EXTRACT: empty list");
  5251.     when 31 =>
  5252.         Expected := "Use";    --Use_Error Expected
  5253.         To_List("(I=>1,J=>3)", List1);
  5254.         Extract(List1, 20, List2);
  5255.         No_Exception("31:**ERROR**EXTRACT: position too high");
  5256.     when 32 =>
  5257.         Expected := "Use";    --Use_Error Expected
  5258.         To_List("(1,3)", List2);
  5259.         Extract(List1, "No_Name", List2);
  5260.         No_Exception("32:**ERROR**EXTRACT: mixed name/pos");
  5261.     when 33 =>
  5262.         Expected := "Sea";    --Search_Error Expected
  5263.         To_List("(I=>1,J=>3)", List1);
  5264.         Extract(List1, "No_Name", List2);
  5265.         No_Exception("33:**ERROR**EXTRACT: bad name");
  5266.     when 34 =>
  5267.         Expected := "Use";    --Use_Error Expected
  5268.         To_List("(1,3)", List2);
  5269.         Extract(List1, 12, List2);
  5270.         No_Exception("34:**ERROR**EXTRACT: bad position");
  5271.  
  5272.  
  5273.     when 35 =>                    --MIL STD 5.4.1.17
  5274.         Expected := "Use";    --Use_Error Expected
  5275.         To_List("(1,3)", List2);
  5276.         Replace(List2, List1, "No_Name");
  5277.         No_Exception("35:**ERROR**REPLACE: mixed Name/pos");
  5278.     when 36 =>
  5279.         Expected := "Use";    --Use_Error Expected
  5280.         To_List("(I=>1,J=>3)", List1);
  5281.         Replace(List1, List2, "I");
  5282.         No_Exception("36:**ERROR**REPLACE: item not a list");
  5283.     when 37 =>
  5284.         Expected := "Use";    --Use_Error Expected
  5285.         To_List("(I=>1,J=>3)", List1);
  5286.         Replace(List1, List2, 1);
  5287.         No_Exception("37:**ERROR**REPLACE: pos item not a list");
  5288.     when 38 =>
  5289.         Expected := "Use";    --Use_Error Expected
  5290.         To_List("()", List1);
  5291.         Replace(List1, List2, 2);
  5292.         No_Exception("38:**ERROR**REPLACE: empty list");
  5293.     when 39 =>
  5294.         Expected := "Use";    --Use_Error Expected
  5295.         To_List("(I=>1,J=>3)", List1);
  5296.         Replace(List1, List2, 7);
  5297.         No_Exception("39:**ERROR**REPLACE: position too high");
  5298.     when 40 =>
  5299.         Expected := "Sea";    --Search_Error Expected
  5300.         To_List("(I=>1,J=>3)", List1);
  5301.         Replace(List1, List2, "No_Name");
  5302.         No_Exception("40:**ERROR**REPLACE: bad name");
  5303.  
  5304.  
  5305.     when 41 =>                    --MIL STD 5.4.1.18
  5306.         Expected := "Use";    --Use_Error Expected
  5307.         To_List("(I=>1,J=>3)", List1);
  5308.         Insert(List1, List2, 0);
  5309.         No_Exception("41:**ERROR**INSERT: mixed pos/name");
  5310.     when 42 =>
  5311.         Expected := "Use";    --Use_Error Expected
  5312.         To_List("(1,3)", List2);
  5313.         Insert(List2, List1, "Try_Me",0);
  5314.         No_Exception("42:**ERROR**INSERT: mixed name/pos");
  5315.     when 43 =>
  5316.         Expected := "Use";    --Use_Error Expected
  5317.         To_List("(I=>1,J=>3)", List1);
  5318.         Insert(List1, List2, "I", 0);
  5319.         No_Exception("43:**ERROR**INSERT: duplicate name");
  5320.     when 44 =>
  5321.         Expected := "Use";    --Use_Error Expected
  5322.         To_List("(1,3)", List2);
  5323.         Insert(List2, List1, 4);
  5324.         No_Exception("44:**ERROR**INSERT: bad position");
  5325.  
  5326.  
  5327.     when 45 =>                    --MIL STD 5.4.1.19
  5328.         Expected := "Use";    --Use_Error Expected
  5329.         To_List("(I=>1,J=>3)", List1);
  5330.         Posit1 := Position_By_Value(List1, List2, 4, 6);
  5331.         No_Exception("45:**ERROR**POSITION_BY_VALUE: high start");
  5332.     when 46 =>
  5333.         Expected := "Use";    --Use_Error Expected
  5334.         To_List("()", List2);
  5335.         Posit1 := Position_By_Value(List2, List1, 4, 6);
  5336.         No_Exception("46:**ERROR**POSITION_BY_VALUE: empty list");
  5337.     when 47 =>
  5338.         Expected := "Use";    --Use_Error Expected
  5339.         To_List("(I=>1,J=>3)", List1);
  5340.         Posit1 := Position_By_Value(List1, List2, 2, 1);
  5341.         No_Exception("47:**ERROR**POSITION_BY_VALUE: bad range");
  5342.     when 48 =>
  5343.         Expected := "Sea";    --Search_Error Expected
  5344.         To_List("(I=>1,J=>3)", List1);
  5345.         Posit1 := Position_By_Value(List1, List2, 1, 2);
  5346.         No_Exception("48:**ERROR**POSITION_BY_VALUE: bad value");
  5347.  
  5348.  
  5349.     when 49 =>                    --MIL STD 5.4.1.20.1
  5350.         Expected := "Use";    --Use_Error Expected
  5351.         To_Token("bad__format", Token1);
  5352.         No_Exception("49:**ERROR**TO_TOKEN: bad identifier syntax");
  5353.  
  5354.  
  5355.                             --MIL STD 5.4.1.20.2
  5356.                               --No Exceptions
  5357.                             --MIL STD 5.4.1.20.3
  5358.                               --No Exceptions
  5359.  
  5360.  
  5361.     when 50 =>                    --MIL STD 5.4.1.20.4
  5362.         Expected := "Use";    --Use_Error Expected
  5363.         To_List("(ONE,TWO)", List2);
  5364.         Extract(List1, "No_Name", Token1);
  5365.         No_Exception("50:**ERROR**EXTRACT: mixed pos/name");
  5366.     when 51 =>
  5367.         Expected := "Sea";    --Search_Error Expected
  5368.         To_List("(I=>ONE,J=>TWO)", List1);
  5369.         Extract(List1, "No_Name", Token1);
  5370.         No_Exception("51:**ERROR**EXTRACT: bad name");
  5371.     when 52 =>
  5372.         Expected := "Use";    --Use_Error Expected
  5373.         To_List("(ONE,TWO)", List2);
  5374.         Extract(List2, 3, Token1);
  5375.         No_Exception("52:**ERROR**EXTRACT: bad position");
  5376.     when 53 =>
  5377.         Expected := "Use";    --Use_Error Expected
  5378.         To_List("(I=>1,J=>TWO)", List1);
  5379.         Extract(List1, "I", Token1);
  5380.         No_Exception("53:**ERROR**EXTRACT: name item not a token");
  5381.  
  5382.  
  5383.     when 54 =>                    --MIL STD 5.4.1.10
  5384.         Expected := "Use";    --Use_Error Expected
  5385.         To_List("(I=>1,J=>TWO)", List1);
  5386.         Extract(List1, 1, Token1);
  5387.         No_Exception("54:**ERROR**EXTRACT: pos item not a token");
  5388.     when 55 =>
  5389.         Expected := "Use";    --Use_Error Expected
  5390.         To_List("()", List2);
  5391.         Extract(List2, 1, Token1);
  5392.         No_Exception("55:**ERROR**EXTRACT: empty list");
  5393.  
  5394.  
  5395.     when 56 =>                    --MIL STD 5.4.1.20.5
  5396.         Expected := "Use";    --Use_Error Expected
  5397.         To_List("()", List2);
  5398.         Replace(List2, Token1, 1);
  5399.         No_Exception("56:**ERROR**REPLACE: empty list");
  5400.     when 57 =>
  5401.         Expected := "Use";    --Use_Error Expected
  5402.         To_List("(1,TWO)", List1);
  5403.         Replace(List1, Token1, "No_Name");
  5404.         No_Exception("57:**ERROR**REPLACE: mixed name/pos");
  5405.     when 58 =>
  5406.         Expected := "Use";    --Use_Error Expected
  5407.         To_List("(I=>1,J=>TWO)", List1);
  5408.         Replace(List1, Token1, 5);
  5409.         No_Exception("58:**ERROR**REPLACE: bad position");
  5410.     when 59 =>
  5411.         Expected := "Use";    --Use_Error Expected
  5412.         To_List("(I=>1,J=>TWO)", List1);
  5413.         Replace(List1, Token1, "I");
  5414.         No_Exception("59:**ERROR**REPLACE: name item not an ident");
  5415.     when 60 =>
  5416.         Expected := "Use";    --Use_Error Expected
  5417.         To_List("(I=>1,J=>TWO)", List1);
  5418.         Replace(List1, Token1, 1);
  5419.         No_Exception("60:**ERROR**REPLACE: pos item not an ident");
  5420.     when 61 =>
  5421.         Expected := "Sea";    --Search_Error Expected
  5422.         To_List("(I=>1,J=>TWO)", List1);
  5423.         Replace(List1, Token1, "No_Name");
  5424.         No_Exception("61:**ERROR**REPLACE: bad name");
  5425.  
  5426.  
  5427.     when 62 =>                    --MIL STD 5.4.1.20.6
  5428.         Expected := "Use";    --Use_Error Expected
  5429.         To_List("(1,TWO)", List1);
  5430.         Insert(List1, Token1, "No_Name", 2);
  5431.         No_Exception("62:**ERROR**INSERT: mixed name/pos");
  5432.     when 63 =>
  5433.         Expected := "Use";    --Use_Error Expected
  5434.         To_List("(I=>1,J=>TWO)", List1);
  5435.         Insert(List1, Token1, 1);
  5436.         No_Exception("63:**ERROR**INSERT: mixed pos/name");
  5437.     when 64 =>
  5438.         Expected := "Use";    --Use_Error Expected
  5439.         To_List("(I=>1,J=>TWO)", List1);
  5440.         Insert(List1, Token1, "J", 0);
  5441.         No_Exception("64:**ERROR**INSERT: duplicate name");
  5442.     when 65 =>
  5443.         Expected := "Use";    --Use_Error Expected
  5444.         To_List("(I=>1,J=>TWO)", List1);
  5445.         Insert(List1, Token1, Token1, 10);
  5446.         No_Exception("65:**ERROR**INSERT: bad position");
  5447.  
  5448.  
  5449.     when 66 =>                    --MIL STD 5.4.1.20.7
  5450.         Expected := "Use";    --Use_Error Expected
  5451.         To_List("(I=>1,J=>TWO)", List1);
  5452.         Posit1 := Position_By_Value(List1, "TWO", 7, 9);
  5453.         No_Exception("66:**ERROR**POSITION_BY_VALUE: high start");
  5454.     when 67 =>
  5455.         Expected := "Use";    --Use_Error Expected
  5456.         To_List("()", List1);
  5457.         Posit1 := Position_By_Value(List1, "TWO", 7, 9);
  5458.         No_Exception("66:**ERROR**POSITION_BY_VALUE: empty list");
  5459.     when 68 =>
  5460.         Expected := "Use";    --Use_Error Expected
  5461.         To_List("(I=>1,J=>TWO)", List1);
  5462.         Posit1 := Position_By_Value(List1, "TWO", 2, 1);
  5463.         No_Exception("66:**ERROR**POSITION_BY_VALUE: bad range");
  5464.     when 69 =>
  5465.         Expected := "Sea";    --Search_Error Expected
  5466.         To_List("(I=>1,J=>TWO)", List1);
  5467.         Posit1 := Position_By_Value(List1, "ONE", 1, 2);
  5468.         No_Exception("69:**ERROR**POSITION_BY_VALUE: bad value");
  5469.  
  5470.  
  5471.                             --MIL STD 5.4.1.21
  5472.                               --**************
  5473.                               --NOT IMPLEMENTED
  5474.                               --**************
  5475.                             --MIL STD 5.4.1.22
  5476.                               --**************
  5477.                               --NOT IMPLEMENTED
  5478.                               --**************
  5479.  
  5480.  
  5481.  
  5482.     when 70 =>                    --MIL STD 5.4.1.23.1
  5483.         Expected := "Use";    --Use_Error Expected
  5484.         To_List("(ONE,TWO)", List2);
  5485.         String1 := Extract(List1, "No_Name");
  5486.         No_Exception("70:**ERROR**EXTRACT: mixed pos/name");
  5487.     when 71 =>
  5488.         Expected := "Sea";    --Search_Error Expected
  5489.         To_List("(I=>ONE,J=>TWO)", List1);
  5490.         String1 := Extract(List1, "No_Name");
  5491.         No_Exception("71:**ERROR**EXTRACT: bad name");
  5492.     when 72 =>
  5493.         Expected := "Use";    --Use_Error Expected
  5494.         To_List("(ONE,TWO)", List2);
  5495.         String1 := Extract(List2, 3);
  5496.         No_Exception("72:**ERROR**EXTRACT: position too high");
  5497.     when 73 =>
  5498.         Expected := "Use";    --Use_Error Expected
  5499.         To_List("(I=>1,J=>TWO)", List1);
  5500.         String1 := Extract(List1, "I");
  5501.         No_Exception("73:**ERROR**EXTRACT: name item not a token");
  5502.     when 74 =>
  5503.         Expected := "Use";    --Use_Error Expected
  5504.         To_List("(I=>1,J=>TWO)", List1);
  5505.         String1 := Extract(List1, 1);
  5506.         No_Exception("74:**ERROR**EXTRACT: pos item not a token");
  5507.     when 75 =>
  5508.         Expected := "Use";    --Use_Error Expected
  5509.         To_List("()", List2);
  5510.         String1 := Extract(List2, 1);
  5511.         No_Exception("75:**ERROR**EXTRACT: empty list");
  5512.  
  5513.  
  5514.  
  5515.     when 76 =>                    --MIL STD 5.4.1.23.2
  5516.         Expected := "Use";    --Use_Error Expected
  5517.         To_List("()", List2);
  5518.         Replace(List2, String1, 1);
  5519.         No_Exception("76:**ERROR**REPLACE: empty list");
  5520.     when 77 =>
  5521.         Expected := "Use";    --Use_Error Expected
  5522.         To_List("(1,TWO)", List1);
  5523.         Replace(List1, String1, "No_Name");
  5524.         No_Exception("77:**ERROR**REPLACE: mixed name/pos");
  5525.     when 78 =>
  5526.         Expected := "Use";    --Use_Error Expected
  5527.         To_List("(I=>1,J=>TWO)", List1);
  5528.         Replace(List1, String1, 5);
  5529.         No_Exception("78:**ERROR**REPLACE: bad position");
  5530.     when 79 =>
  5531.         Expected := "Use";    --Use_Error Expected
  5532.         To_List("(I=>1,J=>TWO)", List1);
  5533.         Replace(List1, String1, "J");
  5534.         No_Exception("79:**ERROR**REPLACE: name item not a string");
  5535.     when 80 =>
  5536.         Expected := "Use";    --Use_Error Expected
  5537.         To_List("(I=>1,J=>TWO)", List1);
  5538.         Replace(List1, String1, 1);
  5539.         No_Exception("80:**ERROR**REPLACE: pos item not a string");
  5540.     when 81 =>
  5541.         Expected := "Sea";    --Search_Error Expected
  5542.         To_List("(I=>1,J=>TWO)", List1);
  5543.         Replace(List1, String1, "No_Name");
  5544.         No_Exception("81:**ERROR**REPLACE: bad name");
  5545.  
  5546.  
  5547.  
  5548.     when 82 =>                    --MIL STD 5.4.1.23.3
  5549.         Expected := "Use";    --Use_Error Expected
  5550.         To_List("(1,TWO)", List1);
  5551.         Insert(List1, String1, "No_Name", 2);
  5552.         No_Exception("82:**ERROR**INSERT: mixed name/pos");
  5553.     when 83 =>
  5554.         Expected := "Use";    --Use_Error Expected
  5555.         To_List("(I=>1,J=>TWO)", List1);
  5556.         Replace(List1, String1, 1);
  5557.         No_Exception("83:**ERROR**INSERT: mixed pos/name");
  5558.     when 84 =>
  5559.         Expected := "Use";    --Use_Error Expected
  5560.         To_List("(I=>1,J=>TWO)", List1);
  5561.         Insert(List1, String1, "J", 0);
  5562.         No_Exception("84:**ERROR**INSERT: duplicate name");
  5563.     when 85 =>
  5564.         Expected := "Use";    --Use_Error Expected
  5565.         To_List("(I=>1,J=>TWO)", List1);
  5566.         Insert(List1, String1, 10);
  5567.         No_Exception("85:**ERROR**INSERT: bad position");
  5568.  
  5569.  
  5570.  
  5571.     when 86 =>                    --MIL STD 5.4.1.23.4
  5572.         Expected := "Sea";    --Search_Error Expected
  5573.         To_List("(I=>1,J=>TWO)", List1);
  5574.         Posit1 := Position_By_Value(List1, "ONE", 1, 2);
  5575.         No_Exception("86:**ERROR**POSITION_BY_VALUE: bad value");
  5576.     when 87 =>
  5577.         Expected := "Use";    --Use_Error Expected
  5578.         To_List("(I=>1,J=>TWO)", List1);
  5579.         Posit1 := Position_By_Value(List1, "ONE", 8, 9);
  5580.         No_Exception("87:**ERROR**POSITION_BY_VALUE: high start");
  5581.     when 88 =>
  5582.         Expected := "Use";    --Use_Error Expected
  5583.         To_List("(I=>1,J=>TWO)", List1);
  5584.         Posit1 := Position_By_Value(List1, "ONE", 2, 1);
  5585.         No_Exception("88:**ERROR**POSITION_BY_VALUE: bad range");
  5586.     when 89 =>
  5587.         Expected := "Use";    --Use_Error Expected
  5588.         To_List("()", List1);
  5589.         Posit1 := Position_By_Value(List1, "ONE", 2, 3);
  5590.         No_Exception("88:**ERROR**POSITION_BY_VALUE: empty list");
  5591.  
  5592.  
  5593.  
  5594.     when 90 =>                    --MIL STD 5.4.1.13
  5595.         Expected := "Sea";    --Search_Error Expected
  5596.         To_List("(I=>1,J=>3)", List2);
  5597.         Text := Text_Length(List2, "No_Name");
  5598.         No_Exception("24:**ERROR**TEXT_LENGTH: bad name");
  5599.  
  5600.  
  5601.                 --*******************************
  5602.                 --ERROR, SHOULD NEVER BE EXECUTED
  5603.                 --*******************************
  5604.     when others =>
  5605.         put_line( "******No test for: " & integer'image(II) );
  5606.     end case;
  5607.   end Raise_Exception;
  5608.  
  5609.  
  5610.   begin
  5611.     Line_Count := 10;
  5612.     for I in 1..Exceptions_Tested loop
  5613.     begin
  5614.         if Line_Count = 10 then
  5615.         new_line;
  5616.         put("PASSES TEST: ");
  5617.         Line_Count := 0;
  5618.         end if;
  5619.         Raise_Exception(I);
  5620.         exception
  5621.       when Node_Definitions.Use_Error        =>
  5622.                 if Expected /= "Use" then
  5623.                   Wrong_Exception(I,"Use_Error");
  5624.                 else
  5625.                   Line_Count := Line_Count+1;
  5626.                   put( integer'image(I));
  5627.                   put("  ");
  5628.                 end if;
  5629.  
  5630.       when Search_Error     =>
  5631.                 if Expected /= "Sea" then
  5632.                   Wrong_Exception(I,"Search_Error");
  5633.                 else
  5634.                   Line_Count := Line_Count+1;
  5635.                   put( integer'image(I));
  5636.                   put("  ");
  5637.                 end if;
  5638.  
  5639.       when Constraint_Error =>
  5640.                 if Expected /= "Con" then
  5641.                   Wrong_Exception(I,"Constraint_Error");
  5642.                 else
  5643.                   Line_Count := Line_Count+1;
  5644.                   put( integer'image(I));
  5645.                   put("  ");
  5646.                 end if;
  5647.     end;
  5648.   end loop;
  5649.  
  5650.   new_line;
  5651.   put_line("****************************T O T A L S***********************");
  5652.   put_line("Number of tests run: " & integer'image(Exceptions_Tested));
  5653.   put_line("Number of failures : " & integer'image(Failures) );
  5654.   put_line("**************************************************************");
  5655. end Test_Ex;
  5656.  
  5657. --::::::::::::::
  5658. --list_utilities_tests-body.a
  5659. --::::::::::::::
  5660.  
  5661. ----------------------------------------------------------------------
  5662. --                        List_Utilities_Tests
  5663. --                           (Package Body)
  5664. --
  5665. --
  5666. --             A Set of Simple Test Subprograms To Exercise 
  5667. --                      Portions of List_Utilities
  5668. --
  5669. --
  5670. --
  5671. --                  Ada Software Engineering Group
  5672. --                      The MITRE Corporation
  5673. --                         McLean, VA 22102
  5674. --
  5675. --
  5676. --                   Wed Mar 13 10:00:00 EST 1985
  5677. --
  5678. --                 (Unclassified and uncopyrighted)
  5679. --
  5680. ----------------------------------------------------------------------
  5681.  
  5682. ----------------------------------------------------------------------
  5683. --
  5684. --  Purpose:
  5685. --  -------
  5686. --    To provide a set of functions that exercise and test the
  5687. --    behavior of some of the services available in package
  5688. --    List_Utilities.
  5689. --
  5690. --  Usage:
  5691. --  -----
  5692. --    The functions made available in this package will be used
  5693. --    by a "main procedure" named Listutst.  This procedure acts
  5694. --    as a test driver, calling the different test functions in
  5695. --    sequence.  Output from the tests goes to Standard output
  5696. --    Each function returns a value indicated success/failure of
  5697. --    test (i.e. expected results were/were not equal to actual
  5698. --    results).  The driver procedure keeps track of the overall
  5699. --    success/failure count and prints a test summary at the end.
  5700. --
  5701. --    The test functions have two parameters: 
  5702. --        Verbosity - (Kinds_Of_Output) can have the following values:
  5703. --                  None - No messages are sent to Standard_Output
  5704. --                  Status - the test reports on its success or failure
  5705. --                  Dump   - in addition to reporting on its success
  5706. --                           or failure, the test will print the
  5707. --                           string representation of the list(s)
  5708. --                           at the end of the test
  5709. --        Die_On_Exception : Boolean - if true, an unexpected exception
  5710. --                  will be propogated to the calling procedure,
  5711. --                  otherwise it will be caught (it is still
  5712. --                  treated as a failure, though).
  5713. --
  5714. --  Example:
  5715. --  -------
  5716. --    See the procedure Listutst for all the examples you could
  5717. --    ever want...
  5718. --
  5719. --  Notes:
  5720. --  -----
  5721. --    See the sections marked "--HACK" for temporary changes and
  5722. --    "quick fixes".
  5723. --
  5724. --
  5725. --  Revision History:
  5726. --  ----------------
  5727. --    Mar 8  (CCH): Added the Verbosity and Die_On_Exception options.
  5728. --    Mar 8  (CCH): Added the internal procedure Dump_List.
  5729. --    Mar 12 (CCH): Added the internal procedure Report_Status.
  5730. --
  5731. -------------------------------------------------------------------
  5732.  
  5733. with Cais; use Cais;
  5734. with Text_IO; use Text_Io;
  5735.  
  5736. package body List_Utilities_Tests is
  5737.  
  5738. use List_Utilities;
  5739. use String_Items; -- nested package within List_Utilities;
  5740.  
  5741.  
  5742. ----------------------   D U M P _ L I S T     ----------------------
  5743. --
  5744. --  Purpose:
  5745. --  -------
  5746. --    To print the character string representation of a list_type
  5747. --    to Std. Output.
  5748. --
  5749. --  Parameters:
  5750. --  ----------
  5751. --      Verbosity       string will be printed only if this is set
  5752. --            to DUMP.
  5753. --      Item_Name     A string to be printed along with the string
  5754. --            representation.  This allows the identification
  5755. --            of which list_type is being dumped.
  5756. --      List_Item    the list_type item to be dumped.
  5757. --
  5758. --  Exceptions:
  5759. --  ----------
  5760. --    None.
  5761. --
  5762. --  Notes:
  5763. --  -----
  5764. --    None.
  5765. --
  5766. ---------------------------------------------------------------------
  5767.  
  5768.     procedure Dump_List (
  5769.         Verbosity  : Kinds_Of_Output;
  5770.         Item_Name  : String;
  5771.         List_Item  : List_Type) is
  5772.  
  5773.     begin
  5774.  
  5775.         if Verbosity /= Dump then 
  5776.             return; -- do nothing
  5777.         else
  5778.             Put (Item_Name);
  5779.             Put (" is stored as:");
  5780.             Put_Line (To_Text (List_Item));
  5781.         end if;
  5782.  
  5783.     end Dump_List;
  5784.  
  5785. ---------------------  R E P O R T _ S T A T U S --------------------
  5786. --
  5787. --  Purpose:
  5788. --  -------
  5789. --    To print a descriptive test result message to Std. Output,
  5790. --    governed by the level of output desired for the test.
  5791. --
  5792. --  Parameters:
  5793. --  ----------
  5794. --    Verbosity        The message will be printed unless this is
  5795. --            set to NONE.
  5796. --    Msg        The string representing the message to be printed.
  5797. --
  5798. --  Exceptions:
  5799. --  ----------
  5800. --    None.
  5801. --
  5802. --  Notes:
  5803. --  -----
  5804. --    None.
  5805. --
  5806. ---------------------------------------------------------------------
  5807.  
  5808.     procedure Report_Status (
  5809.         Verbosity  : Kinds_Of_Output;
  5810.         Msg        : String) is
  5811.  
  5812.     begin
  5813.  
  5814.         if Verbosity = None then 
  5815.             return; -- do nothing
  5816.         else
  5817.             Put_Line (Msg);
  5818.         end if;
  5819.  
  5820.     end Report_Status;
  5821.  
  5822. ----------------------      T E S T 0 0 1      ----------------------
  5823. --
  5824. --  Purpose:
  5825. --  -------
  5826. --    Simple test of Copy with EMPTY_STRING.
  5827. --
  5828. --  Parameters:
  5829. --  ----------
  5830. --    Verbosity        Specifies the level of output desired. Options:
  5831. --            NONE:   No output from this test
  5832. --            STATUS: Report on success or failure of specific
  5833. --                tests
  5834. --            DUMP:   Same as STATUS, with the additional 
  5835. --                output of the string representation of
  5836. --                the list_type(s) used.
  5837. --    Die_On_Exception       If true, an unhandled exception will be propogated.
  5838. --               If False, the exception will be handled and the
  5839. --               test will return a value of FAIL.
  5840. --    return Test_Result   Simply indicates pass/fail of the test.
  5841. --
  5842. --  Exceptions:
  5843. --  ----------
  5844. --    None.
  5845. --
  5846. --  Notes:
  5847. --  -----
  5848. --    None.
  5849. --
  5850. ---------------------------------------------------------------------
  5851.  
  5852.     function Test001 (
  5853.         Verbosity        : Kinds_Of_Output := Dump;
  5854.         Die_On_Exception : Boolean := True)
  5855.         return Test_Result is
  5856.  
  5857.         Result      : Test_Result := Fail;   
  5858.         Sample_List : List_Type;
  5859.  
  5860.     begin
  5861.  
  5862.         Copy (Sample_List, EMPTY_LIST);
  5863.  
  5864.         if Get_List_Kind (Sample_List) /= Empty then
  5865.             Report_Status ( Verbosity, 
  5866.                 "LIST_UTILITIES TEST 001: SAMPLE_LIST /= EMPTY ");
  5867.         else
  5868.             Result := Pass;
  5869.             Report_Status ( Verbosity, 
  5870.                 "List_Utilities test 001: OK");
  5871.         end if; -- Get_List_Kind (Sample_List) /= Empty 
  5872.  
  5873.         Dump_List  (Verbosity, "EMPTY_LIST", EMPTY_LIST);
  5874.  
  5875.         return Result;
  5876.  
  5877.     exception
  5878.  
  5879.         when others =>
  5880.  
  5881.             Report_Status (Verbosity,
  5882.                 "**** LIST_UTILITIES TEST 001: UNHANDLED EXCEPTION");
  5883.             Dump_List  (Verbosity, "EMPTY_LIST", EMPTY_LIST);
  5884.  
  5885.             if Die_On_Exception then
  5886.                 raise;
  5887.             else
  5888.                 return (Fail);
  5889.             end if;
  5890.     end Test001;
  5891.  
  5892. ----------------------      T E S T 0 0 2      ----------------------
  5893. --
  5894. --  Purpose:
  5895. --  -------
  5896. --
  5897. --  Parameters:
  5898. --  ----------
  5899. --    Verbosity        Specifies the level of output desired. Options:
  5900. --            NONE:   No output from this test
  5901. --            STATUS: Report on success or failure of specific
  5902. --                tests
  5903. --            DUMP:   Same as STATUS, with the additional 
  5904. --                output of the string representation of
  5905. --                the list_type(s) used.
  5906. --    Die_On_Exception       If true, an unhandled exception will be propogated.
  5907. --               If False, the exception will be handled and the
  5908. --               test will return a value of FAIL.
  5909. --    return Test_Result   Simply indicates pass/fail of the test.
  5910. --
  5911. --  Exceptions:
  5912. --  ----------
  5913. --    None.
  5914. --
  5915. --  Notes:
  5916. --  -----
  5917. --    None.
  5918. --
  5919. ---------------------------------------------------------------------
  5920.  
  5921.     function Test002 (
  5922.         Verbosity        : Kinds_Of_Output := Dump;
  5923.         Die_On_Exception : Boolean := True)
  5924.         return Test_Result is
  5925.  
  5926.         Result      : Test_Result := Pass;
  5927.         Sample_List : List_Type;
  5928.  
  5929.     begin
  5930.  
  5931.         Copy (Sample_List, EMPTY_LIST);
  5932.         if Length (Sample_List) /= 0 then
  5933.             Result := Fail;
  5934.             Report_Status (Verbosity, 
  5935.                 "LIST_UTILITIES TEST 002: EMPTY LIST LENGTH /= 0.");
  5936.         end if; 
  5937.         Insert (Sample_List,
  5938.             List_Item => "12345",
  5939.             Named     => "String_1",
  5940.             Position  => 0);
  5941.         if Get_List_Kind (Sample_List) /= Named then
  5942.         Result := Fail;
  5943.             Report_Status ( Verbosity, 
  5944.                 "LIST_UTILITIES TEST 002: SAMPLE_LIST /= NAMED");
  5945.     end if;
  5946.  
  5947.         if Result = Pass then
  5948.             Report_Status (Verbosity, "List_Utilities test 002: OK");
  5949.     end if;
  5950.         Dump_List  (Verbosity, "SAMPLE_LIST", Sample_List);
  5951.  
  5952.         return Result;
  5953.  
  5954.     exception
  5955.  
  5956.         when others => 
  5957.             Report_Status (Verbosity,
  5958.                 "**** LIST_UTILITIES TEST 002: UNHANDLED EXCEPTION");
  5959.             Dump_List  (Verbosity, "EMPTY_LIST", EMPTY_LIST);
  5960.  
  5961.             if Die_On_Exception then
  5962.                 raise;
  5963.             else
  5964.                 return (Fail);
  5965.             end if;
  5966.     end Test002;
  5967.  
  5968. ----------------------      T E S T 0 0 3      ----------------------
  5969. --
  5970. --  Purpose:
  5971. --  -------
  5972. --
  5973. --  Parameters:
  5974. --  ----------
  5975. --    Verbosity        Specifies the level of output desired. Options:
  5976. --            NONE:   No output from this test
  5977. --            STATUS: Report on success or failure of specific
  5978. --                tests
  5979. --            DUMP:   Same as STATUS, with the additional 
  5980. --                output of the string representation of
  5981. --                the list_type(s) used.
  5982. --    Die_On_Exception       If true, an unhandled exception will be propogated.
  5983. --               If False, the exception will be handled and the
  5984. --               test will return a value of FAIL.
  5985. --    return Test_Result   Simply indicates pass/fail of the test.
  5986. --
  5987. --  Exceptions:
  5988. --  ----------
  5989. --    None.
  5990. --
  5991. --  Notes:
  5992. --  -----
  5993. --    None.
  5994. --
  5995. ---------------------------------------------------------------------
  5996.  
  5997.     function Test003 (
  5998.         Verbosity        : Kinds_Of_Output := Dump;
  5999.         Die_On_Exception : Boolean := True)
  6000.         return Test_Result is
  6001.  
  6002.         Result      : Test_Result := Pass;   
  6003.         Sample_List : List_Type;
  6004.     Found_First : Boolean := False;
  6005.  
  6006.     begin
  6007.  
  6008.         Copy (Sample_List, EMPTY_LIST);
  6009.  
  6010.         Insert (Sample_List,
  6011.             List_Item => "12345",
  6012.             Named     => "String1",
  6013.             Position  => 0);
  6014.  
  6015.         if Length (Sample_List) /= 1 then
  6016.             Result := Fail;
  6017.             Report_Status (Verbosity,
  6018.                 "LIST_UTILITIES TEST 003: LENGTH /= 1");
  6019.             Dump_List (Verbosity, "Sample_List", Sample_List);
  6020.         end if;
  6021.  
  6022.         if Extract (Sample_List, "String1") /= "12345" then
  6023.             Result := Fail;
  6024.             Report_Status (Verbosity,
  6025.                 "LIST_UTILITIES TEST 003: String1 /= 12345");
  6026.             Dump_List (Verbosity, "Sample_List", Sample_List);
  6027.     else
  6028.         Found_First := True;
  6029.         end if;
  6030.  
  6031.         if Extract (Sample_List, "StRiNg1") /= "12345" then
  6032.             Result := Fail;
  6033.             Report_Status (Verbosity,
  6034.                 "LIST_UTILITIES TEST 003: StRiNg1 /= 12345");
  6035.             Dump_List (Verbosity, "Sample_List", Sample_List);
  6036.         end if;
  6037.  
  6038.         if Text_Length (Sample_List, "String1") /= 5 then
  6039.             Result := Fail;
  6040.             Report_Status (Verbosity,
  6041.                 "LIST_UTILITIES TEST 003: TEXT LENGTH /= 7");
  6042.             Dump_List (Verbosity, "Sample_List", Sample_List);
  6043.         end if;
  6044.  
  6045.         if Result = Pass then
  6046.             Report_Status (Verbosity, "List_Utilities test 003: OK");
  6047.         end if;
  6048.         Dump_List (Verbosity, "Sample_List", Sample_List);
  6049.         return Result;
  6050.  
  6051.     exception
  6052.  
  6053.     when Search_Error =>
  6054.         if Found_First then
  6055.         Report_Status (Verbosity,
  6056.             "LIST_UTILITIES TEST 003: CAN'T FIND StRiNg1");
  6057.         Dump_List  (Verbosity, "Sample_List", Sample_List);
  6058.         else
  6059.         Report_Status (Verbosity,
  6060.             "LIST_UTILITIES TEST 003: CAN'T FIND String1");
  6061.         Dump_List  (Verbosity, "Sample_List", Sample_List);
  6062.         end if;
  6063.             if Die_On_Exception then
  6064.                 raise;
  6065.             else
  6066.                 return (Fail);
  6067.             end if;
  6068.  
  6069.         when others =>
  6070.             Report_Status (Verbosity,
  6071.                 "**** LIST_UTILITIES TEST 003: UNHANDLED EXCEPTION");
  6072.             Dump_List  (Verbosity, "Sample_List", Sample_List);
  6073.  
  6074.             if Die_On_Exception then
  6075.                 raise;
  6076.             else
  6077.                 return (Fail);
  6078.             end if;
  6079.     end Test003;
  6080.  
  6081. ----------------------      T E S T 0 0 4      ----------------------
  6082. --
  6083. --  Purpose:
  6084. --  -------
  6085. --
  6086. --  Parameters:
  6087. --  ----------
  6088. --    Verbosity        Specifies the level of output desired. Options:
  6089. --            NONE:   No output from this test
  6090. --            STATUS: Report on success or failure of specific
  6091. --                tests
  6092. --            DUMP:   Same as STATUS, with the additional 
  6093. --                output of the string representation of
  6094. --                the list_type(s) used.
  6095. --    Die_On_Exception       If true, an unhandled exception will be propogated.
  6096. --               If False, the exception will be handled and the
  6097. --               test will return a value of FAIL.
  6098. --    return Test_Result   Simply indicates pass/fail of the test.
  6099. --
  6100. --  Exceptions:
  6101. --  ----------
  6102. --    None.
  6103. --
  6104. --  Notes:
  6105. --  -----
  6106. --    None.
  6107. --
  6108. ---------------------------------------------------------------------
  6109.  
  6110.     function Test004 (
  6111.         Verbosity        : Kinds_Of_Output := Dump;
  6112.         Die_On_Exception : Boolean := True)
  6113.         return Test_Result is
  6114.  
  6115.         Result      : Test_Result := Pass;   
  6116.         Sample_List : List_Type;
  6117.         Phyl        : File_Type;
  6118.         Str         : String (1..400) := (others => ' ');
  6119.         Str_Len     : Natural;
  6120.  
  6121.     begin
  6122.  
  6123.         Copy (Sample_List, EMPTY_LIST);
  6124.         Insert (Sample_List,
  6125.             List_Item => "12345",
  6126.             Named     => "String1",
  6127.             Position  => 0);
  6128.  
  6129.     OPEN_FILE:
  6130.     begin   -- to trap exception here
  6131.         Open (Phyl, Out_File, "Phyl.tmp");
  6132.     exception
  6133.         when Name_Error =>
  6134.         Create (Phyl, Out_File, "Phyl.tmp");
  6135.     end OPEN_FILE;
  6136.  
  6137.         Put_Line (Phyl, To_Text (Sample_List));
  6138.  
  6139.         Copy (Sample_List, EMPTY_LIST);
  6140.         if Length (Sample_List) /= 0 then
  6141.             Result := Fail;
  6142.             Report_Status (Verbosity,
  6143.                 "LIST_UTILITIES TEST 004: RESET LIST LENGTH /= 0");
  6144.             Dump_List (Verbosity, "Sample_List", Sample_List);
  6145.         end if;
  6146.  
  6147.         Close (Phyl);
  6148.         Open (Phyl, In_File, "Phyl.tmp");
  6149.         Get_Line (Phyl, Str, Str_Len);
  6150.  
  6151.         To_List (Str (1..Str_Len), Sample_List);
  6152.         if Get_List_Kind (Sample_List) /= Named then
  6153.             Result := Fail;
  6154.             Report_Status (Verbosity,
  6155.                 "LIST_UTILITIES TEST 004: Sample_List is not Named");
  6156.             Dump_List (Verbosity, "Sample_List", Sample_List);
  6157.         end if;
  6158.  
  6159.         if Extract (Sample_List, "String1") /= "12345" then
  6160.             Result := Fail;
  6161.             Report_Status (Verbosity,
  6162.                 "LIST_UTILITIES TEST 004: String1 /= 123435");
  6163.             Dump_List (Verbosity, "Sample_List", Sample_List);
  6164.         end if;
  6165.  
  6166.         if Result = Pass then
  6167.             Report_Status (Verbosity, "List_Utilities test 004: OK");
  6168.             Dump_List (Verbosity, "Sample_List", Sample_List);
  6169.         end if;
  6170.  
  6171.         return Result;
  6172.  
  6173.     exception
  6174.  
  6175.     when Search_Error =>
  6176.         Report_Status (Verbosity,
  6177.         "LIST_UTILITIES TEST 004: CAN'T FIND String1");
  6178.         Dump_List  (Verbosity, "Sample_List", Sample_List);
  6179.             if Die_On_Exception then
  6180.                 raise;
  6181.             else
  6182.                 return (Fail);
  6183.             end if;
  6184.  
  6185.         when others =>
  6186.             Report_Status (Verbosity,
  6187.                 "**** LIST_UTILITIES TEST 004: UNHANDLED EXCEPTION");
  6188.             Dump_List  (Verbosity, "EMPTY_LIST", EMPTY_LIST);
  6189.             if Die_On_Exception then
  6190.                 raise;
  6191.             else
  6192.                 return (Fail);
  6193.             end if;
  6194.     end Test004;
  6195.  
  6196. ----------------------      T E S T 0 0 5      ----------------------
  6197. --
  6198. --  Purpose:
  6199. --  -------
  6200. --
  6201. --  Parameters:
  6202. --  ----------
  6203. --    Verbosity        Specifies the level of output desired. Options:
  6204. --            NONE:   No output from this test
  6205. --            STATUS: Report on success or failure of specific
  6206. --                tests
  6207. --            DUMP:   Same as STATUS, with the additional 
  6208. --                output of the string representation of
  6209. --                the list_type(s) used.
  6210. --    Die_On_Exception       If true, an unhandled exception will be propogated.
  6211. --               If False, the exception will be handled and the
  6212. --               test will return a value of FAIL.
  6213. --    return Test_Result   Simply indicates pass/fail of the test.
  6214. --
  6215. --  Exceptions:
  6216. --  ----------
  6217. --    None.
  6218. --
  6219. --  Notes:
  6220. --  -----
  6221. --    None.
  6222. --
  6223. ---------------------------------------------------------------------
  6224.  
  6225.     function Test005 (
  6226.         Verbosity        : Kinds_Of_Output := Dump;
  6227.         Die_On_Exception : Boolean := True)
  6228.         return Test_Result is
  6229.  
  6230.         Result      : Test_Result := Pass;   
  6231.         List_One    : List_Type;
  6232.         List_Two    : List_Type;
  6233.         Phyl        : File_Type;
  6234.         Str         : String (1..256) := (others => ' ');
  6235.         Str_Len     : Natural;
  6236.  
  6237.     begin
  6238.  
  6239.     Copy (List_One, EMPTY_LIST);
  6240.     Copy (List_Two, EMPTY_LIST);
  6241.     Insert (List_One,
  6242.         List_Item => "'USER(THOMPSON).GONZO",
  6243.         Named     => "Parent",
  6244.         Position  => 0);
  6245.  
  6246.     Insert (List_Two,
  6247.         List_Item => "SECONDARY_STORAGE",
  6248.         Named     => "File_Kind",
  6249.         Position  => 0);
  6250.  
  6251.     Insert (List_Two,
  6252.         List_Item => "TEXT",
  6253.         Named     => "Access_Method",
  6254.         Position  => 0);
  6255.  
  6256.     if Length (List_One) /= 1 then
  6257.         Result := Fail;
  6258.         Report_Status (Verbosity,
  6259.         "LIST_UTILITIES TEST 005: LIST_ONE LENGTH /= 1");
  6260.         Dump_List (Verbosity, "List_One", List_One);
  6261.     end if;
  6262.  
  6263.     if Length (List_Two) /= 2 then
  6264.         Result := Fail;
  6265.         Report_Status (Verbosity,
  6266.         "LIST_UTILITIES TEST 005: LIST_TWO LENGTH /= 2");
  6267.         Dump_List (Verbosity, "List_Two", List_Two);
  6268.     end if;
  6269.  
  6270.     Insert (
  6271.         List      => List_One,
  6272.         List_Item => List_Two,
  6273.         Named     => "Attributes",
  6274.         Position  => 0);
  6275.  
  6276.     if Length (List_One) /= 2 then
  6277.         Result := Fail;
  6278.         Report_Status (Verbosity,
  6279.         "LIST_UTILITIES TEST 005: LIST_ONE LENGTH /= 2");
  6280.         Dump_List (Verbosity, "List_One", List_One);
  6281.     end if;
  6282.  
  6283.     OPEN_FILE:
  6284.     begin   -- to trap exception here
  6285.         Open (Phyl, Out_File, "Phyl2.tmp");
  6286.     exception
  6287.         when Name_Error =>
  6288.         Create (Phyl, Out_File, "Phyl2.tmp");
  6289.     end OPEN_FILE;
  6290.  
  6291.         Put_line (Phyl, To_Text (List_One));
  6292.     Close (Phyl);
  6293.     Copy (List_Two, EMPTY_LIST);
  6294.  
  6295.         Open (Phyl, In_File, "Phyl2.tmp");
  6296.         Get_Line (Phyl, Str, Str_Len);
  6297.         To_List (Str (1..Str_Len), List_Two);
  6298.  
  6299.     Copy (List_One, EMPTY_LIST);
  6300.     Extract (
  6301.         List     => List_Two,
  6302.         Named     => "Attributes",
  6303.         List_Item => List_One); 
  6304.  
  6305.         if Extract (List_One, "File_Kind") /= "SECONDARY_STORAGE" then
  6306.             Result := Fail;
  6307.             Report_Status (Verbosity,
  6308.                 "LIST_UTILITIES TEST 005: FILE_KIND IS WRONG");
  6309.             Dump_List (Verbosity, "List_One", List_One);
  6310.         end if;
  6311.  
  6312.         if Result = Pass then
  6313.             Report_Status (Verbosity, "List_Utilities test 005: OK");
  6314.             Dump_List (Verbosity, "List_One", List_One);
  6315.             Dump_List (Verbosity, "List_Two", List_Two);
  6316.         end if;
  6317.  
  6318.     return Result;
  6319.     exception
  6320.  
  6321.     when Search_Error =>
  6322.         Report_Status (Verbosity,
  6323.         "LIST_UTILITIES TEST 005: SEARCH_ERROR");
  6324.         Dump_List  (Verbosity, "List_One", List_One);
  6325.         Dump_List  (Verbosity, "List_Two", List_Two);
  6326.             if Die_On_Exception then
  6327.                 raise;
  6328.             else
  6329.                 return (Fail);
  6330.             end if;
  6331.         when others =>
  6332.             Report_Status (Verbosity,
  6333.                 "**** LIST_UTILITIES TEST 005: UNHANDLED EXCEPTION");
  6334.             Dump_List  (Verbosity, "EMPTY_LIST", EMPTY_LIST);
  6335.  
  6336.             if Die_On_Exception then
  6337.                 raise;
  6338.             else
  6339.                 return (Fail);
  6340.             end if;
  6341.     end Test005;
  6342.  
  6343. ----------------------      T E S T 0 0 6      ----------------------
  6344. --
  6345. --  Purpose:
  6346. --  -------
  6347. --
  6348. --  Parameters:
  6349. --  ----------
  6350. --    Verbosity        Specifies the level of output desired. Options:
  6351. --            NONE:   No output from this test
  6352. --            STATUS: Report on success or failure of specific
  6353. --                tests
  6354. --            DUMP:   Same as STATUS, with the additional 
  6355. --                output of the string representation of
  6356. --                the list_type(s) used.
  6357. --    Die_On_Exception       If true, an unhandled exception will be propogated.
  6358. --               If False, the exception will be handled and the
  6359. --               test will return a value of FAIL.
  6360. --    return Test_Result   Simply indicates pass/fail of the test.
  6361. --
  6362. --  Exceptions:
  6363. --  ----------
  6364. --    None.
  6365. --
  6366. --  Notes:
  6367. --  -----
  6368. --    None.
  6369. --
  6370. ---------------------------------------------------------------------
  6371.  
  6372. --    function Test006 (
  6373. --        Verbosity        : Kinds_Of_Output := Dump;
  6374. --        Die_On_Exception : Boolean := True)
  6375. --        return Test_Result is
  6376. --
  6377. --        Result      : Test_Result := Fail;   
  6378. --
  6379. --    begin
  6380. --
  6381. --        return Result;
  6382. --
  6383. --    exception
  6384. --
  6385. --        when others =>
  6386. --            Report_Status (Verbosity,
  6387. --                "**** LIST_UTILITIES TEST 006: UNHANDLED EXCEPTION");
  6388. --            Dump_List  (Verbosity, "EMPTY_LIST", EMPTY_LIST);
  6389. --
  6390. --            if Die_On_Exception then
  6391. --                raise;
  6392. --            else
  6393. --                return (Fail);
  6394. --            end if;
  6395. --    end Test006;
  6396.  
  6397. end List_Utilities_Tests;
  6398. --::::::::::::::
  6399. --list_utilities_tests-spec.a
  6400. --::::::::::::::
  6401.  
  6402. ----------------------------------------------------------------------
  6403. --                        List_Utilities_Tests
  6404. --                      (Package Specification)
  6405. --
  6406. --
  6407. --             A Set of Simple Test Subprograms To Exercise 
  6408. --                      Portions of List_Utilities
  6409. --
  6410. --
  6411. --
  6412. --                  Ada Software Engineering Group
  6413. --                      The MITRE Corporation
  6414. --                         McLean, VA 22102
  6415. --
  6416. --
  6417. --                   Wed Mar 13 10:00:00 EST 1985
  6418. --
  6419. --                 (Unclassified and uncopyrighted)
  6420. --
  6421. ----------------------------------------------------------------------
  6422.  
  6423. ----------------------------------------------------------------------
  6424. --
  6425. --  Purpose:
  6426. --  -------
  6427. --    To provide a set of functions that exercise and test the
  6428. --    behavior of some of the services available in package
  6429. --    List_Utilities.
  6430. --
  6431. --  Usage:
  6432. --  -----
  6433. --    The functions made available in this package will be used
  6434. --    by a "main procedure" named Listutst.  This procedure acts
  6435. --    as a test driver, calling the different test functions in
  6436. --    sequence.  Output from the tests goes to Standard output
  6437. --    Each function returns a value indicated success/failure of
  6438. --    test (i.e. expected results were/were not equal to actual
  6439. --    results).  The driver procedure keeps track of the overall
  6440. --    success/failure count and prints a test summary at the end.
  6441. --
  6442. --    The test functions have two parameters: 
  6443. --        Verbosity - (Kinds_Of_Output) can have the following values:
  6444. --                  None - No messages are sent to Standard_Output
  6445. --                  Status - the test reports on its success or failure
  6446. --                  Dump   - in addition to reporting on its success
  6447. --                           or failure, the test will print the
  6448. --                           string representation of the list(s)
  6449. --                           at the end of the test
  6450. --        Die_On_Exception : Boolean - if true, an unexpected exception
  6451. --                  will be propogated to the calling procedure,
  6452. --                  otherwise it will be caught (it is still
  6453. --                  treated as a failure, though).
  6454. --
  6455. --  Example:
  6456. --  -------
  6457. --    See the procedure Listutst for all the examples you could
  6458. --    ever want...
  6459. --
  6460. --  Notes:
  6461. --  -----
  6462. --
  6463. --  Revision History:
  6464. --  ----------------
  6465. --    Mar 8  (CCH): Added the Verbosity and Die_On_Exception options.
  6466. --
  6467. -------------------------------------------------------------------
  6468.  
  6469. package List_Utilities_Tests is
  6470.  
  6471.     type Test_Result is (Pass, Fail);
  6472.     type Kinds_Of_Output is (None, Status, Dump);
  6473.  
  6474.  
  6475.     function Test001 (
  6476.     Verbosity        : Kinds_Of_Output := Dump;
  6477.         Die_On_Exception : Boolean := True)
  6478.         return Test_Result;
  6479.  
  6480.     function Test002 (
  6481.     Verbosity        : Kinds_Of_Output := Dump;
  6482.         Die_On_Exception : Boolean := True)
  6483.         return Test_Result;
  6484.  
  6485.     function Test003 (
  6486.     Verbosity        : Kinds_Of_Output := Dump;
  6487.         Die_On_Exception : Boolean := True)
  6488.         return Test_Result;
  6489.  
  6490.     function Test004 (
  6491.     Verbosity        : Kinds_Of_Output := Dump;
  6492.         Die_On_Exception : Boolean := True)
  6493.         return Test_Result;
  6494.  
  6495.     function Test005 (
  6496.     Verbosity        : Kinds_Of_Output := Dump;
  6497.         Die_On_Exception : Boolean := True)
  6498.         return Test_Result;
  6499.  
  6500. end List_Utilities_Tests;
  6501. --::::::::::::::
  6502. --listutst.a
  6503. --::::::::::::::
  6504.  
  6505. ----------------------------------------------------------------------
  6506. --                              Listutst
  6507. --
  6508. --
  6509. --          Test Driver for Tests of Package List_Utilities
  6510. --
  6511. --
  6512. --
  6513. --                  Ada Software Engineering Group
  6514. --                      The MITRE Corporation
  6515. --                         McLean, VA 22102
  6516. --
  6517. --
  6518. --                   Mon Mar 11 10:00:15 EST 1985
  6519. --
  6520. --                 (Unclassified and uncopyrighted)
  6521. --
  6522. ----------------------------------------------------------------------
  6523.  
  6524. ----------------------------------------------------------------------
  6525. --
  6526. --  Purpose:
  6527. --  -------
  6528. --    This is the test driver for the suite of tests in the package
  6529. --    List_Utilities_Tests.  
  6530. --
  6531. --  Usage:
  6532. --  -----
  6533. --
  6534. --  Example:
  6535. --  -------
  6536. --
  6537. --  Notes:
  6538. --  -----
  6539. --    The use of compile-time constants to determine the test 
  6540. --    configuration is LAME; this should be changed to an interactive
  6541. --    mode (that can be run from a command language file) soon.
  6542. --
  6543. --  Revision History:
  6544. --  ----------------
  6545. --
  6546. -------------------------------------------------------------------
  6547.  
  6548. with Text_IO, List_Utilities_Tests;
  6549. use Text_IO, List_Utilities_Tests;
  6550.  
  6551. procedure Listutst is
  6552.  
  6553.  
  6554.     Valid_Response : Boolean := FALSE;
  6555.     Phyl           : File_Type;
  6556.     MAX_FILENAME   : constant Natural := 39;
  6557.     Phyl_Name      : String (1..30);
  6558.     Name_Length    : Natural;
  6559.     type Response is (YES,NO);
  6560.     Redir          : Response;
  6561.  
  6562.     package YesNo is new Enumeration_IO (Response); use YesNo;
  6563.     package Pos_IO is new Integer_IO (Positive);
  6564.     use Pos_IO;
  6565.  
  6566.     -- Edit these for different "test configuration"
  6567.     -- at least until this turkey becomes more interactive (and 
  6568.     -- then these would be the default values...)
  6569.     TEST_OUTPUT        : constant Kinds_Of_Output := Status;
  6570.     ABORT_ON_EXCEPTION : constant Boolean := TRUE;
  6571.     MAX_TESTS          : constant Positive := 5; -- Max # of tests run
  6572.  
  6573.     subtype Test_Count is Natural range 0..MAX_TESTS;
  6574.  
  6575.     Results : array (1..MAX_TESTS) of Test_Result;
  6576.     Error_Count  : Test_Count := 0;
  6577.     Current_Test : Test_Count := 0;
  6578.  
  6579. begin
  6580.  
  6581.     while not Valid_Response loop
  6582.     Put ("Do you want output redirected to a file? (yes or no):");
  6583.     GET_ANSWER:
  6584.     begin
  6585.         Get (Redir);
  6586.         Valid_Response := TRUE;
  6587.     exception
  6588.         when DATA_ERROR =>
  6589.         Put_Line (ASCII.BEL & "PLEASE ENTER EITHER YES OR NO ONLY.");
  6590.     end GET_ANSWER;
  6591.     end loop;
  6592.     Skip_Line (Standard_Input);
  6593.  
  6594.     if Redir = Yes then
  6595.     Put ("Please enter the filename for redirected output:");
  6596.     Get_Line (Phyl_Name, Name_Length);
  6597.     OPEN_FILE:
  6598.     begin
  6599.         Open (Phyl, Out_File, Phyl_Name (1..Name_Length));
  6600.         Delete (Phyl);
  6601.         Create (Phyl, Out_File, Phyl_Name (1..Name_Length));
  6602.     exception
  6603.         when NAME_ERROR =>
  6604.         Create (Phyl, Out_File, Phyl_Name (1..Name_Length));
  6605.     end OPEN_FILE;
  6606.     Set_Output (Phyl);
  6607.     end if;
  6608.  
  6609.     Put_Line ("**** Beginning Execution of List_Utilities_Tests ****");
  6610.     Put ("    TEST_OUTPUT is set to ");
  6611.     Put_Line (Kinds_Of_Output'Image(TEST_OUTPUT));
  6612.     Put ("    ABORT_ON_EXCEPTION is set to ");
  6613.     Put_Line (Boolean'Image(ABORT_ON_EXCEPTION));
  6614.     Put ("    MAX_TESTS is set to ");
  6615.     Put (MAX_TESTS);
  6616.     New_Line(2);
  6617.  
  6618.     Current_Test := 1;
  6619.     Results (Current_Test) := Test001 (
  6620.     Verbosity => TEST_OUTPUT,
  6621.     Die_On_Exception => ABORT_ON_EXCEPTION);
  6622.     if Results (Current_Test) = Fail then
  6623.     Error_Count := Error_Count +1;
  6624.     end if;
  6625.  
  6626.     Current_Test := 2;
  6627.     Results (Current_Test) := Test002 (
  6628.     Verbosity => TEST_OUTPUT,
  6629.     Die_On_Exception => ABORT_ON_EXCEPTION);
  6630.     if Results (Current_Test) = Fail then
  6631.     Error_Count := Error_Count +1;
  6632.     end if;
  6633.  
  6634.     Current_Test := 3;
  6635.     Results (Current_Test) := Test003 (
  6636.     Verbosity => TEST_OUTPUT,
  6637.     Die_On_Exception => ABORT_ON_EXCEPTION);
  6638.     if Results (Current_Test) = Fail then
  6639.     Error_Count := Error_Count +1;
  6640.     end if;
  6641.  
  6642.     Current_Test := 4;
  6643.     Results (Current_Test) := Test004 (
  6644.     Verbosity => TEST_OUTPUT,
  6645.     Die_On_Exception => ABORT_ON_EXCEPTION);
  6646.     if Results (Current_Test) = Fail then
  6647.     Error_Count := Error_Count +1;
  6648.     end if;
  6649.  
  6650.     Current_Test := 5;
  6651.     Results (Current_Test) := Test005 (
  6652.     Verbosity => TEST_OUTPUT,
  6653.     Die_On_Exception => ABORT_ON_EXCEPTION);
  6654.     if Results (Current_Test) = Fail then
  6655.     Error_Count := Error_Count +1;
  6656.     end if;
  6657.  
  6658.     -- Produce Summary
  6659.     New_Line;
  6660.     Put_Line ("**** End of List_Utilities_Tests ****");
  6661.     if Error_Count = 0 then
  6662.         New_Line;
  6663.     Put_Line ("NO TESTS FAILED. HUZZAH!");
  6664.     else
  6665.         New_Line;
  6666.     Put ("A total of ");
  6667.     Put (Error_Count);
  6668.     Put_Line (" Test(s) failed.");
  6669.     Put_Line ("The following test(s) failed:");
  6670.     for I in 1..MAX_TESTS loop
  6671.         if Results (I) = fail then
  6672.         Put ("Test number ");
  6673.         Put (I);
  6674.                 New_Line;
  6675.         end if;
  6676.     end loop;
  6677.     end if;
  6678.  
  6679. end Listutst;
  6680. --::::::::::::::
  6681. --natt_tst_all.a
  6682. --::::::::::::::
  6683. with Cais; use Cais;
  6684. with Text_Io;        use Text_Io;
  6685. Procedure Natt_Tst_All is
  6686.  
  6687. use Node_Management;
  6688. use Node_Definitions;
  6689. use Attributes;
  6690. use List_Utilities;
  6691.  
  6692.     Time_Value_1  : List_Type;
  6693.     Time_Value_2  : List_Type;
  6694.     Verification_1: List_Type;
  6695.     Verification_2: List_Type;
  6696.     Work_List     : List_Type;
  6697.     Open_Node     : Cais.Node_Type;
  6698.     Mike_Node     : Cais.Node_Type;
  6699.  
  6700.  
  6701.     procedure Print_Attributes(Node : Cais.Node_Type;
  6702.                    Text : string) is
  6703.     Name   : Attribute_Name(1..20);
  6704.     Value  : List_Type;
  6705.     Selected : Attribute_Iterator;
  6706.     begin
  6707.     put_line(Text);
  6708.         Node_Attribute_Iterate(Selected, Node);
  6709.     while more(Selected) loop
  6710.         Name := "                    ";
  6711.         Get_Next(Selected, Name, Value);
  6712.         Put("    ");
  6713.         Put(Name);  Put("=> ");  Put(To_Text(Value));
  6714.         new_line;
  6715.     end loop;
  6716.     end Print_Attributes;
  6717.  
  6718.  
  6719.     procedure Print_Value(List1: List_Type;
  6720.         List2: List_Type) is
  6721.     begin
  6722.     if Is_Equal(List1, list2) then
  6723.         put_line("TEST PASSES: FOUND " & To_Text(List2));
  6724.     else
  6725.         put_line("***ERROR***");
  6726.         put_Line("    LIST1 is " & To_Text(List1) );
  6727.         put_Line("    LIST2 is " & To_Text(List2) );
  6728.     end if;
  6729.     end Print_Value;
  6730.  
  6731. begin
  6732.  
  6733.     To_List("(Hour=>12, Minute=>30, Seconds=>49)", Time_Value_1 );
  6734.     To_List("(Hour=>10, Minute=>15, Seconds=>17)", Time_Value_2 );
  6735.     To_List("(true)",  Verification_1 );
  6736.     To_List("(false)", Verification_2 );
  6737.  
  6738.     Open(Open_Node, "'current_node.howell", (1=>write, 2=>read));
  6739.  
  6740. --CREATE(5.1.3.1 AND 2)
  6741.     Create_Node_Attribute(Open_Node, "Time", Time_Value_1);
  6742.     Create_Node_Attribute(Open_Node, "Verified", Verification_1);
  6743.     Create_Node_Attribute("mike", "Time", Time_Value_2);
  6744.     Print_Attributes(Open_Node,"TST_NODE1 EXPECTS: time, verified");
  6745.  
  6746.     Open(Mike_Node, "'current_node.mike", (1=>write, 2=>read));
  6747.     Print_Attributes(Mike_Node,"TST_NODE2 EXPECTS: time");
  6748.         Close(Mike_Node);
  6749.  
  6750. --GET(5.1.3.7 AND 8)
  6751.     Get_Node_Attribute(Open_Node, "Time", Work_List);
  6752.     Print_Value(Work_List, Time_Value_1);
  6753.  
  6754.     Get_Node_Attribute(Open_Node, "Verified", Work_List);
  6755.     Print_Value(Work_List, Verification_1);
  6756.  
  6757.     Get_Node_Attribute("mike", "Time", Work_List);
  6758.     Print_Value(Work_List, Time_Value_2);
  6759.  
  6760. --SET(5.1.3.5 AND 6)
  6761.     Set_Node_Attribute(Open_Node, "Time", Time_Value_2);
  6762.     Set_Node_Attribute(Open_Node, "Verified", Verification_2);
  6763.     Set_Node_Attribute("mike", "Time", Time_Value_2);
  6764.    Print_Attributes(Open_Node,"TST_NODE1 EXPECTS: time=101517, verified=false");
  6765.  
  6766.    Open(Mike_Node, "'current_node.mike", (1=>write, 2=>read));
  6767.    Print_Attributes(Mike_Node,"TST_NODE2 EXPECTS: time=101517");
  6768.    Close(Mike_Node);
  6769.  
  6770. --DELETE(5.1.3.3 AND 4)
  6771.     Delete_Node_Attribute(Open_Node, "Verified");
  6772.     Print_Attributes(Open_Node,"ONLY TIME EXPECTED: ");
  6773.     Delete_Node_Attribute(Open_Node, "Time");
  6774.     Print_Attributes(Open_Node,"NOTHING EXPECTED  : ");
  6775.     Delete_Node_Attribute("mike", "Time");
  6776.     Open(Mike_Node, "'current_node.mike", (1=>write, 2=>read));
  6777.     Print_Attributes(Mike_Node,"NOTHING EXPECTED  : ");
  6778.         Close(Mike_Node);
  6779.  
  6780. end Natt_Tst_All;
  6781. --::::::::::::::
  6782. --natt_tst_it.a
  6783. --::::::::::::::
  6784. with Cais; use Cais;
  6785. with Text_Io;    use Text_Io;
  6786. Procedure Natt_Tst_It is
  6787.  
  6788. use Attributes;
  6789. use List_Utilities;
  6790. use Node_Management;
  6791. use Node_Definitions;
  6792.  
  6793.     Node   : Cais.Node_Type;
  6794.  
  6795.  
  6796.     procedure Test_Setup  is
  6797.     NULL_LIST : LIST_TYPE;
  6798.     begin
  6799.         To_List("()", NULL_LIST);                
  6800.     Create_Node_Attribute(Node,"ammamma",NULL_LIST);        
  6801.     Create_Node_Attribute(Node,"axxaxxa",NULL_LIST);        
  6802.     Create_Node_Attribute(Node,"a      ",NULL_LIST);        
  6803.     Create_Node_Attribute(Node,"m      ",NULL_LIST);        
  6804.     Create_Node_Attribute(Node,"z      ",NULL_LIST);        
  6805.     Create_Node_Attribute(Node,"aaa    ",NULL_LIST);        
  6806.     Create_Node_Attribute(Node,"xxx    ",NULL_LIST);        
  6807.     Create_Node_Attribute(Node,"ax     ",NULL_LIST);        
  6808.     Create_Node_Attribute(Node,"xx     ",NULL_LIST);        
  6809.     Create_Node_Attribute(Node,"xz     ",NULL_LIST);        
  6810.     Create_Node_Attribute(Node,"axz    ",NULL_LIST);        
  6811.     Create_Node_Attribute(Node,"amz    ",NULL_LIST);        
  6812.     Create_Node_Attribute(Node,"xmx    ",NULL_LIST);        
  6813.     Create_Node_Attribute(Node,"xmxz   ",NULL_LIST);        
  6814.     Create_Node_Attribute(Node,"xmxm   ",NULL_LIST);        
  6815.     Create_Node_Attribute(Node,"axxz   ",NULL_LIST);        
  6816.     Create_Node_Attribute(Node,"am     ",NULL_LIST);        
  6817.     Create_Node_Attribute(Node,"az     ",NULL_LIST);        
  6818.     Create_Node_Attribute(Node,"aazz   ",NULL_LIST);        
  6819.     Create_Node_Attribute(Node,"aaxx   ",NULL_LIST);        
  6820.     Create_Node_Attribute(Node,"xxzz   ",NULL_LIST);        
  6821.     Create_Node_Attribute(Node,"aa     ",NULL_LIST);        
  6822.     Create_Node_Attribute(Node,"aaaa   ",NULL_LIST);        
  6823.     Create_Node_Attribute(Node,"axa    ",NULL_LIST);        
  6824.     Create_Node_Attribute(Node,"axxa   ",NULL_LIST);        
  6825.     Create_Node_Attribute(Node,"axaxa  ",NULL_LIST);        
  6826.     end Test_Setup;
  6827.  
  6828.  
  6829.     procedure Print_Iterator(Selector: Attribute_Pattern;
  6830.                  Amount : integer) is
  6831.     Name   : Attribute_Name(1..15);
  6832.     Value  : List_Type;
  6833.     II     : integer range 0..400 := 0;
  6834.     Selected : Attribute_Iterator;
  6835.     begin
  6836.         Put(Selector & " EXPECTS: " & integer'image(Amount) );
  6837.         Node_Attribute_Iterate(Selected, Node, Selector);
  6838.     while More(Selected) loop
  6839.         Name := (others => ' ');
  6840.         Get_Next(Selected, Name, Value);
  6841.         if II mod 3 = 0 then
  6842.         New_Line;
  6843.         Put("    ");
  6844.         end if;
  6845.         Put(Name); Put( "=>" & To_Text(Value));
  6846.         II := II+1;
  6847.     end loop;
  6848.     New_Line;
  6849.     Put_Line(Selector & "***FINDS: " & integer'image(II) & "********");
  6850.     end Print_Iterator;
  6851.  
  6852. begin
  6853.     put_line("The total set consists of :");
  6854.     put_line("  a         aa        aaa       aaaa      aaxx      aazz    ");
  6855.     put_line("  am        ammamma   amz       ax        axa       axaxa   ");
  6856.     put_line("  axz       axxa      axxaxxa   axxz                az      ");
  6857.     put_line("  m         xmx       xmxm      xmxz      xx        xxx     ");
  6858.     put_line("  xxzz      xz        z         ");
  6859.  
  6860.     Open(Node, "'current_node", (1=>read,
  6861.                2=>write));
  6862.     Test_Setup;
  6863.     Put_Line("**********************************************************");
  6864.     Put_Line("**NOTE: expected results do not account for meaningful  **");
  6865.     Put_Line("**      attributes already associated with the node.  If**");
  6866.     Put_Line("**      they occur, just check that they conform to the **");
  6867.     Put_Line("**      pattern submitted.                              **");
  6868.     Put_Line("**********************************************************");
  6869.  
  6870.  
  6871.     Print_Iterator("????????", 0);
  6872.     Print_Iterator("???", 6);
  6873.     Print_Iterator("?", 3);
  6874.     Print_Iterator("?z", 2);
  6875.     Print_Iterator("?m?", 2);
  6876.     Print_Iterator("?m?z", 1);
  6877.     Print_Iterator("?m?j", 0);
  6878.     Print_Iterator("a?z", 2);
  6879.     Print_Iterator("a??z", 2);
  6880.     Print_Iterator("a?", 4);
  6881.     Print_Iterator("*", 26);
  6882.     Print_Iterator("***", 26);
  6883.     Print_Iterator("a*", 17);
  6884.     Print_Iterator("aa*", 5);
  6885.     Print_Iterator("a*a*a", 5);
  6886.     Print_Iterator("*z", 9);
  6887.     Print_Iterator("*zz", 2);
  6888.     Print_Iterator("*x*", 15);
  6889.     Print_Iterator("*xx*", 7);
  6890.     Print_Iterator("*m*", 7);
  6891.     Print_Iterator("a*a", 8);
  6892.     Print_Iterator("*m??", 3);
  6893.     Print_Iterator("a??*", 12);
  6894.     Print_Iterator("*?*?*", 23);
  6895.     Print_Iterator("amz", 1);
  6896.     Print_Iterator("a", 1);
  6897.     Print_Iterator("z", 1);
  6898. end Natt_Tst_It;
  6899. --::::::::::::::
  6900. --new_user.a
  6901. --::::::::::::::
  6902. with Cais; use Cais;
  6903. procedure New_User is
  6904. begin
  6905.     Add_User;
  6906. end New_User;
  6907. --::::::::::::::
  6908. --node_management_tests-body.a
  6909. --::::::::::::::
  6910. ----------------------------------------------------------------------
  6911. --                N O D E _ M A N A G E M E N T _ T E S T S
  6912. --                           (Package Body)
  6913. --
  6914. --
  6915. --             A Set of Simple Test Subprograms To Exercise 
  6916. --                      Portions of Node_Management
  6917. --
  6918. --
  6919. --
  6920. --
  6921. --                  Ada Software Engineering Group
  6922. --                      The MITRE Corporation
  6923. --                         McLean, VA 22102
  6924. --
  6925. --
  6926. --                  Fri Feb 21 14:47:34 EST 1986
  6927. --
  6928. --                 (Unclassified and uncopyrighted)
  6929. --
  6930. ----------------------------------------------------------------------
  6931.  
  6932. ----------------------------------------------------------------------
  6933. --
  6934. --  Purpose:
  6935. --  -------
  6936. --    To provide a set of functions that exercise and test the
  6937. --    behavior of some of the services available in package
  6938. --    Node_Management.
  6939. --
  6940. --  Usage:
  6941. --  -----
  6942. --    The functions made available in this package will be used
  6943. --    by a "main procedure" named Node_Mgmt.  This procedure acts
  6944. --    as a test driver, calling the different test functions in
  6945. --    sequence.  Output from the tests can be redirected to a file,
  6946. --    or sent to Standard_Output.
  6947. --    Each function returns a value indicated success/failure of
  6948. --    test (i.e. expected results were/were not equal to actual
  6949. --    results).  The driver procedure keeps track of the overall
  6950. --    success/failure count and prints a test summary at the end.
  6951. --
  6952. --    The test functions have two parameters: 
  6953. --        Verbosity - (Kinds_Of_Output) can have the following values:
  6954. --                  None - No messages are sent to Standard_Output
  6955. --                  Status - the test reports on its success or failure
  6956. --        Die_On_Exception : Boolean - if FALSE, an unexpected exception
  6957. --                  will be propogated to the calling procedure,
  6958. --                  otherwise it will be caught (it is still
  6959. --                  treated as a failure, though).
  6960. --
  6961. --  Example:
  6962. --  -------
  6963. --    See the procedure Node_Mgmt for all the examples you could
  6964. --    ever want...
  6965. --
  6966. --  Notes:
  6967. --  -----
  6968. --    None.
  6969. --
  6970. --  Revision History:
  6971. --  ----------------
  6972. --
  6973. -------------------------------------------------------------------
  6974. with Text_IO; use Text_IO;
  6975. with Cais; use Cais;
  6976.  
  6977. package body Node_Management_Tests is
  6978. use Node_Definitions;
  6979. use Node_Management;
  6980. use Structural_Nodes;
  6981.  
  6982. ---------------------  R E P O R T _ S T A T U S --------------------
  6983. --
  6984. --  Purpose:
  6985. --  -------
  6986. --    To print a descriptive test result message to Std. Output,
  6987. --    governed by the level of output desired for the test.
  6988. --
  6989. --  Parameters:
  6990. --  ----------
  6991. --    Verbosity        The message will be printed unless this is
  6992. --            set to NONE.
  6993. --    Msg        The string representing the message to be printed.
  6994. --
  6995. --  Exceptions:
  6996. --  ----------
  6997. --    None.
  6998. --
  6999. --  Notes:
  7000. --  -----
  7001. --    None.
  7002. --
  7003. ---------------------------------------------------------------------
  7004.  
  7005.     procedure Report_Status (
  7006.         Verbosity  : Kinds_Of_Output;
  7007.         Msg        : String) is
  7008.  
  7009.     begin
  7010.  
  7011.         if Verbosity = NONE then 
  7012.             return; -- do nothing
  7013.         else
  7014.             Put_Line (Msg);
  7015.         end if;
  7016.  
  7017.     end Report_Status;
  7018.  
  7019. ----------------------      T E S T 0 0 1      ----------------------
  7020. --
  7021. --  Purpose:
  7022. --  -------
  7023. --    Test that NAME_ERROR is raised with a syntax error in the pathname
  7024. --    for Node_Management.Open.
  7025. --
  7026. --  Parameters:
  7027. --  ----------
  7028. --    Verbosity        Specifies the level of output desired. Options:
  7029. --            NONE:   No output from this test
  7030. --            STATUS: Report on success or failure of specific
  7031. --                tests
  7032. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  7033. --               If FALSE, the exception will be handled and the
  7034. --               test will return a value of FAIL.
  7035. --    return Test_Result   Simply indicates pass/FAIL of the test.
  7036. --
  7037. --  Exceptions:
  7038. --  ----------
  7039. --    None.
  7040. --
  7041. --  Notes:
  7042. --  -----
  7043. --    None.
  7044. --
  7045. ---------------------------------------------------------------------
  7046.  
  7047.     function Test001 (
  7048.         Verbosity        : Kinds_Of_Output := STATUS;
  7049.         Die_On_Exception : Boolean := FALSE)
  7050.         return Test_Result is
  7051.  
  7052.         Result      : Test_Result := FAIL;   
  7053.     Node        : Node_Definitions.Node_Type;
  7054.     begin
  7055.     Node_Management.Open (Node, "wazoo??");
  7056.         return Result;
  7057.     exception
  7058.  
  7059.         when Node_Definitions.NAME_ERROR =>
  7060.             Report_Status (Verbosity,
  7061.                 "Test 001: Bad Pathname raised " & 
  7062.             " NAME_ERROR correctly");
  7063.         return PASS;
  7064.         when OTHERS =>
  7065.             Report_Status (Verbosity,
  7066.                 "**** Test 001: UNHANDLED EXCEPTION");
  7067.             if Die_On_Exception then
  7068.                 raise;
  7069.             else
  7070.                 return FAIL;
  7071.             end if;
  7072.     end Test001;
  7073.  
  7074. ----------------------      T E S T 0 0 2      ----------------------
  7075. --
  7076. --  Purpose:
  7077. --  -------
  7078. --    Test if Open called with an Open node handle will raise STATUS_ERROR
  7079. --
  7080. --  Parameters:
  7081. --  ----------
  7082. --    Verbosity        Specifies the level of output desired. Options:
  7083. --            NONE:   No output from this test
  7084. --            STATUS: Report on success or failure of specific
  7085. --                tests
  7086. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  7087. --               If FALSE, the exception will be handled and the
  7088. --               test will return a value of FAIL.
  7089. --    return Test_Result   Simply indicates pass/FAIL of the test.
  7090. --
  7091. --  Exceptions:
  7092. --  ----------
  7093. --    None.
  7094. --
  7095. --  Notes:
  7096. --  -----
  7097. --    None.
  7098. --
  7099. ---------------------------------------------------------------------
  7100.  
  7101.     function Test002 (
  7102.         Verbosity        : Kinds_Of_Output := STATUS;
  7103.         Die_On_Exception : Boolean := FALSE)
  7104.         return Test_Result is
  7105.  
  7106.         Result      : Test_Result := FAIL;   
  7107.     Node        : Node_Definitions.Node_Type;
  7108.     begin
  7109.     Node_Management.Open (Node, "'Parent");
  7110.     Node_Management.Open (Node, CURRENT_NODE);
  7111.     
  7112.     exception
  7113.         when Node_Definitions.STATUS_ERROR =>
  7114.             Report_Status (Verbosity,
  7115.                 "Test 002: Node_Management.Open with Open node " & 
  7116.             "handle raised STATUS_ERROR correctly");
  7117.         return PASS;
  7118.         when OTHERS =>
  7119.             Report_Status (Verbosity,
  7120.                 "**** Test 002: UNHANDLED EXCEPTION");
  7121.             if Die_On_Exception then
  7122.                 raise;
  7123.             else
  7124.                 return (FAIL);
  7125.             end if;
  7126.     end Test002;
  7127.  
  7128. ----------------------      T E S T 0 0 3      ----------------------
  7129. --
  7130. --  Purpose:
  7131. --  -------
  7132. --    This is a simple test of Is_Same.  Two nodes to the same pathname
  7133. --    are Node_Management.Opened; they should be the same.
  7134. --
  7135. --  Parameters:
  7136. --  ----------
  7137. --    Verbosity        Specifies the level of output desired. Options:
  7138. --            NONE:   No output from this test
  7139. --            STATUS: Report on success or failure of specific
  7140. --                tests
  7141. --            NONE:   Same as STATUS, with the additional 
  7142. --                output of the string representation of
  7143. --                the list_type(s) used.
  7144. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  7145. --               If FALSE, the exception will be handled and the
  7146. --               test will return a value of FAIL.
  7147. --    return Test_Result   Simply indicates pass/FAIL of the test.
  7148. --
  7149. --  Exceptions:
  7150. --  ----------
  7151. --    None.
  7152. --
  7153. --  Notes:
  7154. --  -----
  7155. --    None.
  7156. --
  7157. ---------------------------------------------------------------------
  7158.  
  7159.     function Test003 (
  7160.         Verbosity        : Kinds_Of_Output := STATUS;
  7161.         Die_On_Exception : Boolean := FALSE)
  7162.         return Test_Result is
  7163.  
  7164.     Result : Test_Result := PASS;
  7165.     Node1, Node2, Node3  : Node_Definitions.Node_Type;
  7166.     begin
  7167.     Node_Management.Open (Node1, CURRENT_NODE);
  7168.     Node_Management.Open (Node2, CURRENT_NODE);
  7169.     if not Is_Same (Node1, Node2) then
  7170.         Report_Status (Verbosity, "Test 003 Is_Equal is FALSE for" &
  7171.         " equal nodes");
  7172.         Result := FAIL;
  7173.     end if;
  7174.  
  7175.     Node_Management.Open (Node3, "'Current_Job");
  7176.     if Is_Same (Node1, Node3) then
  7177.         Report_Status (Verbosity, "Test 003 Is_Equal is TRUE for" &
  7178.         " nodes not equal");
  7179.         Result := FAIL;
  7180.     end if;
  7181.     if Result = PASS then
  7182.         Report_Status (Verbosity, "Test 003 Is_Equal is OK");
  7183.     end if;
  7184.         return Result;
  7185.     exception
  7186.         when OTHERS =>
  7187.             Report_Status (Verbosity,
  7188.                 "**** Test 003: UNHANDLED EXCEPTION");
  7189.             if Die_On_Exception then
  7190.                 raise;
  7191.             else
  7192.                 return (FAIL);
  7193.             end if;
  7194.     end Test003;
  7195.  
  7196. ----------------------      T E S T 0 0 4      ----------------------
  7197. --
  7198. --  Purpose:
  7199. --  -------
  7200. --    To test that Node_Management.Open with a pathname and Node_Management.Open with a base node handle
  7201. --    return a node handle to the same node when the base, rel name,
  7202. --    and rel key are equivalent to the pathname.
  7203. --
  7204. --  Parameters:
  7205. --  ----------
  7206. --    Verbosity        Specifies the level of output desired. Options:
  7207. --            NONE:   No output from this test
  7208. --            STATUS: Report on success or failure of specific
  7209. --                tests
  7210. --            NONE:   Same as STATUS, with the additional 
  7211. --                output of the string representation of
  7212. --                the list_type(s) used.
  7213. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  7214. --               If FALSE, the exception will be handled and the
  7215. --               test will return a value of FAIL.
  7216. --    return Test_Result   Simply indicates pass/FAIL of the test.
  7217. --
  7218. --  Exceptions:
  7219. --  ----------
  7220. --    None.
  7221. --
  7222. --  Notes:
  7223. --  -----
  7224. --
  7225. ---------------------------------------------------------------------
  7226.  
  7227.     function Test004 (
  7228.         Verbosity        : Kinds_Of_Output := STATUS;
  7229.         Die_On_Exception : Boolean := FALSE)
  7230.         return Test_Result is
  7231.  
  7232.     Node1, Node2, Base  : Node_Definitions.Node_Type;
  7233.     begin
  7234.     Node_Management.Open (Node1, "'Current_Node");
  7235.     Node_Management.Open (Base, "'Current_Node'Job");
  7236.     Node_Management.Open (Node2, Base => Base, Key => "", 
  7237.         Relation => "Parent");
  7238.     if Is_Same (Node1, Node2) then
  7239.         Report_Status (Verbosity, "Test 004: Different Node_Management.Open" &
  7240.         " interfaces are equivalant.");
  7241.         return PASS;
  7242.     end if;
  7243.     return FAIL;
  7244.     exception
  7245.         when OTHERS =>
  7246.             Report_Status (Verbosity,
  7247.                 "**** Test 004: UNHANDLED EXCEPTION");
  7248.             if Die_On_Exception then
  7249.                 raise;
  7250.             else
  7251.                 return (FAIL);
  7252.             end if;
  7253.     end Test004;
  7254.  
  7255. ----------------------      T E S T 0 0 5      ----------------------
  7256. --
  7257. --  Purpose:
  7258. --  -------
  7259. --    To test the behavior of Node_Management.Close on a Node_Management.Closed node handle and
  7260. --    a node handle that was never Node_Management.Opened.
  7261. --
  7262. --  Parameters:
  7263. --  ----------
  7264. --    Verbosity        Specifies the level of output desired. Options:
  7265. --            NONE:   No output from this test
  7266. --            STATUS: Report on success or failure of specific
  7267. --                tests
  7268. --            NONE:   Same as STATUS, with the additional 
  7269. --                output of the string representation of
  7270. --                the list_type(s) used.
  7271. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  7272. --               If FALSE, the exception will be handled and the
  7273. --               test will return a value of FAIL.
  7274. --    return Test_Result   Simply indicates pass/FAIL of the test.
  7275. --
  7276. --  Exceptions:
  7277. --  ----------
  7278. --    None.
  7279. --
  7280. --  Notes:
  7281. --  -----
  7282. --    None.
  7283. --
  7284. ---------------------------------------------------------------------
  7285.  
  7286.     function Test005 (
  7287.         Verbosity        : Kinds_Of_Output := STATUS;
  7288.         Die_On_Exception : Boolean := FALSE)
  7289.         return Test_Result is
  7290.  
  7291.     Node1, Node2 : Node_Definitions.Node_Type;
  7292.         Result      : Test_Result := PASS;   
  7293.     begin
  7294.     Node_Management.Close (Node1);
  7295.     Node_Management.Open (Node1, "'parent");
  7296.     Node_Management.Close (Node1);
  7297.     Node_Management.Close (Node1);
  7298.     -- if we get here, everything went as expected...
  7299.     Report_Status (Verbosity,
  7300.         "Test 005: Node_Management.Close worked as advertised.");
  7301.     return PASS;
  7302.     exception
  7303.         when OTHERS =>
  7304.             Report_Status (Verbosity,
  7305.                 "**** Test 005: UNHANDLED EXCEPTION");
  7306.             if Die_On_Exception then
  7307.                 raise;
  7308.             else
  7309.                 return (FAIL);
  7310.             end if;
  7311.     end Test005;
  7312.  
  7313.  
  7314. ----------------------      T E S T 0 0 6      ----------------------
  7315. --
  7316. --  Purpose:
  7317. --  -------
  7318. --    Exercise the Link and Unlink services.  First, 
  7319. --    attempt an Node_Management.Open for a relationship that does not exist (after
  7320. --    an Unlink to ensure that the relationship does not exist).
  7321. --    Try to create a link with a predefined relation name.
  7322. --    Then create a link, and try the Node_Management.Open again.  Remove the link.
  7323. --    Try to unlink a nonexistant relationship; try to unlink a
  7324. --    primary relationship.
  7325. --
  7326. --  Parameters:
  7327. --  ----------
  7328. --    Verbosity        Specifies the level of output desired. Options:
  7329. --            NONE:   No output from this test
  7330. --            STATUS: Report on success or failure of specific
  7331. --                tests
  7332. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  7333. --               If FALSE, the exception will be handled and the
  7334. --               test will return a value of FAIL.
  7335. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  7336. --
  7337. --  Exceptions:
  7338. --  ----------
  7339. --    None.
  7340. --
  7341. --  Notes:
  7342. --  -----
  7343. --    None.
  7344. --
  7345. ---------------------------------------------------------------------
  7346.  
  7347.     function Test006 (
  7348.         Verbosity        : Kinds_Of_Output := STATUS;
  7349.         Die_On_Exception : Boolean := FALSE)
  7350.         return Test_Result is
  7351.  
  7352.     Base_Node, Target_Node  : Node_Definitions.Node_Type;
  7353.     begin
  7354.  
  7355.     Block1: -- use Unlink to ensure this link doesn't exist
  7356.     begin
  7357.         Unlink ("'Current_Node'Test_Relation(Test_Key)");
  7358.     exception
  7359.         when Node_Definitions.Name_Error => 
  7360.         null;
  7361.         when others =>
  7362.         Report_Status (Verbosity,
  7363.             "**** Test 006: Block1 failed");
  7364.         if Die_On_Exception then
  7365.             raise;
  7366.         else
  7367.             return (FAIL);
  7368.         end if;
  7369.     end Block1;
  7370.  
  7371.     Block2: -- try an Node_Management.Open with nonexistant link
  7372.     begin
  7373.         Node_Management.Open (Base_Node, 
  7374.         "'Current_Node'Test_Relation(Test_Key)");
  7375.         -- ?huh? We shouldn't be here!
  7376.         Report_Status (Verbosity,
  7377.         "**** Test 006: Block2 Node_Management.Open did NOT Fail");
  7378.         return Fail;
  7379.     exception
  7380.         when Node_Definitions.Name_Error => 
  7381.         null;
  7382.         when others =>
  7383.         Report_Status (Verbosity,
  7384.             "**** Test 006: Block2 failed");
  7385.         if Die_On_Exception then
  7386.             raise;
  7387.         else
  7388.             return (FAIL);
  7389.         end if;
  7390.     end Block2;
  7391.     Node_Management.Close (Base_Node);
  7392.  
  7393.  
  7394.     Block3: -- Node_Management.Open target node, create link to it
  7395.     begin
  7396.         Node_Management.Open (Target_Node, "'Current_Node'Job");
  7397.         Link (Target_Node, "'Current_Node'Test_Relation(Test_Key)");
  7398.     exception
  7399.         when others =>
  7400.         Report_Status (Verbosity,
  7401.             "**** Test 006: Block3 failed");
  7402.         if Die_On_Exception then
  7403.             raise;
  7404.         else
  7405.             return (FAIL);
  7406.         end if;
  7407.     end Block3;
  7408.     
  7409.     Block4: -- try the Node_Management.Open again
  7410.     begin
  7411.         Node_Management.Open (Base_Node, "'Current_Node'Test_Relation(Test_Key)");
  7412.     exception
  7413.         when others =>
  7414.         Report_Status (Verbosity,
  7415.             "**** Test 006: Block4 failed");
  7416.         if Die_On_Exception then
  7417.             raise;
  7418.         else
  7419.             return (FAIL);
  7420.         end if;
  7421.     end Block4;
  7422.  
  7423.     Block5: -- Try Unlink again
  7424.     begin
  7425.         Unlink ("'Current_Node'Test_Relation(Test_Key)");
  7426.     exception
  7427.         when others =>
  7428.         Report_Status (Verbosity,
  7429.             "**** Test 006: Block5 failed");
  7430.         if Die_On_Exception then
  7431.             raise;
  7432.         else
  7433.             return (FAIL);
  7434.         end if;
  7435.     end Block5;
  7436.  
  7437.     Block6: -- Try Unlink with Predefined primary relation
  7438.     begin
  7439.         Unlink ("'Current_Node'Job");
  7440.         -- ?huh? We shouldn't be here!
  7441.         Report_Status (Verbosity,
  7442.         "**** Test 006: Block6 Unlink did NOT Fail");
  7443.         return Fail;
  7444.     exception
  7445.         when Node_Definitions.Use_Error =>
  7446.         null;
  7447.         when others =>
  7448.         Report_Status (Verbosity,
  7449.             "**** Test 006: Block6 failed");
  7450.         if Die_On_Exception then
  7451.             raise;
  7452.         else
  7453.             return (FAIL);
  7454.         end if;
  7455.     end Block6;
  7456.  
  7457.     Block7: -- Try Unlink with nonexistant relation
  7458.     begin
  7459.         Node_Management.Close (Base_Node);
  7460.         Node_Management.Open (Base_Node, "'Current_Node",
  7461.         Intent => (1 => Exclusive_Write, 2=> Read_Relationships));
  7462.         Unlink (Base_Node, Key => "Bogus", Relation => "swill");
  7463.         -- ?huh? We shouldn't be here!
  7464.         Report_Status (Verbosity,
  7465.         "**** Test 006: Block7 Unlink did NOT Fail");
  7466.         return Fail;
  7467.     exception
  7468.         when Node_Definitions.Name_Error =>
  7469.         null;
  7470.         when others =>
  7471.         Report_Status (Verbosity,
  7472.             "**** Test 006: Block7 failed");
  7473.         if Die_On_Exception then
  7474.             raise;
  7475.         else
  7476.             return (FAIL);
  7477.         end if;
  7478.     end Block7;
  7479.  
  7480.     -- If we finally get here, the test was passed!
  7481.     return Pass;
  7482.  
  7483.     exception
  7484.  
  7485.         when others =>
  7486.             Report_Status (Verbosity,
  7487.                 "**** Test 006: UNHANDLED EXCEPTION");
  7488.  
  7489.             if Die_On_Exception then
  7490.                 raise;
  7491.             else
  7492.                 return (FAIL);
  7493.             end if;
  7494.     end Test006;
  7495.  
  7496.  
  7497. ----------------------      T E S T 0 0 7      ----------------------
  7498. --
  7499. --  Purpose:
  7500. --  -------
  7501. --    This test exercises a variety of Node_Management services and
  7502. --    their interactions.  The node 'Current_Node'Test_Rel(Test_Key)
  7503. --    is deleted (in case it existed prior to the running of this
  7504. --    test), then created.  Is_Obtainable should then return True for
  7505. --    that node.  The node handle is Closed, then Opened for existence
  7506. --    intent only.  Is_Obtainable should still return True.  The
  7507. --    node is again Closed, and Opened for Write intent.  An attempt
  7508. --    to delete the node should then raise an Intent_Violation.
  7509. --    Finally, the node is Opened with Exclusive_Write and Read intents,
  7510. --    and deleted.  An Open with Existence Intent should still be ok,
  7511. --    and Is_Obtainable should now return False.
  7512. --
  7513. --  Parameters:
  7514. --  ----------
  7515. --    Verbosity        Specifies the level of output desired. Options:
  7516. --            NONE:   No output from this test
  7517. --            STATUS: Report on success or failure of specific
  7518. --                tests
  7519. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  7520. --               If FALSE, the exception will be handled and the
  7521. --               test will return a value of FAIL.
  7522. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  7523. --
  7524. --  Exceptions:
  7525. --  ----------
  7526. --    None.
  7527. --
  7528. --  Notes:
  7529. --  -----
  7530. --    This test uses Structural_Nodes.Create.
  7531. --
  7532. ---------------------------------------------------------------------
  7533.  
  7534.     function Test007 (
  7535.         Verbosity        : Kinds_Of_Output := STATUS;
  7536.         Die_On_Exception : Boolean := FALSE)
  7537.         return Test_Result is
  7538.  
  7539.         Result      : Test_Result := FAIL;   
  7540.     Node        : Node_Definitions.Node_Type;
  7541.  
  7542.     begin
  7543.  
  7544.     Block1:  -- delete the node (just in case it exists)
  7545.     begin
  7546.         Node_Management.Open (Node, "'Current_Node'Test_Rel(Test_Key)",
  7547.         Intent => (1 => Exclusive_Write, 2 => Read));
  7548.         Delete_Node (Node);
  7549.     exception
  7550.         when Node_Definitions.Name_Error => null;
  7551.         when others =>
  7552.         Report_Status (Verbosity,
  7553.             "**** Test 007: Block1 failed");
  7554.         if Die_On_Exception then
  7555.             raise;
  7556.         else
  7557.             return (FAIL);
  7558.         end if;
  7559.     end Block1;
  7560.     Node_Management.Close (Node);
  7561.  
  7562.     Block2: -- now create the test node
  7563.     begin
  7564.         Structural_Nodes.Create_Node 
  7565.         ("'Current_User'Test_Rel(Test_Key)");
  7566.     exception
  7567.         when others =>
  7568.         Report_Status (Verbosity,
  7569.             "**** Test 007: Block2 failed");
  7570.         if Die_On_Exception then
  7571.             raise;
  7572.         else
  7573.             return (FAIL);
  7574.         end if;
  7575.     end Block2;
  7576.  
  7577.     Block3: -- Node_Management.Open it for Existence
  7578.     begin
  7579.         Node_Management.Open (Node, "'Current_User'Test_Rel(Test_Key)",
  7580.         Intent => (1 => Existence));
  7581.         if not Is_Obtainable (Node) then
  7582.         Report_Status (Verbosity,
  7583.             "Test 007: Block3 Is_Obtainable failed");
  7584.         return (Fail);
  7585.         end if;
  7586.  
  7587.     exception
  7588.         when others =>
  7589.         Report_Status (Verbosity,
  7590.             "**** Test 007: Block3 failed");
  7591.         if Die_On_Exception then
  7592.             raise;
  7593.         else
  7594.             return (FAIL);
  7595.         end if;
  7596.     end Block3;
  7597.     Node_Management.Close (Node);
  7598.  
  7599.     Block4: -- Node_Management.Open without Intents required for Node_Delete
  7600.     begin
  7601.         Node_Management.Open (Node, "'Current_User'Test_Rel(Test_Key)",
  7602.         Intent => (1 =>Read));
  7603.         Delete_Node (Node);
  7604.     exception
  7605.         when Intent_Violation => null;
  7606.         when others =>
  7607.         Report_Status (Verbosity,
  7608.             "**** Test 007: Block4 failed");
  7609.         if Die_On_Exception then
  7610.             raise;
  7611.         else
  7612.             return (FAIL);
  7613.         end if;
  7614.     end Block4;
  7615.     Node_Management.Close (Node);
  7616.  
  7617.     Block5: -- Node_Management.Open with Intents required for Node_Delete
  7618.     begin
  7619.         Node_Management.Open (Node, "'Current_User'Test_Rel(Test_Key)",
  7620.         Intent => (1 => Exclusive_Write, 2 => Read));
  7621.         Delete_Node (Node);
  7622.     exception
  7623.         when others =>
  7624.         Report_Status (Verbosity,
  7625.             "**** Test 007: Block5 failed");
  7626.         if Die_On_Exception then
  7627.             raise;
  7628.         else
  7629.             return (FAIL);
  7630.         end if;
  7631.     end Block5;
  7632.     Node_Management.Close (Node);
  7633.  
  7634.  
  7635.     -- if we get here, everything was copasetic...
  7636.     return Pass;
  7637.     exception
  7638.  
  7639.         when others =>
  7640.             Report_Status (Verbosity,
  7641.                 "**** Test 007: UNHANDLED EXCEPTION");
  7642.  
  7643.             if Die_On_Exception then
  7644.                 raise;
  7645.             else
  7646.                 return (FAIL);
  7647.             end if;
  7648.     end Test007;
  7649.  
  7650. ----------------------      T E S T 0 0 8      ----------------------
  7651. --
  7652. --  Purpose:
  7653. --  -------
  7654. --
  7655. --  Parameters:
  7656. --  ----------
  7657. --    Verbosity        Specifies the level of output desired. Options:
  7658. --            NONE:   No output from this test
  7659. --            STATUS: Report on success or failure of specific
  7660. --                tests
  7661. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  7662. --               If FALSE, the exception will be handled and the
  7663. --               test will return a value of FAIL.
  7664. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  7665. --
  7666. --  Exceptions:
  7667. --  ----------
  7668. --    None.
  7669. --
  7670. --  Notes:
  7671. --  -----
  7672. --    None.
  7673. --
  7674. ---------------------------------------------------------------------
  7675.  
  7676.     function Test008 (
  7677.         Verbosity        : Kinds_Of_Output := STATUS;
  7678.         Die_On_Exception : Boolean := FALSE)
  7679.         return Test_Result is
  7680.  
  7681.         Result      : Test_Result := FAIL;   
  7682.  
  7683.     begin
  7684.  
  7685.         return Result;
  7686.  
  7687.     exception
  7688.  
  7689.         when others =>
  7690.             Report_Status (Verbosity,
  7691.                 "**** Test 008: UNHANDLED EXCEPTION");
  7692.  
  7693.             if Die_On_Exception then
  7694.                 raise;
  7695.             else
  7696.                 return (FAIL);
  7697.             end if;
  7698.     end Test008;
  7699.  
  7700. ----------------------      T E S T 0 0 9      ----------------------
  7701. --
  7702. --  Purpose:
  7703. --  -------
  7704. --
  7705. --  Parameters:
  7706. --  ----------
  7707. --    Verbosity        Specifies the level of output desired. Options:
  7708. --            NONE:   No output from this test
  7709. --            STATUS: Report on success or failure of specific
  7710. --                tests
  7711. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  7712. --               If FALSE, the exception will be handled and the
  7713. --               test will return a value of FAIL.
  7714. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  7715. --
  7716. --  Exceptions:
  7717. --  ----------
  7718. --    None.
  7719. --
  7720. --  Notes:
  7721. --  -----
  7722. --    None.
  7723. --
  7724. ---------------------------------------------------------------------
  7725.  
  7726.     function Test009 (
  7727.         Verbosity        : Kinds_Of_Output := STATUS;
  7728.         Die_On_Exception : Boolean := FALSE)
  7729.         return Test_Result is
  7730.  
  7731.         Result      : Test_Result := FAIL;   
  7732.  
  7733.     begin
  7734.  
  7735.         return Result;
  7736.  
  7737.     exception
  7738.  
  7739.         when others =>
  7740.             Report_Status (Verbosity,
  7741.                 "**** Test 009: UNHANDLED EXCEPTION");
  7742.  
  7743.             if Die_On_Exception then
  7744.                 raise;
  7745.             else
  7746.                 return (FAIL);
  7747.             end if;
  7748.     end Test009;
  7749.  
  7750. ----------------------      T E S T 0 1 0      ----------------------
  7751. --
  7752. --  Purpose:
  7753. --  -------
  7754. --
  7755. --  Parameters:
  7756. --  ----------
  7757. --    Verbosity        Specifies the level of output desired. Options:
  7758. --            NONE:   No output from this test
  7759. --            STATUS: Report on success or failure of specific
  7760. --                tests
  7761. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  7762. --               If FALSE, the exception will be handled and the
  7763. --               test will return a value of FAIL.
  7764. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  7765. --
  7766. --  Exceptions:
  7767. --  ----------
  7768. --    None.
  7769. --
  7770. --  Notes:
  7771. --  -----
  7772. --    None.
  7773. --
  7774. ---------------------------------------------------------------------
  7775.  
  7776.     function Test010 (
  7777.         Verbosity        : Kinds_Of_Output := STATUS;
  7778.         Die_On_Exception : Boolean := FALSE)
  7779.         return Test_Result is
  7780.  
  7781.         Result      : Test_Result := FAIL;   
  7782.  
  7783.     begin
  7784.  
  7785.         return Result;
  7786.  
  7787.     exception
  7788.  
  7789.         when others =>
  7790.             Report_Status (Verbosity,
  7791.                 "**** Test 010: UNHANDLED EXCEPTION");
  7792.  
  7793.             if Die_On_Exception then
  7794.                 raise;
  7795.             else
  7796.                 return (FAIL);
  7797.             end if;
  7798.     end Test010;
  7799.  
  7800. ----------------------      T E S T 0 1 1      ----------------------
  7801. --
  7802. --  Purpose:
  7803. --  -------
  7804. --
  7805. --  Parameters:
  7806. --  ----------
  7807. --    Verbosity        Specifies the level of output desired. Options:
  7808. --            NONE:   No output from this test
  7809. --            STATUS: Report on success or failure of specific
  7810. --                tests
  7811. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  7812. --               If FALSE, the exception will be handled and the
  7813. --               test will return a value of FAIL.
  7814. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  7815. --
  7816. --  Exceptions:
  7817. --  ----------
  7818. --    None.
  7819. --
  7820. --  Notes:
  7821. --  -----
  7822. --    None.
  7823. --
  7824. ---------------------------------------------------------------------
  7825.  
  7826.     function Test011 (
  7827.         Verbosity        : Kinds_Of_Output := STATUS;
  7828.         Die_On_Exception : Boolean := FALSE)
  7829.         return Test_Result is
  7830.  
  7831.         Result      : Test_Result := FAIL;   
  7832.  
  7833.     begin
  7834.  
  7835.         return Result;
  7836.  
  7837.     exception
  7838.  
  7839.         when others =>
  7840.             Report_Status (Verbosity,
  7841.                 "**** Test 011: UNHANDLED EXCEPTION");
  7842.  
  7843.             if Die_On_Exception then
  7844.                 raise;
  7845.             else
  7846.                 return (FAIL);
  7847.             end if;
  7848.     end Test011;
  7849.  
  7850. ----------------------      T E S T 0 1 2      ----------------------
  7851. --
  7852. --  Purpose:
  7853. --  -------
  7854. --
  7855. --  Parameters:
  7856. --  ----------
  7857. --    Verbosity        Specifies the level of output desired. Options:
  7858. --            NONE:   No output from this test
  7859. --            STATUS: Report on success or failure of specific
  7860. --                tests
  7861. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  7862. --               If FALSE, the exception will be handled and the
  7863. --               test will return a value of FAIL.
  7864. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  7865. --
  7866. --  Exceptions:
  7867. --  ----------
  7868. --    None.
  7869. --
  7870. --  Notes:
  7871. --  -----
  7872. --    None.
  7873. --
  7874. ---------------------------------------------------------------------
  7875.  
  7876.     function Test012 (
  7877.         Verbosity        : Kinds_Of_Output := STATUS;
  7878.         Die_On_Exception : Boolean := FALSE)
  7879.         return Test_Result is
  7880.  
  7881.         Result      : Test_Result := FAIL;   
  7882.  
  7883.     begin
  7884.  
  7885.         return Result;
  7886.  
  7887.     exception
  7888.  
  7889.         when others =>
  7890.             Report_Status (Verbosity,
  7891.                 "**** Test 012: UNHANDLED EXCEPTION");
  7892.  
  7893.             if Die_On_Exception then
  7894.                 raise;
  7895.             else
  7896.                 return (FAIL);
  7897.             end if;
  7898.     end Test012;
  7899.  
  7900. ----------------------      T E S T 0 1 3      ----------------------
  7901. --
  7902. --  Purpose:
  7903. --  -------
  7904. --
  7905. --  Parameters:
  7906. --  ----------
  7907. --    Verbosity        Specifies the level of output desired. Options:
  7908. --            NONE:   No output from this test
  7909. --            STATUS: Report on success or failure of specific
  7910. --                tests
  7911. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  7912. --               If FALSE, the exception will be handled and the
  7913. --               test will return a value of FAIL.
  7914. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  7915. --
  7916. --  Exceptions:
  7917. --  ----------
  7918. --    None.
  7919. --
  7920. --  Notes:
  7921. --  -----
  7922. --    None.
  7923. --
  7924. ---------------------------------------------------------------------
  7925.  
  7926.     function Test013 (
  7927.         Verbosity        : Kinds_Of_Output := STATUS;
  7928.         Die_On_Exception : Boolean := FALSE)
  7929.         return Test_Result is
  7930.  
  7931.         Result      : Test_Result := FAIL;   
  7932.  
  7933.     begin
  7934.  
  7935.         return Result;
  7936.  
  7937.     exception
  7938.  
  7939.         when others =>
  7940.             Report_Status (Verbosity,
  7941.                 "**** Test 013: UNHANDLED EXCEPTION");
  7942.  
  7943.             if Die_On_Exception then
  7944.                 raise;
  7945.             else
  7946.                 return (FAIL);
  7947.             end if;
  7948.     end Test013;
  7949.  
  7950. ----------------------      T E S T 0 1 4      ----------------------
  7951. --
  7952. --  Purpose:
  7953. --  -------
  7954. --
  7955. --  Parameters:
  7956. --  ----------
  7957. --    Verbosity        Specifies the level of output desired. Options:
  7958. --            NONE:   No output from this test
  7959. --            STATUS: Report on success or failure of specific
  7960. --                tests
  7961. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  7962. --               If FALSE, the exception will be handled and the
  7963. --               test will return a value of FAIL.
  7964. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  7965. --
  7966. --  Exceptions:
  7967. --  ----------
  7968. --    None.
  7969. --
  7970. --  Notes:
  7971. --  -----
  7972. --    None.
  7973. --
  7974. ---------------------------------------------------------------------
  7975.  
  7976.     function Test014 (
  7977.         Verbosity        : Kinds_Of_Output := STATUS;
  7978.         Die_On_Exception : Boolean := FALSE)
  7979.         return Test_Result is
  7980.  
  7981.         Result      : Test_Result := FAIL;   
  7982.  
  7983.     begin
  7984.  
  7985.         return Result;
  7986.  
  7987.     exception
  7988.  
  7989.         when others =>
  7990.             Report_Status (Verbosity,
  7991.                 "**** Test 014: UNHANDLED EXCEPTION");
  7992.  
  7993.             if Die_On_Exception then
  7994.                 raise;
  7995.             else
  7996.                 return (FAIL);
  7997.             end if;
  7998.     end Test014;
  7999.  
  8000. ----------------------      T E S T 0 1 5      ----------------------
  8001. --
  8002. --  Purpose:
  8003. --  -------
  8004. --
  8005. --  Parameters:
  8006. --  ----------
  8007. --    Verbosity        Specifies the level of output desired. Options:
  8008. --            NONE:   No output from this test
  8009. --            STATUS: Report on success or failure of specific
  8010. --                tests
  8011. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  8012. --               If FALSE, the exception will be handled and the
  8013. --               test will return a value of FAIL.
  8014. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  8015. --
  8016. --  Exceptions:
  8017. --  ----------
  8018. --    None.
  8019. --
  8020. --  Notes:
  8021. --  -----
  8022. --    None.
  8023. --
  8024. ---------------------------------------------------------------------
  8025.  
  8026.     function Test015 (
  8027.         Verbosity        : Kinds_Of_Output := STATUS;
  8028.         Die_On_Exception : Boolean := FALSE)
  8029.         return Test_Result is
  8030.  
  8031.         Result      : Test_Result := FAIL;   
  8032.  
  8033.     begin
  8034.  
  8035.         return Result;
  8036.  
  8037.     exception
  8038.  
  8039.         when others =>
  8040.             Report_Status (Verbosity,
  8041.                 "**** Test 015: UNHANDLED EXCEPTION");
  8042.  
  8043.             if Die_On_Exception then
  8044.                 raise;
  8045.             else
  8046.                 return (FAIL);
  8047.             end if;
  8048.     end Test015;
  8049.  
  8050. end Node_Management_Tests;
  8051. --::::::::::::::
  8052. --node_management_tests-spec.a
  8053. --::::::::::::::
  8054. ----------------------------------------------------------------------
  8055. --                N O D E _ M A N A G E M E N T _ T E S T S
  8056. --                        (Package Specification)
  8057. --
  8058. --
  8059. --             A Set of Simple Test Subprograms To Exercise 
  8060. --                      Portions of Node_Management
  8061. --
  8062. --
  8063. --
  8064. --                  Ada Software Engineering Group
  8065. --                      The MITRE Corporation
  8066. --                         McLean, VA 22102
  8067. --
  8068. --
  8069. --                  Sun Aug 11 14:48:31 EDT 1985
  8070. --
  8071. --                 (Unclassified and uncopyrighted)
  8072. --
  8073. ----------------------------------------------------------------------
  8074.  
  8075. ----------------------------------------------------------------------
  8076. --
  8077. --  Purpose:
  8078. --  -------
  8079. --    To provide a set of functions that exercise and test the
  8080. --    behavior of some of the services available in package
  8081. --    Node_Management.
  8082. --
  8083. --  Usage:
  8084. --  -----
  8085. --    The functions made available in this package will be used
  8086. --    by a "main procedure" named Node_Mgmt.  This procedure acts
  8087. --    as a test driver, calling the different test functions in
  8088. --    sequence.  Output from the tests can be redirected to a file,
  8089. --    or sent to Standard_Output.
  8090. --    Each function returns a value indicated success/failure of
  8091. --    test (i.e. expected results were/were not equal to actual
  8092. --    results).  The driver procedure keeps track of the overall
  8093. --    success/failure count and prints a test summary at the end.
  8094. --
  8095. --    The test functions have two parameters: 
  8096. --        Verbosity - (Kinds_Of_Output) can have the following values:
  8097. --                  None - No messages are sent to Standard_Output
  8098. --                  Status - the test reports on its success or failure
  8099. --        Die_On_Exception : Boolean - if true, an unexpected exception
  8100. --                  will be propogated to the calling procedure,
  8101. --                  otherwise it will be caught (it is still
  8102. --                  treated as a failure, though).
  8103. --
  8104. --  Example:
  8105. --  -------
  8106. --    See the procedure Node_Mgmt for all the examples you could
  8107. --    ever want...
  8108. --
  8109. --  Notes:
  8110. --  -----
  8111. --    None.
  8112. --
  8113. --  Revision History:
  8114. --  ----------------
  8115. --
  8116. -------------------------------------------------------------------
  8117.  
  8118. package Node_Management_Tests is
  8119.  
  8120.     type Test_Result is (Pass, Fail);
  8121.     type Kinds_Of_Output is (NONE, STATUS);
  8122.  
  8123.  
  8124.     function Test001 (
  8125.     Verbosity        : Kinds_Of_Output := STATUS;
  8126.         Die_On_Exception : Boolean := FALSE)
  8127.         return Test_Result;
  8128.  
  8129.     function Test002 (
  8130.     Verbosity        : Kinds_Of_Output := STATUS;
  8131.         Die_On_Exception : Boolean := FALSE)
  8132.         return Test_Result;
  8133.  
  8134.     function Test003 (
  8135.     Verbosity        : Kinds_Of_Output := STATUS;
  8136.         Die_On_Exception : Boolean := FALSE)
  8137.         return Test_Result;
  8138.  
  8139.     function Test004 (
  8140.     Verbosity        : Kinds_Of_Output := STATUS;
  8141.         Die_On_Exception : Boolean := FALSE)
  8142.         return Test_Result;
  8143.  
  8144.     function Test005 (
  8145.     Verbosity        : Kinds_Of_Output := STATUS;
  8146.         Die_On_Exception : Boolean := FALSE)
  8147.         return Test_Result;
  8148.  
  8149.     function Test006 (
  8150.     Verbosity        : Kinds_Of_Output := STATUS;
  8151.         Die_On_Exception : Boolean := FALSE)
  8152.         return Test_Result;
  8153.  
  8154.     function Test007 (
  8155.     Verbosity        : Kinds_Of_Output := STATUS;
  8156.         Die_On_Exception : Boolean := FALSE)
  8157.         return Test_Result;
  8158.  
  8159.     function Test008 (
  8160.     Verbosity        : Kinds_Of_Output := STATUS;
  8161.         Die_On_Exception : Boolean := FALSE)
  8162.         return Test_Result;
  8163.  
  8164.     function Test009 (
  8165.     Verbosity        : Kinds_Of_Output := STATUS;
  8166.         Die_On_Exception : Boolean := FALSE)
  8167.         return Test_Result;
  8168.  
  8169.     function Test010 (
  8170.     Verbosity        : Kinds_Of_Output := STATUS;
  8171.         Die_On_Exception : Boolean := FALSE)
  8172.         return Test_Result;
  8173.  
  8174.     function Test011 (
  8175.     Verbosity        : Kinds_Of_Output := STATUS;
  8176.         Die_On_Exception : Boolean := FALSE)
  8177.         return Test_Result;
  8178.  
  8179.     function Test012 (
  8180.     Verbosity        : Kinds_Of_Output := STATUS;
  8181.         Die_On_Exception : Boolean := FALSE)
  8182.         return Test_Result;
  8183.  
  8184.     function Test013 (
  8185.     Verbosity        : Kinds_Of_Output := STATUS;
  8186.         Die_On_Exception : Boolean := FALSE)
  8187.         return Test_Result;
  8188.  
  8189.     function Test014 (
  8190.     Verbosity        : Kinds_Of_Output := STATUS;
  8191.         Die_On_Exception : Boolean := FALSE)
  8192.         return Test_Result;
  8193.  
  8194.     function Test015 (
  8195.     Verbosity        : Kinds_Of_Output := STATUS;
  8196.         Die_On_Exception : Boolean := FALSE)
  8197.         return Test_Result;
  8198.  
  8199. end Node_Management_Tests;
  8200. --::::::::::::::
  8201. --node_mgmt.a
  8202. --::::::::::::::
  8203. ----------------------------------------------------------------------
  8204. --                         N O D E _ M G M T 
  8205. --
  8206. --
  8207. --          Test Driver for Tests of Package Node_Management
  8208. --
  8209. --
  8210. --
  8211. --
  8212. --                  Ada Software Engineering Group
  8213. --                      The MITRE Corporation
  8214. --                         McLean, VA 22102
  8215. --
  8216. --
  8217. --                   Wed Jun 12 14:11:46 EDT 1985
  8218. --
  8219. --                 (Unclassified and uncopyrighted)
  8220. --
  8221. ----------------------------------------------------------------------
  8222.  
  8223. ----------------------------------------------------------------------
  8224. --
  8225. --  Purpose:
  8226. --  -------
  8227. --    This is the test driver for the suite of tests in the package
  8228. --    Node_Management_Tests.  
  8229. --
  8230. --  Usage:
  8231. --  -----
  8232. --
  8233. --  Example:
  8234. --  -------
  8235. --
  8236. --  Notes:
  8237. --  -----
  8238. --
  8239. --  Revision History:
  8240. --  ----------------
  8241. --
  8242. -------------------------------------------------------------------
  8243. with Text_IO; use Text_IO;
  8244. with Node_Management_Tests; use Node_Management_Tests;
  8245.  
  8246. procedure Node_Mgmt is
  8247.  
  8248.     Valid_Response : Boolean := FALSE;
  8249.     Phyl           : File_Type;
  8250.     MAX_FILENAME   : constant Natural := 39;  -- Arbitrary number
  8251.     Phyl_Name      : String (1..MAX_FILENAME);
  8252.     Name_Length    : Natural;
  8253.  
  8254.     Test_Output        : Kinds_Of_Output;
  8255.     Abort_On_Exception : Boolean;
  8256.  
  8257.     MAX_TESTS         : constant Positive := 15;
  8258.     Subtype Count is Integer range 0 .. MAX_TESTS;
  8259.     package Count_IO is new Integer_IO (Count);
  8260.     use Count_IO;
  8261.  
  8262.     type Response is (YES,NO);
  8263.     Yesno          : Response;
  8264.     package YesNo_IO is new Enumeration_IO (Response); use YesNo_IO;
  8265.  
  8266.     package Verbosity_IO is new Enumeration_IO (Kinds_Of_Output);
  8267.     use Verbosity_IO;
  8268.  
  8269.  
  8270.     Results : array (1..MAX_TESTS) of Test_Result;
  8271.     Test_Count   : Natural;
  8272.     Error_Count  : Natural := 0;
  8273.     Current_Test : Natural := 0;
  8274.  
  8275. begin
  8276.  
  8277.  
  8278.     Valid_Response := FALSE;
  8279.     while not Valid_Response loop
  8280.     Put ("Enter the highest test number to be run: ");
  8281.     GET_TEST_COUNT:
  8282.     begin
  8283.         Get (Test_Count);
  8284.         Valid_Response := TRUE;
  8285.     exception
  8286.         when DATA_ERROR =>
  8287.         Put_Line (ASCII.BEL & 
  8288.             "PLEASE ENTER AN INTEGER 0 .. " &
  8289.             Integer'image(MAX_TESTS));
  8290.     end GET_TEST_COUNT;
  8291.     end loop;
  8292.     Skip_Line (Standard_Input);
  8293.  
  8294.  
  8295.     Valid_Response := FALSE;
  8296.     while not Valid_Response loop
  8297.     Put ("Abort the test upon an unexpected exception? (Yes or No): ");
  8298.     GET_ABORT_STATUS:
  8299.     begin
  8300.         Get (Yesno);
  8301.         Valid_Response := TRUE;
  8302.     exception
  8303.         when DATA_ERROR =>
  8304.         Put_Line (ASCII.BEL & "PLEASE ENTER EITHER YES OR NO ONLY.");
  8305.     end GET_ABORT_STATUS;
  8306.     end loop;
  8307.     Skip_Line (Standard_Input);
  8308.     Abort_On_Exception := (Yesno = YES);
  8309.  
  8310.  
  8311.     Valid_Response := FALSE;
  8312.     while not Valid_Response loop
  8313.     Put ("Enter the level of test output to be printed: ");
  8314.     GET_VERBOSITY:
  8315.     begin
  8316.         Get (Test_Output);
  8317.         Valid_Response := TRUE;
  8318.     exception
  8319.         when DATA_ERROR =>
  8320.         Put_Line (ASCII.BEL & 
  8321.             "PLEASE ENTER ONE OF THE FOLLOWING:");
  8322.             for i in Kinds_Of_Output'pos(Kinds_Of_Output'base'first)
  8323.             .. Kinds_Of_Output'pos(Kinds_Of_Output'base'last) 
  8324.             loop
  8325.             Put("    ");
  8326.             Put(Kinds_Of_Output'val(i));
  8327.             New_line;
  8328.             end loop;
  8329.     end GET_VERBOSITY;
  8330.     end loop;
  8331.     Skip_Line (Standard_Input);
  8332.  
  8333.  
  8334.     Valid_Response := FALSE;
  8335.     while not Valid_Response loop
  8336.     Put ("Do you want output redirected to a file? (yes or no): ");
  8337.     GET_ANSWER:
  8338.     begin
  8339.         Get (Yesno);
  8340.         Valid_Response := TRUE;
  8341.     exception
  8342.         when DATA_ERROR =>
  8343.         Put_Line (ASCII.BEL & "PLEASE ENTER EITHER YES OR NO ONLY.");
  8344.     end GET_ANSWER;
  8345.     end loop;
  8346.     Skip_Line (Standard_Input);
  8347.  
  8348.  
  8349.     if Yesno = YES then
  8350.     Put ("Enter the filename for redirected output: ");
  8351.     Get_Line (Phyl_Name, Name_Length);
  8352.     OPEN_FILE:
  8353.     begin
  8354.         Open (Phyl, Out_File, Phyl_Name (1..Name_Length));
  8355.         Delete (Phyl);
  8356.         Create (Phyl, Out_File, Phyl_Name (1..Name_Length));
  8357.     exception
  8358.         when NAME_ERROR =>
  8359.         Create (Phyl, Out_File, Phyl_Name (1..Name_Length));
  8360.     end OPEN_FILE;
  8361.     Set_Output (Phyl);
  8362.     end if;
  8363.  
  8364.     New_Line;
  8365.     Put_Line ("**** Beginning Execution of Node_Management_Tests ****");
  8366.     Put ("    TEST_OUTPUT is set to ");
  8367.     Put_Line (Kinds_Of_Output'Image(TEST_OUTPUT));
  8368.     Put ("    ABORT_ON_EXCEPTION is set to ");
  8369.     Put_Line (Boolean'Image(ABORT_ON_EXCEPTION));
  8370.     Put ("    TEST_COUNT is set to ");
  8371.     Put (Test_Count);
  8372.     New_Line(2);
  8373.  
  8374.     Current_Test := Current_Test + 1;
  8375.     if Current_Test > Test_Count then
  8376.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  8377.     end if;
  8378.     Results (Current_Test) := Test001 (
  8379.     Verbosity => TEST_OUTPUT,
  8380.     Die_On_Exception => ABORT_ON_EXCEPTION);
  8381.     if Results (Current_Test) = Fail then
  8382.     Error_Count := Error_Count +1;
  8383.     end if;
  8384.  
  8385.     Current_Test := Current_Test + 1;
  8386.     if Current_Test > Test_Count then
  8387.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  8388.     end if;
  8389.     Results (Current_Test) := Test002 (
  8390.     Verbosity => TEST_OUTPUT,
  8391.     Die_On_Exception => ABORT_ON_EXCEPTION);
  8392.     if Results (Current_Test) = Fail then
  8393.     Error_Count := Error_Count +1;
  8394.     end if;
  8395.  
  8396.  
  8397.     Current_Test := Current_Test + 1;
  8398.     if Current_Test > Test_Count then
  8399.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  8400.     end if;
  8401.     Results (Current_Test) := Test003 (
  8402.     Verbosity => TEST_OUTPUT,
  8403.     Die_On_Exception => ABORT_ON_EXCEPTION);
  8404.     if Results (Current_Test) = Fail then
  8405.     Error_Count := Error_Count +1;
  8406.     end if;
  8407.  
  8408.     Current_Test := Current_Test + 1;
  8409.     if Current_Test > Test_Count then
  8410.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  8411.     end if;
  8412.     Results (Current_Test) := Test004 (
  8413.     Verbosity => TEST_OUTPUT,
  8414.     Die_On_Exception => ABORT_ON_EXCEPTION);
  8415.     if Results (Current_Test) = Fail then
  8416.     Error_Count := Error_Count +1;
  8417.     end if;
  8418.  
  8419.     Current_Test := Current_Test + 1;
  8420.     if Current_Test > Test_Count then
  8421.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  8422.     end if;
  8423.     Results (Current_Test) := Test005 (
  8424.     Verbosity => TEST_OUTPUT,
  8425.     Die_On_Exception => ABORT_ON_EXCEPTION);
  8426.     if Results (Current_Test) = Fail then
  8427.     Error_Count := Error_Count +1;
  8428.     end if;
  8429.  
  8430.     Current_Test := Current_Test + 1;
  8431.     if Current_Test > Test_Count then
  8432.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  8433.     end if;
  8434.     Results (Current_Test) := Test006 (
  8435.     Verbosity => TEST_OUTPUT,
  8436.     Die_On_Exception => ABORT_ON_EXCEPTION);
  8437.     if Results (Current_Test) = Fail then
  8438.     Error_Count := Error_Count +1;
  8439.     end if;
  8440.  
  8441.     Current_Test := Current_Test + 1;
  8442.     if Current_Test > Test_Count then
  8443.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  8444.     end if;
  8445.     Results (Current_Test) := Test007 (
  8446.     Verbosity => TEST_OUTPUT,
  8447.     Die_On_Exception => ABORT_ON_EXCEPTION);
  8448.     if Results (Current_Test) = Fail then
  8449.     Error_Count := Error_Count +1;
  8450.     end if;
  8451.  
  8452.     Current_Test := Current_Test + 1;
  8453.     if Current_Test > Test_Count then
  8454.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  8455.     end if;
  8456.     Results (Current_Test) := Test008 (
  8457.     Verbosity => TEST_OUTPUT,
  8458.     Die_On_Exception => ABORT_ON_EXCEPTION);
  8459.     if Results (Current_Test) = Fail then
  8460.     Error_Count := Error_Count +1;
  8461.     end if;
  8462.  
  8463.     Current_Test := Current_Test + 1;
  8464.     if Current_Test > Test_Count then
  8465.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  8466.     end if;
  8467.     Results (Current_Test) := Test009 (
  8468.     Verbosity => TEST_OUTPUT,
  8469.     Die_On_Exception => ABORT_ON_EXCEPTION);
  8470.     if Results (Current_Test) = Fail then
  8471.     Error_Count := Error_Count +1;
  8472.     end if;
  8473.  
  8474.     Current_Test := Current_Test + 1;
  8475.     if Current_Test > Test_Count then
  8476.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  8477.     end if;
  8478.     Results (Current_Test) := Test010 (
  8479.     Verbosity => TEST_OUTPUT,
  8480.     Die_On_Exception => ABORT_ON_EXCEPTION);
  8481.     if Results (Current_Test) = Fail then
  8482.     Error_Count := Error_Count +1;
  8483.     end if;
  8484.  
  8485.     Current_Test := Current_Test + 1;
  8486.     if Current_Test > Test_Count then
  8487.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  8488.     end if;
  8489.     Results (Current_Test) := Test011 (
  8490.     Verbosity => TEST_OUTPUT,
  8491.     Die_On_Exception => ABORT_ON_EXCEPTION);
  8492.     if Results (Current_Test) = Fail then
  8493.     Error_Count := Error_Count +1;
  8494.     end if;
  8495.  
  8496.     Current_Test := Current_Test + 1;
  8497.     if Current_Test > Test_Count then
  8498.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  8499.     end if;
  8500.     Results (Current_Test) := Test012 (
  8501.     Verbosity => TEST_OUTPUT,
  8502.     Die_On_Exception => ABORT_ON_EXCEPTION);
  8503.     if Results (Current_Test) = Fail then
  8504.     Error_Count := Error_Count +1;
  8505.     end if;
  8506.  
  8507.     Current_Test := Current_Test + 1;
  8508.     if Current_Test > Test_Count then
  8509.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  8510.     end if;
  8511.     Results (Current_Test) := Test013 (
  8512.     Verbosity => TEST_OUTPUT,
  8513.     Die_On_Exception => ABORT_ON_EXCEPTION);
  8514.     if Results (Current_Test) = Fail then
  8515.     Error_Count := Error_Count +1;
  8516.     end if;
  8517.  
  8518.     Current_Test := Current_Test + 1;
  8519.     if Current_Test > Test_Count then
  8520.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  8521.     end if;
  8522.     Results (Current_Test) := Test014 (
  8523.     Verbosity => TEST_OUTPUT,
  8524.     Die_On_Exception => ABORT_ON_EXCEPTION);
  8525.     if Results (Current_Test) = Fail then
  8526.     Error_Count := Error_Count +1;
  8527.     end if;
  8528.  
  8529.  
  8530.     Current_Test := Current_Test + 1;
  8531.     if Current_Test > Test_Count then
  8532.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  8533.     end if;
  8534.     Results (Current_Test) := Test015 (
  8535.     Verbosity => TEST_OUTPUT,
  8536.     Die_On_Exception => ABORT_ON_EXCEPTION);
  8537.     if Results (Current_Test) = Fail then
  8538.     Error_Count := Error_Count +1;
  8539.     end if;
  8540.  
  8541.     -- Produce Summary
  8542.  
  8543.     <<PRINT_RESULTS>>
  8544.     New_Line;
  8545.     Put_Line ("**** End of Node_Management_Tests ****");
  8546.     if Error_Count = 0 then
  8547.         New_Line;
  8548.     Put_Line ("NO TESTS FAILED. HUZZAH!");
  8549.     else
  8550.         New_Line;
  8551.     Put ("A total of ");
  8552.     Put (Error_Count);
  8553.     Put_Line (" Test(s) failed.");
  8554.     Put_Line ("The following test(s) failed:");
  8555.     for I in 1 .. Test_Count loop
  8556.         if Results (I) = fail then
  8557.         Put ("Test number ");
  8558.         Put (I);
  8559.                 New_Line;
  8560.         end if;
  8561.     end loop;
  8562.     end if;
  8563.  
  8564. end Node_Mgmt;
  8565. --::::::::::::::
  8566. --nodetree_cleanup.a
  8567. --::::::::::::::
  8568. with Cais; use Cais;
  8569. with Text_Io; use Text_Io;
  8570. procedure Nodetree_Cleanup is
  8571.  
  8572. use Node_Definitions;
  8573. use Node_Management;
  8574.  
  8575.     Node    : Cais.Node_Type;
  8576. begin
  8577.     Open(Node,"'current_user.Nowalk", 
  8578.             (1=>read_relationships, 2=>Exclusive_Write));
  8579.     Put_Line("Nowalk is Open");
  8580.     Delete_Tree(Node);
  8581. end Nodetree_Cleanup;
  8582. --::::::::::::::
  8583. --nodetree_ex.a
  8584. --::::::::::::::
  8585. -----------------------------N O D E T R E E _ E X---------------------------
  8586. -- Purpose:
  8587. -- -------
  8588. --    This program runs exception tests for the subprogams in sections
  8589. --    7,8,9,17,18,19,20, and 22 of MIL-STD-CAIS 5.1.2.  These routines
  8590. --      provide information on the primary_name, provide access to the
  8591. --    parent node, provide for copying and deleting trees, and provide
  8592. --    for copying and renaming nodes.
  8593. --
  8594. --    Tests for Lock_Error, Access_Violation, and Security_Violation
  8595. --    are not included because these features are not yet implemented.
  8596. --
  8597. --    In order to perform these tests, several nodes are created. Several
  8598. --    nodes have strange properties, such as inaccessibility.  The
  8599. --    manner in which these properties have been created likely violates
  8600. --    rules enforced by access_methods or locking_checks.  Therefore,
  8601. --    this program must be updated once these features are implemented.
  8602. --
  8603. ------------------------------------------------------------------------------
  8604. with Cais;    use Cais;
  8605. with Text_Io; use Text_Io;
  8606. procedure Nodetree_Ex is
  8607.  
  8608. use Attributes;
  8609. use List_Utilities;
  8610. use Node_Management;
  8611. use Node_Definitions;
  8612.  
  8613.   Exceptions_Tested : constant := 50;
  8614.   Failures   : integer := 0;
  8615.   Line_Count : integer;
  8616.   Expected   : string(1..3);
  8617.   Check_Inaccessibility : boolean;
  8618.  
  8619.     Inaccessible_Node : Cais.Node_Type;
  8620.     In_Traversed_Node : Cais.Node_Type;
  8621.     Closed_Node       : Cais.Node_Type;
  8622.     Open_Node      : Cais.Node_Type;
  8623.     Locked_Node      : Cais.Node_Type;
  8624.     Impotent_Node      : Cais.Node_Type;
  8625.     Hidden_Node      : Cais.Node_Type;
  8626.     Process_Node      : Cais.Node_Type;
  8627.     Top_Node      : Cais.Node_Type;
  8628.     Living_Node      : Cais.Node_Type;
  8629.     Offspring_Node      : Cais.Node_Type;
  8630.     Parent           : Cais.Node_Type;
  8631.     Temp_File      : Cais.Text_Io.File_Type;
  8632.  
  8633.     Node      : Cais.Node_Type;
  8634.     Node1     : Cais.Node_Type;
  8635.  
  8636.     Wait      : string(1..100);
  8637.     Last      : natural;
  8638.     No_Intent : Intention(1..2) := (Existence, read);
  8639.     Key       : Relationship_Key(1..6) := "howell";
  8640.     Relation  : Relation_Name(1..4)    := "user";
  8641.     Null_List : List_Type;
  8642.  
  8643.  
  8644.  
  8645.   procedure Wrong_Exception(II: integer;
  8646.                 SS: string) is
  8647.  
  8648.   begin
  8649.     Failures := Failures + 1;
  8650.     Line_Count := 10;
  8651.     new_line;
  8652.     put(
  8653.          integer'image(II)   &
  8654.          ":**ERROR**"     &
  8655.          " Received: "       &
  8656.              SS                  &
  8657.              " Expected: "       &
  8658.              Expected            );
  8659.   end Wrong_Exception;
  8660.  
  8661.  
  8662.   procedure No_Ex(Error: in string) is
  8663.   begin
  8664.     new_line;
  8665.     put(Error);
  8666.     Line_Count := 10;
  8667.     Failures := Failures + 1;
  8668.   end No_Ex;
  8669.  
  8670.  
  8671.  
  8672.  
  8673.  
  8674.   procedure Raise_Exception(II: integer ) is
  8675.     Text    : Natural;
  8676.     String1 : string(1..3);
  8677.     Name1   : NameString(1..3);
  8678.     Iterator      : Attribute_Iterator;
  8679.     Attribute     : Attribute_Name(1..32);
  8680.   begin
  8681.  
  8682.     case II is
  8683.                             --MIL STD 5.1.3.1
  8684.                               --not applicable
  8685.  
  8686.                         --Access_Violation not checked
  8687.                         --Lock_Error not checked
  8688.     when  1 =>                    --MIL STD 5.1.2.7
  8689.       if check_inaccessibility then
  8690.         Expected := "Nam";
  8691.         Put_Line (Primary_Name(In_Traversed_Node) );
  8692.         No_Ex(" 1***ERROR***Primary_Name: inaccessible");
  8693.       end if;
  8694.     when  2 =>
  8695.         Expected := "Sta";
  8696.         Put_Line (Primary_Name(Closed_Node) );
  8697.         No_Ex(" 2***ERROR***Primary_Name: not open");
  8698.     when  3 =>
  8699.         Expected := "Int";
  8700.         Put_Line (Primary_Name(Impotent_Node) );
  8701.         No_Ex(" 3***ERROR***Primary_Name: bad intent");
  8702.                         --Access_Violation not checked
  8703.                         --Lock_Error not checked
  8704.     when  4 =>                    --MIL STD 5.1.2.8
  8705.       if check_inaccessibility then
  8706.         Expected := "Nam";
  8707.         Put_Line (Primary_Key(In_Traversed_Node) );
  8708.         No_Ex(" 4***ERROR***Primary_Key: inaccessible");
  8709.       end if;
  8710.     when  5 =>
  8711.         Expected := "Sta";
  8712.         Put_Line (Primary_Key(Closed_Node) );
  8713.         No_Ex(" 5***ERROR***Primary_Key: not open");
  8714.     when  6 =>
  8715.         Expected := "Int";
  8716.         Put_Line (Primary_Key(Impotent_Node) );
  8717.         No_Ex(" 6***ERROR***Primary_Key: bad intent");
  8718.                         --Access_Violation not checked
  8719.                         --Lock_Error not checked
  8720.     when  7 =>                    --MIL STD 5.1.2.9
  8721.       if check_inaccessibility then
  8722.         Expected := "Nam";
  8723.         Put_Line (Primary_Relation(In_Traversed_Node) );
  8724.         No_Ex(" 7***ERROR***Primary_Relation: inaccessible");
  8725.       end if;
  8726.     when  8 =>
  8727.         Expected := "Sta";
  8728.         Put_Line (Primary_Relation(Closed_Node) );
  8729.         No_Ex(" 8***ERROR***Primary_Relation: not open");
  8730.     when  9 =>
  8731.         Expected := "Int";
  8732.         Put_Line (Primary_Relation(Impotent_Node) );
  8733.         No_Ex(" 9***ERROR***Primary_Relation: bad intent");
  8734.  
  8735.                         --Security_Violation not checked
  8736.                         --Access_Violation not checked
  8737.                         --Lock_Error not checked
  8738.     when  10 =>                    --MIL STD 5.1.2.17
  8739.         Expected := "Nam";
  8740.         Get_Parent(Parent, Top_Node);
  8741.         No_Ex(" 10***ERROR***Get_Parent: top-level");
  8742.         Close(Parent);
  8743.     when  11 =>
  8744.       if check_inaccessibility then
  8745.         Expected := "Nam";
  8746.         Get_Parent(Parent, In_Traversed_Node);
  8747.         No_Ex(" 11***ERROR***Get_Parent: inaccessible parent");
  8748.         Close(Parent);
  8749.       end if;
  8750.     when  12 =>                    
  8751.         Expected := "Use";
  8752.         Get_Parent(Parent, Offspring_Node, No_Intent(2..1) );
  8753.         No_Ex(" 12***ERROR***Get_Parent: null intention");
  8754.         Close(Parent);
  8755.     when  13 =>
  8756.         Expected := "Sta";
  8757.         Get_Parent(Open_Node, Offspring_Node);
  8758.         No_Ex(" 13***ERROR***Get_Parent: open parent");
  8759.         Close(Parent);
  8760.     when  14 =>    
  8761.         Expected := "Sta";
  8762.         Get_Parent(Parent, Closed_Node);
  8763.         No_Ex(" 14***ERROR***Get_Parent: closed node");
  8764.         Close(Parent);
  8765.     when  15 =>
  8766.         Expected := "Int";
  8767.         Get_Parent(Parent, Impotent_Node);
  8768.         No_Ex(" 15***ERROR***Get_Parent: bad intent");
  8769.         Close(Parent);
  8770.                         --Security_Violation not checked
  8771.     when  16 =>                    --MIL STD 5.1.2.18
  8772.         Expected := "Nam";
  8773.         Copy_Node(Impotent_Node,Living_Node, "Bad__Key");
  8774.         No_Ex(" 16***ERROR***Copy_Node: illegal key");
  8775.     when  17 =>
  8776.         Expected := "Nam";
  8777.         Copy_Node(Impotent_Node,Living_Node, "OK", "Bad__Rel");
  8778.         No_Ex(" 17***ERROR***Copy_Node: illegal relation");
  8779.     when  18 =>                    
  8780.         Expected := "Nam";
  8781.         Copy_Node(Impotent_Node,Living_Node, "johnjr", "dot" );
  8782.         No_Ex(" 18***ERROR***Copy_Node: existing node");
  8783.     when  19 =>
  8784.         Expected := "Use";
  8785.         Copy_Node(Process_Node,Living_Node, "dan", "dot" );
  8786.         No_Ex(" 19***ERROR***Copy_Node: wrong node kind");
  8787.     when  20 =>    
  8788.         Expected := "Use";
  8789.         Copy_Node(Living_Node, Living_Node, "jim", "dot");
  8790.         No_Ex(" 20***ERROR***Copy_Node: primary relationships");
  8791.     when  21 =>
  8792.         Expected := "Use";
  8793.         Copy_Node(Offspring_Node,Living_Node, "dummy", "access");
  8794.         No_Ex(" 21***ERROR***Copy_Node: predefined relation");
  8795.     when  22 =>                    
  8796.         Expected := "Sta";
  8797.         Copy_Node(Closed_Node,Living_Node, "dummy", "link" );
  8798.         No_Ex(" 22***ERROR***Copy_Node: from closed");
  8799.     when  23 =>
  8800.         Expected := "Sta";
  8801.         Copy_Node(Living_Node,Closed_Node,"dummy", "link" );
  8802.         No_Ex(" 23***ERROR***Copy_Node: to closed");
  8803.     when  24 =>    
  8804.         Expected := "Int";
  8805.         Copy_Node(Impotent_Node,Living_Node, "dummy", "link" );
  8806.         No_Ex(" 24***ERROR***Copy_Node: from bad intent");
  8807.     when  25 =>
  8808.         Expected := "Int";
  8809.         Copy_Node(Living_Node,Impotent_Node, "dummy", "link" );
  8810.         No_Ex(" 25***ERROR***Copy_Node: to bad intent");
  8811.  
  8812.                         --Security_Violation not checked
  8813.                         --Access_Violation not checked
  8814.                         --Lock_Error not checked
  8815.     when  26 =>                    --MIL STD 5.1.2.19
  8816.         Expected := "Nam";
  8817.         Copy_Tree(Impotent_Node,Living_Node, "Bad__Key");
  8818.         No_Ex(" 26***ERROR***Copy_Tree: illegal key");
  8819.     when  27 =>
  8820.         Expected := "Nam";
  8821.         Copy_Tree(Impotent_Node,Living_Node, "OK", "Bad__Rel");
  8822.         No_Ex(" 27***ERROR***Copy_Tree: illegal relation");
  8823.     when  28 =>                    
  8824.         Expected := "Nam";
  8825.         Copy_Tree(Impotent_Node,Living_Node, "johnjr", "dot" );
  8826.         No_Ex(" 28***ERROR***Copy_Tree: existing node");
  8827.     when  29 =>
  8828.         Expected := "Use";
  8829.         Copy_Tree(Process_Node,Living_Node, "dan", "dot" );
  8830.         No_Ex(" 29***ERROR***Copy_Tree: wrong node kind");
  8831.     when  30 =>
  8832.         Expected := "Use";
  8833.         Copy_Tree(Offspring_Node,Living_Node, "dummy", "access");
  8834.         No_Ex(" 30***ERROR***Copy_Tree: predefined relation");
  8835.     when  31 =>                    
  8836.         Expected := "Sta";
  8837.         Copy_Tree(Closed_Node,Living_Node, "dummy", "link" );
  8838.         No_Ex(" 31***ERROR***Copy_Tree: from closed");
  8839.     when  32 =>
  8840.         Expected := "Sta";
  8841.         Copy_Tree(Living_Node,Closed_Node,"dummy", "link" );
  8842.         No_Ex(" 32***ERROR***Copy_Tree: to closed");
  8843.     when  33 =>    
  8844.         Expected := "Int";
  8845.         Copy_Tree(Impotent_Node,Living_Node, "dummy", "link" );
  8846.         No_Ex(" 33***ERROR***Copy_Tree: from bad intent");
  8847.     when  34 =>
  8848.         Expected := "Int";
  8849.         Copy_Tree(Offspring_Node,Hidden_Node, "dummy", "link" );
  8850.         No_Ex(" 34***ERROR***Copy_Tree: to bad intent");
  8851.                      --Security_Violation not checked
  8852.                         --Access_Violation not checked
  8853.                         --Lock_Error not checked
  8854.     when  35 =>                    --MIL STD 5.1.2.20
  8855.         Expected := "Nam";
  8856.         Rename(Hidden_Node,Living_Node, "Bad__Key");
  8857.         No_Ex(" 35***ERROR***Rename: illegal key");
  8858.     when  36 =>
  8859.         Expected := "Nam";
  8860.         Rename(Hidden_Node,Living_Node, "OK", "Bad__Rel");
  8861.         No_Ex(" 36***ERROR***Rename: illegal relation");
  8862.     when  37 =>                    
  8863.         Expected := "Nam";
  8864.         Rename(Hidden_Node,Living_Node, "johnjr", "dot" );
  8865.         No_Ex(" 37***ERROR***Rename: existing node");
  8866.     when  38 =>
  8867.         Expected := "Use";
  8868.         Rename(Process_Node,Living_Node, "dan", "dot" );
  8869.         No_Ex(" 38***ERROR***Rename: wrong node kind");
  8870.     when  39 =>
  8871.         Expected := "Use";
  8872.         Rename(Living_Node,Offspring_Node, "dummy", "dot");
  8873.         No_Ex(" 39***ERROR***Rename: acircularity test");
  8874.     when  40 =>
  8875.         Expected := "Use";
  8876.         Rename(Offspring_Node,Living_Node, "dummy", "access");
  8877.         No_Ex(" 40***ERROR***Rename: predefined relation");
  8878.     when  41 =>
  8879.         Expected := "Use";
  8880.         Rename(Top_Node,Living_Node, "dummy", "dot");
  8881.         No_Ex(" 41***ERROR***Rename: parent relation is predefined");
  8882.     when  42 =>                    
  8883.         Expected := "Sta";
  8884.         Rename(Closed_Node,Living_Node, "dummy", "link" );
  8885.         No_Ex(" 42***ERROR***Rename: from closed");
  8886.     when  43 =>
  8887.         Expected := "Sta";
  8888.         Rename(Living_Node,Closed_Node,"dummy", "link" );
  8889.         No_Ex(" 43***ERROR***Rename: to closed");
  8890.     when  44 =>    
  8891.         Expected := "Int";
  8892.         Rename(Hidden_Node,Living_Node, "dummy", "link" );
  8893.         No_Ex(" 44***ERROR***Rename: from bad intent");
  8894.     when  45 =>
  8895.         Expected := "Int";
  8896.         Rename(Living_Node,Impotent_Node, "dummy", "link" );
  8897.         No_Ex(" 45***ERROR***Rename: to bad intent");
  8898.                          --Security_Violation not checked
  8899.                         --Access_Violation not checked
  8900.                         --Lock_Error not checked
  8901.     when  46 =>                    --MIL STD 5.1.2.22
  8902.       if check_inaccessibility then
  8903.         Expected := "Nam";
  8904.         Delete_Tree(In_Traversed_Node);
  8905.         No_Ex(" 46***ERROR***Delete_Tree: inaccessible parent");
  8906.       end if;
  8907.     when  47 =>                    --MIL STD 5.1.2.22
  8908.       if check_inaccessibility then
  8909.         Expected := "Nam";
  8910.         Delete_Tree(Living_Node);
  8911.         No_Ex(" 47***ERROR***Delete_Tree: inaccessible subtree");
  8912.       end if;
  8913.     when  48 =>                    --MIL STD 5.1.2.22
  8914.         Expected := "Use";
  8915.         Delete_Tree(Top_Node);
  8916.         No_Ex(" 48***ERROR***Delete_Tree: parent relation is predefined");
  8917.     when  49 =>                    --MIL STD 5.1.2.22
  8918.         Expected := "Sta";
  8919.         Delete_Tree(Closed_Node);
  8920.         No_Ex(" 49***ERROR***Delete_Tree: unopened node");
  8921.     when  50 =>                    --MIL STD 5.1.2.22
  8922.         Expected := "Int";
  8923.         Delete_Tree(Hidden_Node);
  8924.         No_Ex(" 50***ERROR***Delete_Tree: bad intent");
  8925.     when others =>
  8926.         Put_Line("***TEST SET-UP ERROR*** " & integer'image(II) &
  8927.              " NOT EXPECTED!!");
  8928.     end case;
  8929.   end Raise_Exception;
  8930.  
  8931.  
  8932.   begin
  8933.         Open(Top_Node,"'current_user",(1=>Exclusive_Write, 2=>Read));
  8934.         Open(Impotent_Node,"'current_user",(1=>read_contents));
  8935.  
  8936.     Put_Line("CREATE --TREE");
  8937.     Structural_Nodes.Create_Node(Node, Name=>"'current_user.Nowalk");
  8938.     Close(Node);
  8939.     Open(Node1, "'current_user.Nowalk",
  8940.             (1=>read, 2=>append_relationships));
  8941.  
  8942.     Put_Line("CREATE --Nowalk.john");
  8943.     Structural_Nodes.Create_Node(Living_Node, Node1, "john", "dot"  );
  8944.     Close(Living_Node);
  8945.     Open(Living_Node, Node1, "john","dot", 
  8946.             (1=>read, 2=>append_relationships));
  8947.  
  8948.     Put_Line("CREATE --Nowalk.john.johnjr");
  8949.     Cais.Text_Io.Create(Temp_File, Living_Node, "johnjr", "dot" );
  8950.     Cais.Text_Io.Close(Temp_File);
  8951.     Open(Offspring_Node,Living_Node, "johnjr","dot", 
  8952.             (1=>read, 2=>Exclusive_Write, 3=>append_relationships));
  8953.  
  8954.     Put_Line("CREATE --Nowalk.john.johnjr.mark");
  8955.     Cais.Text_Io.Create(Temp_File, Offspring_Node, "mark", "dot" );
  8956.     Cais.Text_Io.Close(Temp_File);
  8957.  
  8958.     Put_Line("CREATE --Nowalk.john.will");
  8959.     Cais.Text_Io.Create(Temp_File, Living_Node, "will", "dot"  );
  8960.     Cais.Text_Io.Close(Temp_File);
  8961.     Open(Node, Living_Node, "will","dot", 
  8962.         (1=>Exclusive_write, 2=>append_relationships,3=>read));
  8963.  
  8964.     Put_Line("CREATE --Nowalk.john.will.kitty");
  8965.     Cais.Text_Io.Create(Temp_File, Node, "kitty", "dot"  );
  8966.     Cais.Text_Io.Close(Temp_File);
  8967.  
  8968.     Open(Inaccessible_Node, Living_Node, "will","dot", (1=>write, 2=>read));
  8969.     Open(In_traversed_Node,Node,"kitty","dot",(1=>exclusive_write,2=>read));
  8970.  
  8971.  
  8972.     Put_Line("NOW YOU must make the node dot(will) inaccessible");
  8973.     Put_Line("It should be the 2nd from last node created.");
  8974.     Put_Line("Should Inaccessibility tests be run (Y/N)");
  8975.     Get_Line(Wait, Last);
  8976.     if Last = 1 and then Wait(1) = 'Y' then
  8977.         Check_Inaccessibility := true;
  8978.     else
  8979.         Check_Inaccessibility := false;
  8980.     end if;
  8981.  
  8982.         Open(Process_Node,"'current_job",(1=>Existence));
  8983.     Open(Hidden_Node,Living_Node, "johnjr","dot", (1=>existence));
  8984.     Open(Open_Node, Living_Node, "johnjr","dot", (1=>write, 2=>read));
  8985.  
  8986. --========================================================================
  8987. --===================S E T U P   C O M P L E T E D========================
  8988. --========================================================================
  8989.  
  8990.     Line_Count := 10;
  8991.     for I in 1..Exceptions_Tested loop
  8992.     begin
  8993.         if Line_Count = 10 then
  8994.         new_line;
  8995.         put("PASSES TEST: ");
  8996.         Line_Count := 0;
  8997.         end if;
  8998.         Raise_Exception(I);
  8999.         exception
  9000.       when Node_Definitions.Use_Error     =>
  9001.                 if Expected /= "Use" then
  9002.                   Wrong_Exception(I,"Use_Error");
  9003.                 else
  9004.                   Line_Count := Line_Count+1;
  9005.                   put( integer'image(I));
  9006.                   put("  ");
  9007.                 end if;
  9008.  
  9009.       when Node_Definitions.Status_Error     =>
  9010.                 if Expected /= "Sta" then
  9011.                   Wrong_Exception(I,"Status_Error");
  9012.                 else
  9013.                   Line_Count := Line_Count+1;
  9014.                   put( integer'image(I));
  9015.                   put("  ");
  9016.                 end if;
  9017.  
  9018.       when Intent_Violation =>
  9019.                 if Expected /= "Int" then
  9020.                   Wrong_Exception(I,"Intent_Error");
  9021.                 else
  9022.                   Line_Count := Line_Count+1;
  9023.                   put( integer'image(I));
  9024.                   put("  ");
  9025.                 end if;
  9026.  
  9027.       when Lock_Error         =>
  9028.                 if Expected /= "Loc" then
  9029.                   Wrong_Exception(I,"Lock_Error");
  9030.                 else
  9031.                   Line_Count := Line_Count+1;
  9032.                   put( integer'image(I));
  9033.                   put("  ");
  9034.                 end if;
  9035.  
  9036.       when Security_Violation =>
  9037.                 if Expected /= "Sec" then
  9038.                   Wrong_Exception(I,"Security_Violation");
  9039.                 else
  9040.                   Line_Count := Line_Count+1;
  9041.                   put( integer'image(I));
  9042.                   put("  ");
  9043.                 end if;
  9044.  
  9045.       when Node_Definitions.Name_Error =>
  9046.                 if Expected /= "Nam" then
  9047.                   Wrong_Exception(I,"Name_Error");
  9048.                 else
  9049.                   Line_Count := Line_Count+1;
  9050.                   put( integer'image(I));
  9051.                   put("  ");
  9052.                 end if;
  9053.     end;
  9054.   end loop;
  9055.  
  9056.   new_line;
  9057.   put_line("****************************T O T A L S***********************");
  9058.   put_line("Number of tests run: " & integer'image(Exceptions_Tested));
  9059.   put_line("Number of failures : " & integer'image(Failures) );
  9060.   put_line("*** NOTE 6 TESTS ARE SKIPPED IF INACCESSIBILITY NOT CHECKED***");
  9061.   put_line("**************************************************************");
  9062. end Nodetree_Ex;
  9063. --::::::::::::::
  9064. --patt_tst_all.a
  9065. --::::::::::::::
  9066. with Cais; use Cais;
  9067. with Text_Io;          use Text_Io;
  9068. Procedure Patt_Tst_All is
  9069.  
  9070. use Node_Management;
  9071. use Node_Definitions;
  9072. use Attributes;
  9073. use List_Utilities;
  9074.  
  9075. package LU renames List_Utilities;
  9076.  
  9077.     Time_Value_1  : List_Type;
  9078.     Time_Value_2  : List_Type;
  9079.     Verification_1: List_Type;
  9080.     Verification_2: List_Type;
  9081.     Work_List     : List_Type;
  9082.     Base          : Cais.Node_Type;
  9083.     Key          : Relationship_Key(1..6) := "howell";
  9084.     Key1          : Relationship_Key(1..4) := "mike";
  9085.     Relation      : Relation_Name(1..3)    := "dot";
  9086.  
  9087.  
  9088.     procedure Print_Attributes(Node : Cais.Node_Type;
  9089.                    Text : string;
  9090.                    Key  : Relationship_Key) is
  9091.     Name   : Attribute_Name(1..32);
  9092.     Value  : List_Type;
  9093.     Selected : Attribute_Iterator;
  9094.     begin
  9095.     put_line(Text);
  9096.         Path_Attribute_Iterate(Selected, Node, Key, Relation);
  9097.     while more(Selected) loop
  9098.         Name := (others => ' ');
  9099.         Get_Next(Selected, Name, Value);
  9100.         Put("    ");
  9101.         Put(Name);  Put("=> ");  Put(To_Text(Value));
  9102.         new_line;
  9103.     end loop;
  9104.     end Print_Attributes;
  9105.  
  9106.     procedure Print_Attributes(Name: Name_String;
  9107.              Text: string)is
  9108.     Node : Cais.Node_Type;
  9109.     begin
  9110.     Open(Node, Name, (1=>write_relationships,
  9111.               2=>read_relationships,
  9112.               3=>append_relationships,
  9113.               4=>write_attributes));
  9114.     Print_Attributes(Node, Text, Key1);
  9115.     Close(Node);
  9116.     end Print_Attributes;
  9117.  
  9118.     procedure Print_Value(List1: List_Type;
  9119.         List2: List_Type) is
  9120.     begin
  9121.     if Is_Equal(List1, list2) then
  9122.         put_line("TEST PASSES: FOUND " & To_Text(List2));
  9123.     else
  9124.         put_line("***ERROR***");
  9125.         put_Line("    LIST1 is " & To_Text(List1) );
  9126.         put_Line("    LIST2 is " & To_Text(List2) );
  9127.     end if;
  9128.     end Print_Value;
  9129.  
  9130. begin
  9131.     To_List("(Hour=>12, Minute=>30, Seconds=>49)", Time_Value_1 );
  9132.     To_List("(Hour=>10, Minute=>15, Seconds=>17)", Time_Value_2 );
  9133.     To_List("(true)",  Verification_1 );
  9134.     To_List("(false)", Verification_2 );
  9135.    Open(Base,"'current_node",(1=>write_relationships,
  9136.             2=>read_relationships,
  9137.             3=>append_relationships,
  9138.             4=>write_attributes));
  9139.  
  9140. --CREATE(5.1.3.1 AND 2)
  9141.     New_Line;
  9142.     Put_Line("TESTING CREATE");
  9143.     Create_Path_Attribute(Base, Key, Relation, "Time", Time_Value_1);
  9144.     Create_Path_Attribute(Base, Key, Relation, "Verified", Verification_1);
  9145.     Create_Path_Attribute("'current_node.mike", "Time", Time_Value_1);
  9146.     Print_Attributes(Base,"TST_NODE1 EXPECTS: time, verified",Key);
  9147.     Print_Attributes("'current_node","TST_NODE2 EXPECTS: time");
  9148.  
  9149. --GET(5.1.3.7 AND 8)
  9150.     New_Line;
  9151.     Put_Line("TESTING GET");
  9152.     Get_Path_Attribute(Base, Key, Relation, "Time", Work_List);
  9153.     Print_Value(Work_List, Time_Value_1);
  9154.  
  9155.     Get_Path_Attribute(Base, Key, Relation, "Verified", Work_List);
  9156.     Print_Value(Work_List, Verification_1);
  9157.  
  9158.     Get_Path_Attribute("'current_node.mike", "Time", Work_List);
  9159.     Print_Value(Work_List, Time_Value_1);
  9160.  
  9161. --SET(5.1.3.5 AND 6)
  9162.     New_Line;
  9163.     Put_Line("TESTING SET");
  9164.     Set_Path_Attribute(Base, Key, Relation, "Time", Time_Value_2);
  9165.     Set_Path_Attribute(Base, Key, Relation, "Verified", Verification_2);
  9166.     Set_Path_Attribute("'current_node.mike", "Time", Time_Value_2);
  9167.    Print_Attributes(Base,"TST_NODE1 EXPECTS: time=101517, verified=false",Key);
  9168.    Print_Attributes("'current_node","TST_NODE2 EXPECTS: time=101517");
  9169.  
  9170. --DELETE(5.1.3.3 AND 4)
  9171.     New_Line;
  9172.     Put_Line("TESTING DELETE");
  9173.     Delete_Path_Attribute(Base, Key, Relation, "Time");
  9174.     Print_Attributes(Base,"ONLY VERIFIED EXPECTED: ",Key);
  9175.     Delete_Path_Attribute(Base, Key, Relation, "Verified");
  9176.     Print_Attributes(Base,"NOTHING EXPECTED  : ",Key);
  9177.     Delete_Path_Attribute("'current_node.mike", "Time");
  9178.     Print_Attributes("'current_node","NOTHING EXPECTED  : ");
  9179. end Patt_Tst_All;
  9180. --::::::::::::::
  9181. --patt_tst_it.a
  9182. --::::::::::::::
  9183. with Cais; use Cais;
  9184. with Text_Io;          use Text_Io;
  9185. Procedure Patt_Tst_It is
  9186.  
  9187. use Attributes;
  9188. use List_Utilities;
  9189. use Node_Definitions;
  9190. use Node_Management;
  9191.  
  9192.     Base : Cais.Node_Type;
  9193.     Key    : Relationship_Key(1..6) := "howell";
  9194.     Relation : Relation_Name(1..3)  := "dot";
  9195.  
  9196.     procedure Test_Setup  is
  9197.     NULL_LIST : LIST_TYPE;
  9198.     begin
  9199.         To_List("()", NULL_LIST);                
  9200.     Create_Path_Attribute(Base,Key,Relation,"ammamma",NULL_LIST);        
  9201.     Create_Path_Attribute(Base,Key,Relation,"axxaxxa",NULL_LIST);        
  9202.     Create_Path_Attribute(Base,Key,Relation,"a      ",NULL_LIST);        
  9203.     Create_Path_Attribute(Base,Key,Relation,"m      ",NULL_LIST);        
  9204.     Create_Path_Attribute(Base,Key,Relation,"z      ",NULL_LIST);        
  9205.     Create_Path_Attribute(Base,Key,Relation,"aaa    ",NULL_LIST);        
  9206.     Create_Path_Attribute(Base,Key,Relation,"xxx    ",NULL_LIST);        
  9207.     Create_Path_Attribute(Base,Key,Relation,"ax     ",NULL_LIST);        
  9208.     Create_Path_Attribute(Base,Key,Relation,"xx     ",NULL_LIST);        
  9209.     Create_Path_Attribute(Base,Key,Relation,"xz     ",NULL_LIST);        
  9210.     Create_Path_Attribute(Base,Key,Relation,"axz    ",NULL_LIST);        
  9211.     Create_Path_Attribute(Base,Key,Relation,"amz    ",NULL_LIST);        
  9212.     Create_Path_Attribute(Base,Key,Relation,"xmx    ",NULL_LIST);        
  9213.     Create_Path_Attribute(Base,Key,Relation,"xmxz   ",NULL_LIST);        
  9214.     Create_Path_Attribute(Base,Key,Relation,"xmxm   ",NULL_LIST);        
  9215.     Create_Path_Attribute(Base,Key,Relation,"axxz   ",NULL_LIST);        
  9216.     Create_Path_Attribute(Base,Key,Relation,"am     ",NULL_LIST);        
  9217.     Create_Path_Attribute(Base,Key,Relation,"az     ",NULL_LIST);        
  9218.     Create_Path_Attribute(Base,Key,Relation,"aazz   ",NULL_LIST);        
  9219.     Create_Path_Attribute(Base,Key,Relation,"aaxx   ",NULL_LIST);        
  9220.     Create_Path_Attribute(Base,Key,Relation,"xxzz   ",NULL_LIST);        
  9221.     Create_Path_Attribute(Base,Key,Relation,"aa     ",NULL_LIST);        
  9222.     Create_Path_Attribute(Base,Key,Relation,"aaaa   ",NULL_LIST);        
  9223.     Create_Path_Attribute(Base,Key,Relation,"axa    ",NULL_LIST);        
  9224.     Create_Path_Attribute(Base,Key,Relation,"axxa   ",NULL_LIST);        
  9225.     Create_Path_Attribute(Base,Key,Relation,"axaxa  ",NULL_LIST);        
  9226.     end Test_Setup;
  9227.  
  9228.  
  9229.     procedure Print_Iterator(Selector: Attribute_Pattern;
  9230.                  Amount : integer) is
  9231.     Name   : Attribute_Name(1..15);
  9232.     Value  : List_Type;
  9233.     II     : integer range 0..400 := 0;
  9234.     Selected : Attribute_Iterator;
  9235.     begin
  9236.         Put(Selector & " EXPECTS: " & integer'image(Amount) );
  9237.         Path_Attribute_Iterate(Selected, Base, Key, Relation, Selector);
  9238.     while more(Selected) loop
  9239.         Name := (others => ' ');
  9240.         Get_Next(Selected, Name, Value);
  9241.         if II mod 3 = 0 then
  9242.         New_Line;
  9243.         Put("    ");
  9244.         end if;
  9245.         Put(Name); Put( "=>" & To_Text(Value));
  9246.         II := II+1;
  9247.     end loop;
  9248.     New_Line;
  9249.     Put_Line(Selector & "***FINDS: " & integer'image(II) & "********");
  9250.     end Print_Iterator;
  9251.  
  9252. begin
  9253.     put_line("The total set consists of :");
  9254.     put_line("  a         aa        aaa       aaaa      aaxx      aazz    ");
  9255.     put_line("  am        ammamma   amz       ax        axa       axaxa   ");
  9256.     put_line("  axz       axxa      axxaxxa   axxz                az      ");
  9257.     put_line("  m         xmx       xmxm      xmxz      xx        xxx     ");
  9258.     put_line("  xxzz      xz        z         ");
  9259.  
  9260.     Open(Base, "'current_node", (1=>read_relationships,
  9261.                2=>write_relationships,
  9262.                3=>append_relationships));
  9263.     Test_Setup;
  9264.     Put_Line("**********************************************************");
  9265.     Put_Line("**NOTE: expected results do not account for meaningful  **");
  9266.     Put_Line("**      attributes already associated with the path.  If**");
  9267.     Put_Line("**      they occur, just check that they conform to the **");
  9268.     Put_Line("**      pattern submitted.                              **");
  9269.     Put_Line("**********************************************************");
  9270.  
  9271.     Print_Iterator("????????", 0);
  9272.     Print_Iterator("???", 6);
  9273.     Print_Iterator("?", 3);
  9274.     Print_Iterator("?z", 2);
  9275.     Print_Iterator("?m?", 2);
  9276.     Print_Iterator("?m?z", 1);
  9277.     Print_Iterator("?m?j", 0);
  9278.     Print_Iterator("a?z", 2);
  9279.     Print_Iterator("a??z", 2);
  9280.     Print_Iterator("a?", 4);
  9281.     Print_Iterator("*", 26);
  9282.     Print_Iterator("***", 26);
  9283.     Print_Iterator("a*", 17);
  9284.     Print_Iterator("aa*", 5);
  9285.     Print_Iterator("a*a*a", 5);
  9286.     Print_Iterator("*z", 9);
  9287.     Print_Iterator("*zz", 2);
  9288.     Print_Iterator("*x*", 15);
  9289.     Print_Iterator("*xx*", 7);
  9290.     Print_Iterator("*m*", 7);
  9291.     Print_Iterator("a*a", 8);
  9292.     Print_Iterator("*m??", 3);
  9293.     Print_Iterator("a??*", 12);
  9294.     Print_Iterator("*?*?*", 23);
  9295.     Print_Iterator("amz", 1);
  9296.     Print_Iterator("a", 1);
  9297.     Print_Iterator("z", 1);
  9298. end Patt_Tst_It;
  9299. --::::::::::::::
  9300. --struct_nodes.a
  9301. --::::::::::::::
  9302. ----------------------------------------------------------------------
  9303. --                     S T R U C T _ N O D E S  
  9304. --
  9305. --
  9306. --          Test Driver for Tests of Structural_Nodes  
  9307. --
  9308. --
  9309. --
  9310. --                  Ada Software Engineering Group
  9311. --                      The MITRE Corporation
  9312. --                         McLean, VA 22102
  9313. --
  9314. --
  9315. --                   Mon Jun 24 22:17:26 EDT 1985
  9316. --
  9317. --                 (Unclassified and uncopyrighted)
  9318. --
  9319. ----------------------------------------------------------------------
  9320.  
  9321. ----------------------------------------------------------------------
  9322. --
  9323. --  Purpose:
  9324. --  -------
  9325. --    This is the test driver for the suite of tests in the package
  9326. --    Structural_Nodes.
  9327. --
  9328. --  Usage:
  9329. --  -----
  9330. --    TBS
  9331. --
  9332. --  Example:
  9333. --  -------
  9334. --    See Node_mgmt for an early example of this sort of program.
  9335. --
  9336. --  Notes:
  9337. --  -----
  9338. --   TBS
  9339. --
  9340. --  Revision History:
  9341. --  ----------------
  9342. --
  9343. -------------------------------------------------------------------
  9344. with Text_IO; use Text_IO;
  9345. with Trace; use Trace;
  9346. with Structural_Nodes_Tests; use Structural_Nodes_Tests;
  9347. procedure Struct_Nodes is
  9348.  
  9349.     Valid_Response : Boolean := FALSE;
  9350.     Phyl           : File_Type;
  9351.     MAX_FILENAME   : constant Natural := 40;  -- Arbitrary number
  9352.     Phyl_Name      : String (1..MAX_FILENAME);
  9353.     Name_Length    : Natural;
  9354.  
  9355.     Test_Output        : Structural_Nodes_Tests.Kinds_Of_Output; 
  9356.     Abort_On_Exception : Boolean;
  9357.  
  9358.     MAX_TESTS         : constant Positive := 15; -- any number you like
  9359.     Subtype Count is Integer range 0 .. MAX_TESTS;
  9360.  
  9361.     --  This is the only instantiation that would not be replaced in
  9362.     --  the "first cut" of the generic procedure Interactive_Get...
  9363.     package Count_IO is new Integer_IO (Count);
  9364.     use Count_IO;
  9365.  
  9366.     type Response is (YES,NO);
  9367.     Yesno          : Response;
  9368.  
  9369.     -- presumably we would replace this with something like
  9370.     -- procedure Get_YesNO is new Interactive_Get (Response); etc.
  9371.     package YesNo_IO is new Enumeration_IO (Response); use YesNo_IO;
  9372.  
  9373.     -- presumably we would replace this with something like
  9374.     -- procedure Get_Verbosity is new Interactive_Get (Kinds_Of_Output); etc.
  9375.     package Verbosity_IO is new Enumeration_IO (Kinds_Of_Output);
  9376.     use Verbosity_IO;
  9377.  
  9378.  
  9379.     Results : array (1..MAX_TESTS) of Test_Result;
  9380.     Test_Count   : Natural;
  9381.     Error_Count  : Natural := 0;
  9382.     Current_Test : Natural := 0;
  9383.  
  9384. begin
  9385.  
  9386.  
  9387.     Enable_All;  --!Debug
  9388.     Valid_Response := FALSE;
  9389.     while not Valid_Response loop
  9390.     Put ("Enter the highest test number to be run: ");
  9391.     GET_TEST_COUNT:
  9392.     begin
  9393.         Get (Test_Count);
  9394.         Valid_Response := TRUE;
  9395.     exception
  9396.         when DATA_ERROR =>
  9397.         Put_Line (ASCII.BEL & 
  9398.             "PLEASE ENTER AN INTEGER 0 .. " &
  9399.             Integer'image(MAX_TESTS));
  9400.     end GET_TEST_COUNT;
  9401.     end loop;
  9402.     Skip_Line (Standard_Input);
  9403.  
  9404.  
  9405.     Valid_Response := FALSE;
  9406.     while not Valid_Response loop
  9407.     Put ("Abort the test upon an unexpected exception? (Yes or No): ");
  9408.     GET_ABORT_STATUS:
  9409.     begin
  9410.         Get (Yesno);
  9411.         Valid_Response := TRUE;
  9412.     exception
  9413.         when DATA_ERROR =>
  9414.         Put_Line (ASCII.BEL & "PLEASE ENTER EITHER YES OR NO ONLY.");
  9415.     end GET_ABORT_STATUS;
  9416.     end loop;
  9417.     Skip_Line (Standard_Input);
  9418.     Abort_On_Exception := (Yesno = YES);
  9419.  
  9420.  
  9421.     -- basic general_case algorithm is in this section of code..
  9422.     -- missing the concept of max number of tries, of course...
  9423.     Valid_Response := FALSE;
  9424.     while not Valid_Response loop
  9425.     Put ("Enter the level of test output to be printed: ");
  9426.     GET_VERBOSITY:
  9427.     begin
  9428.         Get (Test_Output);
  9429.         Valid_Response := TRUE;
  9430.     exception
  9431.         when DATA_ERROR =>
  9432.         Put_Line (ASCII.BEL & 
  9433.             "PLEASE ENTER ONE OF THE FOLLOWING:");
  9434.             for i in Kinds_Of_Output'pos(Kinds_Of_Output'base'first)
  9435.             .. Kinds_Of_Output'pos(Kinds_Of_Output'base'last) 
  9436.             loop
  9437.             Put("    ");
  9438.             Put(Kinds_Of_Output'val(i));
  9439.             New_line;
  9440.             end loop;
  9441.     end GET_VERBOSITY;
  9442.     end loop;
  9443.     Skip_Line (Standard_Input); -- the skip_line is in effect a "flush"
  9444.                 -- of the input buffer...
  9445.  
  9446.     Valid_Response := FALSE;
  9447.     while not Valid_Response loop
  9448.     Put ("Do you want output redirected to a file? (yes or no): ");
  9449.     GET_ANSWER:
  9450.     begin
  9451.         Get (Yesno);
  9452.         Valid_Response := TRUE;
  9453.     exception
  9454.         when DATA_ERROR =>
  9455.         Put_Line (ASCII.BEL & "PLEASE ENTER EITHER YES OR NO ONLY.");
  9456.     end GET_ANSWER;
  9457.     end loop;
  9458.     Skip_Line (Standard_Input);
  9459.  
  9460.  
  9461.     if Yesno = YES then
  9462.     Put ("Enter the filename for redirected output: ");
  9463.     Get_Line (Phyl_Name, Name_Length);
  9464.     OPEN_FILE:
  9465.     begin
  9466.         Open (Phyl, Out_File, Phyl_Name (1..Name_Length));
  9467.         Delete (Phyl);
  9468.         Create (Phyl, Out_File, Phyl_Name (1..Name_Length));
  9469.     exception
  9470.         when NAME_ERROR =>
  9471.         Create (Phyl, Out_File, Phyl_Name (1..Name_Length));
  9472.     end OPEN_FILE;
  9473.     Set_Output (Phyl);
  9474.     end if;
  9475.  
  9476.     New_Line;
  9477.     Put_Line ("**** Beginning Execution of Structural_Nodes_Tests ****");
  9478.     Put ("    TEST_OUTPUT is set to ");
  9479.     Put_Line (Kinds_Of_Output'Image(TEST_OUTPUT));
  9480.     Put ("    ABORT_ON_EXCEPTION is set to ");
  9481.     Put_Line (Boolean'Image(ABORT_ON_EXCEPTION));
  9482.     Put ("    TEST_COUNT is set to ");
  9483.     Put (Test_Count);
  9484.     New_Line(2);
  9485.  
  9486.     Current_Test := Current_Test + 1;
  9487.     if Current_Test > Test_Count then
  9488.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  9489.     end if;
  9490.     Results (Current_Test) := Test001 (
  9491.     Verbosity => TEST_OUTPUT,
  9492.     Die_On_Exception => ABORT_ON_EXCEPTION);
  9493.     if Results (Current_Test) = Fail then
  9494.     Error_Count := Error_Count +1;
  9495.     end if;
  9496.  
  9497.     Current_Test := Current_Test + 1;
  9498.     if Current_Test > Test_Count then
  9499.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  9500.     end if;
  9501.     Results (Current_Test) := Test002 (
  9502.     Verbosity => TEST_OUTPUT,
  9503.     Die_On_Exception => ABORT_ON_EXCEPTION);
  9504.     if Results (Current_Test) = Fail then
  9505.     Error_Count := Error_Count +1;
  9506.     end if;
  9507.  
  9508.  
  9509.     Current_Test := Current_Test + 1;
  9510.     if Current_Test > Test_Count then
  9511.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  9512.     end if;
  9513.     Results (Current_Test) := Test003 (
  9514.     Verbosity => TEST_OUTPUT,
  9515.     Die_On_Exception => ABORT_ON_EXCEPTION);
  9516.     if Results (Current_Test) = Fail then
  9517.     Error_Count := Error_Count +1;
  9518.     end if;
  9519.  
  9520.     Current_Test := Current_Test + 1;
  9521.     if Current_Test > Test_Count then
  9522.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  9523.     end if;
  9524.     Results (Current_Test) := Test004 (
  9525.     Verbosity => TEST_OUTPUT,
  9526.     Die_On_Exception => ABORT_ON_EXCEPTION);
  9527.     if Results (Current_Test) = Fail then
  9528.     Error_Count := Error_Count +1;
  9529.     end if;
  9530.  
  9531.     Current_Test := Current_Test + 1;
  9532.     if Current_Test > Test_Count then
  9533.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  9534.     end if;
  9535.     Results (Current_Test) := Test005 (
  9536.     Verbosity => TEST_OUTPUT,
  9537.     Die_On_Exception => ABORT_ON_EXCEPTION);
  9538.     if Results (Current_Test) = Fail then
  9539.     Error_Count := Error_Count +1;
  9540.     end if;
  9541.  
  9542.     Current_Test := Current_Test + 1;
  9543.     if Current_Test > Test_Count then
  9544.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  9545.     end if;
  9546.     Results (Current_Test) := Test006 (
  9547.     Verbosity => TEST_OUTPUT,
  9548.     Die_On_Exception => ABORT_ON_EXCEPTION);
  9549.     if Results (Current_Test) = Fail then
  9550.     Error_Count := Error_Count +1;
  9551.     end if;
  9552.  
  9553.     Current_Test := Current_Test + 1;
  9554.     if Current_Test > Test_Count then
  9555.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  9556.     end if;
  9557.     Results (Current_Test) := Test007 (
  9558.     Verbosity => TEST_OUTPUT,
  9559.     Die_On_Exception => ABORT_ON_EXCEPTION);
  9560.     if Results (Current_Test) = Fail then
  9561.     Error_Count := Error_Count +1;
  9562.     end if;
  9563.  
  9564.     Current_Test := Current_Test + 1;
  9565.     if Current_Test > Test_Count then
  9566.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  9567.     end if;
  9568.     Results (Current_Test) := Test008 (
  9569.     Verbosity => TEST_OUTPUT,
  9570.     Die_On_Exception => ABORT_ON_EXCEPTION);
  9571.     if Results (Current_Test) = Fail then
  9572.     Error_Count := Error_Count +1;
  9573.     end if;
  9574.  
  9575.     Current_Test := Current_Test + 1;
  9576.     if Current_Test > Test_Count then
  9577.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  9578.     end if;
  9579.     Results (Current_Test) := Test009 (
  9580.     Verbosity => TEST_OUTPUT,
  9581.     Die_On_Exception => ABORT_ON_EXCEPTION);
  9582.     if Results (Current_Test) = Fail then
  9583.     Error_Count := Error_Count +1;
  9584.     end if;
  9585.  
  9586.     Current_Test := Current_Test + 1;
  9587.     if Current_Test > Test_Count then
  9588.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  9589.     end if;
  9590.     Results (Current_Test) := Test010 (
  9591.     Verbosity => TEST_OUTPUT,
  9592.     Die_On_Exception => ABORT_ON_EXCEPTION);
  9593.     if Results (Current_Test) = Fail then
  9594.     Error_Count := Error_Count +1;
  9595.     end if;
  9596.  
  9597.     Current_Test := Current_Test + 1;
  9598.     if Current_Test > Test_Count then
  9599.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  9600.     end if;
  9601.     Results (Current_Test) := Test011 (
  9602.     Verbosity => TEST_OUTPUT,
  9603.     Die_On_Exception => ABORT_ON_EXCEPTION);
  9604.     if Results (Current_Test) = Fail then
  9605.     Error_Count := Error_Count +1;
  9606.     end if;
  9607.  
  9608.     Current_Test := Current_Test + 1;
  9609.     if Current_Test > Test_Count then
  9610.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  9611.     end if;
  9612.     Results (Current_Test) := Test012 (
  9613.     Verbosity => TEST_OUTPUT,
  9614.     Die_On_Exception => ABORT_ON_EXCEPTION);
  9615.     if Results (Current_Test) = Fail then
  9616.     Error_Count := Error_Count +1;
  9617.     end if;
  9618.  
  9619.     Current_Test := Current_Test + 1;
  9620.     if Current_Test > Test_Count then
  9621.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  9622.     end if;
  9623.     Results (Current_Test) := Test013 (
  9624.     Verbosity => TEST_OUTPUT,
  9625.     Die_On_Exception => ABORT_ON_EXCEPTION);
  9626.     if Results (Current_Test) = Fail then
  9627.     Error_Count := Error_Count +1;
  9628.     end if;
  9629.  
  9630.     Current_Test := Current_Test + 1;
  9631.     if Current_Test > Test_Count then
  9632.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  9633.     end if;
  9634.     Results (Current_Test) := Test014 (
  9635.     Verbosity => TEST_OUTPUT,
  9636.     Die_On_Exception => ABORT_ON_EXCEPTION);
  9637.     if Results (Current_Test) = Fail then
  9638.     Error_Count := Error_Count +1;
  9639.     end if;
  9640.  
  9641.  
  9642.     Current_Test := Current_Test + 1;
  9643.     if Current_Test > Test_Count then
  9644.     goto PRINT_RESULTS;  -- the ultimate taboo!!
  9645.     end if;
  9646.     Results (Current_Test) := Test015 (
  9647.     Verbosity => TEST_OUTPUT,
  9648.     Die_On_Exception => ABORT_ON_EXCEPTION);
  9649.     if Results (Current_Test) = Fail then
  9650.     Error_Count := Error_Count +1;
  9651.     end if;
  9652.  
  9653.     -- Produce Summary
  9654.  
  9655.     <<PRINT_RESULTS>>
  9656.     New_Line;
  9657.     Put_Line ("**** End of Structural Nodes Tests ****"); 
  9658.     New_Line;
  9659.     New_Line;
  9660.     if Error_Count = 0 then
  9661.         New_Line;
  9662.     Put_Line ("NO TESTS FAILED. HUZZAH!");
  9663.     else
  9664.         New_Line;
  9665.     Put ("A total of ");
  9666.     Put (Error_Count);
  9667.     Put_Line (" Test(s) failed.");
  9668.     Put_Line ("The following test(s) failed:");
  9669.     for I in 1 .. Test_Count loop
  9670.         if Results (I) = fail then
  9671.         Put ("Test number ");
  9672.         Put (I);
  9673.                 New_Line;
  9674.         end if;
  9675.     end loop;
  9676.     end if;
  9677.  
  9678. end Struct_Nodes;
  9679. --::::::::::::::
  9680. --structural_nodes_tests-body.a
  9681. --::::::::::::::
  9682. ----------------------------------------------------------------------
  9683. --                    S T R U C T U R A L _ N O D E S
  9684. --                             (Package Body)
  9685. --
  9686. --
  9687. --             A Set of Simple Test Subprograms To Exercise 
  9688. --                          Structural_Nodes
  9689. --
  9690. --
  9691. --
  9692. --
  9693. --                  Ada Software Engineering Group
  9694. --                      The MITRE Corporation
  9695. --                         McLean, VA 22102
  9696. --
  9697. --
  9698. --                  Fri Feb 21 15:05:21 EST 1986
  9699. --
  9700. --                 (Unclassified and uncopyrighted)
  9701. --
  9702. ----------------------------------------------------------------------
  9703.  
  9704. ----------------------------------------------------------------------
  9705. --
  9706. --  Purpose:
  9707. --  -------
  9708. --    To provide a set of functions that exercise and test the
  9709. --    behavior of some of the services available in 
  9710. --    Structural_Nodes.
  9711. --
  9712. --  Usage:
  9713. --  -----
  9714. --    The functions made available in this package will be used
  9715. --    by a "test driver" named Struct_Nodes.  This test driver calls the 
  9716. --    different test functions in sequence.  Output from the tests can 
  9717. --    be redirected to a file.
  9718. --    Each function returns a value indicated success/failure of
  9719. --    test (i.e. expected results were/were not equal to actual
  9720. --    results).  The driver procedure keeps track of the overall
  9721. --    success/failure count and prints a test summary at the end.
  9722. --
  9723. --    *** The verbosity may be changed (e.g. if you want to add a
  9724. --    *** DUMP option).
  9725. --    The test functions have two parameters: 
  9726. --
  9727. --        Verbosity - (Kinds_Of_Output) can have the following values:
  9728. --                  NONE   - No messages are sent to Standard_Output
  9729. --                  STATUS - the test reports on its success or failure
  9730. --
  9731. --        Die_On_Exception - (Boolean)  if true, an unexpected exception
  9732. --                  will be propogated to the calling procedure,
  9733. --                  otherwise it will be caught (it is still
  9734. --                  treated as a failure, though).
  9735. --
  9736. --  Example:
  9737. --  -------
  9738. --    See the package Node_Management_Tests for some examples.
  9739. --
  9740. --  Notes:
  9741. --  -----
  9742. --    None.
  9743. --
  9744. --  Revision History:
  9745. --  ----------------
  9746. --
  9747. -------------------------------------------------------------------
  9748.  
  9749. with Text_IO; use Text_IO;
  9750. with Cais; use Cais;
  9751.  
  9752.  
  9753. package body structural_nodes_tests is
  9754.  
  9755.     use Node_Management;
  9756.     use Node_Definitions;
  9757.     use List_Utilities;
  9758.     use Structural_Nodes;
  9759.  
  9760.  
  9761. ---------------------  R E P O R T _ S T A T U S --------------------
  9762. --
  9763. --  Purpose:
  9764. --  -------
  9765. --    To print a descriptive test result message to Std. Output,
  9766. --    governed by the level of output desired for the test.
  9767. --
  9768. --  Parameters:
  9769. --  ----------
  9770. --    Verbosity        The message will be printed unless this is
  9771. --            set to NONE.
  9772. --    Msg        The string representing the message to be printed.
  9773. --
  9774. --  Exceptions:
  9775. --  ----------
  9776. --    None.
  9777. --
  9778. --  Notes:
  9779. --  -----
  9780. --    None.
  9781. --
  9782. ---------------------------------------------------------------------
  9783.  
  9784.     procedure Report_Status (
  9785.         Verbosity  : Kinds_Of_Output;
  9786.         Msg        : String) is
  9787.  
  9788.     begin
  9789.  
  9790.         if Verbosity = NONE then 
  9791.             return; -- do nothing
  9792.         else
  9793.             Put_Line (Msg);
  9794.         end if;
  9795.  
  9796.     end Report_Status;
  9797.  
  9798. ----------------------      T E S T 0 0 1      ----------------------
  9799. --
  9800. --  Purpose:
  9801. --  -------
  9802. --    This test verifies that Structural_Nodes.Create correctly handles
  9803. --    the following erroneous situations:
  9804. --        using an unopened node handle for a base
  9805. --        using an opened node handle as the node
  9806. --        using a predefined relation name
  9807. --        using a syntactically invalid relation name
  9808. --        using a syntactically invalid relation key
  9809. --        including a predefined attribute as a node attribute
  9810. --        attempting to create an existing node
  9811. --        
  9812. --
  9813. --  Parameters:
  9814. --  ----------
  9815. --    Verbosity        Specifies the level of output desired. Options:
  9816. --            NONE:   No output from this test
  9817. --            STATUS: Report on success or FAILure of specific
  9818. --                tests
  9819. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  9820. --               If FALSE, the exception will be handled and the
  9821. --               test will return a value of FAIL.
  9822. --    return Test_Result   Simply indicates pass/FAIL of the test.
  9823. --
  9824. --  Exceptions:
  9825. --  ----------
  9826. --    None.
  9827. --
  9828. --  Notes:
  9829. --  -----
  9830. --    None.
  9831. --
  9832. ---------------------------------------------------------------------
  9833.  
  9834.     function Test001 (
  9835.         Verbosity        : Kinds_Of_Output := STATUS;
  9836.         Die_On_Exception : Boolean := FALSE)
  9837.         return Test_Result is
  9838.  
  9839.     Node            : Node_Definitions.Node_Type;
  9840.     Base            : Node_Definitions.Node_Type;
  9841.     Simple_List     : List_Type;
  9842.     Result          : Test_Result := PASS;
  9843.     begin
  9844.     --        attempting to use a predefined relation
  9845.     begin
  9846.         Create_Node (Node => Node,
  9847.         Name => "'Parent'Job'Parent");
  9848.     exception
  9849.         when Node_Definitions.USE_ERROR =>
  9850.         Node_Management.Close (Node);  -- as expected
  9851.         when others =>
  9852.         Report_Status (Verbosity,
  9853.             "Test 001: Creating w/ predefined relation had problems");
  9854.         raise;
  9855.     end;
  9856.     --        using an unopened node handle for a base
  9857.     begin
  9858.         Create_Node (
  9859.         Node => Node,
  9860.         Base => Base);
  9861.  
  9862.     exception
  9863.         when Node_Definitions.STATUS_ERROR =>
  9864.         Node_Management.Close (Node);  -- as expected
  9865.         when others =>
  9866.         Report_Status (Verbosity,
  9867.             "Test 001: Open w/ closed Base had problems");
  9868.         raise;
  9869.     end;
  9870.     --        using an opened node handle as the node
  9871.     begin
  9872.         Open (Node, "'parent'Job");
  9873.         Create_Node (
  9874.         Node => Node,
  9875.         Base => Base);
  9876.     exception
  9877.         when Node_Definitions.STATUS_ERROR =>
  9878.         Node_Management.Close (Node);  -- as expected
  9879.         when others =>
  9880.         Report_Status (Verbosity,
  9881.             "Test 001: Open w/ open Node had problems");
  9882.         raise;
  9883.     end;
  9884.     --        using a syntactically invalid relation name
  9885. --  this runs into problem in list_utilities.find'2 (a loop)
  9886.     begin
  9887.         Open (Base, "'current_node'job",
  9888.         (1 => APPEND_RELATIONSHIPS));
  9889.         Create_Node (
  9890.         Node => Node,
  9891.         Base => Base,
  9892.         Relation => "xyz+123");
  9893.     exception
  9894.         when Node_Definitions.NAME_ERROR =>
  9895.         Node_Management.Close (Node);  -- as expected
  9896.         Node_Management.Close (Base);  -- as expected
  9897.         when others =>
  9898.         Report_Status (Verbosity,
  9899.             "Test 001: Open w/ invalid relation name had problems");
  9900.         raise;
  9901.     end;
  9902.     --        using a syntactically invalid relation key
  9903.     begin
  9904.         Open (Base, "'current_node'job",
  9905.         (1 => APPEND_RELATIONSHIPS));
  9906.         Create_Node (
  9907.         Node => Node,
  9908.         Base => Base,
  9909.         Key => "xyz+123");
  9910.     exception
  9911.         when Node_Definitions.NAME_ERROR =>
  9912.         Node_Management.Close (Node);  -- as expected
  9913.         Node_Management.Close (Base);  -- as expected
  9914.         when others =>
  9915.         Report_Status (Verbosity,
  9916.             "Test 001: Open w/ invalid relation key had problems");
  9917.         raise;
  9918.     end;
  9919.     --        using a predefined relation name
  9920.     --        creating an existing node
  9921.     --        including a predefined attribute as a node attribute
  9922.     return Result;
  9923.     exception
  9924.  
  9925.         when OTHERS =>
  9926.             Report_Status (Verbosity,
  9927.                 "**** Test 001: UNHANDLED EXCEPTION");
  9928.             if Die_On_Exception then
  9929.                 raise;
  9930.             else
  9931.                 return FAIL;
  9932.             end if;
  9933.     end Test001;
  9934.  
  9935. ----------------------      T E S T 0 0 2      ----------------------
  9936. --
  9937. --  Purpose:
  9938. --  -------
  9939. --    Simple test of creating and deleting a node.
  9940. --
  9941. --  Parameters:
  9942. --  ----------
  9943. --    Verbosity        Specifies the level of output desired. Options:
  9944. --            NONE:   No output from this test
  9945. --            STATUS: Report on success or FAILure of specific
  9946. --                tests
  9947. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  9948. --               If FALSE, the exception will be handled and the
  9949. --               test will return a value of FAIL.
  9950. --    return Test_Result   Simply indicates pass/FAIL of the test.
  9951. --
  9952. --  Exceptions:
  9953. --  ----------
  9954. --    None.
  9955. --
  9956. --  Notes:
  9957. --  -----
  9958. --    None.
  9959. --
  9960. ---------------------------------------------------------------------
  9961.  
  9962.     function Test002 (
  9963.         Verbosity        : Kinds_Of_Output := STATUS;
  9964.         Die_On_Exception : Boolean := FALSE)
  9965.         return Test_Result is
  9966.  
  9967.     Node      : Node_Definitions.Node_Type;
  9968.     Result    : Test_Result := PASS;
  9969.  
  9970.     begin
  9971.     -- make certain we are starting from scratch...
  9972.     DELETE1:
  9973.     begin
  9974.         Open (Node, "'current_Node'new_rel(New_Key)",
  9975.         (1 => EXCLUSIVE_WRITE, 2=> READ_RELATIONSHIPS));
  9976.         Delete_Node (Node);
  9977.     exception
  9978.         when Node_Definitions.NAME_ERROR =>
  9979.         Close (Node);   -- Open croaked trying to get to it...
  9980.     end DELETE1;
  9981.  
  9982.     Create_Node (Node, Name => "'current_Node'new_rel(New_Key)");
  9983.     Close (Node);
  9984.     Open (Node, "'current_Node'new_rel(New_Key)",
  9985.         (1 => EXCLUSIVE_WRITE, 2=> READ_RELATIONSHIPS));
  9986.     Delete_Node (Node);
  9987.  
  9988.     return Result;
  9989.     
  9990.     exception
  9991.         when OTHERS =>
  9992.             Report_Status (Verbosity,
  9993.                 "**** Test 002: UNHANDLED EXCEPTION");
  9994.             if Die_On_Exception then
  9995.                 raise;
  9996.             else
  9997.                 return (FAIL);
  9998.             end if;
  9999.     end Test002;
  10000.  
  10001. ----------------------      T E S T 0 0 3      ----------------------
  10002. --
  10003. --  Purpose:
  10004. --  -------
  10005. --
  10006. --  Parameters:
  10007. --  ----------
  10008. --    Verbosity        Specifies the level of output desired. Options:
  10009. --            NONE:   No output from this test
  10010. --            STATUS: Report on success or FAILure of specific
  10011. --                tests
  10012. --            NONE:   Same as STATUS, with the additional 
  10013. --                output of the string representation of
  10014. --                the list_type(s) used.
  10015. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  10016. --               If FALSE, the exception will be handled and the
  10017. --               test will return a value of FAIL.
  10018. --    return Test_Result   Simply indicates pass/FAIL of the test.
  10019. --
  10020. --  Exceptions:
  10021. --  ----------
  10022. --    None.
  10023. --
  10024. --  Notes:
  10025. --  -----
  10026. --    None.
  10027. --
  10028. ---------------------------------------------------------------------
  10029.  
  10030.     function Test003 (
  10031.         Verbosity        : Kinds_Of_Output := STATUS;
  10032.         Die_On_Exception : Boolean := FALSE)
  10033.         return Test_Result is
  10034.  
  10035.     Result : Test_Result := FAIL;
  10036.     begin
  10037.         return Result;
  10038.     exception
  10039.         when OTHERS =>
  10040.             Report_Status (Verbosity,
  10041.                 "**** Test 003: UNHANDLED EXCEPTION");
  10042.             if Die_On_Exception then
  10043.                 raise;
  10044.             else
  10045.                 return (FAIL);
  10046.             end if;
  10047.     end Test003;
  10048.  
  10049. ----------------------      T E S T 0 0 4      ----------------------
  10050. --
  10051. --  Purpose:
  10052. --  -------
  10053. --
  10054. --  Parameters:
  10055. --  ----------
  10056. --    Verbosity        Specifies the level of output desired. Options:
  10057. --            NONE:   No output from this test
  10058. --            STATUS: Report on success or FAILure of specific
  10059. --                tests
  10060. --            NONE:   Same as STATUS, with the additional 
  10061. --                output of the string representation of
  10062. --                the list_type(s) used.
  10063. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  10064. --               If FALSE, the exception will be handled and the
  10065. --               test will return a value of FAIL.
  10066. --    return Test_Result   Simply indicates pass/FAIL of the test.
  10067. --
  10068. --  Exceptions:
  10069. --  ----------
  10070. --    None.
  10071. --
  10072. --  Notes:
  10073. --  -----
  10074. --
  10075. ---------------------------------------------------------------------
  10076.  
  10077.     function Test004 (
  10078.         Verbosity        : Kinds_Of_Output := STATUS;
  10079.         Die_On_Exception : Boolean := FALSE)
  10080.         return Test_Result is
  10081.  
  10082.     Result    : Test_Result := FAIL;
  10083.  
  10084.     begin
  10085.     return Result;
  10086.     exception
  10087.         when OTHERS =>
  10088.             Report_Status (Verbosity,
  10089.                 "**** Test 004: UNHANDLED EXCEPTION");
  10090.             if Die_On_Exception then
  10091.                 raise;
  10092.             else
  10093.                 return (FAIL);
  10094.             end if;
  10095.     end Test004;
  10096.  
  10097. ----------------------      T E S T 0 0 5      ----------------------
  10098. --
  10099. --  Purpose:
  10100. --  -------
  10101. --
  10102. --  Parameters:
  10103. --  ----------
  10104. --    Verbosity        Specifies the level of output desired. Options:
  10105. --            NONE:   No output from this test
  10106. --            STATUS: Report on success or FAILure of specific
  10107. --                tests
  10108. --            NONE:   Same as STATUS, with the additional 
  10109. --                output of the string representation of
  10110. --                the list_type(s) used.
  10111. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  10112. --               If FALSE, the exception will be handled and the
  10113. --               test will return a value of FAIL.
  10114. --    return Test_Result   Simply indicates pass/FAIL of the test.
  10115. --
  10116. --  Exceptions:
  10117. --  ----------
  10118. --    None.
  10119. --
  10120. --  Notes:
  10121. --  -----
  10122. --    None.
  10123. --
  10124. ---------------------------------------------------------------------
  10125.  
  10126.     function Test005 (
  10127.         Verbosity        : Kinds_Of_Output := STATUS;
  10128.         Die_On_Exception : Boolean := FALSE)
  10129.         return Test_Result is
  10130.  
  10131.         Result      : Test_Result := FAIL;   
  10132.     begin
  10133.         return Result;
  10134.     exception
  10135.         when OTHERS =>
  10136.             Report_Status (Verbosity,
  10137.                 "**** Test 005: UNHANDLED EXCEPTION");
  10138.             if Die_On_Exception then
  10139.                 raise;
  10140.             else
  10141.                 return (FAIL);
  10142.             end if;
  10143.     end Test005;
  10144.  
  10145.  
  10146. ----------------------      T E S T 0 0 6      ----------------------
  10147. --
  10148. --  Purpose:
  10149. --  -------
  10150. --
  10151. --  Parameters:
  10152. --  ----------
  10153. --    Verbosity        Specifies the level of output desired. Options:
  10154. --            NONE:   No output from this test
  10155. --            STATUS: Report on success or FAILure of specific
  10156. --                tests
  10157. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  10158. --               If FALSE, the exception will be handled and the
  10159. --               test will return a value of FAIL.
  10160. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  10161. --
  10162. --  Exceptions:
  10163. --  ----------
  10164. --    None.
  10165. --
  10166. --  Notes:
  10167. --  -----
  10168. --    None.
  10169. --
  10170. ---------------------------------------------------------------------
  10171.  
  10172.     function Test006 (
  10173.         Verbosity        : Kinds_Of_Output := STATUS;
  10174.         Die_On_Exception : Boolean := FALSE)
  10175.         return Test_Result is
  10176.  
  10177.         Result      : Test_Result := FAIL;   
  10178.  
  10179.     begin
  10180.  
  10181.         return Result;
  10182.  
  10183.     exception
  10184.  
  10185.         when others =>
  10186.             Report_Status (Verbosity,
  10187.                 "**** Test 006: UNHANDLED EXCEPTION");
  10188.  
  10189.             if Die_On_Exception then
  10190.                 raise;
  10191.             else
  10192.                 return (FAIL);
  10193.             end if;
  10194.     end Test006;
  10195.  
  10196.  
  10197. ----------------------      T E S T 0 0 7      ----------------------
  10198. --
  10199. --  Purpose:
  10200. --  -------
  10201. --
  10202. --  Parameters:
  10203. --  ----------
  10204. --    Verbosity        Specifies the level of output desired. Options:
  10205. --            NONE:   No output from this test
  10206. --            STATUS: Report on success or FAILure of specific
  10207. --                tests
  10208. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  10209. --               If FALSE, the exception will be handled and the
  10210. --               test will return a value of FAIL.
  10211. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  10212. --
  10213. --  Exceptions:
  10214. --  ----------
  10215. --    None.
  10216. --
  10217. --  Notes:
  10218. --  -----
  10219. --    None.
  10220. --
  10221. ---------------------------------------------------------------------
  10222.  
  10223.     function Test007 (
  10224.         Verbosity        : Kinds_Of_Output := STATUS;
  10225.         Die_On_Exception : Boolean := FALSE)
  10226.         return Test_Result is
  10227.  
  10228.         Result      : Test_Result := FAIL;   
  10229.  
  10230.     begin
  10231.  
  10232.         return Result;
  10233.  
  10234.     exception
  10235.  
  10236.         when others =>
  10237.             Report_Status (Verbosity,
  10238.                 "**** Test 007: UNHANDLED EXCEPTION");
  10239.  
  10240.             if Die_On_Exception then
  10241.                 raise;
  10242.             else
  10243.                 return (FAIL);
  10244.             end if;
  10245.     end Test007;
  10246.  
  10247. ----------------------      T E S T 0 0 8      ----------------------
  10248. --
  10249. --  Purpose:
  10250. --  -------
  10251. --
  10252. --  Parameters:
  10253. --  ----------
  10254. --    Verbosity        Specifies the level of output desired. Options:
  10255. --            NONE:   No output from this test
  10256. --            STATUS: Report on success or FAILure of specific
  10257. --                tests
  10258. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  10259. --               If FALSE, the exception will be handled and the
  10260. --               test will return a value of FAIL.
  10261. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  10262. --
  10263. --  Exceptions:
  10264. --  ----------
  10265. --    None.
  10266. --
  10267. --  Notes:
  10268. --  -----
  10269. --    None.
  10270. --
  10271. ---------------------------------------------------------------------
  10272.  
  10273.     function Test008 (
  10274.         Verbosity        : Kinds_Of_Output := STATUS;
  10275.         Die_On_Exception : Boolean := FALSE)
  10276.         return Test_Result is
  10277.  
  10278.         Result      : Test_Result := FAIL;   
  10279.  
  10280.     begin
  10281.  
  10282.         return Result;
  10283.  
  10284.     exception
  10285.  
  10286.         when others =>
  10287.             Report_Status (Verbosity,
  10288.                 "**** Test 008: UNHANDLED EXCEPTION");
  10289.  
  10290.             if Die_On_Exception then
  10291.                 raise;
  10292.             else
  10293.                 return (FAIL);
  10294.             end if;
  10295.     end Test008;
  10296.  
  10297. ----------------------      T E S T 0 0 9      ----------------------
  10298. --
  10299. --  Purpose:
  10300. --  -------
  10301. --
  10302. --  Parameters:
  10303. --  ----------
  10304. --    Verbosity        Specifies the level of output desired. Options:
  10305. --            NONE:   No output from this test
  10306. --            STATUS: Report on success or FAILure of specific
  10307. --                tests
  10308. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  10309. --               If FALSE, the exception will be handled and the
  10310. --               test will return a value of FAIL.
  10311. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  10312. --
  10313. --  Exceptions:
  10314. --  ----------
  10315. --    None.
  10316. --
  10317. --  Notes:
  10318. --  -----
  10319. --    None.
  10320. --
  10321. ---------------------------------------------------------------------
  10322.  
  10323.     function Test009 (
  10324.         Verbosity        : Kinds_Of_Output := STATUS;
  10325.         Die_On_Exception : Boolean := FALSE)
  10326.         return Test_Result is
  10327.  
  10328.         Result      : Test_Result := FAIL;   
  10329.  
  10330.     begin
  10331.  
  10332.         return Result;
  10333.  
  10334.     exception
  10335.  
  10336.         when others =>
  10337.             Report_Status (Verbosity,
  10338.                 "**** Test 009: UNHANDLED EXCEPTION");
  10339.  
  10340.             if Die_On_Exception then
  10341.                 raise;
  10342.             else
  10343.                 return (FAIL);
  10344.             end if;
  10345.     end Test009;
  10346.  
  10347. ----------------------      T E S T 0 1 0      ----------------------
  10348. --
  10349. --  Purpose:
  10350. --  -------
  10351. --
  10352. --  Parameters:
  10353. --  ----------
  10354. --    Verbosity        Specifies the level of output desired. Options:
  10355. --            NONE:   No output from this test
  10356. --            STATUS: Report on success or FAILure of specific
  10357. --                tests
  10358. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  10359. --               If FALSE, the exception will be handled and the
  10360. --               test will return a value of FAIL.
  10361. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  10362. --
  10363. --  Exceptions:
  10364. --  ----------
  10365. --    None.
  10366. --
  10367. --  Notes:
  10368. --  -----
  10369. --    None.
  10370. --
  10371. ---------------------------------------------------------------------
  10372.  
  10373.     function Test010 (
  10374.         Verbosity        : Kinds_Of_Output := STATUS;
  10375.         Die_On_Exception : Boolean := FALSE)
  10376.         return Test_Result is
  10377.  
  10378.         Result      : Test_Result := FAIL;   
  10379.  
  10380.     begin
  10381.  
  10382.         return Result;
  10383.  
  10384.     exception
  10385.  
  10386.         when others =>
  10387.             Report_Status (Verbosity,
  10388.                 "**** Test 010: UNHANDLED EXCEPTION");
  10389.  
  10390.             if Die_On_Exception then
  10391.                 raise;
  10392.             else
  10393.                 return (FAIL);
  10394.             end if;
  10395.     end Test010;
  10396.  
  10397. ----------------------      T E S T 0 1 1      ----------------------
  10398. --
  10399. --  Purpose:
  10400. --  -------
  10401. --
  10402. --  Parameters:
  10403. --  ----------
  10404. --    Verbosity        Specifies the level of output desired. Options:
  10405. --            NONE:   No output from this test
  10406. --            STATUS: Report on success or FAILure of specific
  10407. --                tests
  10408. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  10409. --               If FALSE, the exception will be handled and the
  10410. --               test will return a value of FAIL.
  10411. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  10412. --
  10413. --  Exceptions:
  10414. --  ----------
  10415. --    None.
  10416. --
  10417. --  Notes:
  10418. --  -----
  10419. --    None.
  10420. --
  10421. ---------------------------------------------------------------------
  10422.  
  10423.     function Test011 (
  10424.         Verbosity        : Kinds_Of_Output := STATUS;
  10425.         Die_On_Exception : Boolean := FALSE)
  10426.         return Test_Result is
  10427.  
  10428.         Result      : Test_Result := FAIL;   
  10429.  
  10430.     begin
  10431.  
  10432.         return Result;
  10433.  
  10434.     exception
  10435.  
  10436.         when others =>
  10437.             Report_Status (Verbosity,
  10438.                 "**** Test 011: UNHANDLED EXCEPTION");
  10439.  
  10440.             if Die_On_Exception then
  10441.                 raise;
  10442.             else
  10443.                 return (FAIL);
  10444.             end if;
  10445.     end Test011;
  10446.  
  10447. ----------------------      T E S T 0 1 2      ----------------------
  10448. --
  10449. --  Purpose:
  10450. --  -------
  10451. --
  10452. --  Parameters:
  10453. --  ----------
  10454. --    Verbosity        Specifies the level of output desired. Options:
  10455. --            NONE:   No output from this test
  10456. --            STATUS: Report on success or FAILure of specific
  10457. --                tests
  10458. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  10459. --               If FALSE, the exception will be handled and the
  10460. --               test will return a value of FAIL.
  10461. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  10462. --
  10463. --  Exceptions:
  10464. --  ----------
  10465. --    None.
  10466. --
  10467. --  Notes:
  10468. --  -----
  10469. --    None.
  10470. --
  10471. ---------------------------------------------------------------------
  10472.  
  10473.     function Test012 (
  10474.         Verbosity        : Kinds_Of_Output := STATUS;
  10475.         Die_On_Exception : Boolean := FALSE)
  10476.         return Test_Result is
  10477.  
  10478.         Result      : Test_Result := FAIL;   
  10479.  
  10480.     begin
  10481.  
  10482.         return Result;
  10483.  
  10484.     exception
  10485.  
  10486.         when others =>
  10487.             Report_Status (Verbosity,
  10488.                 "**** Test 012: UNHANDLED EXCEPTION");
  10489.  
  10490.             if Die_On_Exception then
  10491.                 raise;
  10492.             else
  10493.                 return (FAIL);
  10494.             end if;
  10495.     end Test012;
  10496.  
  10497. ----------------------      T E S T 0 1 3      ----------------------
  10498. --
  10499. --  Purpose:
  10500. --  -------
  10501. --
  10502. --  Parameters:
  10503. --  ----------
  10504. --    Verbosity        Specifies the level of output desired. Options:
  10505. --            NONE:   No output from this test
  10506. --            STATUS: Report on success or FAILure of specific
  10507. --                tests
  10508. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  10509. --               If FALSE, the exception will be handled and the
  10510. --               test will return a value of FAIL.
  10511. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  10512. --
  10513. --  Exceptions:
  10514. --  ----------
  10515. --    None.
  10516. --
  10517. --  Notes:
  10518. --  -----
  10519. --    None.
  10520. --
  10521. ---------------------------------------------------------------------
  10522.  
  10523.     function Test013 (
  10524.         Verbosity        : Kinds_Of_Output := STATUS;
  10525.         Die_On_Exception : Boolean := FALSE)
  10526.         return Test_Result is
  10527.  
  10528.         Result      : Test_Result := FAIL;   
  10529.  
  10530.     begin
  10531.  
  10532.         return Result;
  10533.  
  10534.     exception
  10535.  
  10536.         when others =>
  10537.             Report_Status (Verbosity,
  10538.                 "**** Test 013: UNHANDLED EXCEPTION");
  10539.  
  10540.             if Die_On_Exception then
  10541.                 raise;
  10542.             else
  10543.                 return (FAIL);
  10544.             end if;
  10545.     end Test013;
  10546.  
  10547. ----------------------      T E S T 0 1 4      ----------------------
  10548. --
  10549. --  Purpose:
  10550. --  -------
  10551. --
  10552. --  Parameters:
  10553. --  ----------
  10554. --    Verbosity        Specifies the level of output desired. Options:
  10555. --            NONE:   No output from this test
  10556. --            STATUS: Report on success or FAILure of specific
  10557. --                tests
  10558. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  10559. --               If FALSE, the exception will be handled and the
  10560. --               test will return a value of FAIL.
  10561. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  10562. --
  10563. --  Exceptions:
  10564. --  ----------
  10565. --    None.
  10566. --
  10567. --  Notes:
  10568. --  -----
  10569. --    None.
  10570. --
  10571. ---------------------------------------------------------------------
  10572.  
  10573.     function Test014 (
  10574.         Verbosity        : Kinds_Of_Output := STATUS;
  10575.         Die_On_Exception : Boolean := FALSE)
  10576.         return Test_Result is
  10577.  
  10578.         Result      : Test_Result := FAIL;   
  10579.  
  10580.     begin
  10581.  
  10582.         return Result;
  10583.  
  10584.     exception
  10585.  
  10586.         when others =>
  10587.             Report_Status (Verbosity,
  10588.                 "**** Test 014: UNHANDLED EXCEPTION");
  10589.  
  10590.             if Die_On_Exception then
  10591.                 raise;
  10592.             else
  10593.                 return (FAIL);
  10594.             end if;
  10595.     end Test014;
  10596.  
  10597. ----------------------      T E S T 0 1 5      ----------------------
  10598. --
  10599. --  Purpose:
  10600. --  -------
  10601. --
  10602. --  Parameters:
  10603. --  ----------
  10604. --    Verbosity        Specifies the level of output desired. Options:
  10605. --            NONE:   No output from this test
  10606. --            STATUS: Report on success or FAILure of specific
  10607. --                tests
  10608. --    Die_On_Exception       If TRUE, an unhandled exception will be propogated.
  10609. --               If FALSE, the exception will be handled and the
  10610. --               test will return a value of FAIL.
  10611. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  10612. --
  10613. --  Exceptions:
  10614. --  ----------
  10615. --    None.
  10616. --
  10617. --  Notes:
  10618. --  -----
  10619. --    None.
  10620. --
  10621. ---------------------------------------------------------------------
  10622.  
  10623.     function Test015 (
  10624.         Verbosity        : Kinds_Of_Output := STATUS;
  10625.         Die_On_Exception : Boolean := FALSE)
  10626.         return Test_Result is
  10627.  
  10628.         Result      : Test_Result := FAIL;   
  10629.  
  10630.     begin
  10631.  
  10632.         return Result;
  10633.  
  10634.     exception
  10635.  
  10636.         when others =>
  10637.             Report_Status (Verbosity,
  10638.                 "**** Test 015: UNHANDLED EXCEPTION");
  10639.  
  10640.             if Die_On_Exception then
  10641.                 raise;
  10642.             else
  10643.                 return (FAIL);
  10644.             end if;
  10645.     end Test015;
  10646.  
  10647. end structural_nodes_tests;
  10648. --::::::::::::::
  10649. --structural_nodes_tests-spec.a
  10650. --::::::::::::::
  10651. ----------------------------------------------------------------------
  10652. --                    S T R U C T U R A L _ N O D E S
  10653. --                        (Package Specification)
  10654. --
  10655. --
  10656. --             A Set of Simple Test Subprograms To Exercise 
  10657. --                          Structural_Nodes
  10658. --
  10659. --
  10660. --
  10661. --                  Ada Software Engineering Group
  10662. --                      The MITRE Corporation
  10663. --                         McLean, VA 22102
  10664. --
  10665. --
  10666. --                  Mon Jun 24 22:26:04 EDT 1985
  10667. --
  10668. --                 (Unclassified and uncopyrighted)
  10669. --
  10670. ----------------------------------------------------------------------
  10671.  
  10672. ----------------------------------------------------------------------
  10673. --
  10674. --  Purpose:
  10675. --  -------
  10676. --    To provide a set of functions that exercise and test the
  10677. --    behavior of some of the services available in 
  10678. --    Structural_Nodes.
  10679. --
  10680. --  Usage:
  10681. --  -----
  10682. --    The functions made available in this package will be used
  10683. --    by a "test driver" named Struct_Nodes.  This test driver calls the 
  10684. --    different test functions in sequence.  Output from the tests can 
  10685. --    be redirected to a file.
  10686. --    Each function returns a value indicated success/failure of
  10687. --    test (i.e. expected results were/were not equal to actual
  10688. --    results).  The driver procedure keeps track of the overall
  10689. --    success/failure count and prints a test summary at the end.
  10690. --
  10691. --    *** The verbosity may be changed (e.g. if you want to add a
  10692. --    *** DUMP option).
  10693. --    The test functions have two parameters: 
  10694. --
  10695. --        Verbosity - (Kinds_Of_Output) can have the following values:
  10696. --                  NONE   - No messages are sent to Standard_Output
  10697. --                  STATUS - the test reports on its success or failure
  10698. --
  10699. --        Die_On_Exception - (Boolean)  if true, an unexpected exception
  10700. --                  will be propogated to the calling procedure,
  10701. --                  otherwise it will be caught (it is still
  10702. --                  treated as a failure, though).
  10703. --
  10704. --  Example:
  10705. --  -------
  10706. --    See the package Node_Management_Tests for some examples.
  10707. --
  10708. --  Notes:
  10709. --  -----
  10710. --    None.
  10711. --
  10712. --  Revision History:
  10713. --  ----------------
  10714. --
  10715. -------------------------------------------------------------------
  10716.  
  10717. package Structural_Nodes_Tests is 
  10718.  
  10719.     type Test_Result is (PASS, FAIL);  
  10720.  
  10721.     --*** See note above re possible additional values.
  10722.     type Kinds_Of_Output is (NONE, STATUS);
  10723.  
  10724.  
  10725.     function Test001 (
  10726.     Verbosity        : Kinds_Of_Output := STATUS;
  10727.         Die_On_Exception : Boolean := FALSE)
  10728.         return Test_Result;
  10729.  
  10730.     function Test002 (
  10731.     Verbosity        : Kinds_Of_Output := STATUS;
  10732.         Die_On_Exception : Boolean := FALSE)
  10733.         return Test_Result;
  10734.  
  10735.     function Test003 (
  10736.     Verbosity        : Kinds_Of_Output := STATUS;
  10737.         Die_On_Exception : Boolean := FALSE)
  10738.         return Test_Result;
  10739.  
  10740.     function Test004 (
  10741.     Verbosity        : Kinds_Of_Output := STATUS;
  10742.         Die_On_Exception : Boolean := FALSE)
  10743.         return Test_Result;
  10744.  
  10745.     function Test005 (
  10746.     Verbosity        : Kinds_Of_Output := STATUS;
  10747.         Die_On_Exception : Boolean := FALSE)
  10748.         return Test_Result;
  10749.  
  10750.     function Test006 (
  10751.     Verbosity        : Kinds_Of_Output := STATUS;
  10752.         Die_On_Exception : Boolean := FALSE)
  10753.         return Test_Result;
  10754.  
  10755.     function Test007 (
  10756.     Verbosity        : Kinds_Of_Output := STATUS;
  10757.         Die_On_Exception : Boolean := FALSE)
  10758.         return Test_Result;
  10759.  
  10760.     function Test008 (
  10761.     Verbosity        : Kinds_Of_Output := STATUS;
  10762.         Die_On_Exception : Boolean := FALSE)
  10763.         return Test_Result;
  10764.  
  10765.     function Test009 (
  10766.     Verbosity        : Kinds_Of_Output := STATUS;
  10767.         Die_On_Exception : Boolean := FALSE)
  10768.         return Test_Result;
  10769.  
  10770.     function Test010 (
  10771.     Verbosity        : Kinds_Of_Output := STATUS;
  10772.         Die_On_Exception : Boolean := FALSE)
  10773.         return Test_Result;
  10774.  
  10775.     function Test011 (
  10776.     Verbosity        : Kinds_Of_Output := STATUS;
  10777.         Die_On_Exception : Boolean := FALSE)
  10778.         return Test_Result;
  10779.  
  10780.     function Test012 (
  10781.     Verbosity        : Kinds_Of_Output := STATUS;
  10782.         Die_On_Exception : Boolean := FALSE)
  10783.         return Test_Result;
  10784.  
  10785.     function Test013 (
  10786.     Verbosity        : Kinds_Of_Output := STATUS;
  10787.         Die_On_Exception : Boolean := FALSE)
  10788.         return Test_Result;
  10789.  
  10790.     function Test014 (
  10791.     Verbosity        : Kinds_Of_Output := STATUS;
  10792.         Die_On_Exception : Boolean := FALSE)
  10793.         return Test_Result;
  10794.  
  10795.     function Test015 (
  10796.     Verbosity        : Kinds_Of_Output := STATUS;
  10797.         Die_On_Exception : Boolean := FALSE)
  10798.         return Test_Result;
  10799.  
  10800. end Structural_Nodes_Tests;
  10801. --::::::::::::::
  10802. --test_internals.a
  10803. --::::::::::::::
  10804. with Cais; use Cais;
  10805. procedure Test_Internals is
  10806. begin
  10807.     Delete_User;
  10808. end Test_Internals;
  10809. --::::::::::::::
  10810. --test_node_iterate.a
  10811. --::::::::::::::
  10812. with Cais; use Cais;
  10813. with Trace;
  10814. with text_io; use text_io;
  10815. procedure test_node_iterate is
  10816.  
  10817. use node_management;
  10818. use node_definitions;
  10819.  
  10820.     Node    : Cais.Node_Type;
  10821.     Node1    : Cais.Node_Type;
  10822.     Next_Node    : Cais.Node_Type;
  10823.     Io_File    : Cais.Text_Io.File_Type;
  10824.     Iter    : Node_Iterator;
  10825.  
  10826.     procedure Test_Setup is
  10827.     begin
  10828.     Put_Line("CREATE --TEST");
  10829.     Structural_Nodes.Create_Node(Node, Name=>"'current_user.test_att");
  10830.     Close(Node);
  10831.     Open(Node, "'current_user.test_att",
  10832.             (1=>read_relationships, 2=>append_relationships));
  10833.     Put_Line("CREATE --a(b)");
  10834.     Structural_Nodes.Create_Node(Node1, Node, "a" , "b" );
  10835.     Put_Line("huzzah");
  10836.     Close(Node1);
  10837.     Put_Line("CREATE --a(ab)");
  10838.     Cais.Text_Io.Create(Io_File, Node, "a" , "ab");
  10839.     Cais.Text_Io.Close(Io_File);
  10840.     Put_Line("CREATE --b(a)");
  10841.     Cais.Text_Io.Create(Io_File, Node, "b" , "a" );
  10842.     Cais.Text_Io.Close(Io_File);
  10843.     Put_Line("CREATE --ab(a)");
  10844.     Cais.Text_Io.Create(Io_File, Node, "ab", "a" );
  10845.     Cais.Text_Io.Close(Io_File);
  10846.     Put_Line("CREATE --ab(ab)");
  10847.     Cais.Text_Io.Create(Io_File, Node, "ab", "ab");
  10848.     Cais.Text_Io.Close(Io_File);
  10849.     Put_Line("Nodes created are: test'a(b)   test'a(ab)  test'b(a)");
  10850.     Put_Line("                   test'ab(a)  test'ab(ab)          ");
  10851.     Put_Line("--TEST SETUP COMPLETED");
  10852.     end Test_Setup;
  10853.  
  10854.     procedure Test_Cleanup is
  10855.     begin
  10856.     Put_Line("--BEGIN TEST CLEANUP");
  10857.     Open(Node1, "'current_user.test_att'a(b)",
  10858.             (exclusive_write, read_relationships) );
  10859.     Delete_Node(Node1);
  10860.     Open(Node1, "'current_user.test_att'a(ab)",
  10861.             (exclusive_write, read_relationships) );
  10862.     Delete_Node(Node1);
  10863.     Open(Node1, "'current_user.test_att'b(a)",
  10864.             (exclusive_write, read_relationships) );
  10865.     Delete_Node(Node1);
  10866.     Open(Node1, "'current_user.test_att'ab(a)",
  10867.             (exclusive_write, read_relationships) );
  10868.     Delete_Node(Node1);
  10869.     Open(Node1, "'current_user.test_att'ab(ab)",
  10870.             (exclusive_write, read_relationships) );
  10871.     Delete_Node(Node1);
  10872.     Open(Node1, "'current_user.test_att",
  10873.             (exclusive_write, read_relationships) );
  10874.     Delete_Node(Node1);
  10875.     end Test_Cleanup;
  10876.  
  10877. begin
  10878.     Trace.Enable_All;
  10879.     Test_Setup;
  10880.  
  10881.     New_Line;
  10882.     New_Line;
  10883.     Put_Line("2 EXPECTED, Iterator over ( *, a ) (File, Primary) yeilds :");
  10884.     Iterate(Iter, Node, File, "*", "a", true);
  10885.     while More(Iter) loop
  10886.     Get_Next(Iter, Next_Node);
  10887.     Put("     ");
  10888.     Put(Path_Relation(Next_Node)); Put("( ");
  10889.     Put(Path_Key     (Next_Node)); Put(" )");
  10890.     New_Line;
  10891.     end loop;
  10892.  
  10893.  
  10894.     New_Line;
  10895.     New_Line;
  10896.     Put_Line("0 EXPECTED, Iterator over ( *, a ) (Structural, Primary) yeilds :");
  10897.     Iterate(Iter, Node, Structural, "*", "a", true);
  10898.     while More(Iter) loop
  10899.     Get_Next(Iter, Next_Node);
  10900.     Put("     ");
  10901.     Put(Path_Relation(Next_Node)); Put("( ");
  10902.     Put(Path_Key     (Next_Node)); Put(" )");
  10903.     New_Line;
  10904.     end loop;
  10905.  
  10906.     New_Line;
  10907.     New_Line;
  10908.     Put_Line("1 EXPECTED, Iterator over ( b, * ) (File, Primary) yeilds :");
  10909.     Iterate(Iter, Node, File, "b", "*", true);
  10910.     while More(Iter) loop
  10911.     Get_Next(Iter, Next_Node);
  10912.     Put("     ");
  10913.     Put(Path_Relation(Next_Node)); Put("( ");
  10914.     Put(Path_Key     (Next_Node)); Put(" )");
  10915.     New_Line;
  10916.     end loop;
  10917.  
  10918.     New_Line;
  10919.     New_Line;
  10920.     Put_Line("2 EXPECTED, Iterator over ( *, ?b ) (File, Primary) yeilds :");
  10921.     Iterate(Iter, Node, File, "*", "?b", true);
  10922.     while More(Iter) loop
  10923.     Get_Next(Iter, Next_Node);
  10924.     Put("     ");
  10925.     Put(Path_Relation(Next_Node)); Put("( ");
  10926.     Put(Path_Key     (Next_Node)); Put(" )");
  10927.     New_Line;
  10928.     end loop;
  10929.  
  10930.     New_Line;
  10931.     New_Line;
  10932.     Put_Line("1 EXPECTED, Iterator over ( *a*, * ) (Structural, Primary) yeilds :");
  10933.     Iterate(Iter, Node, Structural, "*a*", "*", true);
  10934.     while More(Iter) loop
  10935.     Get_Next(Iter, Next_Node);
  10936.     Put("     ");
  10937.     Put(Path_Relation(Next_Node)); Put("( ");
  10938.     Put(Path_Key     (Next_Node)); Put(" )");
  10939.     New_Line;
  10940.     end loop;
  10941.  
  10942.  
  10943.     New_Line;
  10944.     New_Line;
  10945.     Put_Line("3 EXPECTED, Iterator over ( *a*, * ) (File, Primary) yeilds :");
  10946.     Iterate(Iter, Node, File, "*a*", "*", true);
  10947.     while More(Iter) loop
  10948.     Get_Next(Iter, Next_Node);
  10949.     Put("     ");
  10950.     Put(Path_Relation(Next_Node)); Put("( ");
  10951.     Put(Path_Key     (Next_Node)); Put(" )");
  10952.     New_Line;
  10953.     end loop;
  10954.  
  10955.     New_Line;
  10956.     New_Line;
  10957.     Put_Line("2 EXPECTED, Iterator over ( *b*, a ) (File, Primary) yeilds :");
  10958.     Iterate(Iter, Node, File, "*b*", "a", true);
  10959.     while More(Iter) loop
  10960.     Get_Next(Iter, Next_Node);
  10961.     Put("     ");
  10962.     Put(Path_Relation(Next_Node)); Put("( ");
  10963.     Put(Path_Key     (Next_Node)); Put(" )");
  10964.     New_Line;
  10965.     end loop;
  10966.  
  10967.     New_Line;
  10968.     New_Line;
  10969.     Put_Line("4 EXPECTED, Iterator over ( *, * ) (File, Non-Primary) yeilds :");
  10970.     Iterate(Iter, Node, File, "*", "*", false);
  10971.     while More(Iter) loop
  10972.     Get_Next(Iter, Next_Node);
  10973.     Put("     ");
  10974.     Put(Path_Relation(Next_Node)); Put("( ");
  10975.     Put(Path_Key     (Next_Node)); Put(" )");
  10976.     New_Line;
  10977.     end loop;
  10978.  
  10979.  
  10980.     New_Line;
  10981.     New_Line;
  10982.     Put_Line("4 EXPECTED, Iterator over ( *, * ) (File, Primary) yeilds :");
  10983.     Iterate(Iter, Node, File, "*", "*", true);
  10984.     while More(Iter) loop
  10985.     Get_Next(Iter, Next_Node);
  10986.     Put("     ");
  10987.     Put(Path_Relation(Next_Node)); Put("( ");
  10988.     Put(Path_Key     (Next_Node)); Put(" )");
  10989.     New_Line;
  10990.     end loop;
  10991.  
  10992.     New_Line;
  10993.     New_Line;
  10994.     Put_Line("0 EXPECTED, Iterator over ( *x, * ) (File, Primary) yeilds :");
  10995.     Iterate(Iter, Node, File, "*x", "*", true);
  10996.     while More(Iter) loop
  10997.     Get_Next(Iter, Next_Node);
  10998.     Put("     ");
  10999.     Put(Path_Relation(Next_Node)); Put("( ");
  11000.     Put(Path_Key     (Next_Node)); Put(" )");
  11001.     New_Line;
  11002.     end loop;
  11003.  
  11004.     Test_Cleanup;
  11005. end Test_Node_Iterate;
  11006.  
  11007. --::::::::::::::
  11008. --text_io_tests-body.a
  11009. --::::::::::::::
  11010.  
  11011. ----------------------------------------------------------------------
  11012. --                            TEXT_IO_TESTS
  11013. --                             (Package Body)
  11014. --
  11015. --
  11016. --             A Set of Simple Test Subprograms To Exercise 
  11017. --                       Package Cais.Text_Io
  11018. --
  11019. --
  11020. --
  11021. --
  11022. --                  Ada Software Engineering Group
  11023. --                      The MITRE Corporation
  11024. --                         McLean, VA 22102
  11025. --
  11026. --
  11027. --                  Wed Jun 19 16:54:58 EDT 1985 
  11028. --
  11029. --                 (Unclassified and uncopyrighted)
  11030. --
  11031. ----------------------------------------------------------------------
  11032.  
  11033. ----------------------------------------------------------------------
  11034. --
  11035. --  Purpose:
  11036. --  -------
  11037. --    To provide a set of functions that exercise and test the
  11038. --    behavior of some of the services available in 
  11039. --    Cais.Text_Io.
  11040. --
  11041. --  Usage:
  11042. --  -----
  11043. --    The functions made available in this package will be used
  11044. --    by a "test driver" named Text_Test.  This test driver calls the 
  11045. --    different test functions in sequence.  Output from the tests can 
  11046. --    be redirected to a file.
  11047. --    Each function returns a value indicated success/failure of
  11048. --    test (i.e. expected results were/were not equal to actual
  11049. --    results).  The driver procedure keeps track of the overall
  11050. --    success/failure count and prints a test summary at the end.
  11051. --
  11052. --    *** The verbosity may be changed (e.g. if you want to add a
  11053. --    *** DUMP option).
  11054. --    The test functions have two parameters: 
  11055. --
  11056. --        Verbosity - (Kinds_Of_Output) can have the following values:
  11057. --                  NONE   - No messages are sent to Standard_Output
  11058. --                  STATUS - the test reports on its success or failure
  11059. --
  11060. --        Die_On_Exception - (Boolean)  if true, an unexpected exception
  11061. --                  will be propagated to the calling procedure,
  11062. --                  otherwise it will be caught (it is still
  11063. --                  treated as a failure, though).
  11064. --
  11065. --
  11066. --  Notes:
  11067. --  -----
  11068. --    None.
  11069. --
  11070. --  Revision History:
  11071. --  ----------------
  11072. --
  11073. -------------------------------------------------------------------
  11074. with Text_IO; 
  11075. with Cais; use Cais;
  11076.  
  11077. package body Text_Io_Tests is
  11078.  
  11079. use Cais.Text_Io;
  11080. use List_Utilities;
  11081.  
  11082.  
  11083. ----------------------      T E S T 0 0 1      ----------------------
  11084. --
  11085. --  Purpose:
  11086. --  -------
  11087. --        Tests primary interface Create
  11088. --
  11089. --  Parameters:
  11090. --  ----------
  11091. --    Verbosity        Specifies the level of output desired. Options:
  11092. --            NONE:   No output from this test
  11093. --            STATUS: Report on success or FAILure of specific
  11094. --                tests
  11095. --    Die_On_Exception       If TRUE, an unhandled exception will be propagated.
  11096. --               If FALSE, the exception will be handled and the
  11097. --               test will return a value of FAIL.
  11098. --    return Test_Result   Simply indicates pass/FAIL of the test.
  11099. --
  11100. --  Exceptions:
  11101. --  ----------
  11102. --    None.
  11103. --
  11104. --  Notes:
  11105. --  -----
  11106. --    None.
  11107. --
  11108. ---------------------------------------------------------------------
  11109.  
  11110.     function Test001 (
  11111.         Verbosity        : Kinds_Of_Output := STATUS;
  11112.         Die_On_Exception : Boolean := FALSE)
  11113.         return Test_Result is
  11114.  
  11115.     File      : File_Type;
  11116.     Base      : Node_Definitions.Node_Type;
  11117.     Attributes : List_Type;
  11118.  
  11119.     begin
  11120.     Node_Management.Open (Base, "'Current_Node", 
  11121.             (1=>Node_Definitions.Append_Relationships));
  11122.     To_List ("(File_Kind=>(Queue), Access_Method=>(Text), " &
  11123.                 "User_Attr=>(Test))",  
  11124.             Attributes);
  11125.     Create (File => File,
  11126.         Base => Base,
  11127.         Key => "Test001",
  11128.         Relation => "Testdriver",
  11129.         Mode => Inout_File,
  11130.         Form => Empty_List,
  11131.         Attributes => Attributes,
  11132.         Access_Control => Empty_List,
  11133.         Level => Empty_List);
  11134.  
  11135.     Close (File);
  11136.     return PASS;
  11137.  
  11138.     end Test001;
  11139.  
  11140. ----------------------      T E S T 0 0 2      ----------------------
  11141. --
  11142. --  Purpose:
  11143. --  -------
  11144. --        Test Create secondary interface 
  11145. --
  11146. --  Parameters:
  11147. --  ----------
  11148. --    Verbosity        Specifies the level of output desired. Options:
  11149. --            NONE:   No output from this test
  11150. --            STATUS: Report on success or FAILure of specific
  11151. --                tests
  11152. --    Die_On_Exception       If TRUE, an unhandled exception will be propagated.
  11153. --               If FALSE, the exception will be handled and the
  11154. --               test will return a value of FAIL.
  11155. --    return Test_Result   Simply indicates pass/FAIL of the test.
  11156. --
  11157. --  Exceptions:
  11158. --  ----------
  11159. --    None.
  11160. --
  11161. --  Notes:
  11162. --  -----
  11163. --    None.
  11164. --
  11165. ---------------------------------------------------------------------
  11166.  
  11167.     function Test002 (
  11168.         Verbosity        : Kinds_Of_Output := STATUS;
  11169.         Die_On_Exception : Boolean := FALSE)
  11170.         return Test_Result is
  11171.  
  11172.     File      : File_Type;
  11173.     Attributes : List_Type;
  11174.  
  11175.     begin
  11176.     To_List ("(File_Kind=>(Secondary_Storage), Access_Method=>(Text))", 
  11177.             Attributes);
  11178.     Create (File => File,
  11179.         Name => "'Current_Node'Testdriver(Test002)",
  11180.         Mode => Inout_File,
  11181.         Form => Empty_List,
  11182.         Attributes => Attributes,
  11183.         Access_Control => Empty_List,
  11184.         Level => Empty_List);
  11185.  
  11186.     Close (File);
  11187.     return PASS;
  11188.  
  11189.     end Test002;
  11190.  
  11191. ----------------------      T E S T 0 0 3      ----------------------
  11192. --
  11193. --  Purpose:
  11194. --  -------
  11195. --    Test primary interface for Open
  11196. --
  11197. --  Parameters:
  11198. --  ----------
  11199. --    Verbosity        Specifies the level of output desired. Options:
  11200. --            NONE:   No output from this test
  11201. --            STATUS: Report on success or FAILure of specific
  11202. --                tests
  11203. --            NONE:   Same as STATUS, with the additional 
  11204. --                output of the string representation of
  11205. --                the list_type(s) used.
  11206. --    Die_On_Exception       If TRUE, an unhandled exception will be propagated.
  11207. --               If FALSE, the exception will be handled and the
  11208. --               test will return a value of FAIL.
  11209. --    return Test_Result   Simply indicates pass/FAIL of the test.
  11210. --
  11211. --  Exceptions:
  11212. --  ----------
  11213. --    None.
  11214. --
  11215. --  Notes:
  11216. --  -----
  11217. --    None.
  11218. --
  11219. ---------------------------------------------------------------------
  11220.  
  11221.     function Test003 (
  11222.         Verbosity        : Kinds_Of_Output := STATUS;
  11223.         Die_On_Exception : Boolean := FALSE)
  11224.         return Test_Result 
  11225.     is
  11226.     File        : File_Type;
  11227.     Node        : Node_Definitions.Node_Type;
  11228.     
  11229.     begin
  11230.     Node_Management.Open (Node => Node,
  11231.         Name => "'Current_Node'Testdriver(Test002)",
  11232.         Intent => (1=>Node_Definitions.Write_Contents));
  11233.  
  11234.     Open (File => File,
  11235.           Node => Node,
  11236.           Mode => Out_File);
  11237.  
  11238.     Close (File);
  11239.         return  PASS; 
  11240.     end Test003;
  11241.  
  11242. ----------------------      T E S T 0 0 4      ----------------------
  11243. --
  11244. --  Purpose:
  11245. --  -------
  11246. --
  11247. --  Parameters:
  11248. --  ----------
  11249. --    Verbosity        Specifies the level of output desired. Options:
  11250. --            NONE:   No output from this test
  11251. --            STATUS: Report on success or FAILure of specific
  11252. --                tests
  11253. --            NONE:   Same as STATUS, with the additional 
  11254. --                output of the string representation of
  11255. --                the list_type(s) used.
  11256. --    Die_On_Exception       If TRUE, an unhandled exception will be propagated.
  11257. --               If FALSE, the exception will be handled and the
  11258. --               test will return a value of FAIL.
  11259. --    return Test_Result   Simply indicates pass/FAIL of the test.
  11260. --
  11261. --  Exceptions:
  11262. --  ----------
  11263. --    None.
  11264. --
  11265. --  Notes:
  11266. --  -----
  11267. --
  11268. ---------------------------------------------------------------------
  11269.  
  11270.     function Test004 (
  11271.         Verbosity        : Kinds_Of_Output := STATUS;
  11272.         Die_On_Exception : Boolean := FALSE)
  11273.         return Test_Result is
  11274.  
  11275.     File      : File_Type;
  11276.  
  11277.     begin
  11278.     Open (File => File,
  11279.           Name => "'Current_Node'Testdriver(Test002)",
  11280.           Mode => Out_File);
  11281.  
  11282.     Close (File);
  11283.         return  PASS; 
  11284.     end Test004;
  11285.  
  11286. ----------------------      T E S T 0 0 5      ----------------------
  11287. --
  11288. --  Purpose:
  11289. --  -------
  11290. --    Test Put string to Out_File
  11291. --
  11292. --  Parameters:
  11293. --  ----------
  11294. --    Verbosity        Specifies the level of output desired. Options:
  11295. --            NONE:   No output from this test
  11296. --            STATUS: Report on success or FAILure of specific
  11297. --                tests
  11298. --            NONE:   Same as STATUS, with the additional 
  11299. --                output of the string representation of
  11300. --                the list_type(s) used.
  11301. --    Die_On_Exception       If TRUE, an unhandled exception will be propagated.
  11302. --               If FALSE, the exception will be handled and the
  11303. --               test will return a value of FAIL.
  11304. --    return Test_Result   Simply indicates pass/FAIL of the test.
  11305. --
  11306. --  Exceptions:
  11307. --  ----------
  11308. --    None.
  11309. --
  11310. --  Notes:
  11311. --  -----
  11312. --    None.
  11313. --
  11314. ---------------------------------------------------------------------
  11315.  
  11316.     function Test005 (
  11317.         Verbosity        : Kinds_Of_Output := STATUS;
  11318.         Die_On_Exception : Boolean := FALSE)
  11319.         return Test_Result is
  11320.  
  11321.     File      : File_Type;
  11322.     begin
  11323.     Open (File => File,
  11324.           Name => "'Current_Node'Testdriver(Test002)",
  11325.           Mode => Out_File);
  11326.     Put (File, "ABCEDFGHIJ");
  11327.     Put (File, "KLMNOPQRST");
  11328.     Close (File);
  11329.         return  PASS; 
  11330.     end Test005;
  11331.  
  11332.  
  11333. ----------------------      T E S T 0 0 6      ----------------------
  11334. --
  11335. --  Purpose:
  11336. --  -------
  11337. --    Test Get string from In_File
  11338. --
  11339. --  Parameters:
  11340. --  ----------
  11341. --    Verbosity        Specifies the level of output desired. Options:
  11342. --            NONE:   No output from this test
  11343. --            STATUS: Report on success or FAILure of specific
  11344. --                tests
  11345. --    Die_On_Exception       If TRUE, an unhandled exception will be propagated.
  11346. --               If FALSE, the exception will be handled and the
  11347. --               test will return a value of FAIL.
  11348. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  11349. --
  11350. --  Exceptions:
  11351. --  ----------
  11352. --    None.
  11353. --
  11354. --  Notes:
  11355. --  -----
  11356. --    None.
  11357. --
  11358. ---------------------------------------------------------------------
  11359.  
  11360.     function Test006 (
  11361.         Verbosity        : Kinds_Of_Output := STATUS;
  11362.         Die_On_Exception : Boolean := FALSE)
  11363.         return Test_Result is
  11364.  
  11365.     File      : File_Type;
  11366.     String1, String2 : String(1..10);
  11367.  
  11368.     begin
  11369.     Open (File => File,
  11370.           Name => "'Current_Node'Testdriver(Test002)",
  11371.           Mode => In_File);
  11372.  
  11373.     Get (File, String1);
  11374.     Get (File, String2);
  11375.     Close (File);
  11376.     if 
  11377.         String1 /= "ABCEDFGHIJ"
  11378.     then 
  11379.         return FAIL;
  11380.     end if;
  11381.     
  11382.     if 
  11383.         String2 /= "KLMNOPQRST"
  11384.     then 
  11385.         return FAIL;
  11386.     end if;
  11387.         return  PASS; 
  11388.  
  11389.     end Test006;
  11390.  
  11391.  
  11392. ----------------------      T E S T 0 0 7      ----------------------
  11393. --
  11394. --  Purpose:
  11395. --  -------
  11396. --    Test file Reset, both interfaces
  11397. --
  11398. --  Parameters:
  11399. --  ----------
  11400. --    Verbosity        Specifies the level of output desired. Options:
  11401. --            NONE:   No output from this test
  11402. --            STATUS: Report on success or FAILure of specific
  11403. --                tests
  11404. --    Die_On_Exception       If TRUE, an unhandled exception will be propagated.
  11405. --               If FALSE, the exception will be handled and the
  11406. --               test will return a value of FAIL.
  11407. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  11408. --
  11409. --  Exceptions:
  11410. --  ----------
  11411. --    None.
  11412. --
  11413. --  Notes:
  11414. --  -----
  11415. --    None.
  11416. --
  11417. ---------------------------------------------------------------------
  11418.  
  11419.     function Test007 (
  11420.         Verbosity        : Kinds_Of_Output := STATUS;
  11421.         Die_On_Exception : Boolean := FALSE)
  11422.         return Test_Result 
  11423.     is
  11424.     String1, String2 : String(1..5);
  11425.     File      : File_Type;
  11426.  
  11427.     begin
  11428.  
  11429.     Open (File => File,
  11430.           Name => "'Current_Node'Testdriver(Test002)",
  11431.           Mode => Inout_File);
  11432.     Put (File, "XXXXX");
  11433.     Reset (File, In_File);
  11434.     Get (File, String1);
  11435.     Reset (File);
  11436.     Get (File, String2);
  11437.     Close (File);
  11438.     if
  11439.         String1 /= String2
  11440.     then
  11441.         return FAIL;
  11442.     end if;
  11443.         return  PASS; 
  11444.  
  11445.     end Test007;
  11446.  
  11447.  
  11448. ----------------------      T E S T 0 0 8      ----------------------
  11449. --
  11450. --  Purpose:
  11451. --  -------
  11452. --    Test function End_Of_File
  11453. --
  11454. --  Parameters:
  11455. --  ----------
  11456. --    Verbosity        Specifies the level of output desired. Options:
  11457. --            NONE:   No output from this test
  11458. --            STATUS: Report on success or FAILure of specific
  11459. --                tests
  11460. --    Die_On_Exception       If TRUE, an unhandled exception will be propagated.
  11461. --               If FALSE, the exception will be handled and the
  11462. --               test will return a value of FAIL.
  11463. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  11464. --
  11465. --  Exceptions:
  11466. --  ----------
  11467. --    None.
  11468. --
  11469. --  Notes:
  11470. --  -----
  11471. --    None.
  11472. --
  11473. ---------------------------------------------------------------------
  11474.  
  11475.     function Test008 (
  11476.         Verbosity        : Kinds_Of_Output := STATUS;
  11477.         Die_On_Exception : Boolean := FALSE)
  11478.         return Test_Result 
  11479.     is
  11480.  
  11481.     String1 : String(1..5);
  11482.     File      : File_Type;
  11483.     Char    : Character;
  11484.     Number  : Natural := 0;
  11485.  
  11486.     begin
  11487.  
  11488.     Open (File => File,
  11489.           Name => "'Current_Node'Testdriver(Test002)",
  11490.           Mode => Out_File);
  11491.     Put_Line (File, "XXXXX");
  11492.     Close (File);
  11493.     Open (File => File,
  11494.           Name => "'Current_Node'Testdriver(Test002)",
  11495.           Mode => In_File);
  11496.     while not End_Of_File (File) 
  11497.     loop
  11498.         Number := Number + 1;
  11499.         Get (File, Char);
  11500.     end loop;
  11501.     Close (File);
  11502.  
  11503.         return  PASS; 
  11504.  
  11505.     end Test008;
  11506.  
  11507. ----------------------      T E S T 0 0 9      ----------------------
  11508. --
  11509. --  Purpose:
  11510. --  -------
  11511. --        Test character I/O
  11512. --
  11513. --  Parameters:
  11514. --  ----------
  11515. --    Verbosity        Specifies the level of output desired. Options:
  11516. --            NONE:   No output from this test
  11517. --            STATUS: Report on success or FAILure of specific
  11518. --                tests
  11519. --    Die_On_Exception       If TRUE, an unhandled exception will be propagated.
  11520. --               If FALSE, the exception will be handled and the
  11521. --               test will return a value of FAIL.
  11522. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  11523. --
  11524. --  Exceptions:
  11525. --  ----------
  11526. --    None.
  11527. --
  11528. --  Notes:
  11529. --  -----
  11530. --    None.
  11531. --
  11532. ---------------------------------------------------------------------
  11533.  
  11534.     function Test009 (
  11535.         Verbosity        : Kinds_Of_Output := STATUS;
  11536.         Die_On_Exception : Boolean := FALSE)
  11537.         return Test_Result 
  11538.     is
  11539.     Value1,    Value2 : character;
  11540.     File      : File_Type;
  11541.     begin
  11542.  
  11543.     Value1 := '&';
  11544.     Open (File => File,
  11545.           Name => "'Current_Node'Testdriver(Test002)",
  11546.           Mode => Inout_File);
  11547.     Put (File, Value1);
  11548.     Reset (File, In_File);
  11549.     Get (File, Value2);
  11550.     Close (File);
  11551.     if 
  11552.         Value1 /= Value2
  11553.     then
  11554.         return FAIL;
  11555.     end if;
  11556.         return  PASS; 
  11557.  
  11558.     end Test009;
  11559.  
  11560. ----------------------      T E S T 0 1 0      ----------------------
  11561. --
  11562. --  Purpose:
  11563. --  -------
  11564. --        Tests CAIS generic Integer I/O package
  11565. --
  11566. --  Parameters:
  11567. --  ----------
  11568. --    Verbosity        Specifies the level of output desired. Options:
  11569. --            NONE:   No output from this test
  11570. --            STATUS: Report on success or FAILure of specific
  11571. --                tests
  11572. --    Die_On_Exception       If TRUE, an unhandled exception will be propagated.
  11573. --               If FALSE, the exception will be handled and the
  11574. --               test will return a value of FAIL.
  11575. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  11576. --
  11577. --  Exceptions:
  11578. --  ----------
  11579. --    None.
  11580. --
  11581. --  Notes:
  11582. --  -----
  11583. --    None.
  11584. --
  11585. ---------------------------------------------------------------------
  11586.  
  11587.     function Test010 (
  11588.         Verbosity        : Kinds_Of_Output := STATUS;
  11589.         Die_On_Exception : Boolean := FALSE)
  11590.         return Test_Result 
  11591.     is
  11592.     type Small_Integer is range 1..20;
  11593.     Value1, Value2 : Small_Integer;
  11594.     File      : File_Type;
  11595.     package Small_Io is new Integer_Io (Small_Integer);
  11596.  
  11597.     begin
  11598.  
  11599.     Value1 := 12;
  11600.     Open (File => File,
  11601.           Name => "'Current_Node'Testdriver(Test002)",
  11602.           Mode => Inout_File);
  11603.     Small_Io.Put (File, Value1);
  11604.     Reset (File, In_File);
  11605.     Small_Io.Get (File, Value2);
  11606.     Close (File);
  11607.     if 
  11608.         Value1 /= Value2
  11609.     then
  11610.         return FAIL;
  11611.     end if;
  11612.         return  PASS; 
  11613.  
  11614.     end Test010;
  11615. ----------------------      T E S T 0 1 1      ----------------------
  11616. --
  11617. --  Purpose:
  11618. --  -------
  11619. --        Tests CAIS generic package for Fixed I/O
  11620. --
  11621. --  Parameters:
  11622. --  ----------
  11623. --    Verbosity        Specifies the level of output desired. Options:
  11624. --            NONE:   No output from this test
  11625. --            STATUS: Report on success or FAILure of specific
  11626. --                tests
  11627. --    Die_On_Exception       If TRUE, an unhandled exception will be propagated.
  11628. --               If FALSE, the exception will be handled and the
  11629. --               test will return a value of FAIL.
  11630. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  11631. --
  11632. --  Exceptions:
  11633. --  ----------
  11634. --    None.
  11635. --
  11636. --  Notes:
  11637. --  -----
  11638. --    None.
  11639. --
  11640. ---------------------------------------------------------------------
  11641.  
  11642.     function Test011 (
  11643.         Verbosity        : Kinds_Of_Output := STATUS;
  11644.         Die_On_Exception : Boolean := FALSE)
  11645.         return Test_Result
  11646.     is
  11647.     type Real_Fixed is delta 0.001 range 0.000 .. 9.999;
  11648.     Value1, Value2 : Real_Fixed;
  11649.     File      : File_Type;
  11650.     package Real_Io is new Fixed_Io (Real_Fixed);
  11651.  
  11652.     begin
  11653.  
  11654.     Value1 := 5.432;
  11655.     Open (File => File,
  11656.           Name => "'Current_Node'Testdriver(Test002)",
  11657.           Mode => Inout_File);
  11658.     Real_Io.Put (File, Value1);
  11659.     Reset (File, In_File);
  11660.     Real_Io.Get (File, Value2);
  11661.     Close (File);
  11662.     if 
  11663.        Abs (Value1 - Value2) >  Real_Fixed'delta
  11664.     then
  11665.         return FAIL;
  11666.     end if;
  11667.         return  PASS; 
  11668.  
  11669.     end Test011;
  11670.  
  11671. ----------------------      T E S T 0 1 2      ----------------------
  11672. --
  11673. --  Purpose:
  11674. --  -------
  11675. --        Tests CAIS generic package for Float I/O
  11676. --
  11677. --  Parameters:
  11678. --  ----------
  11679. --    Verbosity        Specifies the level of output desired. Options:
  11680. --            NONE:   No output from this test
  11681. --            STATUS: Report on success or FAILure of specific
  11682. --                tests
  11683. --    Die_On_Exception       If TRUE, an unhandled exception will be propagated.
  11684. --               If FALSE, the exception will be handled and the
  11685. --               test will return a value of FAIL.
  11686. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  11687. --
  11688. --  Exceptions:
  11689. --  ----------
  11690. --    None.
  11691. --
  11692. --  Notes:
  11693. --  -----
  11694. --    None.
  11695. --
  11696. ---------------------------------------------------------------------
  11697.  
  11698.     function Test012 (
  11699.         Verbosity        : Kinds_Of_Output := STATUS;
  11700.         Die_On_Exception : Boolean := FALSE)
  11701.         return Test_Result
  11702.     is
  11703.     type Real_Float is digits 5 range 0.0000 .. 9.9999;
  11704.     Value1, Value2 : Real_Float;
  11705.     File      : File_Type;
  11706.     package Real_Io is new Float_Io (Real_Float);
  11707.  
  11708.     begin
  11709.  
  11710.     Value1 := 1.2345;
  11711.     Open (File => File,
  11712.           Name => "'Current_Node'Testdriver(Test002)",
  11713.           Mode => Inout_File);
  11714.     Real_Io.Put (File, Value1);
  11715.     Reset (File, In_File);
  11716.     Real_Io.Get (File, Value2);
  11717.     Close (File);
  11718.     if 
  11719.        abs (Value1 - Value2) >  Real_Float'epsilon
  11720.     then
  11721.         return FAIL;
  11722.     end if;
  11723.         return  PASS; 
  11724.  
  11725.     end Test012;
  11726.  
  11727. ----------------------      T E S T 0 1 3      ----------------------
  11728. --
  11729. --  Purpose:
  11730. --  -------
  11731. --        Tests CAIS generic package for Enumeration I/O
  11732. --
  11733. --  Parameters:
  11734. --  ----------
  11735. --    Verbosity        Specifies the level of output desired. Options:
  11736. --            NONE:   No output from this test
  11737. --            STATUS: Report on success or FAILure of specific
  11738. --                tests
  11739. --    Die_On_Exception       If TRUE, an unhandled exception will be propagated.
  11740. --               If FALSE, the exception will be handled and the
  11741. --               test will return a value of FAIL.
  11742. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  11743. --
  11744. --  Exceptions:
  11745. --  ----------
  11746. --    None.
  11747. --
  11748. --  Notes:
  11749. --  -----
  11750. --
  11751. ---------------------------------------------------------------------
  11752.  
  11753.     function Test013 (
  11754.         Verbosity        : Kinds_Of_Output := STATUS;
  11755.         Die_On_Exception : Boolean := FALSE)
  11756.         return Test_Result 
  11757.     is
  11758.     type Fish is (Big, Whopper, Whale);
  11759.     Value1, Value2 : Fish;
  11760.     File      : File_Type;
  11761.     package Scalar_Io is new Enumeration_Io (Fish);
  11762.  
  11763.     begin
  11764.  
  11765.     Value1 := Whopper;
  11766.     Open (File => File,
  11767.           Name => "'Current_Node'Testdriver(Test002)",
  11768.           Mode => Inout_File);
  11769.     Scalar_Io.Put (File, Value1);
  11770.     Reset (File, In_File);
  11771.     Scalar_Io.Get (File, Value2);
  11772.     Close (File);
  11773.     if 
  11774.         Value1 /= Value2
  11775.     then
  11776.         return FAIL;
  11777.     end if;
  11778.         return  PASS; 
  11779.  
  11780.     end Test013;
  11781.  
  11782. ----------------------      T E S T 0 1 4      ----------------------
  11783. --
  11784. --  Purpose:
  11785. --  -------
  11786. --
  11787. --  Parameters:
  11788. --  ----------
  11789. --    Verbosity        Specifies the level of output desired. Options:
  11790. --            NONE:   No output from this test
  11791. --            STATUS: Report on success or FAILure of specific
  11792. --                tests
  11793. --    Die_On_Exception       If TRUE, an unhandled exception will be propagated.
  11794. --               If FALSE, the exception will be handled and the
  11795. --               test will return a value of FAIL.
  11796. --    return Test_Result   Simply indicates PASS/FAIL of the test.
  11797. --
  11798. --  Exceptions:
  11799. --  ----------
  11800. --    None.
  11801. --
  11802. --  Notes:
  11803. --  -----
  11804. --    None.
  11805. --
  11806. ---------------------------------------------------------------------
  11807.  
  11808.     function Test014 (
  11809.         Verbosity        : Kinds_Of_Output := STATUS;
  11810.         Die_On_Exception : Boolean := FALSE)
  11811.         return Test_Result 
  11812.     is
  11813.      use Node_Management;
  11814.      use Node_Definitions;
  11815.  
  11816.     File : File_Type;
  11817.     Node : Cais.Node_Type;
  11818.  
  11819.     begin
  11820.  
  11821.     Open (File, "'Current_Node'Testdriver(Test001)", Out_File);
  11822.     Delete (File);
  11823.     Open (File, "'Current_Node'Testdriver(Test002)", Out_File);
  11824.     Delete (File);
  11825.  
  11826.     begin
  11827.         Open (Node, "'Current_Node'Testdriver(Test001)", (1 => Existence));
  11828.         Close (Node);
  11829.         return FAIL;
  11830.     exception
  11831.         when Node_Definitions.Name_Error =>
  11832.         return PASS;
  11833.         when others =>
  11834.         raise;
  11835.     end;
  11836.  
  11837.     begin
  11838.         Open (Node, "'Current_Node'Testdriver(Test002)", (1 => Existence));
  11839.         Close (Node);
  11840.         return FAIL;
  11841.     exception
  11842.         when Node_Definitions.Name_Error =>
  11843.         return PASS;
  11844.         when others =>
  11845.         raise;
  11846.     end;
  11847.  
  11848.  
  11849.     end Test014;
  11850.  
  11851. end Text_Io_Tests;
  11852. --::::::::::::::
  11853. --text_io_tests-spec.a
  11854. --::::::::::::::
  11855.  
  11856.  
  11857. ----------------------------------------------------------------------
  11858. --                             TEXT_IO_TESTS
  11859. --                             (Package Spec)
  11860. --
  11861. --
  11862. --             A Set of Simple Test Subprograms To Exercise 
  11863. --                       Package Cais.Text_Io
  11864. --
  11865. --
  11866. --
  11867. --
  11868. --                  Ada Software Engineering Group
  11869. --                      The MITRE Corporation
  11870. --                         McLean, VA 22102
  11871. --
  11872. --
  11873. --                  Wed Jun 19 16:54:58 EDT 1985 %%%
  11874. --
  11875. --                 (Unclassified and uncopyrighted)
  11876. --
  11877. ----------------------------------------------------------------------
  11878.  
  11879. ----------------------------------------------------------------------
  11880. --
  11881. --  Purpose:
  11882. --  -------
  11883. --    To provide a set of functions that exercise and test the
  11884. --    behavior of some of the services available in 
  11885. --    Cais.Text_Io.
  11886. --
  11887. --  Usage:
  11888. --  -----
  11889. --    The functions made available in this package will be used
  11890. --    by a "test driver" named Text_Test.  This test driver calls the 
  11891. --    different test functions in sequence.  Output from the tests can 
  11892. --    be redirected to a file.
  11893. --    Each function returns a value indicated success/failure of
  11894. --    test (i.e. expected results were/were not equal to actual
  11895. --    results).  The driver procedure keeps track of the overall
  11896. --    success/failure count and prints a test summary at the end.
  11897. --
  11898. --    *** The verbosity may be changed (e.g. if you want to add a
  11899. --    *** DUMP option).
  11900. --    The test functions have two parameters: 
  11901. --
  11902. --        Verbosity - (Kinds_Of_Output) can have the following values:
  11903. --                  NONE   - No messages are sent to Standard_Output
  11904. --                  STATUS - the test reports on its success or failure
  11905. --
  11906. --        Die_On_Exception - (Boolean)  if true, an unexpected exception
  11907. --                  will be propagated to the calling procedure,
  11908. --                  otherwise it will be caught (it is still
  11909. --                  treated as a failure, though).
  11910. --
  11911. --  Example:
  11912. --  -------
  11913. --    See the package Node_Management_Tests for some examples.
  11914. --
  11915. --  Notes:
  11916. --  -----
  11917. --    None.
  11918. --
  11919. --  Revision History:
  11920. --  ----------------
  11921. --
  11922. -------------------------------------------------------------------
  11923.  
  11924. package Text_Io_Tests is
  11925.  
  11926.     type Test_Result is (PASS, FAIL);  
  11927.  
  11928.     --*** See note above re possible additional values.
  11929.     type Kinds_Of_Output is (NONE, STATUS);
  11930.  
  11931.     function Test001 (
  11932.     Verbosity        : Kinds_Of_Output := STATUS;
  11933.         Die_On_Exception : Boolean := FALSE)
  11934.         return Test_Result;
  11935.  
  11936.     function Test002 (
  11937.     Verbosity        : Kinds_Of_Output := STATUS;
  11938.         Die_On_Exception : Boolean := FALSE)
  11939.         return Test_Result;
  11940.  
  11941.     function Test003 (
  11942.     Verbosity        : Kinds_Of_Output := STATUS;
  11943.         Die_On_Exception : Boolean := FALSE)
  11944.         return Test_Result;
  11945.  
  11946.     function Test004 (
  11947.     Verbosity        : Kinds_Of_Output := STATUS;
  11948.         Die_On_Exception : Boolean := FALSE)
  11949.         return Test_Result;
  11950.  
  11951.     function Test005 (
  11952.     Verbosity        : Kinds_Of_Output := STATUS;
  11953.         Die_On_Exception : Boolean := FALSE)
  11954.         return Test_Result;
  11955.  
  11956.     function Test006 (
  11957.     Verbosity        : Kinds_Of_Output := STATUS;
  11958.         Die_On_Exception : Boolean := FALSE)
  11959.         return Test_Result;
  11960.  
  11961.     function Test007 (
  11962.     Verbosity        : Kinds_Of_Output := STATUS;
  11963.         Die_On_Exception : Boolean := FALSE)
  11964.         return Test_Result;
  11965.  
  11966.     function Test008 (
  11967.     Verbosity        : Kinds_Of_Output := STATUS;
  11968.         Die_On_Exception : Boolean := FALSE)
  11969.         return Test_Result;
  11970.  
  11971.     function Test009 (
  11972.     Verbosity        : Kinds_Of_Output := STATUS;
  11973.         Die_On_Exception : Boolean := FALSE)
  11974.         return Test_Result;
  11975.  
  11976.     function Test010 (
  11977.     Verbosity        : Kinds_Of_Output := STATUS;
  11978.         Die_On_Exception : Boolean := FALSE)
  11979.         return Test_Result;
  11980.  
  11981.     function Test011 (
  11982.     Verbosity        : Kinds_Of_Output := STATUS;
  11983.         Die_On_Exception : Boolean := FALSE)
  11984.         return Test_Result;
  11985.  
  11986.     function Test012 (
  11987.     Verbosity        : Kinds_Of_Output := STATUS;
  11988.         Die_On_Exception : Boolean := FALSE)
  11989.         return Test_Result;
  11990.  
  11991.     function Test013 (
  11992.     Verbosity        : Kinds_Of_Output := STATUS;
  11993.         Die_On_Exception : Boolean := FALSE)
  11994.         return Test_Result;
  11995.  
  11996.     function Test014 (
  11997.     Verbosity        : Kinds_Of_Output := STATUS;
  11998.         Die_On_Exception : Boolean := FALSE)
  11999.         return Test_Result;
  12000.  
  12001. end Text_Io_Tests;
  12002. --::::::::::::::
  12003. --text_test.a
  12004. --::::::::::::::
  12005. ----------------------------------------------------------------------
  12006. --                         TEXT_TEST
  12007. --
  12008. --
  12009. --          Test Driver for Tests of Cais_Text_Io
  12010. --
  12011. --
  12012. --
  12013. --
  12014. --                  Ada Software Engineering Group
  12015. --                      The MITRE Corporation
  12016. --                         McLean, VA 22102
  12017. --
  12018. --
  12019. --                   Wed Aug  7 13:26:38 EDT 1985
  12020. --
  12021. --                 (Unclassified and uncopyrighted)
  12022. --
  12023. ----------------------------------------------------------------------
  12024.  
  12025. ----------------------------------------------------------------------
  12026. --
  12027. --  Purpose:
  12028. --  -------
  12029. --    This is the test driver for the suite of tests in the package
  12030. --    Text_Io_Tests.
  12031. --
  12032. --  Usage:
  12033. --  -----
  12034. --    Run the executable, responding "14" to the number of tests.
  12035. --    The message level requested should be "none" or "status".
  12036. --
  12037. --  Notes:
  12038. --  -----
  12039. --
  12040. --  Revision History:
  12041. --  ----------------
  12042. --
  12043. -------------------------------------------------------------------
  12044. with Text_IO; use Text_IO;
  12045. with Cais;    use Cais;
  12046. with Text_Io_Tests; use Text_Io_Tests;
  12047.  
  12048.  
  12049. procedure Text_Test is
  12050.  
  12051.     Valid_Response : Boolean := FALSE;
  12052.     Phyl           : File_Type;
  12053.     MAX_FILENAME   : constant Natural := 40;  -- Arbitrary number
  12054.     Phyl_Name      : String (1..MAX_FILENAME);
  12055.     Name_Length    : Natural;
  12056.  
  12057.     Test_Output        : Text_Io_Tests.Kinds_Of_Output; 
  12058.     Abort_On_Exception : Boolean;
  12059.  
  12060.     MAX_TESTS         : constant Positive := 14;
  12061.     Subtype Count is Integer range 0 .. MAX_TESTS;
  12062.  
  12063.     package Count_IO is new Integer_IO (Count);
  12064.     use Count_IO;
  12065.  
  12066.     type Response is (YES,NO);
  12067.     Yesno          : Response;
  12068.  
  12069.     MaxTries       : constant Natural := 5;
  12070.  
  12071.  
  12072.     package Interact is
  12073.  
  12074.     generic
  12075.     type Enum_type is (<>);
  12076.     procedure Interactive_Get (
  12077.     Prompt : in String;        -- Prompt string
  12078.     Tries : Natural;         -- Number of invalid responses accepted
  12079.     Response : in out Enum_type);    -- Returns user response
  12080.                     --    before DATA-ERROR is raised
  12081.     end Interact;
  12082.     use Interact;
  12083.  
  12084.     procedure Get_YesNO is new Interactive_Get (Response); 
  12085.  
  12086.     procedure Get_Verbosity is new Interactive_Get (Kinds_Of_Output); 
  12087.  
  12088.  
  12089.     Results : array (1..MAX_TESTS) of Test_Result;
  12090.     Test_Count   : Natural;
  12091.     Error_Count  : Natural := 0;
  12092.  
  12093.  
  12094.  
  12095. -----------------------------------------------------------------------
  12096. --        Local exception handling function
  12097. -----------------------------------------------------------------------
  12098.  
  12099.     function Diagnose  (Test : Positive; 
  12100.             Verbosity : Kinds_Of_Output := STATUS;
  12101.             Die_On_Exception : Boolean) return Test_Result
  12102.     is
  12103.  
  12104.     use Cais.Io_Definitions;
  12105.  
  12106.     Test_String : String(1..3);
  12107.  
  12108.         procedure Report_Status (
  12109.             Verbosity  : Kinds_Of_Output;
  12110.         Test    : Positive;
  12111.             Msg        : String) is
  12112.  
  12113.         begin
  12114.  
  12115.             if Verbosity = NONE then 
  12116.                 return; -- do nothing
  12117.             else
  12118.             Standard.Text_Io.Put_Line ("**Error in Test " &
  12119.                         Positive'Image(Test));
  12120.                    Standard.Text_Io.Put_Line (Msg);
  12121.             end if;
  12122.  
  12123.         end Report_Status;
  12124.  
  12125.     begin
  12126.     case Test is
  12127.       when 1 => return Test001 (Verbosity, Die_On_Exception);
  12128.       when 2 => return Test002 (Verbosity, Die_On_Exception);
  12129.       when 3 => return Test003 (Verbosity, Die_On_Exception);
  12130.       when 4 => return Test004 (Verbosity, Die_On_Exception);
  12131.       when 5 => return Test005 (Verbosity, Die_On_Exception);
  12132.       when 6 => return Test006 (Verbosity, Die_On_Exception);
  12133.       when 7 => return Test007 (Verbosity, Die_On_Exception);
  12134.       when 8 => return Test008 (Verbosity, Die_On_Exception);
  12135.       when 9 => return Test009 (Verbosity, Die_On_Exception);
  12136.       when 10 => return Test010 (Verbosity, Die_On_Exception);
  12137.       when 11 => return Test011 (Verbosity, Die_On_Exception);
  12138.       when 12 => return Test012 (Verbosity, Die_On_Exception);
  12139.       when 13 => return Test013 (Verbosity, Die_On_Exception);
  12140.       when 14 => return Test014 (Verbosity, Die_On_Exception);
  12141.       when others => null;
  12142.     end case;
  12143.     exception
  12144.  
  12145.       when 
  12146.     Cais.Io_Definitions.Name_Error    
  12147.       =>
  12148.       Report_Status (Verbosity, Test,
  12149.         "Cais.Io_Definitions.Name_Error EXCEPTION "); 
  12150.       return FAIL;
  12151.       when 
  12152.     Cais.Io_Definitions.Use_Error      
  12153.       =>
  12154.       Report_Status (Verbosity, Test,
  12155.         "Cais.Io_Definitions.Use_Error EXCEPTION "); 
  12156.       return FAIL;
  12157.       when 
  12158.     Cais.Io_Definitions.Status_Error  
  12159.       =>
  12160.       Report_Status (Verbosity, Test,
  12161.         "Cais.Io_Definitions.Status_Error EXCEPTION "); 
  12162.       return FAIL;
  12163.       when 
  12164.     Cais.Io_Definitions.Mode_Error    
  12165.       =>
  12166.       Report_Status (Verbosity, Test,
  12167.         "Cais.Io_Definitions.Mode_Error EXCEPTION "); 
  12168.       return FAIL;
  12169.       when 
  12170.     Cais.Io_Definitions.Device_Error 
  12171.       =>
  12172.       Report_Status (Verbosity, Test,
  12173.         "Cais.Io_Definitions.Device_Error EXCEPTION "); 
  12174.       return FAIL;
  12175.       when 
  12176.     Cais.Io_Definitions.End_Error    
  12177.       =>
  12178.       Report_Status (Verbosity, Test,
  12179.         "Cais.Io_Definitions.End_Error EXCEPTION "); 
  12180.       return FAIL;
  12181.       when 
  12182.     Cais.Io_Definitions.Data_Error    
  12183.       =>
  12184.       Report_Status (Verbosity, Test,
  12185.         "Cais.Io_Definitions.Data_Error EXCEPTION "); 
  12186.       return FAIL;
  12187.       when 
  12188.     Cais.Io_Definitions.Layout_Error 
  12189.       =>
  12190.       Report_Status (Verbosity, Test,
  12191.         "Cais.Io_Definitions.Layout_Error EXCEPTION "); 
  12192.       return FAIL;
  12193.       when 
  12194.     Node_Definitions.Lock_Error    
  12195.       =>
  12196.       Report_Status (Verbosity, Test,
  12197.         "Node_Definitions.Lock_Error EXCEPTION "); 
  12198.       return FAIL;
  12199.       when 
  12200.     Node_Definitions.Intent_Violation 
  12201.       =>
  12202.       Report_Status (Verbosity, Test,
  12203.         "Node_Definitions.Intent_Violation  EXCEPTION "); 
  12204.       return FAIL;
  12205.       when 
  12206.     Node_Definitions.Access_Violation 
  12207.       =>
  12208.       Report_Status (Verbosity, Test,
  12209.         "Node_Definitions.Access_Violation  EXCEPTION "); 
  12210.       return FAIL;
  12211.       when 
  12212.     Node_Definitions.Security_Violation 
  12213.       =>
  12214.       Report_Status (Verbosity, Test,
  12215.         "Node_Definitions.Security_Violation  EXCEPTION "); 
  12216.       return FAIL;
  12217.  
  12218.  
  12219.         when others =>
  12220.             Report_Status (Verbosity, Test,
  12221.                 "UNHANDLED EXCEPTION");
  12222.  
  12223.             if Die_On_Exception then
  12224.                 raise;
  12225.             else
  12226.                 return (FAIL);
  12227.             end if;
  12228.     end Diagnose;
  12229.  
  12230.  
  12231. package body Interact is
  12232.  
  12233.     procedure Interactive_Get (
  12234.     Prompt : in String;
  12235.     Tries : Natural; 
  12236.     Response : in out Enum_type)
  12237.     is
  12238.  
  12239.     Response_Value : Enum_type;
  12240.     Valid_Response : Boolean := FALSE;
  12241.     Attempt : Natural := 0;
  12242.  
  12243.     package Type_IO is new Enumeration_IO (Enum_type);
  12244.     use Type_IO;
  12245.  
  12246.       begin
  12247.  
  12248.           while (not Valid_Response) loop
  12249.           Put (Prompt);
  12250.           GET_VERBOSITY:
  12251.         begin
  12252.           Get (Response_Value);
  12253.           Valid_Response := TRUE;
  12254.         exception
  12255.           when DATA_ERROR =>
  12256.           Skip_Line;
  12257.           Put_Line (ASCII.BEL & 
  12258.               "PLEASE ENTER ONE OF THE FOLLOWING:");
  12259.               for i in Enum_Type'first
  12260.               .. Enum_Type'last
  12261.               loop
  12262.               Put("    ");
  12263.               Put(i);
  12264.               New_line;
  12265.               end loop;
  12266.         end GET_VERBOSITY;
  12267.     
  12268.         Attempt := Attempt + 1;
  12269.         if Attempt >= Tries 
  12270.         then raise DATA_ERROR;
  12271.         end if;
  12272.         end loop;
  12273.         Skip_Line (Standard_Input); -- the skip_line is in effect a "flush"
  12274.                       -- of the input buffer...
  12275.         Response := Response_Value;
  12276.       end Interactive_Get;
  12277.  
  12278.  
  12279. end Interact;
  12280.  
  12281. begin
  12282.  
  12283.  
  12284.     Valid_Response := FALSE;
  12285.     while not Valid_Response loop
  12286.     Put ("Enter the highest test number to be run: ");
  12287.     GET_TEST_COUNT:
  12288.     begin
  12289.         Get (Test_Count);
  12290.         Valid_Response := TRUE;
  12291.     exception
  12292.         when DATA_ERROR =>
  12293.         Put_Line (ASCII.BEL & 
  12294.             "PLEASE ENTER AN INTEGER 0 .. " &
  12295.             Integer'image(MAX_TESTS));
  12296.     end GET_TEST_COUNT;
  12297.     end loop;
  12298.     Skip_Line (Standard_Input);
  12299.  
  12300.  
  12301.     Get_YesNo (
  12302.     "Abort the test upon an unexpected exception? (Yes or No): ",
  12303.     MaxTries, YesNo);
  12304. ------------------^A                                                         ###
  12305. --### A:warning: RM 3.2.1(18): variable may not yet have a value
  12306.     Abort_On_Exception := (Yesno = YES);
  12307.  
  12308.  
  12309.     Get_Verbosity (
  12310.     "Enter the level of test output to be printed: ",
  12311.     MaxTries, Test_Output);
  12312.  
  12313.     Get_YesNo (
  12314.     "Do you want output redirected to a file? (yes or no): ",
  12315.     MaxTries, Yesno);
  12316.  
  12317.     if Yesno = YES then
  12318.     Put ("Enter the filename for redirected output: ");
  12319.     Get_Line (Phyl_Name, Name_Length);
  12320.     OPEN_FILE:
  12321.     begin
  12322.         Open (Phyl, Out_File, Phyl_Name (1..Name_Length));
  12323.         Delete (Phyl);
  12324.         Create (Phyl, Out_File, Phyl_Name (1..Name_Length));
  12325.     exception
  12326.         when NAME_ERROR =>
  12327.         Create (Phyl, Out_File, Phyl_Name (1..Name_Length));
  12328.     end OPEN_FILE;
  12329.     Set_Output (Phyl);
  12330.     end if;
  12331.  
  12332.     New_Line;
  12333.     Put_Line ("**** Beginning Execution of Text_Test ****"); 
  12334.     Put ("    TEST_OUTPUT is set to ");
  12335.     Put_Line (Kinds_Of_Output'Image(TEST_OUTPUT));
  12336.     Put ("    ABORT_ON_EXCEPTION is set to ");
  12337.     Put_Line (Boolean'Image(ABORT_ON_EXCEPTION));
  12338.     Put ("    TEST_COUNT is set to ");
  12339.     Put (Test_Count);
  12340.     New_Line(2);
  12341.  
  12342.     for Current_Test in 1..Test_Count loop
  12343.         Results (Current_Test) := Diagnose (Current_Test,
  12344.         Verbosity => TEST_OUTPUT,
  12345.         Die_On_Exception => ABORT_ON_EXCEPTION);
  12346.         if Results (Current_Test) = Fail then
  12347.         Error_Count := Error_Count +1;
  12348.         end if;
  12349.     end loop;
  12350.  
  12351.  
  12352.     -- Produce Summary
  12353.  
  12354.     <<PRINT_RESULTS>>
  12355.     New_Line;
  12356.     Put_Line ("**** End of Text_Test ****"); 
  12357.     New_Line;
  12358.     New_Line;
  12359.     if Error_Count = 0 then
  12360.         New_Line;
  12361.     Put_Line ("NO TESTS FAILED. ");
  12362.     else
  12363.         New_Line;
  12364.     Put ("A total of ");
  12365.     Put (Error_Count);
  12366.     Put_Line (" Test(s) failed.");
  12367.     Put_Line ("The following test(s) failed:");
  12368.     for I in 1 .. Test_Count loop
  12369.         if Results (I) = fail then
  12370.         Put ("Test number ");
  12371.         Put (I);
  12372.                 New_Line;
  12373.         end if;
  12374.     end loop;
  12375.     end if;
  12376.  
  12377. end Text_Test;
  12378.