File: 90rt128176.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 (45 lines) | stat: -rw-r--r-- 682 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
#!/usr/bin/perl

use v5.14;
use warnings;

use Test2::V0;

use Future;

use Future::AsyncAwait;

my @f;

sub set_dc { push @f, my $f = Future->new; return $f; }
sub readwrite { Future->done( $_[0] ) }

# Inspired by Device::Chip::SSD1306::SPI4::send_cmd
async sub send_cmd
{
   my $self = shift;
   my @vals = @_;

   await set_dc();
   await readwrite( join "", map { chr } @vals );
}

# Inspired by Device::Chip::SSD1306::init
async sub init
{
   my $self = shift;

   await $self->send_cmd( 1, 2 );
   await $self->send_cmd( 3, 4 );
}

{
   my $f = __PACKAGE__->init;

   # Pump Futures
   ( shift @f )->done() while @f;

   is( $f->get, "\x03\x04", 'result' );
}

done_testing;