xref: /openbsd-src/gnu/usr.bin/perl/os2/OS2/OS2-ExtAttr/t/os2_ea.t (revision b39c515898423c8d899e35282f4b395f7cad3298)
1*b39c5158SmillertBEGIN {
2*b39c5158Smillert    chdir 't' if -d 't/lib';
3*b39c5158Smillert    @INC = '../lib' if -d 'lib';
4*b39c5158Smillert    require Config; import Config;
5*b39c5158Smillert    if (-d 'lib' and $Config{'extensions'} !~ /\bOS2(::|\/)REXX\b/) {
6*b39c5158Smillert	print "1..0\n";
7*b39c5158Smillert	exit 0;
8*b39c5158Smillert    }
9*b39c5158Smillert}
10*b39c5158Smillert
11*b39c5158Smillert# Before `make install' is performed this script should be runnable with
12*b39c5158Smillert# `make test'. After `make install' it should work as `perl test.pl'
13*b39c5158Smillert
14*b39c5158Smillert######################### We start with some black magic to print on failure.
15*b39c5158Smillert
16*b39c5158Smillert# Change 1..1 below to 1..last_test_to_print .
17*b39c5158Smillert# (It may become useful if the test is moved to ./t subdirectory.)
18*b39c5158Smillert
19*b39c5158SmillertBEGIN { $| = 1; print "1..21\n"; }
20*b39c5158SmillertEND {print "not ok 1\n" unless $loaded;}
21*b39c5158Smillertuse OS2::ExtAttr;
22*b39c5158Smillert$loaded = 1;
23*b39c5158Smillertprint "ok 1\n";
24*b39c5158Smillert
25*b39c5158Smillert######################### End of black magic.
26*b39c5158Smillert
27*b39c5158Smillert# Insert your test code below (better if it prints "ok 13"
28*b39c5158Smillert# (correspondingly "not ok 13") depending on the success of chunk 13
29*b39c5158Smillert# of the test code):
30*b39c5158Smillert
31*b39c5158Smillertunlink 't.out' if -f 't.out';
32*b39c5158Smillertsystem 'cmd', '/c', 'echo OK > t.out';
33*b39c5158Smillert
34*b39c5158Smillert{
35*b39c5158Smillert  my %a;
36*b39c5158Smillert  tie %a, 'OS2::ExtAttr', 't.out';
37*b39c5158Smillert  print "ok 2\n";
38*b39c5158Smillert
39*b39c5158Smillert  keys %a == 0 ? print "ok 3\n" : print "not ok 3\n";
40*b39c5158Smillert# Standard Extended Attributes (SEAs) have a dot (.) as a prefix.
41*b39c5158Smillert# This identifies the extended attribute as a SEA. The leading dot is reserved,
42*b39c5158Smillert# so applications should not define extended attributes that start with a dot.
43*b39c5158Smillert# Also, extended attributes
44*b39c5158Smillert# that start with the characters $, @, &, or + are reserved for system use.
45*b39c5158Smillert  $a{'X--Y'} = '---';		# '++', -++', '!++', 'X++Y' fail on JFS
46*b39c5158Smillert  print "ok 4\n";
47*b39c5158Smillert  $a{'AAA'} = 'xyz';		# Name is going to be uppercased???
48*b39c5158Smillert  print "ok 5\n";
49*b39c5158Smillert}
50*b39c5158Smillert
51*b39c5158Smillert{
52*b39c5158Smillert  my %a;
53*b39c5158Smillert  tie %a, 'OS2::ExtAttr', 't.out';
54*b39c5158Smillert  print "ok 6\n";
55*b39c5158Smillert
56*b39c5158Smillert  my $c = keys %a;
57*b39c5158Smillert  $c == 2 ? print "ok 7\n" : print "not ok 7\n# c=$c\n";
58*b39c5158Smillert  my @b = sort keys %a;
59*b39c5158Smillert  "@b" eq 'AAA X--Y' ? print "ok 8\n" : print "not ok 8\n# keys=`@b'\n";
60*b39c5158Smillert  $a{'X--Y'} eq '---' ? print "ok 9\n" : print "not ok 9\n";;
61*b39c5158Smillert  $a{'AAA'} eq 'xyz' ? print "ok 10\n" : print "not ok 10\n# aaa->`$a{AAA}'\n";
62*b39c5158Smillert  $c = delete $a{'X--Y'};
63*b39c5158Smillert  $c eq '---' ? print "ok 11\n" : print "not ok 11\n# deleted->`$c'\n";;
64*b39c5158Smillert}
65*b39c5158Smillert
66*b39c5158Smillertprint "ok 12\n";
67*b39c5158Smillert
68*b39c5158Smillert{
69*b39c5158Smillert  my %a;
70*b39c5158Smillert  tie %a, 'OS2::ExtAttr', 't.out';
71*b39c5158Smillert  print "ok 13\n";
72*b39c5158Smillert
73*b39c5158Smillert  keys %a == 1 ? print "ok 14\n" : print "not ok 14\n";
74*b39c5158Smillert  my @b = sort keys %a;
75*b39c5158Smillert  "@b" eq 'AAA' ? print "ok 15\n" : print "not ok 15\n";
76*b39c5158Smillert  $a{'AAA'} eq 'xyz' ? print "ok 16\n" : print "not ok 16\n";;
77*b39c5158Smillert  ! exists $a{'+'} ? print "ok 17\n" : print "not ok 17\n";;
78*b39c5158Smillert  ! defined $a{'+'} ? print "ok 18\n" : print "not ok 18\n# ->`$a{'X--Y'}'\n";;
79*b39c5158Smillert  ! exists $a{'X--Y'} ? print "ok 19\n" : print "not ok 19\n";;
80*b39c5158Smillert  ! defined $a{'X--Y'} ? print "ok 20\n" : print "not ok 20\n# ->`$a{'X--Y'}'\n";;
81*b39c5158Smillert}
82*b39c5158Smillert
83*b39c5158Smillertprint "ok 21\n";
84*b39c5158Smillertunlink 't.out';
85*b39c5158Smillert
86