mediawiki-extensions-AbuseF.../tests/parserTestsEquivset/mwexamples-functions.t
Daimona Eaytoy d51ca862c6 Move parser tests to /unit
IMHO these can be considered unit tests; they were already fast, but now
they're executed in an instant.
This requires several changes: 1 - delay retrieving messages in
AFPUserVisibleException, to avoid having to deal with i18n whenever we
want to test exceptions; 2 - Use some DI for Parser and Tokenizer.
Equivset-dependend tests are also moved to a new class, thus helping to
fix the AF part of T189560.

Change-Id: If4585bf9bb696857005cf40a0d6985c36ac7e7a8
2019-08-28 16:36:37 +00:00

22 lines
1.1 KiB
Perl
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* Examples from [[mw:Extension:AbuseFilter/Rules format#Functions]] */
length( "Wikipedia" ) === 9 &
lcase( "WikiPedia" ) === 'wikipedia' &
ccnorm( "w1k1p3d14" ) === 'WIKIPEDIA' &
ccnorm( "ωɨƙɩƐƉ1α" ) === 'WIKIPEDIA' &
ccnorm_contains_any( "w1k1p3d14", "wiKiP3D1A", "foo", "bar" ) === true &
ccnorm_contains_any( "w1k1p3d14", "foo", "bar", "baz" ) === false &
ccnorm_contains_any( "w1k1p3d14 is 4w3s0me", "bar", "baz", "some" ) === true &
ccnorm( "ìíîïĩїį!ľ₤ĺľḷĿ" ) === 'IIIIIII!LLLLLL' &
norm( "!!ω..ɨ..ƙ..ɩ....Ɛ.Ɖ@@1%%α!!" ) === 'WIKIPEDAIA' &
norm( "F00 B@rr" ) === 'FOBAR' &
rmdoubles( "foobybboo" ) === 'fobybo' &
specialratio( "Wikipedia!" ) === 0.1 &
count( "foo", "foofooboofoo" ) === 3 &
count( "foo,bar,baz" ) === 3 &
rmspecials( "FOOBAR!!1" ) === 'FOOBAR1' &
rescape( "abc* (def)" ) === 'abc\* \(def\)' &
str_replace( "foobarbaz", "bar", "-" ) === 'foo-baz' &
ip_in_range( "127.0.10.0", "127.0.0.0/12" ) === true &
contains_any( "foobar", "x", "y", "f" ) === true &
get_matches( "(foo?ba+r) is (so+ good)", "fobaaar is soooo good to eat" ) === ['fobaaar is soooo good', 'fobaaar', 'soooo good']