7 use SQL::Abstract qw(is_plain_value is_literal_value);
14 # *DELIBERATELY* unspecified
16 '0+' => sub { ${$_[0]} },
20 SQLATest::SillyInt::Subclass;
22 our @ISA = 'SQLATest::SillyInt';
34 SQLATest::SillierInt::Subclass;
37 '0+' => sub { ${$_[0]} },
38 '+' => sub { ${$_[0]} + $_[1] },
41 our @ISA = 'SQLATest::SillierInt';
44 # make sure we recognize overloaded stuff properly
46 my $num = bless( \do { my $foo = 69 }, 'SQLATest::SillyInt::Subclass' );
47 ok( is_plain_value $num, 'parent-fallback-provided stringification detected' );
48 is("$num", 69, 'test overloaded object stringifies, without specified fallback');
49 } 'overload testing lives';
52 my $nummifiable_maybefallback_num = bless( \do { my $foo = 42 }, 'SQLATest::SillierInt::Subclass' );
54 ok( ( $nummifiable_maybefallback_num + 1) == 43 )
57 my $can_str = !! eval { "$nummifiable_maybefallback_num" };
61 is_plain_value $nummifiable_maybefallback_num,
62 ( $can_str ? [ 42 ] : undef ),
63 'parent-disabled-fallback stringification detected same as perl',
69 is_plain_value { -value => [] },
78 'nonvalues correctly recognized'
82 for (undef, { -value => undef }) {
86 'NULL -value recognized'
91 is_literal_value { -ident => 'foo' },
93 '-ident recognized as literal'
97 is_literal_value \[ 'sql', 'bind1', [ {} => 'bind2' ] ],
98 [ 'sql', 'bind1', [ {} => 'bind2' ] ],
99 'literal correctly unpacked'
103 for ([], {}, \'', undef) {
105 is_literal_value { -ident => $_ },
107 'illegal -ident does not trip up detection'