Better te-form testing

This commit is contained in:
Bill Rossi 2025-08-16 09:08:45 -04:00
parent f2caa10be2
commit 60ce9f2690
2 changed files with 56 additions and 36 deletions

View File

@ -61,18 +61,22 @@ class Verb
dict
end
def long_form_present_positive
stem + "ます"
end
def long_form_present_negative
stem + "ません"
end
def short_form_present_positive
dictionary
end
end
class IchidanVerb < Verb
def long_form_present_positive
all_but_last_character + "ます"
end
def long_form_present_negative
all_but_last_character + "ません"
def stem
all_but_last_character
end
def short_form_present_negative
@ -85,12 +89,12 @@ class IchidanVerb < Verb
end
class GodanVerb < Verb
def long_form_present_positive
all_but_last_character + last_character("i") + "ます"
def iku?
dict.kanji == "行く"
end
def long_form_present_negative
all_but_last_character + last_character("i") + "ません"
def stem
all_but_last_character + last_character("i")
end
def short_form_present_negative
@ -98,25 +102,25 @@ class GodanVerb < Verb
end
def te
case last_character
all_but_last_character + case last_character
when ""
all_but_last_character + "って"
"って"
when ""
all_but_last_character + "って"
"って"
when ""
all_but_last_character + "って"
"って"
when ""
all_but_last_character + "して"
"して"
when ""
all_but_last_character + "いて"
iku? ? "って" : "いて"
when ""
all_but_last_character + "いで"
"いで"
when ""
all_but_last_character + "んで"
"んで"
when ""
all_but_last_character + "んで"
"んで"
when ""
all_but_last_character + "んで"
"んで"
end
end
end
@ -126,12 +130,8 @@ class SuruVerb < Verb
dict[..-3]
end
def long_form_present_positive
prefix + "します"
end
def long_form_present_negative
prefix + "しません"
def stem
prefix + ""
end
def short_form_present_negative

View File

@ -5,6 +5,16 @@ class TestVerb < Minitest::Test
def setup
@miru = IchidanVerb.new("見る", "みる", "to look")
@nomu = GodanVerb.new("飲む", "のむ", "to drink")
@au = GodanVerb.new("会う", "あう", "to meet")
@matsu = GodanVerb.new("待つ", "まつ", "to wait")
@toru = GodanVerb.new("取る", "とる", "to take")
@yomu = GodanVerb.new("読む", "よむ", "to read")
@asobu = GodanVerb.new("遊ぶ", "あそぶ", "to play")
@shinu = GodanVerb.new("死ぬ", "しぬ", "to die")
@kaku = GodanVerb.new("書く", "かく", "to write")
@iku = GodanVerb.new("行く", "いく", "to go")
@oyogu = GodanVerb.new("泳ぐ", "およぐ", "to swim")
@hanasu = GodanVerb.new("話す", "はなす", "to speak")
@suru = SuruVerb.new("する", "する", "to do")
@benkyousuru = SuruVerb.new("勉強する", "べんきょうする", "to study")
end
@ -18,6 +28,16 @@ class TestVerb < Minitest::Test
assert_equal "して", @suru.te.kana
assert_equal "勉強して", @benkyousuru.te.kanji
assert_equal "べんきょうして", @benkyousuru.te.kana
assert_equal "会って", @au.te.kanji
assert_equal "待って", @matsu.te.kanji
assert_equal "取って", @toru.te.kanji
assert_equal "読んで", @yomu.te.kanji
assert_equal "遊んで", @asobu.te.kanji
assert_equal "死んで", @shinu.te.kanji
assert_equal "書いて", @kaku.te.kanji
assert_equal "行って", @iku.te.kanji
assert_equal "泳いで", @oyogu.te.kanji
assert_equal "話して", @hanasu.te.kanji
end
def test_long_form_present_positive