File: 90rt142468.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 (49 lines) | stat: -rw-r--r-- 865 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/perl

use v5.14;
use warnings;

use Test2::V0;

use Future;
use Future::AsyncAwait;

# Check that folded constants stored on the pad with the SvPADTMP flag set are
# still copied successfully by cv_copy_flags().
#
#   https://rt.cpan.org/Ticket/Display.html?id=142468

use constant {
   REG_LUXH => 0x03,
   REG_LUXL => 0x04,
};

my @written;

my $ftick;
sub write_then_read
{
   my ( $bytes, $len ) = @_;

   push @written, [ $bytes, $len ];

   return $ftick = Future->new;
}

async sub read_lux
{
   return unpack "S>", join "",
      await write_then_read( ( pack "C", REG_LUXH ), 1 ),
      await write_then_read( ( pack "C", REG_LUXL ), 1 );
}

{
   my $fret = read_lux;

   do { my $f = $ftick; undef $ftick; $f->done } while $ftick;

   is( \@written, [ [ "\x03", 1 ], [ "\x04", 1 ], ],
      'arguments to ->write_then_read' );
}

done_testing;