Commit 52e00262 authored by Steffen Michels's avatar Steffen Michels

Merge branch 'testevent-type' into 'master'

Add TestEvent type for both Start and End events

See merge request !107
parents b37f9b7c 11185b0f
Pipeline #9428 passed with stage
in 1 minute and 52 seconds
......@@ -9,6 +9,15 @@ definition module Testing.TestEvents
from Text.JSON import generic JSONEncode, generic JSONDecode, :: JSONNode, :: Maybe
/**
* Events that are emitted from tests.
* Specialised JSONEncode/JSONDecode instances are used for this type, which
* have to be adapted in case the type definition is changed!
*/
:: TestEvent
= StartEvent StartEvent //* A test has started
| EndEvent EndEvent //* A test has finished
/**
* Event emitted when a test is started.
* Specialised JSONEncode/JSONDecode instances are used for this type, which
......@@ -34,6 +43,5 @@ from Text.JSON import generic JSONEncode, generic JSONDecode, :: JSONNode, :: Ma
| Failed //* The test failed
| Skipped //* The test was not executed, but should be executed and pass for future versions
derive JSONEncode StartEvent, EndEvent
derive JSONDecode StartEvent, EndEvent
derive JSONEncode TestEvent, StartEvent, EndEvent
derive JSONDecode TestEvent, StartEvent, EndEvent
......@@ -2,6 +2,15 @@ implementation module Testing.TestEvents
import Text.JSON, Control.Monad, StdFunc, StdTuple, StdList, Data.Maybe, Control.Applicative
JSONEncode{|TestEvent|} c (StartEvent se) = JSONEncode{|*|} c se
JSONEncode{|TestEvent|} c (EndEvent ee) = JSONEncode{|*|} c ee
JSONDecode{|TestEvent|} b json = case JSONDecode{|*|} b json of
(Just se, json) -> (Just (StartEvent se), json)
_ -> case JSONDecode{|*|} b json of
(Just ee, json) -> (Just (EndEvent ee), json)
(Nothing, json) -> (Nothing, json)
JSONEncode{|StartEvent|} _ startEvent = [ JSONObject [ ("name", JSONString startEvent.StartEvent.name)
, ("event", JSONString "start")
]
......@@ -40,4 +49,3 @@ JSONDecode{|EndEventType|} _ nodes = (Nothing, nodes)
derive JSONEncode EndEvent
derive JSONDecode EndEvent
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