Fixed the array-tests. Broke the test up into various smaller tests.

Reduced the test data because it was unmanageable.
# I hope everything is ok :)
This commit is contained in:
Sander Roobol 2002-03-26 18:17:38 +00:00
parent b5f477ba00
commit 9b6a8d2639
6 changed files with 798 additions and 15510 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,570 @@
--TEST--
Test arsort, asort, krsort, ksort, rsort, and sort
--POST--
--GET--
--FILE--
<?php
require('ext/standard/tests/array/data.inc');
function test_sort ($sort_function, $data) {
echo "\n -- Testing $sort_function() -- \n";
echo "No second argument:\n";
$sort_function ($data);
var_dump ($data);
echo "Using SORT_REGULAR:\n";
$sort_function ($data, SORT_REGULAR);
var_dump ($data);
echo "Using SORT_NUMERIC:\n";
$sort_function ($data, SORT_NUMERIC);
var_dump ($data);
echo "Using SORT_STRING\n";
$sort_function ($data, SORT_STRING);
var_dump ($data);
}
foreach (array ('arsort', 'asort', 'krsort', 'ksort', 'rsort', 'sort') as $test_function) {
test_sort ($test_function, $data);
}
?>
--EXPECT--
-- Testing arsort() --
No second argument:
array(7) {
["-2147483648"]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
["test"]=>
int(27)
[2147483647]=>
string(4) "test"
[5]=>
string(4) "Test"
[17]=>
string(27) "PHP: Hypertext Preprocessor"
[0]=>
string(3) "PHP"
[-2147483648]=>
float(-0.33333333333333)
}
Using SORT_REGULAR:
array(7) {
["-2147483648"]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
["test"]=>
int(27)
[2147483647]=>
string(4) "test"
[5]=>
string(4) "Test"
[17]=>
string(27) "PHP: Hypertext Preprocessor"
[0]=>
string(3) "PHP"
[-2147483648]=>
float(-0.33333333333333)
}
Using SORT_NUMERIC:
array(7) {
["test"]=>
int(27)
["-2147483648"]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
[0]=>
string(3) "PHP"
[17]=>
string(27) "PHP: Hypertext Preprocessor"
[5]=>
string(4) "Test"
[2147483647]=>
string(4) "test"
[-2147483648]=>
float(-0.33333333333333)
}
Using SORT_STRING
array(7) {
[2147483647]=>
string(4) "test"
[5]=>
string(4) "Test"
[17]=>
string(27) "PHP: Hypertext Preprocessor"
[0]=>
string(3) "PHP"
["-2147483648"]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
["test"]=>
int(27)
[-2147483648]=>
float(-0.33333333333333)
}
-- Testing asort() --
No second argument:
array(7) {
[-2147483648]=>
float(-0.33333333333333)
[0]=>
string(3) "PHP"
[17]=>
string(27) "PHP: Hypertext Preprocessor"
[5]=>
string(4) "Test"
[2147483647]=>
string(4) "test"
["test"]=>
int(27)
["-2147483648"]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
}
Using SORT_REGULAR:
array(7) {
[-2147483648]=>
float(-0.33333333333333)
[0]=>
string(3) "PHP"
[17]=>
string(27) "PHP: Hypertext Preprocessor"
[5]=>
string(4) "Test"
[2147483647]=>
string(4) "test"
["test"]=>
int(27)
["-2147483648"]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
}
Using SORT_NUMERIC:
array(7) {
[-2147483648]=>
float(-0.33333333333333)
[2147483647]=>
string(4) "test"
[5]=>
string(4) "Test"
[17]=>
string(27) "PHP: Hypertext Preprocessor"
[0]=>
string(3) "PHP"
["-2147483648"]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
["test"]=>
int(27)
}
Using SORT_STRING
array(7) {
[-2147483648]=>
float(-0.33333333333333)
["test"]=>
int(27)
["-2147483648"]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
[0]=>
string(3) "PHP"
[17]=>
string(27) "PHP: Hypertext Preprocessor"
[5]=>
string(4) "Test"
[2147483647]=>
string(4) "test"
}
-- Testing krsort() --
No second argument:
array(7) {
[2147483647]=>
string(4) "test"
[17]=>
string(27) "PHP: Hypertext Preprocessor"
[5]=>
string(4) "Test"
["test"]=>
int(27)
[0]=>
string(3) "PHP"
[-2147483648]=>
float(-0.33333333333333)
["-2147483648"]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
}
Using SORT_REGULAR:
array(7) {
[2147483647]=>
string(4) "test"
[17]=>
string(27) "PHP: Hypertext Preprocessor"
[5]=>
string(4) "Test"
[0]=>
string(3) "PHP"
["test"]=>
int(27)
["-2147483648"]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
[-2147483648]=>
float(-0.33333333333333)
}
Using SORT_NUMERIC:
array(7) {
[2147483647]=>
string(4) "test"
[17]=>
string(27) "PHP: Hypertext Preprocessor"
[5]=>
string(4) "Test"
["test"]=>
int(27)
[0]=>
string(3) "PHP"
[-2147483648]=>
float(-0.33333333333333)
["-2147483648"]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
}
Using SORT_STRING
array(7) {
["test"]=>
int(27)
[5]=>
string(4) "Test"
[2147483647]=>
string(4) "test"
[17]=>
string(27) "PHP: Hypertext Preprocessor"
[0]=>
string(3) "PHP"
["-2147483648"]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
[-2147483648]=>
float(-0.33333333333333)
}
-- Testing ksort() --
No second argument:
array(7) {
["-2147483648"]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
[-2147483648]=>
float(-0.33333333333333)
[0]=>
string(3) "PHP"
["test"]=>
int(27)
[5]=>
string(4) "Test"
[17]=>
string(27) "PHP: Hypertext Preprocessor"
[2147483647]=>
string(4) "test"
}
Using SORT_REGULAR:
array(7) {
[-2147483648]=>
float(-0.33333333333333)
["-2147483648"]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
["test"]=>
int(27)
[0]=>
string(3) "PHP"
[5]=>
string(4) "Test"
[17]=>
string(27) "PHP: Hypertext Preprocessor"
[2147483647]=>
string(4) "test"
}
Using SORT_NUMERIC:
array(7) {
["-2147483648"]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
[-2147483648]=>
float(-0.33333333333333)
[0]=>
string(3) "PHP"
["test"]=>
int(27)
[5]=>
string(4) "Test"
[17]=>
string(27) "PHP: Hypertext Preprocessor"
[2147483647]=>
string(4) "test"
}
Using SORT_STRING
array(7) {
[-2147483648]=>
float(-0.33333333333333)
["-2147483648"]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
[0]=>
string(3) "PHP"
[17]=>
string(27) "PHP: Hypertext Preprocessor"
[2147483647]=>
string(4) "test"
[5]=>
string(4) "Test"
["test"]=>
int(27)
}
-- Testing rsort() --
No second argument:
array(7) {
[0]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
[1]=>
int(27)
[2]=>
string(4) "test"
[3]=>
string(4) "Test"
[4]=>
string(27) "PHP: Hypertext Preprocessor"
[5]=>
string(3) "PHP"
[6]=>
float(-0.33333333333333)
}
Using SORT_REGULAR:
array(7) {
[0]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
[1]=>
int(27)
[2]=>
string(4) "test"
[3]=>
string(4) "Test"
[4]=>
string(27) "PHP: Hypertext Preprocessor"
[5]=>
string(3) "PHP"
[6]=>
float(-0.33333333333333)
}
Using SORT_NUMERIC:
array(7) {
[0]=>
int(27)
[1]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
[2]=>
string(3) "PHP"
[3]=>
string(27) "PHP: Hypertext Preprocessor"
[4]=>
string(4) "Test"
[5]=>
string(4) "test"
[6]=>
float(-0.33333333333333)
}
Using SORT_STRING
array(7) {
[0]=>
string(4) "test"
[1]=>
string(4) "Test"
[2]=>
string(27) "PHP: Hypertext Preprocessor"
[3]=>
string(3) "PHP"
[4]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
[5]=>
int(27)
[6]=>
float(-0.33333333333333)
}
-- Testing sort() --
No second argument:
array(7) {
[0]=>
float(-0.33333333333333)
[1]=>
string(3) "PHP"
[2]=>
string(27) "PHP: Hypertext Preprocessor"
[3]=>
string(4) "Test"
[4]=>
string(4) "test"
[5]=>
int(27)
[6]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
}
Using SORT_REGULAR:
array(7) {
[0]=>
float(-0.33333333333333)
[1]=>
string(3) "PHP"
[2]=>
string(27) "PHP: Hypertext Preprocessor"
[3]=>
string(4) "Test"
[4]=>
string(4) "test"
[5]=>
int(27)
[6]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
}
Using SORT_NUMERIC:
array(7) {
[0]=>
float(-0.33333333333333)
[1]=>
string(4) "test"
[2]=>
string(4) "Test"
[3]=>
string(27) "PHP: Hypertext Preprocessor"
[4]=>
string(3) "PHP"
[5]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
[6]=>
int(27)
}
Using SORT_STRING
array(7) {
[0]=>
float(-0.33333333333333)
[1]=>
int(27)
[2]=>
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(6) "orange"
}
[3]=>
string(3) "PHP"
[4]=>
string(27) "PHP: Hypertext Preprocessor"
[5]=>
string(4) "Test"
[6]=>
string(4) "test"
}

View File

@ -0,0 +1,98 @@
--TEST--
Test usort, uksort and uasort
--POST--
--GET--
--FILE--
<?php
require('ext/standard/tests/array/data.inc');
function cmp ($a, $b) {
is_array ($a)
and $a = array_sum ($a);
is_array ($b)
and $b = array_sum ($b);
return strcmp ($a, $b);
}
echo " -- Testing uasort() -- \n";
uasort ($data, 'cmp');
var_dump ($data);
echo "\n -- Testing uksort() -- \n";
uksort ($data, 'cmp');
var_dump ($data);
echo "\n -- Testing usort() -- \n";
usort ($data, 'cmp');
var_dump ($data);
?>
--EXPECT--
-- Testing uasort() --
array(7) {
[-2147483648]=>
float(-0.33333333333333)
["-2147483648"]=>
array(2) {
[0]=>
int(0)
[1]=>
int(0)
}
["test"]=>
int(27)
[0]=>
string(3) "PHP"
[17]=>
string(27) "PHP: Hypertext Preprocessor"
[5]=>
string(4) "Test"
[2147483647]=>
string(4) "test"
}
-- Testing uksort() --
array(7) {
["-2147483648"]=>
array(2) {
[0]=>
int(0)
[1]=>
int(0)
}
[-2147483648]=>
float(-0.33333333333333)
[0]=>
string(3) "PHP"
[17]=>
string(27) "PHP: Hypertext Preprocessor"
[2147483647]=>
string(4) "test"
[5]=>
string(4) "Test"
["test"]=>
int(27)
}
-- Testing usort() --
array(7) {
[0]=>
float(-0.33333333333333)
[1]=>
array(2) {
[0]=>
int(0)
[1]=>
int(0)
}
[2]=>
int(27)
[3]=>
string(3) "PHP"
[4]=>
string(27) "PHP: Hypertext Preprocessor"
[5]=>
string(4) "Test"
[6]=>
string(4) "test"
}

View File

@ -0,0 +1,59 @@
--TEST--
Test natsort and natcasesort
--POST--
--GET--
--FILE--
<?php
$data = array(
'Test1',
'teST2'=>0,
5=>'test2',
'abc'=>'test10',
'test21'
);
var_dump($data);
natsort($data);
var_dump($data);
natcasesort($data);
var_dump($data);
?>
--EXPECT--
array(5) {
[0]=>
string(5) "Test1"
["teST2"]=>
int(0)
[5]=>
string(5) "test2"
["abc"]=>
string(6) "test10"
[6]=>
string(6) "test21"
}
array(5) {
["teST2"]=>
int(0)
[0]=>
string(5) "Test1"
[5]=>
string(5) "test2"
["abc"]=>
string(6) "test10"
[6]=>
string(6) "test21"
}
array(5) {
["teST2"]=>
int(0)
[0]=>
string(5) "Test1"
[5]=>
string(5) "test2"
["abc"]=>
string(6) "test10"
[6]=>
string(6) "test21"
}

View File

@ -1,195 +0,0 @@
Adam Dickmeiss
Alex Barkov
Alex Belits
Alex Plotnick
Alexander Aulbach
Alexander Feldman
Amitay Isaacs
Andi Gutmans
Andre Langhorst
Andreas Karajannis
Andrei Zmievski
Andrew Avdeev
Andrew Skalski
Andy Sautins
Antoni Pamies Olive
AOLserver
Apache 1.3
Apache 2.0
aspell
Assert
Authors
BC Math
Boian Bonev
Brendan W. McAdams
Brian Wang
bz2
Caudium / Roxen
ccvs
CGI
Chad Robinson
Chris Vandomelen
Christian Cartus
Chuck Hagenbuch
Colin Viebrock
Concept
Contribution
cpdf
crack
ctype
CURL
CyberCash
Daniel Beulshausen
Daniel R Kalowsky
Danny Heijl
Dave Hayden
David Benson
David Croft
David Eriksson
David Hedbor
David Hénot
David Sklar
DBA
dBase
DBM
Derick Rethans
domxml
dotnet
Doug DeJulio
Edited by: Stig Bakken and Egon Schmid
Egon Schmid
Eric Warnke
Evan Klinger
EXIF
Extension Module API
FBSQL
FDF
fhttpd
FilePro
Frank M. Kromann
Fredrik Ohrn
FTP
GD imaging
Gerrit Thomson
GetText
Harald Radi
Hartmut Holzgraefe
Hellekin O. Wolf
Hojtsy Gabor
Holger Zimmermann
HyperWave
icap
iisfunc
Ilia Alshanetsky
IMAP
Informix
Ingres II
InterBase
IRCG
ISAPI
Jalal Pushman
James Moore
Jan Borsodi
Jani Taskinen
Jason Greene
Java
Java Servlet
Jayakumar Muthukumarasamy
Jim Winstead
Joey Smith
John Donagher
Jouni Ahto
Kaj-Michael Lang
Kristian Köhntopp
Language Design
Lars Torben Wilson
LDAP
Mailparse MIME parsing and manipulation functions
Mark Musone
MCAL
mcrypt
mhash
MING
Mitch Golden
mnoGoSearch
Module
Module Authors
MS SQL
mSQL
Multibyte (Japanese) String Functions
MySQL
Nikos Mavroyanopoulos
NSAPI
OCI8
ODBC
Olivier Cahagne
OpenSSL
Oracle
Ovrimos
pcntl
PDF
Perl Compatible Regexps
Phil Driscoll
PHP 4.0 Authors
PHP Documentation Team
PHP Group
PHP Quality Assurance Team
PHP Website Team
phttpd
pi3web
Posix
PostgreSQL
PRINTER
Pspell
qtdom
Ramil Kalimullin
Rasmus Lerdorf
Readline
Recode
Rex Logan
Sablotron XSLT
Sam Ruby
SAPI Modules
Sascha Kettler
Sascha Schumann
Satellite (CORBA)
Sebastian Bergmann
Sergey Kartashoff
Server API (SAPI) Abstraction Layer
Sessions
Shane Caraveo
Shared Memory Operations
Slava Poliakov
SNMP
Sockets
Stefan Roehrich
Stephanie Wehner
Sterling Hughes
Stig Bakken
Stig Venaas
SWF
Sybase-CT
Sybase-DB
System V Semaphores
System V Shared Memory
Thies C. Arntzen
thttpd
Tom May
Tsukada Takuya
UNIX Build and Modularization
Uwe Steinmann
Verisign Payflow Pro
Vlad Krupin
Vpopmail
WDDX
Wez Furlong
Win32 COM
Win32 Port
XML
YAZ
Yellow Pages
Zak Greant
Zeev Suraski
Zend Scripting Language Engine
Zip
Zlib

View File

@ -0,0 +1,13 @@
<?php
$tmp = pow(2,64);
$data = array(
'PHP',
17=>'PHP: Hypertext Preprocessor',
5=>'Test',
'test'=>27,
2147483647=>'test',
"-2147483648"=>array('banana', 'orange'),
'monkey',
$tmp=>-1/3
);
?>