Skip to content

Commit

Permalink
fix pinyin_fluency test
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaozg committed Dec 23, 2023
1 parent 320d357 commit ce43200
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
2 changes: 2 additions & 0 deletions rime/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ local mtSession = {
ret.ascii_mode = toBoolean(status.is_ascii_mode)
ret.full_shape = toBoolean(status.is_full_shape)
ret.simplified = toBoolean(status.is_simplified)
ret.traditional = toBoolean(status.is_traditional)
ret.ascii_punct = toBoolean(status.is_ascii_punct)

return ret
end
Expand Down
2 changes: 2 additions & 0 deletions spec/double_pinyin_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ describe("double_pinyin test", function()
ascii_mode = true,
full_shape = false,
simplified = true,
traditional = false,
ascii_punct = false,
id = schema,
name = '自然码双拼'
}, status)
Expand Down
38 changes: 18 additions & 20 deletions spec/pinyin_fluency_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ describe("luna_pinyin test", function()
local _ref = 0
local schema = "luna_pinyin_fluency"
-- 以空格分詞、標點或回車上屏。
-- FIXME: session:Commit fail
if true then
return
end

setup(function()
if not rime then
Expand Down Expand Up @@ -49,6 +45,8 @@ describe("luna_pinyin test", function()
ascii_mode = true,
full_shape = false,
simplified = true,
traditional = false,
ascii_punct = false,
id = schema,
name = '朙月拼音·語句流'
})
Expand All @@ -71,15 +69,17 @@ describe("luna_pinyin test", function()
ascii_mode = false,
full_shape = false,
simplified = true,
traditional = false,
ascii_punct = false,
id = schema,
name = '朙月拼音·語句流'
})

list = session:Candidates()
assert(type(list)=='table')
assert(#list > 0)
--rime.utils.print_r(list,'list of abcd')
print(session:Select(1))
assert(session:Select(1))
assert(session:commit())
local commit = assert(session:Commit())
assert.equal("啊不错的", commit)
end)
Expand All @@ -90,37 +90,33 @@ describe("luna_pinyin test", function()
session:Option('ascii_mode', false)
local list

--rime.utils.printInfo(session)
assert(session:simulate('xiguanjiuhaole')==true)
--rime.utils.printInfo(session)
list = session:Candidates()
assert(#list > 0)
--rime.utils.print_r(list, "习惯就好了")
assert(session:Select(1))

assert(session:commit())
local commit = session:Commit()
assert.equal("习惯就好了", commit)

assert(session:simulate('burejinsiji')==true)
--rime.utils.printInfo(session)
list = session:Candidates()
assert(#list > 0)
--rime.utils.print_r(list, "布热津斯基")
assert(session:Select(1))
assert(session:commit())
commit = session:Commit()
assert.equal("布热津斯基", commit)

assert(session:simulate('shurufangshizhuanhuanjian')==true)
--rime.utils.printInfo(session)
list = session:Candidates()
assert(session:Select(1))
assert(session:commit())
commit = session:Commit()
assert.equal("输入方式转换键", commit)

assert(session:simulate('chujiangkongwan')==true)
--rime.utils.printInfo(session)
list = session:Candidates()
assert(session:Select(1))
assert(session:commit())
commit = session:Commit()
assert.equal("楚江空晚", commit)

Expand All @@ -130,13 +126,15 @@ describe("luna_pinyin test", function()
session:process(keycode)
end

local status = session:Status()
local selected = {2, 2, 4, 2, 2, 1}
while(status.composing) do
local idx = assert(table.remove(selected, 1))
assert(session:Select(idx))
status = session:Status()
end
repeat
local idx = table.remove(selected, 1)
if idx then
--rime.utils.printInfo(session)
assert(session:Select(idx))
end
until not idx
assert(session:commit())

assert.equal('一条大河波浪宽风吹稻花香两岸', session:Commit())
end)
Expand Down
4 changes: 4 additions & 0 deletions spec/pinyin_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ describe("luna_pinyin test", function()
ascii_mode = true,
full_shape = false,
simplified = true,
traditional = false,
ascii_punct = false,
id = schema,
name = '朙月拼音'
})
Expand All @@ -66,6 +68,8 @@ describe("luna_pinyin test", function()
ascii_mode = false,
full_shape = false,
simplified = true,
traditional = false,
ascii_punct = false,
id = schema,
name = '朙月拼音'
})
Expand Down

0 comments on commit ce43200

Please sign in to comment.