Module:bg-common/testcases

local tests = require("Module:UnitTests") local m_bg = require("Module:bg-common")

--- << is_monosyllabic >> ---

local is_monosyllabic_test_cases = { "Monosyllabic words", { "", true }, { "с", true }, { "и", true }, { "дом", true }, { "спринт", true }, { "Дом", true }, { "СПРИНТ", true }, { "ѝ", true }, { "по-", true }, { "-вам", true }, "Polysyllabic words", { "нека", false }, { "НЕКА", false }, { "полиграф", false }, { "лющян", false }, { "произ-", false }, { "-овам", false }, }

function tests:check_is_monosyllabic(word, expected) local actual = m_bg.is_monosyllabic(word) tests:equals(word, actual, expected) end function tests:test_is_monosyllabic tests:iterate(is_monosyllabic_test_cases, "check_is_monosyllabic") end

--- << add_monosyllabic_stress >> ---

local add_monosyllabic_stress_test_cases = { "Monosyllabic, no acute accent", {"", ""},	{"с", "с"}, {"в", "в"}, {"а", "а́"}, {"я", "я́"}, {"сом", "со́м"}, {"принц", "при́нц"}, {"ѝ", "ѝ"}, -- no idea why this works {"БАЛ", "БА́Л"}, "Monosyllabic with acute accent", {"впря́г", "впря́г"}, {"дъ́лг", "дъ́лг"}, {"ТРЕ́НД", "ТРЕ́НД"}, {"У́", "У́"}, {"на́й-", "на́й-"}, "Polysyllabic, no acute accent", {"лейка", "лейка"}, {"катарама", "катарама"}, {"УНИЦЕФ", "УНИЦЕФ"}, {"Севастопол", "Севастопол"}, "Polysyllabic with acute accent", {"ко́скоджа", "ко́скоджа"}, {"парашу́т", "парашу́т"}, {"Доми́нго", "Доми́нго"}, {"ЮНЕ́СКО", "ЮНЕ́СКО"}, "Suffixes don't get an acute accent", {"-вам", "-вам"}, {"-ка", "-ка"}, "Prefixes *do* get an acute accent", {"по-", "по́-"}, {"при-", "при́-"}, }

function tests:check_add_monosyllabic_stress(word, expected) local actual = m_bg.add_monosyllabic_stress(word) tests:equals(word, actual, expected) end

function tests:test_add_monosyllabic_stress tests:iterate(add_monosyllabic_stress_test_cases, "check_add_monosyllabic_stress") end

--- << remove_monosyllabic_stress >> ---

local remove_monosyllabic_stress_test_cases = { "Monosyllabic with acute accent", {"впря́г", "впряг"}, {"дъ́лг", "дълг"}, {"ТРЕ́НД", "ТРЕНД"}, {"У́", "У"}, {"гра́х", "грах"}, "Monosyllabic, no acute accent", {"", ""},	{"с", "с"}, {"в", "в"}, {"а", "а"}, {"я", "я"}, {"сом", "сом"}, {"принц", "принц"}, {"ѝ", "ѝ"}, -- no idea why this works {"БАЛ", "БАЛ"}, "Polysyllabic, no acute accent", {"лейка", "лейка"}, {"катарама", "катарама"}, {"УНИЦЕФ", "УНИЦЕФ"}, {"Севастопол", "Севастопол"}, "Polysyllabic with acute accent", {"ко́скоджа", "ко́скоджа"}, {"парашу́т", "парашу́т"}, {"Доми́нго", "Доми́нго"}, {"ЮНЕ́СКО", "ЮНЕ́СКО"}, "Suffixes don't get their acute accent removed", {"-а́ч", "-а́ч"}, {"-ни́к", "-ни́к"}, "Prefixes *do* get their acute accent removed", {"по́-", "по-"}, {"при́-", "при-"}, }

function tests:check_remove_monosyllabic_stress(word, expected) local actual = m_bg.remove_monosyllabic_stress(word) tests:equals(word, actual, expected) end

function tests:test_remove_monosyllabic_stress tests:iterate(remove_monosyllabic_stress_test_cases, "check_remove_monosyllabic_stress") end

--- << maybe_stress_initial_syllable >> ---

local maybe_stress_initial_test_cases = { "Zero syllables", {"в", "в"}, {"с", "с"}, "Monosyllabic, no stress", {"щанд", "ща́нд"}, {"сто", "сто́"}, {"иск", "и́ск"}, {"у", "у́"}, "Monosyllabic with stress", {"гра́м", "гра́м"}, {"спи́рт", "спи́рт"}, {"фьо́н", "фьо́н"}, "Polysyllabic, no stress", {"еделвайс", "е́делвайс"}, {"врачка", "вра́чка"}, {"кльомба", "кльо́мба"}, "Polysyllabic with stress", {"ка́мера", "ка́мера"}, {"поли́ция", "поли́ция"}, {"катапу́лт", "катапу́лт"}, }

function tests:check_maybe_stress_initial(word, expected) local actual = m_bg.maybe_stress_initial_syllable(word) tests:equals(word, actual, expected) end

function tests:test_maybe_stress_initial_syllable tests:iterate(maybe_stress_initial_test_cases, "check_maybe_stress_initial") end

return tests