Logtalk 2.30.7 files.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1974 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
14
Logtalk/examples/testing/NOTES.txt
Normal file
14
Logtalk/examples/testing/NOTES.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
================================================================
|
||||
Logtalk - Open source object-oriented logic programming language
|
||||
Release 2.30.7
|
||||
|
||||
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
|
||||
================================================================
|
||||
|
||||
|
||||
This folder contains a preliminary framework for defining and running
|
||||
unit tests in Logtalk.
|
||||
|
||||
The unit tests framework is inspired on the works of Joachim Schimpf
|
||||
(ECLiPSe library "test_util") and Jan Wielemaker (SWI-Prolog "plunit"
|
||||
package).
|
15
Logtalk/examples/testing/SCRIPT.txt
Normal file
15
Logtalk/examples/testing/SCRIPT.txt
Normal file
@@ -0,0 +1,15 @@
|
||||
================================================================
|
||||
Logtalk - Open source object-oriented logic programming language
|
||||
Release 2.30.7
|
||||
|
||||
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
|
||||
================================================================
|
||||
|
||||
|
||||
% start by loading the example:
|
||||
|
||||
| ?- logtalk_load(testing(loader)).
|
||||
...
|
||||
|
||||
|
||||
% take a look at the "results.txt" file in the example directory
|
4
Logtalk/examples/testing/loader.lgt
Normal file
4
Logtalk/examples/testing/loader.lgt
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
:- initialization((
|
||||
logtalk_load(library(lgtunit), [reload(skip)]), % allow for static binding
|
||||
logtalk_load(testing))).
|
134
Logtalk/examples/testing/testing.lgt
Normal file
134
Logtalk/examples/testing/testing.lgt
Normal file
@@ -0,0 +1,134 @@
|
||||
|
||||
:- object(ctx_call_tests,
|
||||
extends(lgtunit)).
|
||||
|
||||
:- info([
|
||||
version is 1.0,
|
||||
author is 'Paulo Moura',
|
||||
date is 2007/04/17,
|
||||
comment is 'Tests <</2 built-in control construct.']).
|
||||
|
||||
% :- initialization(::run).
|
||||
% :- initialization(::run('bios_tests.txt', write)).
|
||||
:- initialization(::run('results.txt', write)).
|
||||
|
||||
throws(ctx1, _ << goal, error(instantiation_error, _, _)).
|
||||
throws(ctx2, object << _, error(instantiation_error, _, _)).
|
||||
throws(ctx3, 3 << goal, error(type_error(object_identifier, 3), _, _)).
|
||||
throws(ctx4, object << 3, error(type_error(callable, 3), _, _)).
|
||||
throws(ctx5, ctx_call_tests << goal, error(existence_error(procedure, goal/0), _)).
|
||||
throws(ctx6, xpto << goal, error(existence_error(object, xpto), _, _)).
|
||||
|
||||
succeeds(ctx7, user << true).
|
||||
|
||||
fails(ctx8, user << fail).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
|
||||
:- object(bios_tests,
|
||||
extends(lgtunit)).
|
||||
|
||||
:- info([
|
||||
version is 1.0,
|
||||
author is 'Paulo Moura',
|
||||
date is 2007/04/17,
|
||||
comment is 'Tests built-in objects.']).
|
||||
|
||||
% :- initialization(::run).
|
||||
% :- initialization(::run('bios_tests.txt', write)).
|
||||
:- initialization(::run('results.txt', append)).
|
||||
|
||||
succeeds(all, (setof(Obj, (current_object(Obj), object_property(Obj, built_in)), Objs), Objs == [debugger,logtalk,user])).
|
||||
|
||||
succeeds(user0, current_object(user)).
|
||||
succeeds(user1, object_property(user, built_in)).
|
||||
succeeds(user2, object_property(user, static)).
|
||||
|
||||
succeeds(debugger0, current_object(debugger)).
|
||||
succeeds(debugger1, object_property(debugger, built_in)).
|
||||
succeeds(debugger2, object_property(debugger, static)).
|
||||
|
||||
succeeds(logtalk0, current_object(logtalk)).
|
||||
succeeds(logtalk1, object_property(logtalk, built_in)).
|
||||
succeeds(logtalk2, object_property(logtalk, static)).
|
||||
|
||||
throws(co0, current_object(1), error(type_error(object_identifier, 1), _)).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
|
||||
:- object(list_tests,
|
||||
extends(lgtunit)).
|
||||
|
||||
:- info([
|
||||
version is 1.0,
|
||||
author is 'Paulo Moura',
|
||||
date is 2007/04/17,
|
||||
comment is 'Tests for the library object "list".']).
|
||||
|
||||
% :- initialization(::run).
|
||||
% :- initialization(::run('list_tests.txt', write)).
|
||||
:- initialization(::run('results.txt', append)).
|
||||
|
||||
setup :-
|
||||
current_logtalk_flag(report, Value),
|
||||
set_logtalk_flag(report, off),
|
||||
logtalk_load(library(types_loader), [reload(skip)]),
|
||||
set_logtalk_flag(report, Value),
|
||||
^^setup.
|
||||
|
||||
fails(member0, list << member(_, [])).
|
||||
|
||||
succeeds(member1, list << member(1, [1,2,3])).
|
||||
succeeds(member2, (findall(X, list << member(X, [1,2,3]), L), L == [1,2,3])).
|
||||
|
||||
succeeds(length, (list << length([1,2,3], Length), Length =:= 3)).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
|
||||
:- object(dyn_tests,
|
||||
extends(lgtunit)).
|
||||
|
||||
:- info([
|
||||
version is 1.1,
|
||||
author is 'Paulo Moura',
|
||||
date is 2007/09/15,
|
||||
comment is 'Tests dynamic objects and dynamic predicates.']).
|
||||
|
||||
% :- initialization(::run).
|
||||
% :- initialization(::run('dyn_tests.txt', write)).
|
||||
:- initialization(::run('results.txt', append)).
|
||||
|
||||
setup :-
|
||||
create_object(dyn_test, [], [], []).
|
||||
|
||||
succeeds(dyn, This << goal) :-
|
||||
this(This).
|
||||
|
||||
goal :-
|
||||
\+ dyn_test::current_predicate(_),
|
||||
dyn_test::asserta(a(1)),
|
||||
dyn_test::current_predicate(a/1),
|
||||
dyn_test::predicate_property(a(_), public),
|
||||
dyn_test::predicate_property(a(_), dynamic),
|
||||
dyn_test::predicate_property(a(_), declared_in(dyn_test)),
|
||||
dyn_test::predicate_property(a(_), defined_in(dyn_test)),
|
||||
dyn_test::assertz(a(2)),
|
||||
dyn_test::retractall(a(_)),
|
||||
\+ dyn_test::a(_),
|
||||
dyn_test::predicate_property(a(_), defined_in(dyn_test)), % closed-world assumption
|
||||
dyn_test::current_predicate(a/1),
|
||||
dyn_test::abolish(a/1),
|
||||
\+ dyn_test::predicate_property(a(_), declared_in(dyn_test)),
|
||||
\+ dyn_test::predicate_property(a(_), defined_in(dyn_test)),
|
||||
\+ dyn_test::current_predicate(_).
|
||||
|
||||
cleanup :-
|
||||
abolish_object(dyn_test).
|
||||
|
||||
:- end_object.
|
Reference in New Issue
Block a user