Fix and expand rename_camel.i testcase
The regex pattern to upper-case things containing an `i` had incorrect escaping (`\\(`...`\\)` instead of `(`...`)`) so `import` didn't get renamed. This wasn't detected because there were no `_runme` files for this testcase, so add rename_camel_runme.php which uses reflection to check the wrapped PHP classes, functions and constants are all named as expected. Also expand coverage of converting to underscore case and add coverage for converting to lower-camel-case. Related to #1041.
This commit is contained in:
parent
e1bb265bf7
commit
cf7bdcf2df
3 changed files with 64 additions and 12 deletions
|
|
@ -7,6 +7,8 @@ class check {
|
|||
|
||||
private static $_extension = null;
|
||||
|
||||
private static $_werror = false;
|
||||
|
||||
// This is called automatically at the end of this file.
|
||||
static function init() {
|
||||
foreach(get_included_files() as $f) {
|
||||
|
|
@ -21,6 +23,10 @@ class check {
|
|||
self::$_extension = new ReflectionExtension($module_name);
|
||||
}
|
||||
|
||||
static function werror($v) {
|
||||
self::$_werror = $v;
|
||||
}
|
||||
|
||||
static function classname($string,$object) {
|
||||
if (!is_object($object))
|
||||
return check::fail("The second argument is a " . gettype($object) . ", not an object.");
|
||||
|
|
@ -139,6 +145,23 @@ class check {
|
|||
|
||||
}
|
||||
|
||||
static function constants($constants) {
|
||||
if (! is_array($constants)) $constants=array($constants);
|
||||
$message=array();
|
||||
$missing=array();
|
||||
$extra = self::$_extension->getConstants();
|
||||
unset($extra['swig_runtime_data_type_pointer']);
|
||||
foreach($constants as $constant) {
|
||||
if (! defined($constant)) $missing[]=$constant;
|
||||
else unset($extra[$constant]);
|
||||
}
|
||||
if ($missing) $message[]=sprintf("Constants missing: %s",join(",",$missing));
|
||||
if ($message) return check::fail(join("\n ",$message));
|
||||
if ($extra) $message[]=sprintf("These extra constants are defined: %s",join(",",array_keys($extra)));
|
||||
if ($message) return check::warn(join("\n ",$message));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static function functionref($a,$type,$message) {
|
||||
if (! preg_match("/^_[a-f0-9]+$type$/i", $a))
|
||||
return check::fail($message);
|
||||
|
|
@ -167,6 +190,7 @@ class check {
|
|||
|
||||
static function warn($pattern) {
|
||||
$args=func_get_args();
|
||||
if (self::$_werror) self::fail($pattern);
|
||||
print("Warning on: ".call_user_func_array("sprintf",$args)."\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue