diff --git a/prolog/metta_lang/metta_testing.pl b/prolog/metta_lang/metta_testing.pl index 4fab135c7..e8b3e11d5 100755 --- a/prolog/metta_lang/metta_testing.pl +++ b/prolog/metta_lang/metta_testing.pl @@ -423,7 +423,7 @@ % @example % % Log the details of a test with a passing status: % ?- write_pass_fail(['source', 'category', 'type'], 'PASS', some_goal(arg1, arg2)). -write_pass_fail([P, C, _], PASS_FAIL, G) :- +write_pass_fail([P, C| _], PASS_FAIL, G) :- !, % Ensures deterministic logging of the test result. must_det_ll(( % Retrieves the current test number. @@ -437,6 +437,7 @@ write_pass_fail(TestName, P, C, PASS_FAIL, G1, G2))). write_pass_fail(LIST, PASS_FAIL, G) :- is_list(LIST), PCC = [P, _, _], member(PCC,LIST), nonvar(P), !, write_pass_fail(PCC, PASS_FAIL, G). +write_pass_fail(LIST, PASS_FAIL, G) :- is_list(LIST), PCC = [P|_], member(PCC,LIST), nonvar(P), !, write_pass_fail(PCC, PASS_FAIL, G). %! write_pass_fail(+TestName, +Source, +Category, +Status, +GoalArg1, +GoalArg2) is det. % diff --git a/prolog/metta_lang/metta_types.pl b/prolog/metta_lang/metta_types.pl index 8e0ff9fa9..595a5e84e 100755 --- a/prolog/metta_lang/metta_types.pl +++ b/prolog/metta_lang/metta_types.pl @@ -2235,26 +2235,33 @@ % Enums for Guarded Type Handling in Prolog % GuardMatchResult: Describes the result of evaluating several type guards against the function arguments. -mo_match_behavior(fail_on_no_match). mo_match_behavior(return_original_on_no_match). +mo_match_behavior(fail_on_no_match). +mo_match_behavior(throw_type_error_on_no_match). % EvaluationOrder: Describes how the type guards are prioritized during evaluation. -evaluation_order(fittest_first_priority). evaluation_order(clause_order_priority). +evaluation_order(fittest_first_priority). % ExecutionResult: Describes the outcome of executing the guarded expression. -execution_result_behavior(cut_on_first_success). execution_result_behavior(continue_on_success). +execution_result_behavior(cut_on_first_success). % ExecutionResult: Describes the outcome of executing the guarded expression. -execution_failed_behavior(cut_on_first_failure). execution_failed_behavior(continue_on_failure). +execution_failed_behavior(cut_on_first_failure). % What do when there are no successfull bodies -out_of_clauses_behavior(fail_on_no_success). -out_of_clauses_behavior(return_original_on_no_success). +out_of_clauses_behavior(fail_on_final_failure). +out_of_clauses_behavior(return_original_on_final_failure). + + %predicate_behavior(Predicate, Len, NoMatchBehavior, EvaluationOrder, SuccessBehavior, FailureBehavior, OutOfClausesBehavior) -predicate_behavior_impl('get-type', 1, fail_on_no_match, clause_order_priority, continue_on_success, continue_on_failure, fail_on_no_success). +predicate_behavior_impl('get-type', 1, fail_on_no_match, clause_order_priority, continue_on_success, continue_on_failure, fail_on_final_failure). + +predicate_behavior_impl('foo', 2, return_original_on_no_match, fittest_first_priority, continue_on_success, continue_on_failure, return_original_on_final_failure). + +predicate_behavior_impl('match', 4, fail_on_no_match, clause_order_priority, continue_on_success, continue_on_failure, fail_on_final_failure). % default -predicate_behavior_fallback(_, _, return_original_on_no_match, clause_order_priority, continue_on_success, continue_on_failure, return_original_on_no_success). +predicate_behavior_fallback(_, _, return_original_on_no_match, clause_order_priority, continue_on_success, continue_on_failure, return_original_on_final_failure). predicate_behavior(Predicate, Len, NoMatchBehavior, EvaluationOrder, SuccessBehavior, FailureBehavior, OutOfClausesBehavior):- predicate_behavior_impl(Predicate, Len, NoMatchBehavior, EvaluationOrder, SuccessBehavior, FailureBehavior, OutOfClausesBehavior) @@ -2312,7 +2319,7 @@ (FailureBehavior == cut_on_first_failure -> (!, fail) ; fail)) % vs continue_on_failure *-> true ; - (OutOfClausesBehavior == fail_on_no_success -> fail ; throw(metta_notreducable([Predicate | Parameters])))). % vs return_original_on_no_success + (OutOfClausesBehavior == fail_on_final_failure -> fail ; throw(metta_notreducable([Predicate | Parameters])))). % vs return_original_on_final_failure