49
|
1 package Test::Resources::Format;
|
|
2 use strict;
|
|
3 use warnings;
|
|
4
|
166
|
5 use parent qw(IMPL::Test::Unit);
|
49
|
6 use IMPL::Test qw(test failed);
|
|
7 use IMPL::Resources::Format qw(FormatMessage);
|
|
8
|
|
9 __PACKAGE__->PassThroughArgs;
|
|
10
|
|
11 {
|
|
12 package Args;
|
166
|
13 use parent qw(IMPL::Object);
|
49
|
14
|
|
15 sub foo {
|
|
16 return { name => 'Args::foo', value => 'some value'}
|
|
17 }
|
|
18 }
|
|
19
|
|
20 test FormatMessage => sub {
|
|
21 my $format = 'This is a %name% message. %args.foo.name% has %args.foo.value% and %some.unknown.param%';
|
|
22
|
|
23 my $args = {
|
|
24 name => 'Test',
|
|
25 args => new Args()
|
|
26 };
|
|
27
|
|
28 my $result = FormatMessage($format,$args);
|
|
29 my $expected = 'This is a Test message. Args::foo has some value and [some.unknown.param]';
|
|
30
|
|
31 failed
|
|
32 "Format message returned unexpected results",
|
|
33 "Expected: $expected",
|
|
34 "Recieved: $result"
|
|
35 unless $result eq $expected;
|
|
36 };
|
|
37
|
|
38
|
|
39 1;
|