| 1 |
use strict; |
|---|
| 2 |
use Test::More tests => 12; |
|---|
| 3 |
|
|---|
| 4 |
#use Carp; |
|---|
| 5 |
#use Devel::Peek; |
|---|
| 6 |
|
|---|
| 7 |
# TODO this test reveals the [possibly very flawed] logic in our |
|---|
| 8 |
# C-struct reference counting. |
|---|
| 9 |
# we need a way to know when to free the struct that |
|---|
| 10 |
# is blessed in an object. we don't want to free it with every |
|---|
| 11 |
# DESTROY, since there might be multiple Perl objects pointing |
|---|
| 12 |
# at the same C pointer, and freeing the underlying pointer |
|---|
| 13 |
# will segfault any remaining Perl objects. |
|---|
| 14 |
|
|---|
| 15 |
use_ok('SWISH::3'); |
|---|
| 16 |
|
|---|
| 17 |
ok( my $s3 = SWISH::3->new( handler => sub { } ), "new parser" ); |
|---|
| 18 |
|
|---|
| 19 |
ok( my $conf1 = $s3->get_config, "get initial config" ); |
|---|
| 20 |
ok( my $config = SWISH::3::Config->new, "new config" ); |
|---|
| 21 |
ok( !$s3->set_config($config), "set config" ); |
|---|
| 22 |
ok( $s3->get_config->isa('SWISH::3::Config'), |
|---|
| 23 |
"get config isa SWISH::3::Config" |
|---|
| 24 |
); |
|---|
| 25 |
ok( my $conf2 = $s3->get_config, "get conf2" ); |
|---|
| 26 |
|
|---|
| 27 |
#diag("config = $config"); |
|---|
| 28 |
#diag("conf1 = $conf1"); |
|---|
| 29 |
#diag("conf2 = $conf2"); |
|---|
| 30 |
|
|---|
| 31 |
ok( my $ana1 = $s3->get_analyzer, "get initial analyzer" ); |
|---|
| 32 |
ok( my $analyzer = SWISH::3::Analyzer->new($config), "new analyzer" ); |
|---|
| 33 |
ok( !$s3->set_analyzer($analyzer), "set analyzer" ); |
|---|
| 34 |
ok( $s3->get_analyzer->isa('SWISH::3::Analyzer'), |
|---|
| 35 |
"get analyzer isa SWISH::3::Analyzer" |
|---|
| 36 |
); |
|---|
| 37 |
ok( my $ana2 = $s3->get_analyzer, "get ana2" ); |
|---|
| 38 |
|
|---|