/* This file is part of »munin«. Copyright 2025 'Fenris Wolf' »munin« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »munin« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »munin«. If not, see . */ namespace _munin.helpers.test { /** * @todo outsource */ type type_testcase_raw = { active ?: boolean; name ?: string; input : type_input; output : type_output; }; /** * @todo outsource */ export type type_testcase = { name : string; input : type_input; output : type_output; }; /** * @todo outsource */ export async function get_data( path : string, { "default_active": default_active = true, } : { default_active ?: boolean; } = { } ) : Promise>> { const content : string = await lib_plankton.file.read(path); const testcases_raw : Array> = ( lib_plankton.json.decode(content) as Array> ); const testcases : Array> = ( testcases_raw .filter( testcase_raw => (testcase_raw.active ?? default_active), ) .map( (testcase_raw, index) => ({ "name": ( testcase_raw.name ?? lib_plankton.string.coin( "{{path}} | #{{index}}", { "path": path, "index": (index + 1).toFixed(0), } ) ), "input": testcase_raw.input, "output": testcase_raw.output, }) ) ); return testcases; } /** * @todo outsource */ export function start( name : string ) : void { lib_plankton.log._info( "test.run", { "details": { "name": name, } } ); } /** * @todo outsource */ export function fail( name : string ) : void { lib_plankton.log._error( "test.failed", { "details": { "name": name, } } ); } }