write("\nCopyright (C) 1999-2002 INRIA/INSA de Rennes."),
write("\n**************************************************\n"),
write("******** Non regression test for Morphine *********\n"),
write("**************************************************\n\n"),


write("**************************************************\n"),
	write("**** Display the first 20 events:\n"),
	run(queens),
	next,
	current(chrono=C), 
	C > 10,
	next_np, 
	print_full_event, 
	current(chrono=C2), 
	C2 >= 20, !, 
	no_trace,
	write("*** the first 20 events: ok.\n").

write("\n**************************************************"),
	write("\n**** Testing toggle/1...\n"),
	rerun,
	fget(name = data and port = exit), !,
	member(X, [chrono, call, port, depth, deter, proc_type, decl_module, 
		def_module, name, arity, mode_number, arg, local_vars, type, 
		goal_path]),
	write("toggle "),
	write(X),
	write(" attribute:\n"),
	toggle(X),
	print_event,
	toggle(X),
	print_event,
	fail.
        no_trace,
	write("*** toggle: ok.\n").

write("\n**************************************************"),
	write("\n**** Testing one by one variable retrieval...\n"),
	rerun,
	fget(name = queen and port = exit),
	current(var_names_and_types = List),
	List = [live_var_names_and_types(VarName, _)| _],
	write(List), nl,
	current_live_var(VarName, Var, _),
	write_trace(Var), !,
	no_trace,
	write("*** one by one variable retrieval: ok.\n").

write("\n**************************************************"),
	write("\n**** Testing current...\n"),
	rerun,
	fget(name = queen and port = exit),
      
	% testing current_live_var
	setof((Name, Value, Type), current_live_var(Name, Value, Type), List),
	write("current_live_var: "),
	write(List), nl,

	% testing attributes retrieval
	write("chrono = "),
 	current(chrono = Xchrono),
	write(Xchrono),
	write("\ncall = "),
	current(call = Xcall),
	write(Xcall),
	write("\ndepth = "),
	current(depth = Xdepth),
	write(Xdepth),
	write("\nport = "),
	current(port = Xport),
	write(Xport),
	write("\npred_or_func = "),
	current(pred_or_func = Xpred_or_func),
	write(Xpred_or_func),
	write("\ndef_module = "),
	current(def_module = Xdef_module),
	write(Xdef_module),
	write("\ndecl_module = "),
	current(decl_module = Xdecl_module),
	write(Xdecl_module),
	write("\nname = "),
	current(name = Xname),
	write(Xname),
	write("\narity = "),
	current(arity = Xarity),
	write(Xarity),
	write("\nproc = "),
	current(proc = Xproc),
	write(Xproc),
	write("\ndet = "),
	current(det = Xdet),
	write(Xdet),
	write("\ngoal_path = "),
	current(goal_path = Xgoal_path),
	write(Xgoal_path),
	write("\nargs = "),
	current(args = Xargs),
	write(Xargs),
	write("\narg_names = "),
	current(arg_names = Xarg_names),
	write(Xarg_names),
	write("\narg_types = "),
	current(arg_types = Xarg_types),
	write(Xarg_types),
	write("\nvars = "),
	current(vars = Xvars),
	write(Xvars),
	write("\nvar_names_and_types = "),
	current(var_names_and_types = Xvar_names_and_types),
	write(Xvar_names_and_types),
	write("\nnon_arg_vars = "),
	current(non_arg_vars = Xnon_arg_vars),
	write(Xnon_arg_vars), nl,
	
	% test current(proc = ...)
	current(proc = (PT1->M1:(P1/A1-MN1))), nl,
	write(PT1->M1:(P1/A1-MN1)),
	current(proc =  M2:(P2/A2-MN2) ), nl,
	write(M2:(P2/A2-MN2)),
	current(proc =  (PT3->(P3/A3-MN3)) ), nl,
	write( PT3->(P3/A3-MN3)),
	current(proc =  (PT4->(M4:(P4-MN4))) ), nl,
	write(PT4->M4:(P4-MN4)),
	current(proc =  (PT5->(M5:(P5/A5))) ), nl,
	write(PT5->(M5:(P5/A5))),
	current(proc =  (P6/A6-MN6) ), nl,
	write((P6/A6-MN6)),
	current(proc =  M7:(P7-MN7) ), nl,
	write(M7:(P7-MN7)),
	current(proc =  M8:(P8/A8) ), nl,
	write(M8:(P8/A8)),
	current(proc =  (PT9->(P9-MN9)) ), nl,
	write(PT9->(P9-MN9)),
	current(proc = ( PT10->(P10/A10)) ), nl,
	write(PT10->(P10/A10)),
	current(proc =  (PT11->(M11:(P11)) )), nl,
	write(PT11->M11:(P11) ),
	current(proc =  (PT12->P12) ), nl,
	write(PT12->P12),
	current(proc =  M13:P13 ), nl,
	write(M13:P13),
	current(proc =  P14/A14 ), nl,
	write(P14/A14),
	current(proc =  P15-MN15 ), nl,
	write( P15-MN15),
	current(proc =  P16), nl, 
	write(P16), !,
 	no_trace,
	write("*** current: ok.\n").

write("\n**************************************************"),
	write("\n**** Testing retry/1...\n"),
	rerun,
	fget(name = queen and port = exit),
	retry, !,
	no_trace,
	write("*** retry: ok.\n").

write("\n**************************************************"),
	write("\n**** Testing stack dumps...\n"),
	rerun,
	fget(name = data and port = exit), !,
	current(stack = Stack),
	stack, !,
	no_trace,
	write("*** stack: ok.\n").

% write("\n**************************************************"),
% 	write("\n**** Testing the term browser...\n"),
% 	rerun,
% 	fget(name = data and port = exit),
% 	open("browse.in", read, browse_stream),
% 	set_stream(input, browse_stream),
% 	browse("HeadVar__1"),
% 	close(browse_stream),
% 	no_trace,
% 	write("*** browser: ok.\n").

write("\n**************************************************"),
	write("\n**** Testing collect...\n"),
	rerun, 
	set_parameter(collect_arg, [yes]),
	collect(solutions, Result),
	writeq(Result), nl, nl,
	rerun,
	collect(test_ln, Result2),
	writeq(Result2),
	write("\n*** collect: ok.\n").

write("\n**************************************************"),
	write("\n**** Testing call_site_cov...\n"),
	make(coverage),
	call_site_cov("queens", Uncovered), 
	write("\nUncovered call sites are:\n"), 
	checklist(printf("%w\n"), Uncovered),
	write("\n*** call_site_cov: ok.\n").

write("\n**************************************************"),
	write("\n**** Testing pred_cov...\n"),
	pred_cov("queens", Uncovered), 
	write("\nUncovered predicates are:\n"), 
	checklist(printf("%w\n"), Uncovered),
	write("\n*** pred_cov: ok.\n").

write("\n**************************************************"),
	write("\n**** Testing other Morphine commands...\n"),
	write("apropos(window)"), nl, 
	apropos(man),
	write("man(apropos)"), nl, 
	man(apropos), 
	write("*** other Morphine commands: ok.\n"),

write("**************************************************\n").
