@@ -4,17 +4,19 @@ import Prelude
4
4
import Data.Either (Either (..))
5
5
import Data.Maybe (Maybe (..))
6
6
import Data.NonEmpty (NonEmpty (..))
7
+ import Data.Tuple.Nested ((/\))
7
8
import Test.Spec (Spec , describe , it )
8
9
import Test.Spec.Assertions (shouldEqual )
9
10
11
+ import Data.Petrinet.Representation.Marking (fromFoldable )
10
12
import Data.Petrinet.Representation.NLL (ErrNetEncoding (..))
11
13
import Statebox.Core.Wiring (NetsAndDiagramsIndex (..))
12
14
import Statebox.Core.WiringTree (LinearizationError (..))
13
15
import Statebox.Protocol.Fire (FiringError (..), fire )
14
16
15
17
suite :: Spec Unit
16
18
suite = do
17
- describe " Firing a firing " do
19
+ describe " Firing" do
18
20
it " fails if the wiring is not valid" do
19
21
-- the only relevant thing here is that the wiring is not valid
20
22
let wiring = { diagrams: [{ name: " diagram"
@@ -91,3 +93,43 @@ suite = do
91
93
}
92
94
marking = mempty
93
95
fire wiring firing marking `shouldEqual` Left FireTransitionNotEnabled
96
+ it " suceeds for an initial transition" do
97
+ let wiring = { diagrams: [{ name: " diagram"
98
+ , names: []
99
+ , pixels: [1 ]
100
+ , width: 1
101
+ }]
102
+ , nets: [{ name: " net"
103
+ , names: [" a" ]
104
+ -- _ -> 1
105
+ , partition: [0 , 1 , 0 ]
106
+ , placeNames: Nothing
107
+ }]
108
+ , labels: [NetsAndDiagramsIndex 0 ]
109
+ }
110
+ firing = { execution: Nothing
111
+ , message: Nothing
112
+ , path: NonEmpty 0 []
113
+ }
114
+ marking = mempty
115
+ fire wiring firing marking `shouldEqual` Right (fromFoldable [1 /\ 1 ])
116
+ it " suceeds for a normal transition" do
117
+ let wiring = { diagrams: [{ name: " diagram"
118
+ , names: []
119
+ , pixels: [1 ]
120
+ , width: 1
121
+ }]
122
+ , nets: [{ name: " net"
123
+ , names: [" a" ]
124
+ -- 1 -> 2
125
+ , partition: [1 , 0 , 2 , 0 ]
126
+ , placeNames: Nothing
127
+ }]
128
+ , labels: [NetsAndDiagramsIndex 0 ]
129
+ }
130
+ firing = { execution: Nothing
131
+ , message: Nothing
132
+ , path: NonEmpty 0 []
133
+ }
134
+ marking = fromFoldable [1 /\ 1 ]
135
+ fire wiring firing marking `shouldEqual` Right (fromFoldable [2 /\ 1 ])
0 commit comments