Commit 36ed7356 authored by Bas Lijnse's avatar Bas Lijnse

Updated test framework to use gPrint values in test events.

parent e406ffac
Pipeline #12665 failed with stage
in 1 minute and 57 seconds
......@@ -3,6 +3,7 @@ import iTasks
import iTasks.Util.Trace
from iTasks.Internal.TaskStore import :: TaskOutputMessage(..)
from Testing.TestEvents import :: EndEventType
from Text.GenPrint import generic gPrint, :: PrintState, class PrintOutput
:: UnitTest
= { name :: String
......@@ -27,16 +28,16 @@ derive gEditor UnitTest
derive gText UnitTest
derive gDefault UnitTest
assert :: String (a -> Bool) a -> UnitTest | JSONEncode{|*|} a
assert :: String (a -> Bool) a -> UnitTest
assertEqual :: String a a -> UnitTest | gEq{|*|} a & JSONEncode{|*|} a
assertEqual :: String a a -> UnitTest | gEq{|*|} a & gPrint{|*|} a
assertWorld :: String (a -> Bool) (*World -> *(a,*World)) -> UnitTest | JSONEncode{|*|} a
assertWorld :: String (a -> Bool) (*World -> *(a,*World)) -> UnitTest
assertEqualWorld :: String a (*World -> *(a,*World)) -> UnitTest | gEq{|*|} a & JSONEncode{|*|} a
assertEqualWorld :: String a (*World -> *(a,*World)) -> UnitTest | gEq{|*|} a & gPrint{|*|} a
checkEqual :: a a -> EndEventType | gEq{|*|} a & JSONEncode{|*|} a
checkEqualWith :: (a a -> Bool) a a -> EndEventType | JSONEncode{|*|} a
checkEqual :: a a -> EndEventType | gEq{|*|} a & gPrint{|*|} a
checkEqualWith :: (a a -> Bool) a a -> EndEventType | gPrint{|*|} a
pass :: String -> UnitTest
......
......@@ -5,7 +5,7 @@ import iTasks.Extensions.Image
import iTasks.UI.Editor, iTasks.UI.Editor.Controls, iTasks.UI.Editor.Common, iTasks.UI.Definition
import iTasks.Extensions.Editors.Ace
import iTasks.Internal.Serialization
import Text, Text.HTML, System.CommandLine
import Text, Text.HTML, Text.GenPrint, System.CommandLine
import qualified Data.Map as DM
import iTasks.Extensions.Development.Codebase
import Data.Func, Data.Either, Data.Error
......@@ -39,36 +39,35 @@ where
pass :: *World -> *(EndEventType,*World)
pass w = (Passed,w)
assert :: String (a -> Bool) a -> UnitTest | JSONEncode{|*|} a
assert :: String (a -> Bool) a -> UnitTest
assert name exp sut = {UnitTest|name=name,test=test}
where
test w = (if (exp sut) Passed (Failed Nothing),w)
assertEqual :: String a a -> UnitTest | gEq{|*|} a & JSONEncode{|*|} a
assertEqual :: String a a -> UnitTest | gEq{|*|} a & gPrint{|*|} a
assertEqual name exp sut = {UnitTest|name=name,test=test}
where
test w = (checkEqual exp sut,w)
assertWorld :: String (a -> Bool) (*World -> *(a,*World)) -> UnitTest | JSONEncode{|*|} a
assertWorld :: String (a -> Bool) (*World -> *(a,*World)) -> UnitTest
assertWorld name exp sut = {UnitTest|name=name,test=test}
where
test w
# (res,w) = sut w
= (if (exp res) Passed (Failed Nothing),w)
assertEqualWorld :: String a (*World -> *(a,*World)) -> UnitTest | gEq{|*|} a & JSONEncode{|*|} a
assertEqualWorld :: String a (*World -> *(a,*World)) -> UnitTest | gEq{|*|} a & gPrint{|*|} a
assertEqualWorld name exp sut = {UnitTest|name=name,test=test}
where
test w
# (res,w) = sut w
= (if (exp === res) Passed (Failed (Just (FailedAssertions [ExpectedRelation (JSON (toJSON exp)) Eq (JSON (toJSON res))]))),w)
= (if (exp === res) Passed (Failed (Just (FailedAssertions [ExpectedRelation (GPrint (printToString exp)) Eq (GPrint (printToString res))]))),w)
checkEqual :: a a -> EndEventType | gEq{|*|} a & JSONEncode{|*|} a
checkEqual :: a a -> EndEventType | gEq{|*|} a & gPrint{|*|} a
checkEqual exp sut = checkEqualWith (===) exp sut
checkEqualWith :: (a a -> Bool) a a -> EndEventType | JSONEncode{|*|} a
checkEqualWith pred exp sut = if (pred exp sut) Passed (Failed (Just (FailedAssertions [ExpectedRelation (JSON (toJSON exp)) Eq (JSON (toJSON sut))])))
checkEqualWith :: (a a -> Bool) a a -> EndEventType | gPrint{|*|} a
checkEqualWith pred exp sut = if (pred exp sut) Passed (Failed (Just (FailedAssertions [ExpectedRelation (GPrint (printToString exp)) Eq (GPrint (printToString sut))])))
pass :: String -> UnitTest
pass name = {UnitTest|name=name,test = \w -> (Passed,w)}
......
......@@ -8,7 +8,8 @@ import Testing.TestEvents
import System.OS, Data.Either, Data.Functor
import qualified Data.Set as DS
import qualified Data.Map as DM
import Text.GenJSON
import Text.GenPrint
derive JSONEncode TaskOutputMessage
......
......@@ -9,7 +9,8 @@ import qualified Data.Set as DS
import Data.Maybe
derive gEq LUI, LUIChanges, LUIEffects, LUIEffectStage, LUINo
derive JSONEncode LUI, LUIChanges, LUIEffects, LUIEffectStage, LUINo, Set
derive gPrint LUI, LUIChanges, LUIEffects, LUIEffectStage, LUINo, Set, UI, UIType, JSONNode, Map
derive gPrint Maybe, UIChange, UIChildChange, UIAttributeChange
import Data.GenLexOrd
derive gLexOrd LUIEffectStage
......
......@@ -2,9 +2,10 @@ module iTasks.WF.Tasks.Core.UnitTests
import iTasks.Util.Testing
import qualified Data.Map as DM
import Data.Either
import Text.GenJSON
import Text.GenPrint
derive JSONEncode TaskOutputMessage
derive gPrint TaskOutputMessage
derive gPrint UIChange, UIChildChange, UIAttributeChange, UI, UIType, Map, JSONNode
//Test interact
expPromptUI msg
......@@ -33,6 +34,7 @@ where
,("mode",JSONString "update")
,("taskId",JSONString "1-0")
,("value",JSONString "Hello world")
,("minlength",JSONInt 1)
])
tests = [minimalInteractUI]
......
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