1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 2;
my $CLASS = "Local::Test::Dialect";
# Test making a dialect
{
package Local::Test::Dialect;
use SQL::Dialects::Role;
sub get_config
{
# There's some deliberate whitespace abuse in here
return <<END;
[THINGS]
elephants
FEELINGS
stuff
[RESERVED WORDS]
FOO
BAR
BAZ
END
}
}
is_deeply(
$CLASS->get_config_as_hash(),
{
things => {
ELEPHANTS => 1,
FEELINGS => 1,
STUFF => 1,
},
reserved_words => {
FOO => 1,
BAR => 1,
BAZ => 1
}
}
);
# Test role injection
{
{
package SQL::Dialects::Test::NoRole;
sub get_config
{
return <<DONE;
[FOO]
bar
baz
DONE
}
}
use SQL::Parser;
my $parser = SQL::Parser->new();
ok eval { $parser->dialect("Test::NoRole"); 1; } or diag($@);
}
|