1#!perl 2# vim:ts=4:sw=4:expandtab 3 4use Test::More tests => 9; 5use Test::Deep; 6use Test::Exception; 7use X11::XCB qw(:all); 8 9BEGIN { 10 use_ok('X11::XCB::Atom') or BAIL_OUT('Unable to load X11::XCB::Atom'); 11} 12 13my $x; 14 15# All atom tests need a working X connection, so we may need to skip them 16SKIP: { 17 eval { $x = X11::XCB::Connection->new; }; 18 19 skip "Could not setup X11 connection", 8 if $@; 20 21 my $atom = $x->atom(name => 'PRIMARY'); 22 23 isa_ok($atom, 'X11::XCB::Atom'); 24 25 is(int($atom->id), $atom->id, 'reply is an integer'); 26 27 my $invalid = $x->atom(name => 'this_atom_does_not_exist'); 28 29 # We should be able to create the object 30 isa_ok($invalid, 'X11::XCB::Atom'); 31 32 # This should crash 33 throws_ok { $invalid->id } qr/No such atom/, 'Invalid atom die()d'; 34 35 ok(!$invalid->exists, 'Invalid atom does not exist'); 36 37 ok($atom->exists, 'Valid atom exists'); 38 39 my $other_invalid = $x->atom(name => 'this_atom_does_not_exist_too'); 40 41 # We should be able to create the object 42 isa_ok($other_invalid, 'X11::XCB::Atom'); 43 44 ok(!$other_invalid->exists, 'Fresh invalid atom does not exist'); 45} 46 47diag( "Testing X11::XCB, Perl $], $^X" ); 48