Mercurial > pub > Impl
comparison _test/Test/Web/View.pm @ 286:d357b5d85d25
*TTView refactoring
author | sergey |
---|---|
date | Mon, 18 Feb 2013 14:46:06 +0400 |
parents | c6d0f889ef87 |
children | 2d253e6e4a88 |
comparison
equal
deleted
inserted
replaced
285:546957c50a36 | 286:d357b5d85d25 |
---|---|
9 | 9 |
10 use File::Slurp; | 10 use File::Slurp; |
11 use Scalar::Util qw(weaken); | 11 use Scalar::Util qw(weaken); |
12 | 12 |
13 use IMPL::lang; | 13 use IMPL::lang; |
14 use IMPL::Test qw(assert test GetCallerSourceLine); | 14 use IMPL::Test qw(assert assertarray test GetCallerSourceLine); |
15 use IMPL::Web::View::TTLoader(); | 15 use IMPL::Web::View::TTLoader(); |
16 | 16 |
17 use constant { | 17 use constant { |
18 TTLoader => 'IMPL::Web::View::TTLoader', | 18 TTLoader => 'IMPL::Web::View::TTLoader', |
19 MProfiler => 'IMPL::Profiler::Memory' | 19 MProfiler => 'IMPL::Profiler::Memory' |
184 my $text = $doc->Render(); | 184 my $text = $doc->Render(); |
185 my $expected = read_file($this->GetResourceFile('Resources', 'TTView.Output', 'complex.default.txt'), binmode => ':utf8' ); | 185 my $expected = read_file($this->GetResourceFile('Resources', 'TTView.Output', 'complex.default.txt'), binmode => ':utf8' ); |
186 #assert($text eq $expected, '$doc->Render(): Bad output', "Got: $text", "Expected: $expected"); | 186 #assert($text eq $expected, '$doc->Render(): Bad output', "Got: $text", "Expected: $expected"); |
187 }; | 187 }; |
188 | 188 |
189 test TestDocumentsIsolation => sub { | |
190 my $this = shift; | |
191 | |
192 my $loader = $this->CreateLoader(); | |
193 | |
194 my $doc = $loader->document('simple'); | |
195 | |
196 assert(ref $loader->context->stash->get([ 'dojo', 0, 'require', 0]) eq 'ARRAY'); | |
197 assertarray($loader->context->stash->get([ 'dojo', 0, 'require', 0]),[]); | |
198 assert($loader->context->stash != $doc->stash); | |
199 | |
200 assert(defined $doc); | |
201 | |
202 # only root stash variables can be localized, to avoid modifying dojo we | |
203 # need to replace it completely | |
204 $doc->context->process(\q{ | |
205 [% SET dojo = { require => [] } %] | |
206 [% dojo.require.push('dijit/form/TextBox') %] | |
207 [% SET user = 'dummy guy' %] | |
208 }); | |
209 | |
210 assert($doc->context->stash->get('user') eq 'dummy guy'); | |
211 assert($loader->context->stash->get('user') eq 'test_user'); | |
212 assertarray($doc->context->stash->get([ 'dojo', 0, 'require', 0]),['dijit/form/TextBox']); | |
213 assertarray($loader->context->stash->get([ 'dojo', 0, 'require', 0]),[]); | |
214 | |
215 my $text = $doc->Render(); | |
216 | |
217 my $doc2 = $loader->document('simple'); | |
218 | |
219 assertarray($doc2->context->stash->get([ 'dojo', 0, 'require', 0]),[]); | |
220 }; | |
221 | |
189 test TestMemoryLeaks => sub { | 222 test TestMemoryLeaks => sub { |
190 my ($this) = @_; | 223 my ($this) = @_; |
191 | 224 |
192 my $loader = $this->CreateLoader(); | 225 my $loader = $this->CreateLoader(); |
193 $loader->document('simple'); # force loader initialization | 226 $loader->document('simple'); # force loader initialization |