1*b39c5158Smillert#! /usr/bin/perl -w 2*b39c5158Smillert 3*b39c5158Smillertuse strict; 4*b39c5158Smillertuse Test::More tests => 48; 5*b39c5158SmillertBEGIN {use_ok 'OS2::Process'} 6*b39c5158Smillert 7*b39c5158Smillertok(SystemAtomTable(), 'SystemAtomTable succeeds'); 8*b39c5158Smillertmy $tbl = CreateAtomTable; 9*b39c5158Smillert 10*b39c5158Smillertok($tbl, 'CreateAtomTable succeeds'); 11*b39c5158Smillert 12*b39c5158Smillertis(AtomLength(133, $tbl), 6, 'AtomLength of unknown atom is 6'); 13*b39c5158Smillertis(AtomLength(1, $tbl), 6, 'AtomLength of unknown atom is 6'); 14*b39c5158Smillertok(!defined eval {AtomLength(100000, $tbl); 1}, 'AtomLength of invalid atom croaks'); 15*b39c5158Smillert# diag($@); 16*b39c5158Smillert 17*b39c5158Smillertis(AtomUsage(134, $tbl), 65535, 'AtomUsage of unknown atom is 65535'); 18*b39c5158Smillertis(AtomUsage(1, $tbl), 65535, 'AtomUsage of unknown atom is 65535'); 19*b39c5158Smillertok(!defined eval {AtomUsage(100000, $tbl); 1}, 'AtomUsage of invalid atom croaks'); 20*b39c5158Smillert# diag($@); 21*b39c5158Smillert 22*b39c5158Smillertis(AtomName(134, $tbl), '#134', 'AtomName of unknown atom is #number'); 23*b39c5158Smillertis(AtomName(2, $tbl), '#2', 'AtomName of unknown atom is #number'); 24*b39c5158Smillertok(!defined eval {AtomName(100000, $tbl); 1}, 'AtomName of invalid atom croaks'); 25*b39c5158Smillert# diag($@); 26*b39c5158Smillert 27*b39c5158Smillertis(FindAtom('#134', $tbl), 134, 'Name of unknown atom per #number'); 28*b39c5158Smillertis(FindAtom('#2', $tbl), 2, 'Name of unknown atom per #number'); 29*b39c5158Smillertok(!defined eval {FindAtom('#90000', $tbl); 1}, 'Finding invalid numeric atom croaks'); 30*b39c5158Smillert# diag($@); 31*b39c5158Smillertok(!defined eval {FindAtom('2#', $tbl); 1}, 'Finding invalid atom croaks'); 32*b39c5158Smillert# diag($@); 33*b39c5158Smillertok(!defined eval {FindAtom('texxt/unnknnown', $tbl); 1}, 'Finding invalid atom croaks'); 34*b39c5158Smillert# diag($@); 35*b39c5158Smillert 36*b39c5158Smillertis(DeleteAtom(125000, $tbl), '', 'Deleting invalid atom returns FALSE'); 37*b39c5158Smillertis(DeleteAtom(10000, $tbl), 1, 'Deleting unknown atom returns 1'); 38*b39c5158Smillertok(!defined eval {DeleteAtom(0, $tbl); 1}, 'Deleting zero atom croaks'); 39*b39c5158Smillert# diag($@); 40*b39c5158Smillert 41*b39c5158Smillertis(AddAtom('#134', $tbl), 134, 'Add unknown atom per #number'); 42*b39c5158Smillertis(AddAtom('#2', $tbl), 2, 'Add unknown atom per #number'); 43*b39c5158Smillertok(!defined eval {AddAtom('#80000', $tbl); 1}, 'Add invalid numeric atom croaks'); 44*b39c5158Smillert# diag($@); 45*b39c5158Smillert 46*b39c5158Smillertmy $a1 = AddAtom("perltest//pp$$", $tbl); 47*b39c5158Smillertok($a1, 'Add unknown atom per string'); 48*b39c5158Smillertmy $a2 = AddAtom("perltest//p$$", $tbl); 49*b39c5158Smillertok($a2, 'Add another unknown atom per string'); 50*b39c5158Smillertis(AddAtom("perltest//p$$", $tbl), $a2, 'Add same unknown atom per string'); 51*b39c5158Smillertisnt($a1, $a2, 'Different strings result in different atoms'); 52*b39c5158Smillertok($a1 > 0, 'Atom positive'); 53*b39c5158Smillertok($a2 > 0, 'Another atom positive'); 54*b39c5158Smillertok($a1 < 0x10000, 'Atom small'); 55*b39c5158Smillertok($a2 < 0x10000, 'Another atom small'); 56*b39c5158Smillert 57*b39c5158Smillertis(AtomLength($a1, $tbl), length "perltest//pp$$", 'AtomLength of known atom'); 58*b39c5158Smillertis(AtomLength($a2, $tbl), length "perltest//p$$", 'AtomLength of another known atom'); 59*b39c5158Smillert 60*b39c5158Smillertis(AtomUsage($a1, $tbl), 1, 'AtomUsage of known atom'); 61*b39c5158Smillertis(AtomUsage($a2, $tbl), 2, 'AtomUsage of another known atom'); 62*b39c5158Smillert 63*b39c5158Smillertis(AtomName($a1, $tbl), "perltest//pp$$", 'AtomName of known atom'); 64*b39c5158Smillertis(AtomName($a2, $tbl), "perltest//p$$", 'AtomName of another known atom'); 65*b39c5158Smillert 66*b39c5158Smillertis(FindAtom("perltest//pp$$", $tbl), $a1, 'Name of known atom'); 67*b39c5158Smillertis(FindAtom("perltest//p$$", $tbl), $a2, 'Name of known atom'); 68*b39c5158Smillert 69*b39c5158Smillert#$^E = 0; 70*b39c5158Smillertok(DeleteAtom($a1, $tbl), 'DeleteAtom of known atom'); 71*b39c5158Smillert#diag("err=$^E"); 72*b39c5158Smillert#$^E = 0; 73*b39c5158Smillertok(DeleteAtom($a2, $tbl), 'DeleteAtom of another known atom'); 74*b39c5158Smillert#diag("err=$^E"); 75*b39c5158Smillert 76*b39c5158Smillertok(!defined eval {AtomUsage($a1, $tbl); 1}, 'AtomUsage of deleted known atom croaks'); 77*b39c5158Smillert# diag($@); 78*b39c5158Smillertis(AtomUsage($a2, $tbl), 1, 'AtomUsage of another known atom'); 79*b39c5158Smillert 80*b39c5158Smillertok(!defined eval {AtomName($a1, $tbl); 1}, 'AtomName of deleted known atom croaks'); 81*b39c5158Smillert# diag($@); 82*b39c5158Smillertis(AtomName($a2, $tbl), "perltest//p$$", 'AtomName of undeleted another known atom'); 83*b39c5158Smillert 84*b39c5158Smillertok(!defined eval {FindAtom("perltest//pp$$", $tbl); 1}, 'Finding known deleted atom croaks'); 85*b39c5158Smillert# diag($@); 86*b39c5158Smillertis(FindAtom("perltest//p$$", $tbl), $a2, 'Finding known undeleted atom'); 87*b39c5158Smillert 88*b39c5158Smillertok(DestroyAtomTable($tbl), 'DestroyAtomTable succeeds'); 89