Mercurial > pub > Impl
comparison _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 |
comparison
equal
deleted
inserted
replaced
188:029c9610528c | 189:08015e2803f1 |
---|---|
22 my $code = shift; | 22 my $code = shift; |
23 my $dump = shift; | 23 my $dump = shift; |
24 | 24 |
25 my $data = MProfiler->Monitor($code, sub { $_ =~ m/^IMPL::/} ); | 25 my $data = MProfiler->Monitor($code, sub { $_ =~ m/^IMPL::/} ); |
26 | 26 |
27 assert( not($data->isLeak), "Memory leak detected", GetCallerSourceLine() , @{$data->{objects}}, $dump ? $data->Dump : () ); | 27 if ($data->isLeak and $dump) { |
28 write_file("dump.out", { binmode => ':utf8' }, $data->Dump() ); | |
29 } | |
30 | |
31 assert( not($data->isLeak), "Memory leak detected", GetCallerSourceLine() , @{$data->{objects}} ); | |
28 } | 32 } |
29 | 33 |
30 sub templatesDir { | 34 sub templatesDir { |
31 $_[0]->GetResourceDir('Resources','TTView'); | 35 $_[0]->GetResourceDir('Resources','TTView'); |
32 } | 36 } |
109 | 113 |
110 my $factory = $doc->require('My/Org/Panel'); | 114 my $factory = $doc->require('My/Org/Panel'); |
111 | 115 |
112 assert(defined $factory); | 116 assert(defined $factory); |
113 | 117 |
114 assert(not $loader->context->stash->get('My.Org.Panel')); | |
115 | 118 |
116 assert($factory->context->stash != $doc->context->stash); | 119 assert($factory->context->stash != $doc->context->stash); |
117 | 120 |
118 assert($factory == $doc->require('My/Org/Panel'), "Control should be loaded only once"); | 121 assert($factory == $doc->require('My/Org/Panel'), "Control should be loaded only once"); |
119 | 122 |
125 | 128 |
126 assert($ctl->nodeProperty('visualClass') eq 'simple'); | 129 assert($ctl->nodeProperty('visualClass') eq 'simple'); |
127 | 130 |
128 assert($factory->instances == 1); | 131 assert($factory->instances == 1); |
129 | 132 |
130 assert($doc->templateVars('My.Org.Panel') == $factory); | 133 $doc->appendChild($ctl); |
131 | 134 |
132 my $text = $ctl->Render(); | 135 my $text = $ctl->Render({ data => ['one','two','hello world']}); |
133 my $expected = read_file($this->GetResourceFile('Resources', 'TTView.Output', 'Panel.txt'), binmode => ':utf8'); | 136 my $expected = read_file($this->GetResourceFile('Resources', 'TTView.Output', 'Panel.txt'), binmode => ':utf8'); |
134 | 137 |
135 assert($text eq $expected, '$ctl->Render(): Bad output', "Got: $text", "Expected: $expected"); | 138 assert($text eq $expected, '$ctl->Render(): Bad output', "Got: $text", "Expected: $expected"); |
136 | 139 |
137 }; | 140 }; |
149 AssertMemoryLeak(sub { | 152 AssertMemoryLeak(sub { |
150 my $doc = $loader->document('simple'); | 153 my $doc = $loader->document('simple'); |
151 $doc->Render( { self => $doc } ); | 154 $doc->Render( { self => $doc } ); |
152 }); | 155 }); |
153 | 156 |
154 AssertMemoryLeak(sub{ | 157 $loader->template('My/Org/Panel'); |
158 $loader->template('My/Org/TextPreview'); | |
159 AssertMemoryLeak(sub { | |
155 my $doc = $loader->document('simple'); | 160 my $doc = $loader->document('simple'); |
156 my $factory = $doc->require('My/Org/Panel'); | 161 my $factory = $doc->require('My/Org/Panel'); |
157 #my $ctl = $doc->AppendChild($factory->new('information', { visualClass => 'complex' }) ); | 162 my $ctl = $doc->AppendChild($factory->new('information', { visualClass => 'complex' }) ); |
158 }); | 163 }); |
164 | |
165 $loader->template('complex'); | |
166 AssertMemoryLeak(sub { | |
167 my $doc = $loader->document('complex'); | |
168 $doc->Render(); | |
169 },'dump'); | |
159 | 170 |
160 }; | 171 }; |
161 | 172 |
162 1; | 173 1; |