Skip to content

Commit

Permalink
refactor: Skk型エイリアスの構造を変更
Browse files Browse the repository at this point in the history
  • Loading branch information
emanon001 committed Jan 9, 2023
1 parent 6b060c4 commit ccad769
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
16 changes: 10 additions & 6 deletions src/Skk.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Skk exposing (AsciiModeValue, HiraganaModeValue, Skk, SkkHenkanMode(..), SkkInputKey, SkkInputMode(..), init, update)
module Skk exposing (AsciiModeValue, HiraganaModeValue, Skk, SkkContext, SkkHenkanMode(..), SkkInputKey, SkkInputMode(..), init, update)

import Regex
import SkkDict
Expand All @@ -7,7 +7,12 @@ import SkkKanaRule

type alias Skk =
{ inputMode : SkkInputMode
, kanaRules : SkkKanaRule.SkkKanaRules
, context : SkkContext
}


type alias SkkContext =
{ kanaRules : SkkKanaRule.SkkKanaRules
, dict : SkkDict.SkkDict
}

Expand Down Expand Up @@ -51,11 +56,10 @@ type SkkHenkanMode
-- factory


init : SkkKanaRule.SkkKanaRules -> SkkDict.SkkDict -> Skk
init kanaRules dict =
init : SkkContext -> Skk
init context =
{ inputMode = AsciiMode { input = "" }
, kanaRules = kanaRules
, dict = dict
, context = context
}


Expand Down
15 changes: 9 additions & 6 deletions tests/SkkTests.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module SkkTests exposing (..)
import Dict
import Expect
import Skk
import SkkDict
import SkkKanaRule
import Test exposing (..)

Expand All @@ -16,10 +15,12 @@ suite =
\_ ->
Expect.equal
{ inputMode = Skk.AsciiMode { input = "" }
, kanaRules = SkkKanaRule.getDefaultRules
, dict = Dict.empty
, context =
{ kanaRules = SkkKanaRule.getDefaultRules
, dict = Dict.empty
}
}
(Skk.init SkkKanaRule.getDefaultRules Dict.empty)
(Skk.init { kanaRules = SkkKanaRule.getDefaultRules, dict = Dict.empty })
]
, describe "Skk.update"
[ describe "ascii mode"
Expand Down Expand Up @@ -97,6 +98,8 @@ suite =
initSkk : Skk.SkkInputMode -> Skk.Skk
initSkk mode =
{ inputMode = mode
, kanaRules = SkkKanaRule.getDefaultRules
, dict = Dict.empty
, context =
{ kanaRules = SkkKanaRule.getDefaultRules
, dict = Dict.empty
}
}

0 comments on commit ccad769

Please sign in to comment.