%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  This file is part of Logtalk <https://logtalk.org/>
%  SPDX-FileCopyrightText: 2017-2026 Paulo Moura <pmoura@logtalk.org>
%  SPDX-License-Identifier: Apache-2.0
%
%  Licensed under the Apache License, Version 2.0 (the "License");
%  you may not use this file except in compliance with the License.
%  You may obtain a copy of the License at
%
%      http://www.apache.org/licenses/LICENSE-2.0
%
%  Unless required by applicable law or agreed to in writing, software
%  distributed under the License is distributed on an "AS IS" BASIS,
%  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%  See the License for the specific language governing permissions and
%  limitations under the License.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


:- object(metric_api_tests,
	extends(lgtunit)).

	:- info([
		version is 1:0:0,
		author is 'Paulo Moura',
		date is 2026-03-16,
		comment is 'API-level tests to exercise the entity/file/directory/library/all predicates in metrics.'
	]).

	cover(code_metric).
	cover(cc_metric).
	cover(noc_metric).
	cover(nor_metric).
	cover(upn_metric).
	cover(wmc_metric).
	cover(rfc_metric).
	cover(cogc_metric).

	test(metric_api_cc, deterministic) :-
		run_metric_api(cc_metric).

	test(metric_api_noc, deterministic) :-
		run_metric_api(noc_metric).

	test(metric_api_nor, deterministic) :-
		run_metric_api(nor_metric).

	test(metric_api_upn, deterministic) :-
		run_metric_api(upn_metric).

	test(metric_api_wmc, deterministic) :-
		run_metric_api(wmc_metric).

	test(metric_api_rfc, deterministic) :-
		run_metric_api(rfc_metric).

	test(metric_api_cogc, deterministic) :-
		run_metric_api(cogc_metric).

	run_metric_api(Metric) :-
		Metric::entity(expert_system),
		object_property(expert_system, file(File)),
		Metric::file(File),
		logtalk::expand_library_path(core, Directory),
		Metric::directory(Directory),
		Metric::rdirectory(Directory),
		Metric::library(core),
		Metric::rlibrary(core),
		Metric::all.

:- end_object.
