Create post-HADVAs expect files
[hiphop-php.git] / hphp / test / zend / good / ext / standard / tests / file / basename_variation3.php
blob2d1d73c8caa75ca9c5e18ccd1ed8521c8e823046
1 <?hh
2 /* Prototype : string basename(string path [, string suffix])
3 * Description: Returns the filename component of the path
4 * Source code: ext/standard/string.c
5 * Alias to functions:
6 */
8 // define some classes
9 class classWithToString
11 public function __toString() {
12 return "Class A object";
16 class classWithoutToString
20 // Define error handler
21 function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
22 if (error_reporting() != 0) {
23 // report non-silenced errors
24 echo "Error: $err_no - $err_msg, $filename($linenum)\n";
27 <<__EntryPoint>> function main(): void {
28 echo "*** Testing basename() : usage variation ***\n";
29 set_error_handler(test_error_handler<>);
32 // heredoc string
33 $heredoc = <<<EOT
34 hello world
35 EOT;
37 // add arrays
38 $index_array = varray [1, 2, 3];
39 $assoc_array = darray ['one' => 1, 'two' => 2];
41 //array of values to iterate over
42 $inputs = darray[
44 // int data
45 'int 0' => 0,
46 'int 1' => 1,
47 'int 12345' => 12345,
48 'int -12345' => -2345,
50 // float data
51 'float 10.5' => 10.5,
52 'float -10.5' => -10.5,
53 'float 12.3456789000e10' => 12.3456789000e10,
54 'float -12.3456789000e10' => -12.3456789000e10,
55 'float .5' => .5,
57 // array data
58 'empty array' => varray[],
59 'int indexed array' => $index_array,
60 'associative array' => $assoc_array,
61 'nested arrays' => varray['foo', $index_array, $assoc_array],
63 // null data
64 'uppercase NULL' => NULL,
65 'lowercase null' => null,
67 // boolean data
68 'lowercase true' => true,
69 'lowercase false' =>false,
70 'uppercase TRUE' =>TRUE,
71 'uppercase FALSE' =>FALSE,
73 // empty data
74 'empty string DQ' => "",
75 'empty string SQ' => '',
77 // object data
78 'instance of classWithToString' => new classWithToString(),
79 'instance of classWithoutToString' => new classWithoutToString(),
84 // loop through each element of the array for path
86 foreach($inputs as $key =>$value) {
87 echo "\n--$key--\n";
88 try { var_dump( basename($value) ); } catch (Exception $e) { echo "\n".'Warning: '.$e->getMessage().' in '.__FILE__.' on line '.__LINE__."\n"; }
91 echo "===DONE===\n";