@@ -7,7 +7,9 @@ import Data.NonEmpty (NonEmpty(..))
7
7
import Test.Spec (Spec , describe , it )
8
8
import Test.Spec.Assertions (shouldEqual )
9
9
10
+ import Data.Petrinet.Representation.NLL (ErrNetEncoding (..))
10
11
import Statebox.Core.Wiring (NetsAndDiagramsIndex (..))
12
+ import Statebox.Core.WiringTree (LinearizationError (..))
11
13
import Statebox.Protocol.Fire (FiringError (..), fire )
12
14
13
15
suite :: Spec Unit
@@ -17,15 +19,75 @@ suite = do
17
19
-- the only relevant thing here is that the wiring is not valid
18
20
let wiring = { diagrams: [{ name: " diagram"
19
21
, names: []
20
- , pixels: [1 , 2 ]
22
+ , pixels: [1 ]
21
23
, width: 1
22
24
}]
23
- , nets : []
24
- , labels : [NetsAndDiagramsIndex 5 ]
25
+ , nets: []
26
+ , labels: [NetsAndDiagramsIndex 5 ]
25
27
}
26
- firing = { execution : Nothing
28
+ firing = { execution: Nothing
27
29
, message: Nothing
28
30
, path: NonEmpty 3 []
29
31
}
30
32
marking = mempty
31
33
fire wiring firing marking `shouldEqual` Left FireInvalidWiringTree
34
+ it " fails if the linearization of the wiring fails" do
35
+ -- the only relevant thing here is that the wiring is not valid
36
+ let wiring = { diagrams: [{ name: " diagram"
37
+ , names: []
38
+ , pixels: [1 ]
39
+ , width: 1
40
+ }]
41
+ , nets: [{ name: " net"
42
+ , names: [" a" ]
43
+ , partition: [0 ]
44
+ , placeNames: Nothing
45
+ }]
46
+ , labels: [NetsAndDiagramsIndex 0 ]
47
+ }
48
+ firing = { execution: Nothing
49
+ , message: Nothing
50
+ , path: NonEmpty 3 []
51
+ }
52
+ marking = mempty
53
+ fire wiring firing marking `shouldEqual` Left (FireLinearizationError (NLLDecodingFailed ErrOddLength ))
54
+ it " fails if the firing path is out of bounds" do
55
+ let wiring = { diagrams: [{ name: " diagram"
56
+ , names: []
57
+ , pixels: [1 ]
58
+ , width: 1
59
+ }]
60
+ , nets: [{ name: " net"
61
+ , names: [" a" ]
62
+ -- 1 -> 2
63
+ , partition: [1 , 0 , 2 , 0 ]
64
+ , placeNames: Nothing
65
+ }]
66
+ , labels: [NetsAndDiagramsIndex 0 ]
67
+ }
68
+ firing = { execution: Nothing
69
+ , message: Nothing
70
+ , path: NonEmpty 3 []
71
+ }
72
+ marking = mempty
73
+ fire wiring firing marking `shouldEqual` Left FireTransitionIndexOutOfBounds
74
+ it " fails if the selected transition is not enabled" do
75
+ let wiring = { diagrams: [{ name: " diagram"
76
+ , names: []
77
+ , pixels: [1 ]
78
+ , width: 1
79
+ }]
80
+ , nets: [{ name: " net"
81
+ , names: [" a" ]
82
+ -- 1 -> 2
83
+ , partition: [1 , 0 , 2 , 0 ]
84
+ , placeNames: Nothing
85
+ }]
86
+ , labels: [NetsAndDiagramsIndex 0 ]
87
+ }
88
+ firing = { execution: Nothing
89
+ , message: Nothing
90
+ , path: NonEmpty 0 []
91
+ }
92
+ marking = mempty
93
+ fire wiring firing marking `shouldEqual` Left FireTransitionNotEnabled
0 commit comments