annotate _test/Test/Resources/Format.pm @ 277:6585464c4664

sync (unstable)
author sergey
date Fri, 01 Feb 2013 16:37:59 +0400
parents 4267a2ac3d46
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
1 package Test::Resources::Format;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
4
166
4267a2ac3d46 Added Class::Template,
wizard
parents: 49
diff changeset
5 use parent qw(IMPL::Test::Unit);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
6 use IMPL::Test qw(test failed);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
7 use IMPL::Resources::Format qw(FormatMessage);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
8
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
9 __PACKAGE__->PassThroughArgs;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
10
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
11 {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
12 package Args;
166
4267a2ac3d46 Added Class::Template,
wizard
parents: 49
diff changeset
13 use parent qw(IMPL::Object);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
14
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
15 sub foo {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
16 return { name => 'Args::foo', value => 'some value'}
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
17 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
18 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
19
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
20 test FormatMessage => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
21 my $format = 'This is a %name% message. %args.foo.name% has %args.foo.value% and %some.unknown.param%';
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
22
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
23 my $args = {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
24 name => 'Test',
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
25 args => new Args()
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
26 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
27
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
28 my $result = FormatMessage($format,$args);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
29 my $expected = 'This is a Test message. Args::foo has some value and [some.unknown.param]';
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
30
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
31 failed
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
32 "Format message returned unexpected results",
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
33 "Expected: $expected",
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
34 "Recieved: $result"
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
35 unless $result eq $expected;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
36 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
37
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
38
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 18
diff changeset
39 1;