Jump to content

Module:string/pattern simplifier/testcases

Wiktionary වෙතින්

All tests passed. (refresh)

TextExpectedActualDiffers at
test_translit:
Passed
Passed%falsefalse
Passed%b()%b()%b()
Passed%b()falsefalse
Passed%b()falsefalse
Passed%b()falsefalse
Passed%b()a%b()a%b()a
Passed%b()%afalsefalse
Passed%afalsefalse
Passed%b%b%b
Passed%cfalsefalse
Passed%dfalsefalse
Passed%e%e%e
Passed%f%f%f
Passed%g%g%g
Passed%h%h%h
Passed%i%i%i
Passed%j%j%j
Passed%k%k%k
Passed%lfalsefalse
Passed%m%m%m
Passed%n%n%n
Passed%o%o%o
Passed%pfalsefalse
Passed%q%q%q
Passed%r%r%r
Passed%sfalsefalse
Passed%t%t%t
Passed%ufalsefalse
Passed%v%v%v
Passed%wfalsefalse
Passed%xfalsefalse
Passed%y%y%y
Passed%z%z%z
Passed%Afalsefalse
Passed%B%B%B
Passed%Cfalsefalse
Passed%Dfalsefalse
Passed%E%E%E
Passed%F%F%F
Passed%G%G%G
Passed%H%H%H
Passed%I%I%I
Passed%J%J%J
Passed%K%K%K
Passed%Lfalsefalse
Passed%M%M%M
Passed%N%N%N
Passed%O%O%O
Passed%Pfalsefalse
Passed%Q%Q%Q
Passed%R%R%R
Passed%Sfalsefalse
Passed%T%T%T
Passed%Ufalsefalse
Passed%V%V%V
Passed%Wfalsefalse
Passed%Xfalsefalse
Passed%Y%Y%Y
Passed%Zfalsefalse
Passed%%a%%a%%a
Passed%%c%%c%%c
Passed%%d%%d%%d
Passed%%l%%l%%l
Passed%%p%%p%%p
Passed%%s%%s%%s
Passed%%u%%u%%u
Passed%%w%%w%%w
Passed%%x%%x%%x
Passed%%A%%A%%A
Passed%%C%%C%%C
Passed%%D%%D%%D
Passed%%L%%L%%L
Passed%%P%%P%%P
Passed%%S%%S%%S
Passed%%U%%U%%U
Passed%%W%%W%%W
Passed%%X%%X%%X
Passed%%Z%%Z%%Z
Passed%%%afalsefalse
Passed%%%cfalsefalse
Passed%%%dfalsefalse
Passed%%%lfalsefalse
Passed%%%pfalsefalse
Passed%%%sfalsefalse
Passed%%%ufalsefalse
Passed%%%wfalsefalse
Passed%%%xfalsefalse
Passed%%%Afalsefalse
Passed%%%Cfalsefalse
Passed%%%Dfalsefalse
Passed%%%Lfalsefalse
Passed%%%Pfalsefalse
Passed%%%Sfalsefalse
Passed%%%Ufalsefalse
Passed%%%Wfalsefalse
Passed%%%Xfalsefalse
Passed%%%Zfalsefalse
Passed%z%afalsefalse
Passed()falsefalse
Passed%()%()%()
Passed(foo)(foo)(foo)
Passed((foo)bar)((foo)bar)((foo)bar)
Passed( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )
Passed( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )falsefalse
Passed(((((((((((((((((((((((((((((((((falsefalse
Passed( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )%( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )%( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )%( )
Passed.[%z�-�-�][�-�]*[%z�-�-�][�-�]*
Passed.....[%z�-�-�][�-�]*[%z�-�-�][�-�]*[%z�-�-�][�-�]*[%z�-�-�][�-�]*[%z�-�-�][�-�]*[%z�-�-�][�-�]*[%z�-�-�][�-�]*[%z�-�-�][�-�]*[%z�-�-�][�-�]*[%z�-�-�][�-�]*
Passedfoo.*.foo.*[%z�-�-�][�-�]*foo.*[%z�-�-�][�-�]*
Passedfoo.+.foo.+[%z�-�-�][�-�]*foo.+[%z�-�-�][�-�]*
Passedfoo.-.foo.-[%z�-�-�][�-�]*foo.-[%z�-�-�][�-�]*
Passedfoo.?.foo[%z�-�-�]?[�-�]*[%z�-�-�][�-�]*foo[%z�-�-�]?[�-�]*[%z�-�-�][�-�]*
Passedfoo[^a]barfalsefalse
Passed[^]falsefalse
Passedfoo%[^a]barfoo%[^a]barfoo%[^a]bar
Passedfoo[barfalsefalse
Passedfoo[bar]bazfoo[bar]bazfoo[bar]baz
Passedfoo[bar]%afalsefalse
Passedfoo[bar%abaz]falsefalse
Passedfoo[bar%zbaz]foo[bar%zbaz]foo[bar%zbaz]
Passedfoo[barжbaz]foo[bar�baz]�?foo[bar�baz]�?
Passedfoo[barЖжbaz]falsefalse
Passedfoo[barжѶҶbaz]foo[bar���baz]�?foo[bar���baz]�?
Passedfoo[barကbaz]falsefalse
Passedfoo[bar𠀀baz]falsefalse
Passedfoo[bar]*bazfoo[bar]*bazfoo[bar]*baz
Passedfoo[bar]+bazfoo[bar]+bazfoo[bar]+baz
Passedfoo[bar]-bazfoo[bar]-bazfoo[bar]-baz
Passedfoo[bar]?bazfoo[bar]?bazfoo[bar]?baz
Passedfoo[bar]*%afalsefalse
Passedfoo[bar]+%afalsefalse
Passedfoo[bar]-%afalsefalse
Passedfoo[bar]?%afalsefalse
Passedfoo[barжbaz]*bazfalsefalse
Passedfoo[barжbaz]+bazfalsefalse
Passedfoo[barжbaz]-bazfalsefalse
Passedfoo[barжbaz]?bazfoo[bar�baz]?�?bazfoo[bar�baz]?�?baz
Passedfoo[barжbaz]?%afalsefalse
Passedfooжbarfooжbarfooжbar
Passedfooж*barfoo[ж]*barfoo[ж]*bar
Passedfooж+barfoo[ж]+barfoo[ж]+bar
Passedfooж-barfoo[ж]-barfoo[ж]-bar
Passedfooж?barfoo�?�?barfoo�?�?bar
Passedfooж%afalsefalse
Passedfooж*%afalsefalse
Passedfooж+%afalsefalse
Passedfooж-%afalsefalse
Passedfooж?%afalsefalse
Passedfooကbarfooကbarfooကbar
Passedfooက*barfalsefalse
Passedfooက+barfalsefalse
Passedfooက-barfalsefalse
Passedfooက?barfoo�?�?�?barfoo�?�?�?bar
Passedfooက%afalsefalse
Passedfooက?%afalsefalse
Passedfoo𠀀barfoo𠀀barfoo𠀀bar
Passedfoo𠀀*barfalsefalse
Passedfoo𠀀+barfalsefalse
Passedfoo𠀀-barfalsefalse
Passedfoo𠀀?barfoo�?�?�?�?barfoo�?�?�?�?bar
Passedfoo𠀀%afalsefalse
Passedfoo𠀀?%afalsefalse

local tests = require("Module:UnitTests")
local ps = require("Module:string/pattern simplifier")

function tests:check_pattern_simplifier(pattern, expected)
	tests:equals(pattern, tostring(ps(pattern)), tostring(expected))
end

function tests:test_translit()
	-- For languages other than Lisu, language is the third item.
	local examples = {
		{"", ""},
		{"%", false},
		{"%b()", "%b()"},
		{"%b()", false},
		{"%b()", false},
		{"%b()", false},
		{"%b()a", "%b()a"},
		{"%b()%a", false},
		{"%a", false},
		{"%b", "%b"},
		{"%c", false},
		{"%d", false},
		{"%e", "%e"},
		{"%f", "%f"},
		{"%g", "%g"},
		{"%h", "%h"},
		{"%i", "%i"},
		{"%j", "%j"},
		{"%k", "%k"},
		{"%l", false},
		{"%m", "%m"},
		{"%n", "%n"},
		{"%o", "%o"},
		{"%p", false},
		{"%q", "%q"},
		{"%r", "%r"},
		{"%s", false},
		{"%t", "%t"},
		{"%u", false},
		{"%v", "%v"},
		{"%w", false},
		{"%x", false},
		{"%y", "%y"},
		{"%z", "%z"},
		{"%A", false},
		{"%B", "%B"},
		{"%C", false},
		{"%D", false},
		{"%E", "%E"},
		{"%F", "%F"},
		{"%G", "%G"},
		{"%H", "%H"},
		{"%I", "%I"},
		{"%J", "%J"},
		{"%K", "%K"},
		{"%L", false},
		{"%M", "%M"},
		{"%N", "%N"},
		{"%O", "%O"},
		{"%P", false},
		{"%Q", "%Q"},
		{"%R", "%R"},
		{"%S", false},
		{"%T", "%T"},
		{"%U", false},
		{"%V", "%V"},
		{"%W", false},
		{"%X", false},
		{"%Y", "%Y"},
		{"%Z", false},
		{"%%a", "%%a"},
		{"%%c", "%%c"},
		{"%%d", "%%d"},
		{"%%l", "%%l"},
		{"%%p", "%%p"},
		{"%%s", "%%s"},
		{"%%u", "%%u"},
		{"%%w", "%%w"},
		{"%%x", "%%x"},
		{"%%A", "%%A"},
		{"%%C", "%%C"},
		{"%%D", "%%D"},
		{"%%L", "%%L"},
		{"%%P", "%%P"},
		{"%%S", "%%S"},
		{"%%U", "%%U"},
		{"%%W", "%%W"},
		{"%%X", "%%X"},
		{"%%Z", "%%Z"},
		{"%%%a", false},
		{"%%%c", false},
		{"%%%d", false},
		{"%%%l", false},
		{"%%%p", false},
		{"%%%s", false},
		{"%%%u", false},
		{"%%%w", false},
		{"%%%x", false},
		{"%%%A", false},
		{"%%%C", false},
		{"%%%D", false},
		{"%%%L", false},
		{"%%%P", false},
		{"%%%S", false},
		{"%%%U", false},
		{"%%%W", false},
		{"%%%X", false},
		{"%%%Z", false},
		{"%z%a", false},
		{"()", false},
		{"%()", "%()"},
		{"(foo)", "(foo)"},
		{"((foo)bar)", "((foo)bar)"},
		{("( )"):rep(32), ("( )"):rep(32)},
		{("( )"):rep(33), false},
		{("("):rep(33), false},
		{("( )"):rep(32) .. "%( )", ("( )"):rep(32) .. "%( )"},
		{".", "[%z\1-\127\194-\244][\128-\191]*"},
		{("."):rep(5), ("[%z\1-\127\194-\244][\128-\191]*"):rep(5)},
		{"foo.*.", "foo.*[%z\1-\127\194-\244][\128-\191]*"},
		{"foo.+.", "foo.+[%z\1-\127\194-\244][\128-\191]*"},
		{"foo.-.", "foo.-[%z\1-\127\194-\244][\128-\191]*"},
		{"foo.?.", "foo[%z\1-\127\194-\244]?[\128-\191]*[%z\1-\127\194-\244][\128-\191]*"},
		{"foo[^a]bar", false},
		{"[^]", false},
		{"foo%[^a]bar", "foo%[^a]bar"},
		{"foo[bar", false},
		{"foo[bar]baz", "foo[bar]baz"},
		{"foo[bar]%a", false},
		{"foo[bar%abaz]", false},
		{"foo[bar%zbaz]", "foo[bar%zbaz]"},
		{"foo[barжbaz]", "foo[bar\208baz]\182?"},
		{"foo[barЖжbaz]", false},
		{"foo[barжѶҶbaz]", "foo[bar\208\209\210baz]\182?"},
		{"foo[barကbaz]", false},
		{"foo[bar𠀀baz]", false},
		{"foo[bar]*baz", "foo[bar]*baz"},
		{"foo[bar]+baz", "foo[bar]+baz"},
		{"foo[bar]-baz", "foo[bar]-baz"},
		{"foo[bar]?baz", "foo[bar]?baz"},
		{"foo[bar]*%a", false},
		{"foo[bar]+%a", false},
		{"foo[bar]-%a", false},
		{"foo[bar]?%a", false},
		{"foo[barжbaz]*baz", false},
		{"foo[barжbaz]+baz", false},
		{"foo[barжbaz]-baz", false},
		{"foo[barжbaz]?baz", "foo[bar\208baz]?\182?baz"},
		{"foo[barжbaz]?%a", false},
		{"fooжbar", "fooжbar"},
		{"fooж*bar", "foo[ж]*bar"},
		{"fooж+bar", "foo[ж]+bar"},
		{"fooж-bar", "foo[ж]-bar"},
		{"fooж?bar", "foo\208?\182?bar"},
		{"fooж%a", false},
		{"fooж*%a", false},
		{"fooж+%a", false},
		{"fooж-%a", false},
		{"fooж?%a", false},
		{"fooကbar", "fooကbar"},
		{"fooက*bar", false},
		{"fooက+bar", false},
		{"fooက-bar", false},
		{"fooက?bar", "foo\225?\128?\128?bar"},
		{"fooက%a", false},
		{"fooက?%a", false},
		{"foo𠀀bar", "foo𠀀bar"},
		{"foo𠀀*bar", false},
		{"foo𠀀+bar", false},
		{"foo𠀀-bar", false},
		{"foo𠀀?bar", "foo\240?\160?\128?\128?bar"},
		{"foo𠀀%a", false},
		{"foo𠀀?%a", false}
	}

	self:iterate(examples, "check_pattern_simplifier")
end

return tests
"https://si.wiktionary.org/w/index.php?title=Module:string/pattern_simplifier/testcases&oldid=164319" වෙතින් සම්ප්‍රවේශනය කෙරිණි