Cross Reference: splice.t
xref
: /
osnet-11
/
usr
/
src
/
cmd
/
perl
/
5.8.4
/
distrib
/
t
/
op
/
splice.t
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
1
N/A
#!./perl
1
N/A
1
N/A
print
"1..12\n"
;
1
N/A
1
N/A
@a =
(
1
..
10
)
;
1
N/A
1
N/A
sub
j
{
join
(
":"
,@_)
}
1
N/A
1
N/A
print
"not "
unless
j
(
splice
(@a,@a,
0
,
11
,
12
)
)
eq
""
&& j
(@a)
eq
j
(
1
..
12
)
;
1
N/A
print
"ok 1\n"
;
1
N/A
1
N/A
print
"not "
unless
j
(
splice
(@a,-
1
)
)
eq
"12"
&& j
(@a)
eq
j
(
1
..
11
)
;
1
N/A
print
"ok 2\n"
;
1
N/A
1
N/A
print
"not "
unless
j
(
splice
(@a,
0
,
1
)
)
eq
"1"
&& j
(@a)
eq
j
(
2
..
11
)
;
1
N/A
print
"ok 3\n"
;
1
N/A
1
N/A
print
"not "
unless
j
(
splice
(@a,
0
,
0
,
0
,
1
)
)
eq
""
&& j
(@a)
eq
j
(
0
..
11
)
;
1
N/A
print
"ok 4\n"
;
1
N/A
1
N/A
print
"not "
unless
j
(
splice
(@a,
5
,
1
,
5
)
)
eq
"5"
&& j
(@a)
eq
j
(
0
..
11
)
;
1
N/A
print
"ok 5\n"
;
1
N/A
1
N/A
print
"not "
unless
j
(
splice
(@a, @a,
0
,
12
,
13
)
)
eq
""
&& j
(@a)
eq
j
(
0
..
13
)
;
1
N/A
print
"ok 6\n"
;
1
N/A
1
N/A
print
"not "
unless
j
(
splice
(@a, -@a, @a,
1
,
2
,
3
)
)
eq
j
(
0
..
13
)
&& j
(@a)
eq
j
(
1
..
3
)
;
1
N/A
print
"ok 7\n"
;
1
N/A
1
N/A
print
"not "
unless
j
(
splice
(@a,
1
, -
1
,
7
,
7
)
)
eq
"2"
&& j
(@a)
eq
j
(
1
,
7
,
7
,
3
)
;
1
N/A
print
"ok 8\n"
;
1
N/A
1
N/A
print
"not "
unless
j
(
splice
(@a,-
3
,-
2
,
2
)
)
eq
j
(
7
)
&& j
(@a)
eq
j
(
1
,
2
,
7
,
3
)
;
1
N/A
print
"ok 9\n"
;
1
N/A
1
N/A
# Bug 20000223.001 - no test for splice(@array). Destructive test!
1
N/A
print
"not "
unless
j
(
splice
(@a)
)
eq
j
(
1
,
2
,
7
,
3
)
&& j
(@a)
eq
''
;
1
N/A
print
"ok 10\n"
;
1
N/A
1
N/A
# Tests 11 and 12:
1
N/A
# [ID 20010711.005] in Tie::Array, SPLICE ignores context, breaking SHIFT
1
N/A
1
N/A
my
$foo
;
1
N/A
1
N/A
@a =
(
'red'
,
'green'
,
'blue'
)
;
1
N/A
$foo
=
splice
@a,
1
,
2
;
1
N/A
print
"not "
unless
$foo
eq
'blue'
;
1
N/A
print
"ok 11\n"
;
1
N/A
1
N/A
@a =
(
'red'
,
'green'
,
'blue'
)
;
1
N/A
$foo
=
shift
@a;
1
N/A
print
"not "
unless
$foo
eq
'red'
;
1
N/A
print
"ok 12\n"
;
1
N/A