Skip to content

Instantly share code, notes, and snippets.

@zoffixznet

zoffixznet/p6.p6 Secret

Created May 28, 2017 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/7c80faf1c35d389b614b9cb11cdca9b6 to your computer and use it in GitHub Desktop.
Save zoffixznet/7c80faf1c35d389b614b9cb11cdca9b6 to your computer and use it in GitHub Desktop.
use v6;
use lib <t/spec/packages/>;
use Test;
use Test::Util;
plan 34;
# IO::Notification tests
my $dir = make-temp-dir;
my $f1 = $dir.add: 'foo.txt';
my $d1 = $dir.add: 'meow';
sub c ($path, $event) { IO::Notification::Change.new: :$path, :$event }
my @got; my @exp;
my $notif = IO::Notification.watch-path($dir).act: { @got.push: $_ };
is-deeply @got, [], 'no notifications';
$f1.spurt: '';
@exp.push: c $f1, FileRenamed;
@exp.push: c $f1, FileChanged;
is-deeply @got.sort, @exp.sort, 'created new file';
$d1.mkdir;
@exp.push: c $d1, FileRenamed;
@exp.push: c $d1, FileChanged;
is-deeply @got.sort, @exp.sort, 'created new directory';
$dir.add('meow' ).chmod: 777;
$dir.add('foo.txt').chmod: 777;
$dir.add('meow' ).rmdir;
$dir.add('foo.txt').unlink;
$dir.add('bar.txt').unlink;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment