-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added TestRunner component, integrated into sidebar
- Loading branch information
1 parent
82a62e5
commit 63827a6
Showing
17 changed files
with
313 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
```mermaid | ||
flowchart TD | ||
not_started((Not Started)) | ||
check_for_port_mismatch | ||
check_for_failed_restriction | ||
convert_to_evaluable | ||
ready_for_testing | ||
level_complete((Level Complete)) | ||
not_started --- check_for_port_mismatch | ||
test_n_succeeded --- check_for_port_mismatch | ||
check_for_port_mismatch --- check_for_failed_restriction | ||
check_for_failed_restriction --- convert_to_evaluable | ||
convert_to_evaluable --- ready_for_testing | ||
ready_for_testing --- run_tests | ||
subgraph test_runner | ||
run_tests | ||
all_tests_succeeded | ||
test_n_failed | ||
test_n_succeeded | ||
run_test_n | ||
run_tests --- test_n_failed | ||
run_tests --- all_tests_succeeded | ||
test_n_failed --- run_test_n | ||
run_test_n --- test_n_failed | ||
run_test_n --- test_n_succeeded | ||
end | ||
all_tests_succeeded --- level_complete | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module Component.TestRunner | ||
( component | ||
, module Component.TestRunner.Types | ||
) where | ||
|
||
import Component.TestRunner.Render | ||
import Component.TestRunner.Types | ||
import Prelude | ||
|
||
import Control.Monad.State.Class (modify_) | ||
import Data.Array as A | ||
import Data.FunctorWithIndex (mapWithIndex) | ||
import Data.LimitQueue (LimitQueue) | ||
import Data.LimitQueue as LQ | ||
import Data.Map (Map) | ||
import Data.Map as M | ||
import Data.Maybe (Maybe(..), maybe) | ||
import Data.Set as S | ||
import Data.Traversable (for) | ||
import Data.TraversableWithIndex (forWithIndex) | ||
import Game.Capacity (Capacity(..)) | ||
import Game.Direction (CardinalDirection) | ||
import Game.Level.Completion (TestCaseOutcome) | ||
import Game.Port (Port(..), isInput, isOutput, portCapacity) | ||
import Game.Signal (Base, Signal, SignalRepresentation(..), printSignal) | ||
import Halogen (ComponentHTML, defaultEval, mkEval) | ||
import Halogen as H | ||
import Halogen.HTML (HTML) | ||
import Halogen.HTML as HH | ||
import Halogen.HTML.Properties as HP | ||
|
||
component :: forall m. H.Component Query Input Output m | ||
component = H.mkComponent { eval, initialState, render } | ||
where | ||
eval = mkEval (defaultEval) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
module Component.TestRunner.Render where | ||
|
||
import Component.TestRunner.Types | ||
import Prelude | ||
|
||
import Data.Array (replicate) | ||
import Data.Array as A | ||
import Data.Foldable (length) | ||
import Data.FunctorWithIndex (mapWithIndex) | ||
import Data.Map as M | ||
import Data.Maybe (maybe) | ||
import Data.Set as S | ||
import Data.Zipper as Z | ||
import Game.Capacity (Capacity(..)) | ||
import Game.Port (isInput, isOutput, portCapacity) | ||
import Game.Signal (SignalRepresentation(..), printSignal) | ||
import Halogen (ComponentHTML) | ||
import Halogen.HTML as HH | ||
import Halogen.HTML.Properties as HP | ||
|
||
render :: forall s m. State -> ComponentHTML Action s m | ||
render state = HH.table_ (renderHeaders <> renderRows) | ||
where | ||
inputDirs = M.keys $ M.filter isInput state.ports | ||
outputDirs = M.keys $ M.filter isOutput state.ports | ||
|
||
renderHeaders = | ||
[ HH.tr_ | ||
[ HH.td_ | ||
[ HH.text "Index" ] | ||
, HH.td | ||
[ HP.colSpan (S.size inputDirs) ] | ||
[ HH.text "Inputs" ] | ||
, HH.td | ||
[ HP.colSpan (S.size outputDirs) ] | ||
[ HH.text "Expected" ] | ||
, HH.td | ||
[ HP.colSpan (S.size outputDirs) ] | ||
[ HH.text "Reveived" ] | ||
, HH.td_ | ||
[ HH.text "Status" ] | ||
] | ||
, HH.tr_ | ||
[ HH.td_ [ ] -- index | ||
, HH.td_ [ HH.text "L"] | ||
, HH.td_ [ HH.text "R"] | ||
, HH.td_ [ HH.text "R"] | ||
] | ||
] | ||
|
||
renderRows :: Array (ComponentHTML Action s m) | ||
renderRows = flip mapWithIndex relevantTestCases \i testCase -> renderRow 99 testCase | ||
where | ||
relevantTestCases = A.slice start end (A.fromFoldable state.testCases) | ||
n = min maxRows (length state.testCases) | ||
start = max 0 (end - n) | ||
end = max n (Z.currentIndex state.testCases) | ||
|
||
renderRow :: Int -> TestCase -> ComponentHTML Action s m | ||
renderRow testIndex testCase = | ||
HH.tr_ $ join | ||
[ [ HH.td_ [ HH.text (show testIndex) ] ] | ||
, renderInputs | ||
, renderExpected | ||
, renderReceived | ||
] | ||
where | ||
rep dir = SignalRepresentation state.base (maybe EightBit portCapacity (M.lookup dir state.ports)) | ||
|
||
renderSignals signals = A.fromFoldable $ | ||
flip mapWithIndex signals \dir signal -> | ||
HH.td_ | ||
[ HH.text (printSignal (rep dir) signal) ] | ||
|
||
renderInputs = renderSignals testCase.inputs | ||
renderExpected = renderSignals testCase.expected | ||
renderReceived = case testCase.status of | ||
Pending -> replicate n (HH.td_ []) | ||
Completed -> renderSignals testCase.expected | ||
Failed -> maybe (replicate (M.size testCase.expected) (HH.td_ [HH.text "X"])) renderSignals testCase.received | ||
where | ||
n = M.size testCase.expected | ||
|
||
|
||
|
Oops, something went wrong.