Skip to content

Commit c21acf3

Browse files
committed
[#336] [stbx-protocol] test other fire failing cases
1 parent ae19513 commit c21acf3

File tree

1 file changed

+66
-4
lines changed
  • stbx-protocol/test/Statebox/Protocol

1 file changed

+66
-4
lines changed

stbx-protocol/test/Statebox/Protocol/Fire.purs

+66-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import Data.NonEmpty (NonEmpty(..))
77
import Test.Spec (Spec, describe, it)
88
import Test.Spec.Assertions (shouldEqual)
99

10+
import Data.Petrinet.Representation.NLL (ErrNetEncoding(..))
1011
import Statebox.Core.Wiring (NetsAndDiagramsIndex(..))
12+
import Statebox.Core.WiringTree (LinearizationError(..))
1113
import Statebox.Protocol.Fire (FiringError(..), fire)
1214

1315
suite :: Spec Unit
@@ -17,15 +19,75 @@ suite = do
1719
-- the only relevant thing here is that the wiring is not valid
1820
let wiring = { diagrams: [{ name: "diagram"
1921
, names: []
20-
, pixels: [1, 2]
22+
, pixels: [1]
2123
, width: 1
2224
}]
23-
, nets : []
24-
, labels : [NetsAndDiagramsIndex 5]
25+
, nets: []
26+
, labels: [NetsAndDiagramsIndex 5]
2527
}
26-
firing = { execution : Nothing
28+
firing = { execution: Nothing
2729
, message: Nothing
2830
, path: NonEmpty 3 []
2931
}
3032
marking = mempty
3133
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

Comments
 (0)