Commit | Line | Data |
---|---|---|
b4514920 CG |
1 | use strict; |
2 | use warnings; | |
3 | BEGIN { require "t/tools.pl" }; | |
4 | ||
5 | use Test2::Event(); | |
6 | ||
7 | { | |
8 | package My::MockEvent; | |
9 | ||
10 | use base 'Test2::Event'; | |
11 | use Test2::Util::HashBase qw/foo bar baz/; | |
12 | } | |
13 | ||
14 | ok(My::MockEvent->can($_), "Added $_ accessor") for qw/foo bar baz/; | |
15 | ||
16 | my $one = My::MockEvent->new(trace => 'fake'); | |
17 | ||
18 | ok(!$one->causes_fail, "Events do not cause failures by default"); | |
19 | ||
20 | ok(!$one->$_, "$_ is false by default") for qw/increments_count terminate global/; | |
21 | ||
22 | ok(!$one->get_meta('xxx'), "no meta-data associated for key 'xxx'"); | |
23 | ||
24 | $one->set_meta('xxx', '123'); | |
25 | ||
26 | is($one->meta('xxx'), '123', "got meta-data"); | |
27 | ||
28 | is($one->meta('xxx', '321'), '123', "did not use default"); | |
29 | ||
30 | is($one->meta('yyy', '1221'), '1221', "got the default"); | |
31 | ||
32 | is($one->meta('yyy'), '1221', "last call set the value to the default for future use"); | |
33 | ||
34 | is($one->summary, 'My::MockEvent', "Default summary is event package"); | |
35 | ||
36 | is($one->diagnostics, 0, "Not diagnostics by default"); | |
37 | ||
38 | ok(!$one->in_subtest, "no subtest_id by default"); | |
39 | ||
40 | done_testing; |