is(strftime('%Y-%m-%d', gmtime($1//0)), '2010-10-02', 'rt: end expand');
$q = $s->query_argv_to_string($g, [qw(something dt:2010-10-02..)]);
like($q, qr/\Asomething dt:20101002\d{6}\.\./, 'dt: expansion');
- $q = $s->query_argv_to_string($g, [qw(x d:yesterday.. y)]);
- is($q, strftime('x d:%Y%m%d.. y', gmtime(time - 86400)),
- '"yesterday" handled');
+ $q = $s->query_argv_to_string($g, [qw(x dt:yesterday.. y)]);
+ my $exp = strftime('%Y%m%d', gmtime(time - 86400));
+ like($q, qr/x dt:$exp[0-9]{6}\.\. y/, '"yesterday" handled');
$q = $s->query_argv_to_string($g, [qw(x dt:20101002054123)]);
is($q, 'x dt:20101002054123..20101003054123', 'single dt: expanded');
$q = $s->query_argv_to_string($g, [qw(x dt:2010-10-02T05:41:23Z)]);
is($qs, qq[f:bob "hello world" d:19931002..20101002],
'post-phrase date corrected');
+ # Xapian uses "" to escape " inside phrases, we don't explictly
+ # handle that, but are able to pass the result through unchanged
+ for my $pair (["\x{201c}", "\x{201d}"], ['"', '"']) {
+ my ($x, $y) = @$pair;
+ $orig = $qs = qq[${x}hello d:1993-10-02.."" world$y];
+ $s->query_approxidate($g, $qs);
+ is($qs, $orig, 'phrases unchanged \x'.ord($x).'-\x'.ord($y));
+
+ $s->query_approxidate($g, my $tmp = "$qs d:..2010-10-02");
+ is($tmp, "$orig d:..20101002",
+ 'two phrases did not throw off date parsing');
+
+ $orig = $qs = qq[${x}hello d:1993-10-02..$y$x world$y];
+ $s->query_approxidate($g, $qs);
+ is($qs, $orig, 'phrases unchanged \x'.ord($x).'-\x'.ord($y));
+
+ $s->query_approxidate($g, $tmp = "$qs d:..2010-10-02");
+ is($tmp, "$orig d:..20101002",
+ 'two phrases did not throw off date parsing');
+ }
+
my $x_days_ago = strftime('%Y%m%d', gmtime(time - (5 * 86400)));
$orig = $qs = qq[broken d:5.days.ago..];
$s->query_approxidate($g, $qs);
- is($qs, qq[broken d:$x_days_ago..], 'date.phrase.with.dots');
+ like($qs, qr/\Abroken dt:$x_days_ago[0-9]{6}\.\./,
+ 'date.phrase.with.dots');
+
+ $orig = $qs = 'd:20101002..now';
+ $s->query_approxidate($g, $qs);
+ like($qs, qr/\Adt:20101002000000\.\.[0-9]{14}\z/,
+ 'approxidate on range-end only');
$ENV{TEST_EXPENSIVE} or
skip 'TEST_EXPENSIVE not set for argv overflow check', 1;