| 1 | :- module(pltables, [ | |
| 2 | new_table/2, add_column/3, | |
| 3 | pltable/2, pltable_header/3, | |
| 4 | delete_tables/0, | |
| 5 | pltable_row/3, add_row/3, | |
| 6 | tables_to_html/2, tables_to_html_stream/2, | |
| 7 | tables_to_latex/2, tables_to_latex_stream/2, | |
| 8 | tables_to_xml/2, tables_to_xml_stream/2, | |
| 9 | tables_to_csv/2, tables_to_csv_stream/2 | |
| 10 | ]). | |
| 11 | ||
| 12 | :- use_module(pltables_export). | |
| 13 | :- use_module(probsrc(self_check)). | |
| 14 | :- use_module(probsrc(module_information)). | |
| 15 | ||
| 16 | :- module_info(group,pltables). | |
| 17 | :- module_info(description,'This module is used to generate, store and export coverage tables.'). | |
| 18 | ||
| 19 | :- volatile pltable/2, pltable_header/3, pltable_row/3. | |
| 20 | :- dynamic pltable/2, pltable_header/3, pltable_row/3. | |
| 21 | ||
| 22 | :- assert_must_succeed((pltables:new_table(a,[]),pltables:delete_tables,\+(pltables:pltable(a,[])))). | |
| 23 | delete_tables :- | |
| 24 | retractall(pltable(_,_)), | |
| 25 | retractall(pltable_header(_,_,_)), | |
| 26 | retractall(pltable_row(_,_,_)). | |
| 27 | ||
| 28 | :- assert_must_succeed((pltables:new_table(a,[]),pltables:delete_tables)). | |
| 29 | :- assert_must_succeed((pltables:new_table(aa,[]),pltables:new_table(bb,[]),pltables:delete_tables)). | |
| 30 | :- assert_must_fail((pltables:new_table(x,[]),pltables:new_table(x,[]),pltables:delete_tables)). | |
| 31 | % As the above test fails, delete_tables is not called. The following test serves as a cleanup routine | |
| 32 | :- assert_must_succeed(pltables:delete_tables). | |
| 33 | new_table(Name, Attributes) :- | |
| 34 | pltable(Name,Attributes) -> false ; assert(pltable(Name, Attributes)). | |
| 35 | ||
| 36 | add_column(TableName, ColumnText, Attributes) :- | |
| 37 | pltable(TableName, _), | |
| 38 | ( retract(pltable_header(TableName, OldHeadings, OldAttributes)) -> | |
| 39 | append(OldAttributes, [Attributes], NewAttributes), | |
| 40 | append(OldHeadings, [ColumnText], NewHeadings), | |
| 41 | assert(pltable_header(TableName, NewHeadings, NewAttributes)) | |
| 42 | ; otherwise -> | |
| 43 | assert(pltable_header(TableName, [ColumnText], [Attributes])) | |
| 44 | ). | |
| 45 | ||
| 46 | add_row(TableName, Entries, Attributes) :- | |
| 47 | pltable_header(TableName, Columns, _), | |
| 48 | length(Columns, NrOfColumns), | |
| 49 | length(Entries, NrOfColumns), | |
| 50 | assert(pltable_row(TableName, Entries, Attributes)). | |
| 51 |