Testing the update function

The picture shows one randomly chosen walk through the city of Königsberg. Unfortunately, it does not visit all bridges exactly once as required by Euler. The red circle indicates where bridge g is crossed twice. Let’s test the walk anyway before we move on.

specSampleWalk :: Spec Unit
specSampleWalk =
  it "should follow the sample walk and visit the expected intermediate states" do
    assertWalk update
      (v @"A")
      [ v @"a" ~> v @"B"
      , v @"f" ~> v @"D"
      , v @"g" ~> v @"C"
      , v @"c" ~> v @"A"
      , v @"e" ~> v @"D"
      , v @"g" ~> v @"C"
      , v @"d" ~> v @"A"
      , v @"b" ~> v @"B"
      ]

🗎 test/Examples/BridgesKoenigsberg.purs L82-L95

We could try many other walks the same way. But — spoiler alert — none of them will visit all bridges exactly once. And in the next section we’ll see a way to prove this for our state machine.

↑ Back to top