/* * Verrückte Turing-Maschinen — A turing complete game * Copyright (C) 2016-2018 kcf * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ module mod_vtm { export module mod_model { export module mod_test { /** * @author kcf */ export type type_test = lib_call.type_complex; /** * @author kcf */ export function input ( test : type_test ) : Array { return ( lib_call.distinguish> ( test, { "acceptortest": (data) => mod_acceptortest.input(data), "transducertest": (data) => mod_transducertest.input(data), } ) ); } /** * @author kcf */ export function pruefen ( test : type_test, accepted : boolean, ausgabe : Array ) : boolean { return ( lib_call.distinguish ( test, { "acceptortest": (data) => mod_acceptortest.pruefen(data, accepted, ausgabe), "transducertest": (data) => mod_transducertest.pruefen(data, accepted, ausgabe), } ) ); } /** * @author kcf */ export function import_ ( test_raw : any ) : type_test { switch (test_raw["kind"]) { case "acceptortest": { return { "kind": "acceptortest", "data": ( mod_acceptortest.create ( test_raw["data"]["input"], test_raw["data"]["accept"] ) ), }; break; } case "transducertest": { return { "kind": "transducertest", "data": ( mod_transducertest.create ( test_raw["data"]["input"], test_raw["data"]["output"] ) ), }; break; } default: { throw (new Error("unbehandelt")); break; } } } } } }