File: 50future-subclass.t

package info (click to toggle)
libfuture-asyncawait-perl 0.70-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 528 kB
  • sloc: perl: 2,647; ansic: 118; pascal: 34; makefile: 3
file content (35 lines) | stat: -rw-r--r-- 587 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/perl

use v5.14;
use warnings;

use Test2::V0;

package SubclassOfFuture {
   use base qw( Future );
}

{
   use Future::AsyncAwait future_class => "SubclassOfFuture";
   BEGIN {
      # gutwrenching
      ok( defined $^H{"Future::AsyncAwait/future"}, '%^H is set inside block' );
   }

   async sub func { return 123 }
}

# Is %^H well-behaved?
{
   ok( !defined $^H{"Future::AsyncAwait/future"}, '%^H restored outside block' );
}

{
   my $f = func();

   isa_ok( $f, [ "SubclassOfFuture" ], 'result of async sub func' );

   is( $f->get, 123, '$f->get' );
}

done_testing;