Rename things and unify error handling a bit
[dbsrgits/SQL-Abstract-2.0-ish.git] / t / 900_errors.t
1 use strict;
2 use warnings;
3
4 use Test::More tests => 3;
5 use Test::Exception;
6
7 use_ok('SQL::Abstract') or BAIL_OUT( "$@" );
8
9 my $sqla = SQL::Abstract->create(1);
10
11 throws_ok {
12   $sqla->dispatch(
13     { -type => 'expr', op => '==',
14       args => [
15         { -type => 'name', args => [qw/me id/] },
16         { -type => 'alias', ident => { -type => 'name', args => [qw/me id/] }, as => 'bar' }
17       ]
18     }
19   )
20 } qr/^'alias' is not a valid AST type in an expression/, "Error from invalid part in where";
21
22 throws_ok {
23   $sqla->dispatch(
24     { -type => 'expr', op => '~' }
25   )
26 } qr/^'~' is not a valid operator in an expression/
27
28 __END__
29 throws_ok {
30   $sqla->dispatch(
31     { -where => 
32       [ '~', [-name => qw/me id/], [ -alias => [-name => qw/me foo/], 'bar' ] ]
33     ]
34   )
35 } qr/^'~' is not a valid operator/, 
36   "Error from invalid operator in where";