TeamSPoon / swipl-devel-unstable

DIFF https://github.com/SWI-Prolog/swipl-devel/compare/master...logicmoo:master_dvard
https://docs.google.com/document/d/1jo8aG_C7wwh1lZzPsFMfh3DEcRjhTQ-MMT_D2_GimEQ/edit
Other
4 stars 1 forks source link

Lists of new tests #3

Open TeamSPoon opened 8 years ago

TeamSPoon commented 8 years ago
root@gitlab:/devel/LogicmooDeveloperFramework/swipl-devel# cat sanity_tests.pl
:- module(demo, [ demo/1]).
demo(Var) :- put_attr(Var, demo, x).
verify_attributes(Var, _Value, [hello(Var)]).
hello(Var) :- writeln(Var).
attr_unify_hook(_,_).

/*

demo(X), X = 1.
Wakeup: wakeup(system,_G1500,att(demo,x,[]),1,[])
1
X = 1
So far, so good. But ... we only get one wakeup here.

demo(X), a(X,Y) = a(1,2).
Wakeup: wakeup(system,_G1584,att(demo,x,[]),1,[])
1
X = 1,
Y = 2.
Or this. I think this should fail right away, no? Now we get dif(X,a), a(X,X) = a(1,2) succeeds with X=1. I fear that the verification hook gets really complicated if unification does not already catch this.

demo(X), a(X,X) = a(1,2).
Wakeup: wakeup(system,_G1572,att(demo,x,[]),1,wakeup(system,_G1572,att(demo,x,[]),2,[]))
1
X = 1.

*/
root@gitlab:/devel/LogicmooDeveloperFramework/swipl-devel# swipl sanity_tests.pl

Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.3.15-69-ga4a72bb-DIRTY)
Copyright (c) 1990-2015 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.

For help, use ?- help(Topic). or ?- apropos(Word).

1 ?- demo(X), X = 1.
1
X = 1.

2 ?- demo(X), a(X,Y) = a(1,2).
1
X = 1,
Y = 2.

3 ?- dif(X,a), a(X,X) = a(1,2).
false.

4 ?- demo(X), a(X,X) = a(1,2).
false.
TeamSPoon commented 8 years ago
?- asserta((va_test:verify_attributes(Var,_,[]):-get_attr(Var,va_test,Val),must_be(var,Val))).

?-  put_attr(X,va_test,Y), t(X,Y)=t(1,1).

DRA_META

ffooo:-writeln(‘foo’).
barrr(G):- writen(‘Calling‘:G),G.
?- '$set_pattr'(ffooo, pred, (dra_meta)=barrr),ffooo.
Calling:ffooo
foo