
:- ensure_loaded(qtest).

app_config(db_dir, './test_persistence.dir').

:- ensure_loaded(db).
:- app_db_init.

:- ensure_loaded(persistent_term_index).
:- persistent_term_index_open.

:- ensure_loaded(persistence). 

:- persistent_term_index_clear.

go :- run_qtests.



:- persistent(test_pred/1).

qtest :-
	\+ test_pred(_),
	\+ test_pred(x),
	passert(test_pred(x)),
	test_pred(x),
	test_pred(_),
	pretractall(test_pred(_)),
	\+ test_pred(_),
	\+ test_pred(x).

qtest :-
	L = [ a, b, c, "Hello, There!", 123123.455, 'Joe!', [] ],
	sort(L, SL),
	forall( member(M, SL),
		passert(test_pred(M))
	      ),
	findall(M,
		test_pred(M),
	       L2),
	sort(L2, SL2),
	SL2 = SL,
	pretractall(test_pred(_)).




:- persistent(test_pred2/2).

qtest :-
	\+ test_pred2(_,_),
	\+ test_pred2(x,y),
	passert(test_pred2(x,y)),
	test_pred2(x,y),
	test_pred2(_,y),
	test_pred2(x,_),
	test_pred2(_,_),
	pretractall(test_pred2(x,y)),
	\+ test_pred2(_,_),
	\+ test_pred2(x,y).




:- persistent(word_to_term/2, [key(c_string)]).

qtest :-
	passert(word_to_term(foo, hello(there))),
	word_to_term(foo, hello(there)),
	passert(word_to_term(foo, 7)),
	\+ word_to_term(foo, hello(there)),
	word_to_term(foo, 7).


