Skip to content

Commit ce5269c

Browse files
committed
shiritori: remove error
The error was actually checking for an empty 'string' rather than a empty list of words. The former would not happen as long as the dictionary of transcription is valid, and the later is already covered by former winning condition (WIN_USED).
1 parent fd70aed commit ce5269c

File tree

2 files changed

+0
-10
lines changed

2 files changed

+0
-10
lines changed

functions/shiritori/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,6 @@ exports.interact = async (dict, word, chain) => {
119119
// ランダムでえらぶ。
120120
const w = unused[Math.floor(Math.random() * unused.length)]
121121
const wk = words[w]
122-
if (wk.length === 0) {
123-
throw new Error(`no dictionary entry for key: ${w}`)
124-
}
125122
if (wk[wk.length - 1] === 'ん') {
126123
return { state: exports.state.WIN_N, word: w, kana: wk }
127124
}

functions/shiritori/test.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,3 @@ test('interact: win ん', async t => {
116116
t.is(result.state, shiritori.state.WIN_N)
117117
t.is(result.kana[result.kana.length - 1], 'ん')
118118
})
119-
120-
test('interact: error', async t => {
121-
await t.throwsAsync(shiritori.interact(k => Promise.resolve({ 'つけまん': '' }),
122-
'とんかつ', ['べんと']),
123-
{ instanceOf: Error,
124-
message: /no dictionary entry/ })
125-
})

0 commit comments

Comments
 (0)