diff options
author | Griffin Smith <grfn@gws.fyi> | 2021-06-20T20·44-0400 |
---|---|---|
committer | grfn <grfn@gws.fyi> | 2021-06-23T21·52+0000 |
commit | 7437a181888f3e8938a943ae22962f21b1c03b1e (patch) | |
tree | e3ce18e867fcf8e964f04f484f08cd1f039caedd /users/grfn/xanthous/test/Xanthous/Game/PromptSpec.hs | |
parent | 76258fbfa1fc04c3ef3ecdb539c6dc48dc4131a5 (diff) |
fix(xanthous): Only use alphabetic chars for menu items r/2682
Previously, we were using `smallestNotIn` for selecting new characters for menu items with duplicate chatacters - this uses the 'Bounded' instance for the type, which for Char meant the first character we would always select was \NUL - making it look like the menu item had no character, and making it impossible to actually select the menu item. This introduces an AlphaChar newtype, which is a wrapper around Char whose Bounded and Enum instances only use alphabetic characters (a-ZA-Z) and uses that for menu characters instead. Change-Id: If34ed9e9ce84f2bcb1cb87432cc6273f40b69f72 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3229 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
Diffstat (limited to 'users/grfn/xanthous/test/Xanthous/Game/PromptSpec.hs')
-rw-r--r-- | users/grfn/xanthous/test/Xanthous/Game/PromptSpec.hs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/users/grfn/xanthous/test/Xanthous/Game/PromptSpec.hs b/users/grfn/xanthous/test/Xanthous/Game/PromptSpec.hs new file mode 100644 index 000000000000..d7a3df4acafa --- /dev/null +++ b/users/grfn/xanthous/test/Xanthous/Game/PromptSpec.hs @@ -0,0 +1,19 @@ +-------------------------------------------------------------------------------- +module Xanthous.Game.PromptSpec (main, test) where +-------------------------------------------------------------------------------- +import Test.Prelude +-------------------------------------------------------------------------------- +import Xanthous.Game.Prompt +-------------------------------------------------------------------------------- + +main :: IO () +main = defaultMain test + +test :: TestTree +test = testGroup "Xanthous.Game.PromptSpec" + [ testGroup "mkMenuItems" + [ testCase "with duplicate items" + $ mkMenuItems @[_] [('a', MenuOption @Int "a" 1), ('a', MenuOption "a" 2)] + @?= mapFromList [('a', MenuOption "a" 1), ('b', MenuOption "a" 2)] + ] + ] |