php-src/Zend/tests/ns_057.phpt

63 lines
1002 B
Plaintext
Raw Normal View History

--TEST--
2008-12-05 04:12:30 +08:00
057: Usage of 'namespace' in compound names (inside namespace)
--FILE--
<?php
2008-12-05 04:12:30 +08:00
namespace Test\ns1;
const C = "const ok\n";
function foo() {
return "func ok\n";
}
class foo {
const C = "const ok\n";
2008-12-05 04:12:30 +08:00
const C2 = namespace\C;
static $var = "var ok\n";
function __construct() {
echo "class ok\n";
}
static function bar() {
return "method ok\n";
}
}
2008-12-05 04:12:30 +08:00
function f1($x=namespace\C) {
return $x;
}
2008-12-05 04:12:30 +08:00
function f2($x=namespace\foo::C) {
return $x;
}
2008-12-05 04:12:30 +08:00
function f3(namespace\foo $x) {
return "ok\n";
}
2008-12-05 04:12:30 +08:00
echo namespace\C;
echo namespace\foo();
echo namespace\foo::C;
echo namespace\foo::C2;
echo namespace\foo::$var;
echo namespace\foo::bar();
echo namespace\f1();
echo namespace\f2();
echo namespace\f3(new namespace\foo());
echo namespace\unknown;
?>
2008-12-05 04:12:30 +08:00
--EXPECTF--
const ok
func ok
const ok
const ok
var ok
method ok
const ok
const ok
class ok
ok
2008-12-05 04:12:30 +08:00
Fatal error: Uncaught Error: Undefined constant 'Test\ns1\unknown' in %sns_057.php:%d
Stack trace:
#0 {main}
thrown in %sns_057.php on line %d