Mercurial > pub > Impl
diff _test/Test/Web/View.pm @ 189:08015e2803f1
IMPL::Vew::Web - fixed memory leaks, more tests
author | cin |
---|---|
date | Wed, 04 Apr 2012 02:49:45 +0400 |
parents | 029c9610528c |
children | cd1ff7029a63 |
line wrap: on
line diff
--- a/_test/Test/Web/View.pm Tue Apr 03 20:08:42 2012 +0400 +++ b/_test/Test/Web/View.pm Wed Apr 04 02:49:45 2012 +0400 @@ -24,7 +24,11 @@ my $data = MProfiler->Monitor($code, sub { $_ =~ m/^IMPL::/} ); - assert( not($data->isLeak), "Memory leak detected", GetCallerSourceLine() , @{$data->{objects}}, $dump ? $data->Dump : () ); + if ($data->isLeak and $dump) { + write_file("dump.out", { binmode => ':utf8' }, $data->Dump() ); + } + + assert( not($data->isLeak), "Memory leak detected", GetCallerSourceLine() , @{$data->{objects}} ); } sub templatesDir { @@ -111,7 +115,6 @@ assert(defined $factory); - assert(not $loader->context->stash->get('My.Org.Panel')); assert($factory->context->stash != $doc->context->stash); @@ -127,9 +130,9 @@ assert($factory->instances == 1); - assert($doc->templateVars('My.Org.Panel') == $factory); + $doc->appendChild($ctl); - my $text = $ctl->Render(); + my $text = $ctl->Render({ data => ['one','two','hello world']}); my $expected = read_file($this->GetResourceFile('Resources', 'TTView.Output', 'Panel.txt'), binmode => ':utf8'); assert($text eq $expected, '$ctl->Render(): Bad output', "Got: $text", "Expected: $expected"); @@ -151,12 +154,20 @@ $doc->Render( { self => $doc } ); }); - AssertMemoryLeak(sub{ + $loader->template('My/Org/Panel'); + $loader->template('My/Org/TextPreview'); + AssertMemoryLeak(sub { my $doc = $loader->document('simple'); my $factory = $doc->require('My/Org/Panel'); - #my $ctl = $doc->AppendChild($factory->new('information', { visualClass => 'complex' }) ); + my $ctl = $doc->AppendChild($factory->new('information', { visualClass => 'complex' }) ); }); + $loader->template('complex'); + AssertMemoryLeak(sub { + my $doc = $loader->document('complex'); + $doc->Render(); + },'dump'); + }; 1; \ No newline at end of file