summaryrefslogtreecommitdiffstats
path: root/web/server/h2o/libh2o/misc/p5-Server-Starter/t/09-guard.t
diff options
context:
space:
mode:
Diffstat (limited to 'web/server/h2o/libh2o/misc/p5-Server-Starter/t/09-guard.t')
-rw-r--r--web/server/h2o/libh2o/misc/p5-Server-Starter/t/09-guard.t31
1 files changed, 31 insertions, 0 deletions
diff --git a/web/server/h2o/libh2o/misc/p5-Server-Starter/t/09-guard.t b/web/server/h2o/libh2o/misc/p5-Server-Starter/t/09-guard.t
new file mode 100644
index 00000000..a51903a4
--- /dev/null
+++ b/web/server/h2o/libh2o/misc/p5-Server-Starter/t/09-guard.t
@@ -0,0 +1,31 @@
+use strict;
+use warnings;
+use Test::More;
+
+use_ok("Server::Starter::Guard");
+
+subtest "guard is called when it goes out of scope" => sub {
+ my $cnt = 0;
+
+ my $guard = Server::Starter::Guard->new(sub {
+ $cnt++;
+ });
+
+ is $cnt, 0;
+ undef $guard;
+ is $cnt, 1;
+};
+
+subtest "guard can be dismissed" => sub {
+ my $cnt = 0;
+
+ my $guard = Server::Starter::Guard->new(sub {
+ $cnt++;
+ });
+
+ $guard->dismiss;
+ undef $guard;
+ is $cnt, 0;
+};
+
+done_testing;