use Scalar::Util ();
use overload (
+ # unary operators
+ (map {
+ my $op = $_;
+ $op => sub {
+ Data::Query::ExprBuilder->new({
+ expr => {
+ type => DQ_OPERATOR,
+ operator => { perl => $op },
+ args => [ $_[0]->{expr} ]
+ }
+ });
+ }
+ } qw(! neg)),
# binary operators
(map {
my ($overload, $as) = ref($_) ? @$_ : ($_, $_);
subtype => { perl => 'Scalar' },
value => $_
}
+ # we're called with ($left, $right, 0) or ($right, $left, 1)
} $_[2] ? @_[1,0] : @_[0,1]
]
},
],
},
'Masquerade for | as or ok';
+
+expr_is { !$_->foo }
+ {
+ type => DQ_OPERATOR,
+ operator => { perl => '!' },
+ args => [ expr { $_->foo } ],
+ },
+ '! ok';