strpos.t 0000666 00000000345 15133475453 0006303 0 ustar 00 strpos( "foobarfoo", "foo" ) === 0 &
strpos( "foobarfoo", "" ) === -1 &
strpos( "foobarfoo", "foo", 1 ) === 6 &
strpos( "foobarfoo", "lol" ) === -1 &
/* Offset not contained in the haystack */
strpos( "foo", "o", 123456 ) === -1
ip-in-ranges.t 0000666 00000003420 15133475453 0007237 0 ustar 00 ip_in_ranges( '12.34.56.78', '12.34.56.0/24', '12.34.0.0/16' ) === true &
ip_in_ranges( '12.34.56.78', '65.43.0.0/16', '12.34.56.78/32' ) === true &
ip_in_ranges( '12.34.56.78', '12.0.0.0/8', '13.0.0.0/8' ) === true &
ip_in_ranges( '12.34.56.78', '12.34.56.78', '2001:db8::/16' ) === true &
ip_in_ranges( '12.34.56.78', '12.1.2.255/8', '::' ) === true &
ip_in_ranges( '1.1.1.1', '1.1.1.1/32', '2.2.2.2/32' ) === true &
ip_in_ranges( '1.1.1.1', '1.1.1.1', '1.1.1.1', '1.1.1.1/32' ) === true &
ip_in_ranges( '1.1.1.1', '0.0.0.0/0', '0.0.0.0/1', '0.0.0.0/2', '0.0.0.0/3' ) === true &
ip_in_ranges( '1.1.1.1', '::', '::/0', '::/1' ) === false &
ip_in_ranges( '123.123.123.123', '123.123.123.123', '123.123.123.123' ) === true &
ip_in_ranges( '123.123.123.123', '123.0.0.0-123.122.0.0', '123.124.0.0-124.122.0.0' ) === false &
ip_in_ranges( '123.123.123.123', '125.0.0.0 - 127.0.0.0', '123.0.0.0-124.0.0.0' ) === true &
ip_in_ranges( '123.123.123.123', '123.0.0.0-127.0.0.0', '123.123.0.0 - 124.0.0.0' ) === true &
ip_in_ranges( '123.123.123.123', '127.0.0.0-123.0.0.0', '120.0.0.0-123.0.0.0' ) === false &
ip_in_ranges( '123.123.123.123', '127.0.0.0-123.0.0.0', '123.0.0.0-127.0.0.0' ) === true &
ip_in_ranges( '11.11.11.11', '11.11.11.1', '1.11.11.11', '11.1.11.11', '11.11.1.11' ) === false &
ip_in_ranges( '1.1.1.1', '::-ffff::', '0.0.0.0-255.255.255.255' ) === true &
ip_in_ranges( '2001:db8:85a3::8a2e:0370:7334', '::-ffff::', '0.0.0.0-255.255.255.255' ) === true &
ip_in_ranges( '2001:db8:85a3::8a2e:0370:7334', '2001:db8:85a3::8a2e:370:7334/113', '2001:db8:85a3::8a2e:370:0000-2001:db8:85a3::8a2e:370:8888' ) === true &
ip_in_ranges( '1.1.1.1', '::-ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', '0.0.0.0' ) === false &
ip_in_ranges( '2001:db8:85a3::8a2e:370:0000', '0.0.0.0-255.255.255.255', '::' ) === false
whitespace1.t 0000666 00000000021 15133475453 0007155 0 ustar 00 1 == length("a")
float.t 0000666 00000000135 15133475453 0006053 0 ustar 00 (5 / 2 === 2.5) & (int(5 / 2) === 2) & (5. / 2 === 2.5) & (5 / 2. === 2.5) & (int(.5) === 0)
like.t 0000666 00000000064 15133475453 0005673 0 ustar 00 "f+oo-bér" like "f+oo-b?r" & "quux" matches "qu*x"
str-replace-regexp.t 0000666 00000000303 15133475453 0010454 0 ustar 00 str_replace_regexp( "foobarbaz", "bar", "" ) === 'foobaz' &
str_replace_regexp( "foo1bar1baz", "\d", "" ) === 'foobarbaz' &
str_replace_regexp( "foobarbaz", "(bar)", "$1baz" ) === 'foobarbazbaz'
vars.t 0000666 00000000222 15133475453 0005716 0 ustar 00 /* Variables test */
test_var1 := test_var2 := "aa";
set( 'ResulT', set_var( 'TV3', "bb" ) );
str_replace( test_var1, test_var2, tv3 ) == result; array-statements3.t 0000666 00000000117 15133475453 0010334 0 ustar 00 /* intEval used to return a tree node for this - T236870 */
a := [];
a[] := 2;
mwexamples-comparisons.t 0000666 00000000651 15133475453 0011466 0 ustar 00 /* Examples from [[mw:Extension:AbuseFilter/Rules format#Simple comparisons]] */
!(1 == 2) &
(1 <= 2) &
!(1 >= 2) &
(1 != 2) &
(1 < 2) &
!(1 > 2) &
(2 = 2) &
('' == false) &
!('' === false) &
(1 == true) &
!(1 === true) &
(['1','2','3'] == ['1','2','3']) &
([1,2,3] === [1,2,3]) &
(['1','2','3'] == [1,2,3]) &
!(['1','2','3'] === [1,2,3]) &
([1,1,''] == [true, true, false]) &
([] == false) &
([] == null) &
!(['1'] == '1')
contains-all.t 0000666 00000000327 15133475453 0007335 0 ustar 00 contains_all("the foo is on the bar", "foo", "is on", "bar") &
!(contains_all(['foo', 'bar', 'hey'], 'foo', 'bar', 'sup')) &
contains_all([1, 2, 3], '1', '2', '3') &
contains_all(
'base',
'b',
'a',
's',
'e',
)
lazykeyword.t 0000666 00000000027 15133475453 0007332 0 ustar 00 1 === 1 | "a" like "b"
mwexamples-bools.t 0000666 00000000270 15133475453 0010244 0 ustar 00 /* Examples from [[mw:Extension:AbuseFilter/Rules format#Boolean operations]] */
(1 | 1) &
(1 | 0) &
!(0 | 0) &
(1 & 1) &
!(1 & 0) &
!(0 & 0) &
!(1 ^ 1) &
(1 ^ 0) &
!(0 ^ 0) &
!(!1)
expn.t 0000666 00000000126 15133475453 0005720 0 ustar 00 /* In filter language, the exponentiation is left-associative */
(2 ** 3 ** 2) === 64
array-statements2.t 0000666 00000000142 15133475453 0010331 0 ustar 00 /* intEval used to return a tree node for this */
var := [1];
var[0] := str_replace('a','b','c');
substr.t 0000666 00000000104 15133475453 0006264 0 ustar 00 substr( "foobar", 0, 3 ) === "foo" &
substr( "barfoo", 4 ) === "oo"
contains-any.t 0000666 00000000260 15133475453 0007350 0 ustar 00 contains_any("like anyone else", "else", "someone") &
contains_any("street fighter", "fight") &
!(contains_any('My foo is cute', 'bar', 'wtf')) &
contains_any([[1], [2,3]], 1)
concatenation.t 0000666 00000000332 15133475453 0007572 0 ustar 00 'foo' + 'bar' === 'foobar' &
'' + 'foo' + '' === 'foo' &
'foo' + ' ' + 'bar' === 'foo bar' &
'foo' + 234 === 'foo234' &
452 + 'foo' === '452foo' &
'foo' + false === 'foo' &
'foo' + [ 'bar', 'foo' ] === 'foobar\nfoo\n'
eq.t 0000666 00000000073 15133475453 0005354 0 ustar 00 (1 == 1) & (1 != 2) & (1 === 1) & (1 == "1") & (1 !== "1")
equals-to-any.t 0000666 00000001123 15133475453 0007443 0 ustar 00 equals_to_any( "foo", "bar", "foo", "pizza" ) &
equals_to_any( 15, 3, 77, 18, 15 ) &
equals_to_any( "", 3, 77, 18, 15, "duh" ) === false &
equals_to_any( "", 3, 77, 18, 15, "duh", "" ) &
equals_to_any( true, 1, "true" ) === false &
equals_to_any( "1", 1, [ 1 ], true ) === false &
equals_to_any( [ 1, "1" ], 1, "1" ) === false &
equals_to_any( [ 1, 2, 3 ], [ 1, 2, 3 ] ) &
equals_to_any( [ 1, 2, 3 ], [ 3, 2, 1 ] ) === false &
equals_to_any( [ "foo", "bar" ], [ ] ) === false &
equals_to_any( [ "foo", "bar" ], [ "foo", "bar" ] ) &
equals_to_any( [], [] ) &
equals_to_any( [ 0 ], [] ) === false
comparisons.t 0000666 00000001006 15133475453 0007301 0 ustar 00 (2 = 2) &
(2 == 2) &
(2 === 2) &
('2' = 2) &
('2' == 2) &
('2' !== 2) &
(['1','2'] = ['1','2']) &
(['1','2'] == ['1','2']) &
(['1','2'] === ['1','2']) &
(['1','2'] != ['2','1']) &
(['1','2'] = ['1',2]) &
(['1','2'] == ['1',2]) &
(['1','2'] !== ['1',2]) &
(true = 1) &
(true == 1) &
(true !== 1) &
(false != 0) &
(false = '') &
(false == '') &
(false !== '') &
(false = []) &
(false == []) &
(false !== []) &
(false = null) &
(false == null) &
(false !== null) &
([] = null) &
([] == null) &
([] !== null) &
([] != '')
multipleconditionals.t 0000666 00000000443 15133475453 0011212 0 ustar 00 /* For T152281 */
v1 := 0; v2 := 0;
if ( 1 == 1 ) then
(
v1 := 1; v2 := 1;
)
else
(
v1 := 2; v2 := 2;
)
end;
if ( 1 == 1 ) then
( v1 := 1; )
else
(
v1 := 2; v2 := 2;
)
end;
if ( 1 == 1 ) then
( v1 := 2 === 2 ? 1 : 3; )
else
(
v1 := 'x' === 'y' ? 2 : 3;
v2 := v1 ** 2;
)
end;
ifthen.t 0000666 00000000202 15133475453 0006216 0 ustar 00 (if 1 then 2 else 3 end) === 2 &
(if false then 2 else 3 end) === 3 &
(if true then 3 end) === 3 &
(if false then 3 end) === null
specialratio.t 0000666 00000000072 15133475453 0007425 0 ustar 00 specialratio("foó;") === 0.25 &
specialratio("") === 0.0
tern.t 0000666 00000000027 15133475453 0005716 0 ustar 00 1 ? 0 ? 3 : 4 : 5 == 4
rmdoubles.t 0000666 00000000051 15133475453 0006737 0 ustar 00 rmdoubles("foobarééqq") === "fobaréq"
array-statements.t 0000666 00000000113 15133475453 0010245 0 ustar 00 /* intEval used to return a tree node for this */
var := [1];
var[0] := 2;
prec.t 0000666 00000000074 15133475453 0005701 0 ustar 00 (1 + 2 * 3 === 7) & (2 ** 2 * 2 === 8) & (1 - 1 - 1 === -1)
ip-in-range.t 0000666 00000002341 15133475453 0007055 0 ustar 00 ip_in_range( '12.34.56.78', '12.34.56.0/24' ) &
ip_in_range( '12.34.56.78', '12.34.0.0/16' ) &
ip_in_range( '12.34.56.78', '12.0.0.0/8' ) &
ip_in_range( '1.1.1.1', '1.1.1.1/32' ) &
ip_in_range( '1.1.1.1', '0.0.0.0/1' ) &
ip_in_range( '1.1.1.1', '1.1.1.0/24' ) === true &
ip_in_range( '55.55.55.55', '55.55.0.0/16' ) === true &
ip_in_range( '123.123.123.123', '123.123.123.123/32' ) === true &
ip_in_range( '123.123.123.123', '123.123.123.123' ) === true &
ip_in_range( '123.123.123.123', '123.0.0.0-124.0.0.0' ) === true &
ip_in_range( '123.123.123.123', '123.0.0.0 - 124.0.0.0' ) === true &
ip_in_range( '123.123.123.123', '123.123.123.0-123.123.123.255' ) === true &
ip_in_range( '123.123.123.123', '125.0.0.0-124.0.0.0' ) === false &
ip_in_range( '11.11.11.11', '11.11.11.1' ) === false &
ip_in_range( '1.1.1.1', '1.1.1.1-255.255.255.255' ) === true &
ip_in_range( '2001:db8:85a3::8a2e:0370:7334', '2001:db8:85a3::8a2e:370:7334/113' ) === true &
ip_in_range( '2001:db8:85a3::8a2e:0370:7334', '2001:db8:85a3::8a2e:370:0000-2001:db8:85a3::8a2e:370:8888' ) === true &
ip_in_range( '1.1.1.1', '2001:db8:85a3::8a2e:370:0000-2001:db8:85a3::8a2e:370:8888' ) === false &
ip_in_range( '2001:db8:85a3::8a2e:370:0000', '0.0.0.0-255.255.255.255' ) === false
lazysum.t 0000666 00000000026 15133475453 0006451 0 ustar 00 1 === 1 | 2 + 3 === 5
get-matches.t 0000666 00000001275 15133475453 0007155 0 ustar 00 get_matches('I am a (dog|cat)', 'What did you say?') === [ false, false ] &
get_matches('The (truth|pineapple) is (?:rarely)? pure and (nee*v(ah|er) sh?imple)', 'The truth is rarely pure and never simple, Wilde said') == ['The truth is rarely pure and never simple', 'truth', 'never simple', 'er'] &
get_matches('You say (.*) \(and I say (.*)\)\.', 'You say hello (and I say goodbye).') === [ 'You say hello (and I say goodbye).', 'hello', 'goodbye' ] &
get_matches('I(?: am)? the ((walrus|egg man).*)\!', 'I am the egg man, I am the walrus !') === [ 'I am the egg man, I am the walrus !', 'egg man, I am the walrus ', 'egg man' ] &
get_matches('this (does) not match', 'foo bar') === [ false, false ] bool-assoc.t 0000666 00000000030 15133475453 0007001 0 ustar 00 !(true | false & false)
arith.t 0000666 00000001076 15133475453 0006062 0 ustar 00 +1 + -1 === 0 &
-1 + +2 === 1 &
-0 === 0 &
(1 + 1 === 2) &
(1.5 + 1.5 === 3.0) &
(2.5 + 1 === 3.5) &
(0 + 1 === 1) &
(2.5 + 0 === 2.5) &
(5 - 3 === 2) &
(5 - 3.5 === 1.5) &
(5.5 - 3.5 === 2.0) &
(1 - 0 === 1) &
(2.5 - 0 === 2.5) &
(2 * 3 === 6) &
(2 * 3.5 === 7.0) &
(2.5 * 3.5 === 8.75) &
(2.5 * 0 === 0.0) &
(10 / 2 === 5) &
(10 / 2.5 === 4.0) &
(18 / 36 === 0.5) &
(0 / 36 === 0) &
(12.5 / 2.5 === 5.0) &
(10.5 / 2.5 === 4.2) &
(10 % 7 === 3) &
(10.48762 % 7 === 3) &
(10 % 7.123576 === 3) &
(2 ** 4 === 16) &
(2.5 ** 2 === 6.25) &
(2.5 ** 0 === 1.0) &
(1000 ** 0 === 1)
shortcircuit-or.t 0000666 00000000126 15133475453 0010106 0 ustar 00 /* The division by zero should not be executed and not crash the filter */
true | 1/0
numbers.t 0000666 00000000501 15133475453 0006416 0 ustar 00 /* Things that are NOT numbers; */
0xfoo := 'foobar';
0b10bar := 'bar';
0xfoo === 'foobar' & 0b10bar === 'bar' &
/* Actual numbers */
0x1A === 0x1a & 0x1a === 26 & 0xa === 10 & 0b11111111 === 255 & 0o123 === 83 & 0x123 === 291 & 0xF === 15 &
0o10 === 8 & 0o1 === 1 & 0b101010 === 42 & 0b101010 === 0x2a & 0x2a === 0o52
shortcircuit-and.t 0000666 00000000131 15133475453 0010224 0 ustar 00 /* The division by zero should not be executed and not crash the filter */
!(false & 1/0) containsfunction.t 0000666 00000000107 15133475453 0010331 0 ustar 00 contains_any( "", "a") === false &
contains_any( "a", "", "a") === true bug25373.t 0000666 00000000034 15133475453 0006125 0 ustar 00 (1 == 1) ? (true) : (false)
length.t 0000666 00000000026 15133475453 0006226 0 ustar 00 length("foobar") == 6
cast.t 0000666 00000000606 15133475453 0005703 0 ustar 00 (string(1) === "1") &
(int("1") === 1) &
(float(1) === 1.0) &
bool(1) & !bool(0) &
bool([]) === false &
bool( [false] ) === true &
bool( [1,2,3,4,5,6] ) === true &
float([]) === 0.0 &
float( [false] ) === 1.0 &
float( [1,2,3,4,5,6] ) === 6.0 &
int([]) === 0 &
int( [false] ) === 1 &
int( [1,2,3,4,5,6] ) === 6 &
true + true === 2 &
null - null === 0 &
true * false === 0 &
163 % true === 0
lazyunarys.t 0000666 00000000023 15133475453 0007163 0 ustar 00 1 === 1 | -4 !== 4
string.t 0000666 00000000424 15133475453 0006255 0 ustar 00 "a\tb" === "a b" &
"a\qb" === "a\qb" &
"a\"b" === 'a"b' &
"a\rb" !== "a\r\nb" &
"\x66\x6f\x6f" === "foo" &
"some\xstring" === "some\\xstring" &
"some\vstring" === "some\\vstring" &
/* T238475 */
'\x{}' === '\x' + '{}' &
length('\x{}') === 4 &
'foobar' rlike '[\x{61}-\x{7a}]'
sanitize.t 0000666 00000000046 15133475453 0006575 0 ustar 00 sanitize('یک') === 'یک'
mwexamples-arithmetic.t 0000666 00000000243 15133475453 0011257 0 ustar 00 /* Examples from [[mw:Extension:AbuseFilter/Rules format#Arithmetic]] */
1 + 1 === 2 &
2 * 2 === 4 &
12 / 24 === 0.5 &
24 / 12 === 2 &
9 ** 2 === 81 &
6 % 5 === 1 rmspecials.t 0000666 00000000113 15133475453 0007104 0 ustar 00 rmspecials("foo;bar!") === "foobar" &
rmspecials("foo; bar!") === "foo bar"