Skip to content

Commit

Permalink
(still red) incorrect attempt to short-circuit accidentally changes L…
Browse files Browse the repository at this point in the history
…eveled into Leaf
  • Loading branch information
MaxWilson committed Jan 6, 2024
1 parent 43835dc commit 4f03ac9
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions test/Chargen.Accept.fs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,11 @@ type Op =
let children = [
for o in options do
let key = o.config.key |> Option.orElse o.config.label
let (value, menu) = o.recur (input.extend key) // we only need the key to distinguish between eithers, not ands, so we extend the input by the child key only for either
let fullKey = input.fullKey key
let selected = key.IsSome && input.selected.Contains fullKey
let (value, menu) =
if selected then o.recur (input.extend key) // we only need the key to distinguish between eithers, not ands, so we extend the input by the child key only for either
else [], Leaf (defaultArg o.config.label "Unknown") // TODO: replace Leaf + default label with something more appropriate
value, (selected, menu)
]
let selectedValues = children |> List.collect fst
Expand Down Expand Up @@ -270,19 +272,11 @@ let units = testList "Unit.Chargen" [
skill("Shield", +2)
])
]
let empty =
Either(None, [
true, Either(Some "Sword!", [
false, Leveled("Rapier", +5)
false, Leveled("Broadsword", +5)
false, Leveled("Shortsword", +5)
])
])
test <@ nestedEither |> evalFor [] =
Either(None, [
false, Either(Some "Sword!", [])
false, Either(Some "Sword and Dagger!", [])
false, Either(Some "Sword and Shield!", [])
false, Leaf "Sword!"
false, Leaf "Sword and Dagger"
false, Leaf "Sword and Shield"
]) @>
test <@ nestedEither |> evalFor ["Sword!"] =
Either(None, [
Expand Down

0 comments on commit 4f03ac9

Please sign in to comment.