Jump to content

Module:string utilities/testcases

Wiktionary වෙතින්

All tests passed. (refresh)

TextExpectedActualDiffers at
test_pattern_simplifier:
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%bfalsefalse
Passed%cfalsefalse
Passed%dfalsefalse
Passed%e%e%e
Passed%ffalsefalse
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%Z[�-�-�][�-�]*[�-�-�][�-�]*
Passed
Passed%ж?falsefalse
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%%%Z%%[�-�-�][�-�]*%%[�-�-�][�-�]*
Passed%z%afalsefalse
Passed%Z%afalsefalse
Passed()falsefalse
Passed%()%()%()
Passed(foo)(foo)(foo)
Passed((foo)bar)((foo)bar)((foo)bar)
Passed( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )
Passed( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )falsefalse
Passed(((((((((((((((((((((((((((((((((falsefalse
Passed( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )%( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )%( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( )%( )
Passed.[^�-�][�-�]*[^�-�][�-�]*
Passed.....[^�-�][�-�]*[^�-�][�-�]*[^�-�][�-�]*[^�-�][�-�]*[^�-�][�-�]*[^�-�][�-�]*[^�-�][�-�]*[^�-�][�-�]*[^�-�][�-�]*[^�-�][�-�]*
Passedfoo.*.foo.*[^�-�][�-�]*foo.*[^�-�][�-�]*
Passedfoo.+.foo.+[^�-�][�-�]*foo.+[^�-�][�-�]*
Passedfoo.-.foo.-[^�-�][�-�]*foo.-[^�-�][�-�]*
Passedfoo.?.foo[^�-�]?[�-�]*[^�-�][�-�]*foo[^�-�]?[�-�]*[^�-�][�-�]*
Passedfoo%Z*%Zfoo%Z*[�-�-�][�-�]*foo%Z*[�-�-�][�-�]*
Passedfoo%Z+%Zfoo%Z+[�-�-�][�-�]*foo%Z+[�-�-�][�-�]*
Passedfoo%Z-%Zfoo%Z-[�-�-�][�-�]*foo%Z-[�-�-�][�-�]*
Passedfoo%Z?%Zfoo[�-�-�]?[�-�]*[�-�-�][�-�]*foo[�-�-�]?[�-�]*[�-�-�][�-�]*
Passedfooжbarfooжbarfooжbar
Passedfooж*barfalsefalse
Passedfooж+barfoo�[ж]*�barfoo�[ж]*�bar
Passedfooж-barfalsefalse
Passedfooж?barfalsefalse
Passedfooကbarfooကbarfooကbar
Passedfooက*barfalsefalse
Passedfooက+barfalsefalse
Passedfooက-barfalsefalse
Passedfooက?barfalsefalse
Passedfoo𠀀barfoo𠀀barfoo𠀀bar
Passedfoo𠀀*barfalsefalse
Passedfoo𠀀+barfalsefalse
Passedfoo𠀀-barfalsefalse
Passedfoo𠀀?barfalsefalse
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]falsefalse
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[БАР]bazfoo�[�-��]bazfoo�[�-��]baz
Passedfoo[БАР]*bazfalsefalse
Passedfoo[БАР]+bazfoo�[�-���]*[�-��]bazfoo�[�-���]*[�-��]baz
Passedfoo[БАР]-bazfalsefalse
Passedfoo[БАР]?bazfalsefalse
Passedfoo[БАРbaz]quxfalsefalse
Passedfoo[bar%Б]bazfalsefalse
Passedfoo[БАР%e]bazfalsefalse
Passedfoo[бар]bazfalsefalse
Passedfoo[бар]*bazfalsefalse
Passedfoo[бар]+bazfalsefalse
Passedfoo[бар]-bazfalsefalse
Passedfoo[бар]?bazfalsefalse
Passedfoo[バー]bazfoo�[��]bazfoo�[��]baz
Passedfoo[バー]*bazfalsefalse
Passedfoo[バー]+bazfalsefalse
Passedfoo[バー]-bazfalsefalse
Passedfoo[バー]?bazfalsefalse
Passedfoo%f[bar]bazfoo%f[bar]bazfoo%f[bar]baz
Passedfoo%f[БАР]bazfalsefalse
Passedfoo%f[%БАР]bazfalsefalse
Passedfoo%f[бар]bazfalsefalse
Passedfoo%f[バー]bazfalsefalse

local tests = require("Module:UnitTests")
local ps = require("Module:string utilities").pattern_simplifier

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

function tests:test_pattern_simplifier()
	local examples = {
		{"", ""},
		{"%", false},
		{"%b()", "%b()"},
		{"%b()", false},
		{"%b()", false},
		{"%b()", false},
		{"%b()a", "%b()a"},
		{"%b()%a", false},
		{"%a", false},
		{"%b", false},
		{"%c", false},
		{"%d", false},
		{"%e", "%e"},
		{"%f", false},
		{"%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", "[\1-\127\194-\244][\128-\191]*"},
		{"%ж", "%ж"},
		{"%ж?", 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", "%%[\1-\127\194-\244][\128-\191]*"},
		{"%z%a", 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) .. "%( )"},
		{".", "[^\128-\191][\128-\191]*"},
		{("."):rep(5), ("[^\128-\191][\128-\191]*"):rep(5)},
		{"foo.*.", "foo.*[^\128-\191][\128-\191]*"},
		{"foo.+.", "foo.+[^\128-\191][\128-\191]*"},
		{"foo.-.", "foo.-[^\128-\191][\128-\191]*"},
		{"foo.?.", "foo[^\128-\191]?[\128-\191]*[^\128-\191][\128-\191]*"},
		{"foo%Z*%Z", "foo%Z*[\1-\127\194-\244][\128-\191]*"},
		{"foo%Z+%Z", "foo%Z+[\1-\127\194-\244][\128-\191]*"},
		{"foo%Z-%Z", "foo%Z-[\1-\127\194-\244][\128-\191]*"},
		{"foo%Z?%Z", "foo[\1-\127\194-\244]?[\128-\191]*[\1-\127\194-\244][\128-\191]*"},
		{"fooжbar", "fooжbar"},
		{"fooж*bar", false},
		{"fooж+bar", "foo\208[ж]*\182bar"},
		{"fooж-bar", false},
		{"fooж?bar", false},
		{"fooကbar", "fooကbar"},
		{"fooက*bar", false},
		{"fooက+bar", false},
		{"fooက-bar", false},
		{"fooက?bar", false},
		{"foo𠀀bar", "foo𠀀bar"},
		{"foo𠀀*bar", false},
		{"foo𠀀+bar", false},
		{"foo𠀀-bar", false},
		{"foo𠀀?bar", false},
		{"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]", false},
		{"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[БАР]baz", "foo\208[\144-\145\160]baz"},
		{"foo[БАР]*baz", false},
		{"foo[БАР]+baz", "foo\208[\144-\145\160\208]*[\144-\145\160]baz"},
		{"foo[БАР]-baz", false},
		{"foo[БАР]?baz", false},
		{"foo[БАРbaz]qux", false},
		{"foo[bar%Б]baz", false},
		{"foo[БАР%e]baz", false},
		{"foo[бар]baz", false},
		{"foo[бар]*baz", false},
		{"foo[бар]+baz", false},
		{"foo[бар]-baz", false},
		{"foo[бар]?baz", false},
		{"foo[バー]baz", "foo\227\131[\144\188]baz"},
		{"foo[バー]*baz", false},
		{"foo[バー]+baz", false},
		{"foo[バー]-baz", false},
		{"foo[バー]?baz", false},
		{"foo%f[bar]baz", "foo%f[bar]baz"},
		{"foo%f[БАР]baz", false},
		{"foo%f[%БАР]baz", false},
		{"foo%f[бар]baz", false},
		{"foo%f[バー]baz", false},
	}

	self:iterate(examples, "check_pattern_simplifier")
end

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