Prolog Coding Guidelines

Revision as of 11:28, 17 November 2011 by Michael Leuschel (talk | contribs)

General Guidelines

Please ensure that there are no compilation errors or warnings when checking in. Also, try to ensure that there are no errors when loading the files in Spider (Eclipse). Ideally, try to get rid of warnings as well.

Have a look at the paper by [Covington et al.] on Prolog coding guidelines.

Module Information

Every module should be annotated with module information. This is used by our coverage analysis tool.

:- module(MYMODULE, [  exported_predicate/arity, ... ]).

:- use_module(tools).

:- module_info(group,kernel).
:- module_info(description,'This module does wonderful things').
:- module_info(revision,'$Rev: 9558 $').
:- module_info(lastchanged,'$LastChangedDate: 2011-11-17 12:09:15 +0100 (Thu, 17 Nov 2011) $').

Afterwards run

  svn propset svn:keywords "Date Revision" MYMODULE.pl

so that svn can automatically update the revision and last changed information. This is important for the coverage report.

Unit Tests

Unit tests should be setup using the self_check module.

:- use_module(self_check).

Afterwards you can use the following to add new unit tests:

:- assert_must_succeed((bsets_clp:empty_sequence([]))).
:- assert_must_fail((bsets_clp:empty_sequence([int(1)]))).

These tests can be run manually from the ProB Tcl/Tk version, from the command-line using the -self_check command. They will also be automatically run on our jenkins server after committing.