Commit | Line | Data |
8d063cd8 |
1 | #!./perl |
2 | |
c512ce4f |
3 | print "1..14\n"; |
8d063cd8 |
4 | |
5 | @x = (1, 2, 3); |
6 | if (join(':',@x) eq '1:2:3') {print "ok 1\n";} else {print "not ok 1\n";} |
7 | |
8 | if (join('',1,2,3) eq '123') {print "ok 2\n";} else {print "not ok 2\n";} |
9 | |
10 | if (join(':',split(/ /,"1 2 3")) eq '1:2:3') {print "ok 3\n";} else {print "not ok 3\n";} |
c212fd85 |
11 | |
12 | my $f = 'a'; |
13 | $f = join ',', 'b', $f, 'e'; |
14 | if ($f eq 'b,a,e') {print "ok 4\n";} else {print "# '$f'\nnot ok 4\n";} |
15 | |
16 | $f = 'a'; |
17 | $f = join ',', $f, 'b', 'e'; |
18 | if ($f eq 'a,b,e') {print "ok 5\n";} else {print "not ok 5\n";} |
19 | |
20 | $f = 'a'; |
21 | $f = join $f, 'b', 'e', 'k'; |
22 | if ($f eq 'baeak') {print "ok 6\n";} else {print "# '$f'\nnot ok 6\n";} |
1426bbf4 |
23 | |
24 | # 7,8 check for multiple read of tied objects |
25 | { package X; |
26 | sub TIESCALAR { my $x = 7; bless \$x }; |
27 | sub FETCH { my $y = shift; $$y += 5 }; |
28 | tie my $t, 'X'; |
29 | my $r = join ':', $t, 99, $t, 99; |
30 | print "# expected '12:99:17:99' got '$r'\nnot " if $r ne '12:99:17:99'; |
31 | print "ok 7\n"; |
32 | $r = join '', $t, 99, $t, 99; |
33 | print "# expected '22992799' got '$r'\nnot " if $r ne '22992799'; |
34 | print "ok 8\n"; |
35 | }; |
36 | |
37 | # 9,10 and for multiple read of undef |
38 | { my $s = 5; |
39 | local ($^W, $SIG{__WARN__}) = ( 1, sub { $s+=4 } ); |
40 | my $r = join ':', 'a', undef, $s, 'b', undef, $s, 'c'; |
41 | print "# expected 'a::9:b::13:c' got '$r'\nnot " if $r ne 'a::9:b::13:c'; |
42 | print "ok 9\n"; |
43 | my $r = join '', 'a', undef, $s, 'b', undef, $s, 'c'; |
44 | print "# expected 'a17b21c' got '$r'\nnot " if $r ne 'a17b21c'; |
45 | print "ok 10\n"; |
46 | }; |
c512ce4f |
47 | |
48 | { my $s = join("", chr(1234),chr(255)); |
7df053ec |
49 | print "not " unless length($s) == 2 && |
50 | ord(substr($s,0,1)) == 1234 && |
51 | ord(substr($s,1,1)) == 255; |
c512ce4f |
52 | print "ok 11\n"; |
53 | } |
54 | |
55 | { my $s = join(chr(2345), chr(1234),chr(255)); |
7df053ec |
56 | print "not " unless length($s) == 3 && |
57 | ord(substr($s,0,1)) == 1234 && |
58 | ord(substr($s,1,1)) == 2345 && |
59 | ord(substr($s,2,1)) == 255; |
c512ce4f |
60 | print "ok 12\n"; |
61 | } |
62 | |
63 | { my $s = join(chr(2345), chr(1234),chr(3456)); |
7df053ec |
64 | print "not " unless length($s) == 3 && |
65 | ord(substr($s,0,1)) == 1234 && |
66 | ord(substr($s,1,1)) == 2345 && |
67 | ord(substr($s,2,1)) == 3456; |
c512ce4f |
68 | print "ok 13\n"; |
69 | } |
70 | |
71 | { my $s = join(chr(255), chr(1234),chr(2345)); |
7df053ec |
72 | print "not " unless length($s) == 3 && |
73 | ord(substr($s,0,1)) == 1234 && |
74 | ord(substr($s,1,1)) == 255 && |
75 | ord(substr($s,2,1)) == 2345; |
c512ce4f |
76 | print "ok 14\n"; |
77 | } |