------------------------------------------------------------------------- --| --| L I S T T E S T --| --| Abstract : This file contains a procedure to test the implementation --| of list operations. --| --| Related compilation units contained in this directory are: --| --| Type Name File --| ---- ---- ---- --| Test Procedure list_test This file --| Procedure get_word get_word.ada --| --| Specification list_package list.ada --| Implementation list_package list.ada --| --------------------------------------------------------------------------- --| Date 4/22/93 Version 1.0 --------------------------------------------------------------------------- with text_io; use text_io; with get_word; with list_package; procedure list_test is package list_pak is new list_package(integer, 4); use list_pak; package iio is new integer_io(integer); use iio; operation : string(1..20); line : string(1..80); n, len, last : natural; object : integer; list1, list2 : list_pak.list := list_pak.empty_list; procedure put_object(object : integer) is begin iio.put(object,3); end put_object; procedure display_list is new list_pak.display(put_object); begin loop1 : loop begin -- This begin block is included so that exceptions -- generated by the package being tested will not -- cuase termination of the test program. loop2 : loop if end_of_file then exit loop1; else get_line(line, len); -- Get next command line. end if; get_word(line(1..len), operation, n); -- Isolate command. if n = 0 then exit loop1; end if; -- Empty line; terminate test. put(line(1..len)); if operation(1..2) = "--" -- Command is a comment. then new_line; else set_col(15); put("=> "); if operation(1..n) = "&_list1" then iio.get(line(n+1..len), object, last); list1 := list1 & object; elsif operation(1..n) = "&_list2" then iio.get(line(n+1..len), object, last); list2 := list2 & object; elsif operation(1..n) = "&" then list1 := list1 & list2; elsif operation(1..n) = "empty_list1" then list1 := empty_list; elsif operation(1..n) = "empty_list2" then list2 := empty_list; elsif operation(1..n) = "head1" then put_object(head(list1)); elsif operation(1..n) = "head2" then put_object(head(list2)); elsif operation(1..n) = "tail1" then list1 := tail(list1); elsif operation(1..n) = "tail2" then list2 := tail(list2); else put("??????"); end if; set_col(25); display_list(list1); set_col(52); display_list(list2); new_line; end if; end loop loop2; exception when list_pak.list_empty => set_col(25); put_line("list_empty exception raised"); when list_pak.list_full => set_col(25); put_line("list_full exception raised"); end; end loop loop1; new_line(2); put_line("list test completed."); end list_test;