Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cogsys
Dare2Del
Demonstrator - Reasoning WebAPI
Commits
60b7f204
Commit
60b7f204
authored
Jun 13, 2021
by
Siebers, Michael
Browse files
test and fix time predicates
parent
1a677f67
Changes
2
Hide whitespace changes
Inline
Side-by-side
irrelevance_common.pl
View file @
60b7f204
...
@@ -121,26 +121,29 @@ item_split_(Item,Basename,Ext) :-
...
@@ -121,26 +121,29 @@ item_split_(Item,Basename,Ext) :-
%! creation_time(++Item, -Timestamp) is semidet.
%! creation_time(++Item, -Timestamp) is semidet.
%
%
% Returns the creation time of the item.
% Returns the creation time of the item.
creation_time
(
Item
,
Time
)
:-
theory_bg
:
item
(
Item
,
Dict
),
!,
creation_time
(
Item
,
Time
)
:-
theory_bg
:
item
(
Item
,
Dict
),
!,
Time
=
Dict
.
creation_time
.
Time
=
Dict
.
get
(
creation_time
)
.
%! change_time(++
Item
, -Timestamp) is semidet.
%! change_time(++
File
, -Timestamp) is semidet.
%
%
% Returns the change time of the item.
% Returns the change time of the a file. File is the absolute
change_time
(
Item
,
Time
)
:-
theory_bg
:
item
(
Item
,
Dict
),
!,
% path of the file.
Time
=
Dict
.
change_time
.
change_time
(
File
,
Time
)
:-
theory_bg
:
item
(
File
,
Dict
),
!,
Time
=
Dict
.
get
(
change_time
).
%! modification_time(++
Item
, -Timestamp) is semidet.
%! modification_time(++
File
, -Timestamp) is semidet.
%
%
% Returns the modification time of the item.
% Returns the modification time of a file. File is the absolute
modification_time
(
Item
,
Time
)
:-
theory_bg
:
item
(
Item
,
Dict
),
!,
% path of the file.
modification_time
(
File
,
Time
)
:-
theory_bg
:
item
(
File
,
Dict
),
!,
Time
=
Dict
.
get
(
modification_time
).
Time
=
Dict
.
get
(
modification_time
).
%! access_time(++
Item
, -Timestamp) is semidet.
%! access_time(++
File
, -Timestamp) is semidet.
%
%
% Returns the access time of the item.
% Returns the access time of the a file. File is the absolute
access_time
(
Item
,
Time
)
:-
theory_bg
:
item
(
Item
,
Dict
),
!,
% path of the file.
Time
=
Dict
.
access_time
.
access_time
(
File
,
Time
)
:-
theory_bg
:
item
(
File
,
Dict
),
!,
Time
=
Dict
.
get
(
access_time
).
%! newer(++File1, ++File2) is semidet.
%! newer(++File1, ++File2) is semidet.
...
...
tests/plunit/irrelevance_common.plt
View file @
60b7f204
...
@@ -129,6 +129,24 @@ test(item_base_name_semidet) :-
...
@@ -129,6 +129,24 @@ test(item_base_name_semidet) :-
semidet_for_file(item_base_name/2).
semidet_for_file(item_base_name/2).
%%
%% creation_time/2
%%
% creation_time(+Item,-Time) is semidet.
test(creation_time_semidet_true,
[forall(theory_bg:creation_time(ItemId, ExpectedTime)),
true(Time == ExpectedTime)
]) :- creation_time(ItemId, Time).
test(creation_time_semidet_false,
[forall(theory_bg:item_false(UnknownId)), fail]) :-
creation_time(UnknownId, _Time).
%%
%% modification_time/2
%%
% modification_time(+File,-Time) is semidet.
% modification_time(+File,-Time) is semidet.
test(modification_time_semidet_true,
test(modification_time_semidet_true,
[forall(theory_bg:modification_time(FileId, ExpectedTime)),
[forall(theory_bg:modification_time(FileId, ExpectedTime)),
...
@@ -143,38 +161,44 @@ test(modification_time_fails_for_directory,
...
@@ -143,38 +161,44 @@ test(modification_time_fails_for_directory,
[forall(theory_bg:file_false(DirId)), fail]) :-
[forall(theory_bg:file_false(DirId)), fail]) :-
modification_time(DirId, _Time).
modification_time(DirId, _Time).
%%
%% access_time/2
%%
% access_time(+File,-Time) is semidet.
test(access_time_semidet_true,
[forall(theory_bg:access_time(FileId, ExpectedTime)),
true(Time == ExpectedTime)
]) :- access_time(FileId, Time).
test(access_time_semidet_false,
[forall(theory_bg:item_false(UnknownId)), fail]) :-
access_time(UnknownId, _Time).
% access_time(+Directory, -Size) fails
test(access_time_fails_for_directory,
[forall(theory_bg:file_false(DirId)), fail]) :-
access_time(DirId, _Time).
%%
%% change_time/2
%%
% change_time(+File,-Time) is semidet.
test(change_time_semidet_true,
[forall(theory_bg:change_time(FileId, ExpectedTime)),
true(Time == ExpectedTime)
]) :- change_time(FileId, Time).
test(change_time_semidet_false,
[forall(theory_bg:item_false(UnknownId)), fail]) :-
change_time(UnknownId, _Time).
% change_time(+Directory, -Size) fails
test(change_time_fails_for_directory,
[forall(theory_bg:file_false(DirId)), fail]) :-
change_time(DirId, _Time).
% access_time(+Item,-Time) is semidet.
% change_time(+Item,-Time) is semidet.
% creation_time(+Item,-Time) is semidet.
test(time_semibound, forall(
( member(TimePred, [
access_time,
change_time,
creation_time
]),
call(theory_bg:TimePred,TrueItemId,TrueTime)
)
)) :-
first_bound(TimePred/2, [TrueItemId, TrueTime]).
% creation_time(+Item, -Time) det if Item is known, false else
test(creation_time_semidet) :-
semidet_for_item(creation_time/2).
% access_time(+File, -Time) det if file is known, false else
% change_time(+File, -Time) det if file is known, false else
test(other_time_semidet, forall(member(TimePred, [
access_time,
change_time,
modification_time
]))
) :-
semidet_for_file(TimePred/2).
%%
%%
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment