File: 15_array_xs.t

package info (click to toggle)
liborlite-perl 1.44-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 348 kB
  • ctags: 182
  • sloc: perl: 2,726; sql: 36; makefile: 2
file content (66 lines) | stat: -rw-r--r-- 1,281 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/perl

# The same as 12_xs.t except with array => 1

BEGIN {
	$|  = 1;
	$^W = 1;
}

use Test::More;

# Only run this test if we have Class::XSAccessor
BEGIN {
	eval { require Class::XSAccessor::Array };
	if ( ! $@ and Class::XSAccessor::Array->VERSION and Class::XSAccessor::Array->VERSION >= 1.05 ) {
		plan( tests => 7 );
	} else {
		plan( skip_all => 'Class::XSAccessor::Array 1.05 is not installed' );
	}
}
use File::Spec::Functions ':ALL';
use t::lib::Test;





#####################################################################
# Set up for testing

# Connect
my $file = test_db();
my $dbh  = create_ok(
	file    => catfile(qw{ t 03_fk.sql }),
	connect => [ "dbi:SQLite:$file" ],
);

# Create the test package
eval <<"END_PERL"; die $@ if $@;
package Foo::Bar;

use strict;
use ORLite {
	file       => '$file',
	array      => 1,
	xsaccessor => 1,
};

1;
END_PERL





#####################################################################
# Run the tests

my @t2 = Foo::Bar::TableTwo->select;
is( scalar(@t2), 1, 'Got one table_two object' );
isa_ok( $t2[0], 'Foo::Bar::TableTwo' );

is( $t2[0]->col1, 1, '->col1 ok' );
isa_ok( $t2[0]->col2, 'Foo::Bar::TableOne' );
is( $t2[0]->col2->col1, 1, '->col1 of fk ok' );
is( $t2[0]->col2->col2, 2, '->col2 of fk ok' );