vtm/quelldatein/aufbau/aufgaben/test.ts
2018-03-26 14:22:20 +02:00

133 lines
3.2 KiB
TypeScript

/*
* Verrückte Turing-Maschinen — A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
module mod_vtm
{
export module mod_aufbau
{
export module mod_test
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_test = typ_komplex<Object>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function eingabe
(
test : typ_test
)
: Array<mod_vtm.mod_aufbau.mod_symbol.typ_symbol>
{
return (
fallunterscheidung<Array<mod_vtm.mod_aufbau.mod_symbol.typ_symbol>>
(
test,
{
"akzeptortest": (angaben) => mod_akzeptortest.eingabe(angaben),
"transduktortest": (angaben) => mod_transduktortest.eingabe(angaben),
}
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function pruefen
(
test : typ_test,
angenommen : boolean,
ausgabe : Array<mod_vtm.mod_aufbau.mod_symbol.typ_symbol>
)
: boolean
{
return (
fallunterscheidung<boolean>
(
test,
{
"akzeptortest": (angaben) => mod_akzeptortest.pruefen(angaben, angenommen, ausgabe),
"transduktortest": (angaben) => mod_transduktortest.pruefen(angaben, angenommen, ausgabe),
}
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function importieren
(
test_roh : any
)
: typ_test
{
switch (test_roh["art"])
{
case "akzeptortest":
{
return {
"art": "akzeptortest",
"angaben": (
mod_akzeptortest.erstellen
(
test_roh["angaben"]["eingabe"],
test_roh["angaben"]["annehmen"]
)
),
};
break;
}
case "transduktortest":
{
return {
"art": "transduktortest",
"angaben": (
mod_transduktortest.erstellen
(
test_roh["angaben"]["eingabe"],
test_roh["angaben"]["ausgabe"]
)
),
};
break;
}
default:
{
throw (new Error("unbehandelt"));
break;
}
}
}
}
}
}