Verified Commit 0f78fc16 authored by Camil Staps's avatar Camil Staps 🚀

Make TestableWithOptions architecture more logical

parent 07a86aae
......@@ -10,26 +10,24 @@ from Gast.Testable import class Testable, :: Testoption
/**
* This class extends TestableWithOptions with a member to get Testoptions.
*/
class TestableWithOptions a | Testable a
where
getOptions :: a -> [Testoption]
class getOptions a :: a -> [Testoption]
/**
* The default implemenetation of TestableWithOptions is to have no options.
*/
instance TestableWithOptions a
instance getOptions a
instance Testable ([o], a) | Testable a
instance TestableWithOptions ([Testoption], a) | Testable a
instance getOptions ([Testoption], a)
/**
* Wrap a TestableWithOptions in an existential type to easily build
* quasi-heterogeneous lists of properties.
*/
:: ExposedProperty = E.p: EP p & TestableWithOptions p
:: ExposedProperty = E.p: EP p & Testable, getOptions p
instance Testable ExposedProperty
instance TestableWithOptions ExposedProperty
instance getOptions ExposedProperty
/**
* Expose a set of Gast properties as a CLI application.
......@@ -37,4 +35,4 @@ instance TestableWithOptions ExposedProperty
* @param The default options for all tests.
* @param The tests to expose.
*/
exposeProperties :: ![Testoption] ![a] !*World -> *World | TestableWithOptions a
exposeProperties :: ![Testoption] ![a] !*World -> *World | Testable, getOptions a
......@@ -19,29 +19,23 @@ import Text
import Gast
instance TestableWithOptions a
where
getOptions _ = []
instance getOptions a where getOptions _ = []
instance Testable ([o], a) | Testable a
where
evaluate (_,p) g a = evaluate p g a
testname (_,p) = testname p
instance TestableWithOptions ([Testoption], a) | Testable a
where
getOptions (opts,_) = opts
instance getOptions ([Testoption], a) where getOptions (opts,_) = opts
instance Testable ExposedProperty
where
evaluate (EP p) g a = evaluate p g a
testname (EP p) = testname p
instance TestableWithOptions ExposedProperty
where
getOptions (EP p) = getOptions p
instance getOptions ExposedProperty where getOptions (EP p) = getOptions p
exposeProperties :: ![Testoption] ![a] !*World -> *World | TestableWithOptions a
exposeProperties :: ![Testoption] ![a] !*World -> *World | Testable, getOptions a
exposeProperties globopts ps w
# ([_:opts], w) = getCommandLine w
# opts = parseOptions optionDescription opts gDefault{|*|}
......@@ -60,7 +54,7 @@ exposeProperties globopts ps w
# (_,w) = fclose io w
= w
where
test :: ![Testoption] !a -> [String] | TestableWithOptions a
test :: ![Testoption] !a -> [String] | Testable, getOptions a
test useropts p = Test (globopts ++ useropts ++ getOptions p) p
error :: !String !*World -> *World
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment