로블록스 서버 통합 테스트 tests/cloud/server.luau 1003개 통과(저장 버전 25). 화면 UI는 다음 커밋. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
84 lines
3.6 KiB
Lua
84 lines
3.6 KiB
Lua
-- 요리 과정 검사: lune run tests/Recipes.spec.luau
|
|
local Economy = require("../src/shared/Economy")
|
|
local Recipes = require("../src/shared/Recipes")
|
|
local T = require("./check")
|
|
|
|
T.eq(Recipes.BASE_COOK, Economy.START_COOK, "기준 화구 수준 = 처음 조리 시간")
|
|
for _, menu in Economy.MENU_ORDER do
|
|
local r = Recipes.LIST[menu]
|
|
T.check(r ~= nil, `{menu} 요리 과정 있음`)
|
|
T.check(#r.steps >= 2 and #r.steps <= 3, `{menu} 단계 2~3개`)
|
|
local kinds = {}
|
|
for i, s in r.steps do
|
|
T.eq(s.key, `cook_{menu}_{i}`, `{menu} {i}단계 안내 글 키`)
|
|
kinds[s.kind] = true
|
|
end
|
|
local n = 0
|
|
for _ in kinds do
|
|
n += 1
|
|
end
|
|
T.check(n >= 2, `{menu}: 단계마다 조작이 달라 지루하지 않음`)
|
|
-- 아이가 한 접시에 쓰는 시간: 처음 3~7초, 화구를 다 사면 더 짧아짐
|
|
local t0 = Recipes.expectedTime(menu, 2.5)
|
|
local t2 = Recipes.expectedTime(menu, 1)
|
|
T.check(t0 >= 3 and t0 <= 7, `{menu} 처음 {t0}초`)
|
|
T.check(t2 < t0 * 0.75, `{menu} 화구 Lv2면 {t2}초로 빨라짐`)
|
|
-- 서버 최소 시간: 정상 플레이(아이 속도)보다 넉넉히 짧고, 0보다는 커서 조리 과정 건너뛰기를 막음
|
|
for _, cook in { 2.5, 1.5, 1 } do
|
|
local m = Recipes.minTime(menu, cook)
|
|
T.check(m > 0.3, `{menu} 화구 {cook}: 최소 시간 {m}초 > 0.3`)
|
|
T.check(
|
|
m < Recipes.expectedTime(menu, cook) * 0.6,
|
|
`{menu} 화구 {cook}: 최소 시간이 보통 시간보다 넉넉히 짧음`
|
|
)
|
|
end
|
|
end
|
|
|
|
-- 서로 다른 메뉴는 과정이 다름
|
|
local seen = {}
|
|
for menu, r in Recipes.LIST do
|
|
local sig = r.stage
|
|
for _, s in r.steps do
|
|
sig ..= s.kind .. s.tool
|
|
end
|
|
T.check(seen[sig] == nil, `{menu} 과정이 다른 메뉴와 같지 않음`)
|
|
seen[sig] = true
|
|
end
|
|
|
|
-- 누르는 횟수는 정수, 최소 2번
|
|
T.eq(Recipes.need({ kind = "tap", key = "", base = 4, tool = "" }, 2.5), 4, "화구 Lv0: 4번")
|
|
T.eq(Recipes.need({ kind = "tap", key = "", base = 4, tool = "" }, 1.5), 2, "화구 Lv1: 2번(2.4 반올림)")
|
|
T.eq(Recipes.need({ kind = "tap", key = "", base = 4, tool = "" }, 1), 2, "화구 Lv2: 최소 2번")
|
|
T.check(
|
|
math.abs(Recipes.need({ kind = "hold", key = "", base = 1, tool = "" }, 1.5) - 0.6) < 1e-9,
|
|
"꾹 누르기 0.6초"
|
|
)
|
|
|
|
-- 진행 상태: 떡볶이(톡톡 4 → 꾹 1초 → 문지르기 3)
|
|
local f = Recipes.newFlow(2.5)
|
|
T.eq(Recipes.input(f, "tap", 1), nil, "메뉴 고르기 전에는 입력 무시")
|
|
T.eq(Recipes.choose(f, "Nope"), false, "없는 메뉴는 못 고름")
|
|
T.eq(Recipes.choose(f, "Tteokbokki"), true, "떡볶이 고름")
|
|
T.eq(f.phase, "cook", "조리 시작")
|
|
T.eq(Recipes.choose(f, "Gimbap"), false, "조리 중에는 다시 못 고름")
|
|
T.eq(Recipes.input(f, "hold", 1), nil, "다른 조작은 무시(실패 없음)")
|
|
T.eq(Recipes.input(f, "tap", 1), "progress", "톡 1")
|
|
T.eq(Recipes.input(f, "tap", 1), "progress", "톡 2")
|
|
T.eq(Recipes.input(f, "tap", 1), "progress", "톡 3")
|
|
T.eq(Recipes.fraction(f), (0 + 3 / 4) / 3, "전체 진행률")
|
|
T.eq(Recipes.input(f, "tap", 1), "step", "톡 4 → 다음 단계")
|
|
T.eq(f.step, 2, "2단계")
|
|
T.eq(Recipes.input(f, "hold", 0.5), "progress", "꾹 0.5초")
|
|
T.eq(Recipes.input(f, "hold", 0.6), "step", "꾹 1초 넘음 → 다음 단계")
|
|
T.eq(Recipes.input(f, "rub", 0), nil, "움직임 0은 무시")
|
|
T.eq(Recipes.input(f, "rub", 2), "progress", "문지르기 2")
|
|
T.eq(Recipes.input(f, "rub", 5), "done", "문지르기 끝 → 완성")
|
|
T.eq(f.phase, "done", "완성 상태")
|
|
T.eq(Recipes.fraction(f), 1, "완성 진행률 1")
|
|
T.eq(Recipes.input(f, "tap", 1), nil, "완성 뒤 입력 무시")
|
|
Recipes.reset(f, 1)
|
|
T.eq(f.phase, "menu", "다음 접시: 메뉴 고르기로")
|
|
T.eq(f.cook, 1, "화구 수준 갱신")
|
|
|
|
T.done("Recipes.spec")
|