summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHartmut Holzgraefe <hholzgra@php.net>2003-05-20 13:43:43 +0000
committerHartmut Holzgraefe <hholzgra@php.net>2003-05-20 13:43:43 +0000
commit2f31208beb148032e1e04dfb1f22ac48ea28041d (patch)
treebace5fb37de19b2ff8f87f4c2a4a9d9b173c84e6 /scripts
parent450d46ce4ff0b449871f444e0d5fa3ddefb538aa (diff)
downloadphp-git-2f31208beb148032e1e04dfb1f22ac48ea28041d.tar.gz
- new method to generate test cases for functions
- beginning support for "pass by reference" parameters
Diffstat (limited to 'scripts')
-rw-r--r--scripts/ext_skel_ng/php_function.php39
1 files changed, 36 insertions, 3 deletions
diff --git a/scripts/ext_skel_ng/php_function.php b/scripts/ext_skel_ng/php_function.php
index 92c970522d..8c39e24cff 100644
--- a/scripts/ext_skel_ng/php_function.php
+++ b/scripts/ext_skel_ng/php_function.php
@@ -61,10 +61,18 @@
if (!$this->is_type($tokens[$n])) return("type name expected instead of '$tokens[$n]'");
$params[$param]['type']=$tokens[$n];
$n++;
+ if ($tokens[$n] == "&") {
+ $params[$param]['by_ref'] = true;
+ $n++;
+ }
if ($this->is_name($tokens[$n])) {
$params[$param]['name']=$tokens[$n];
$n++;
}
+ if ($tokens[$n] == "&") {
+ $params[$param]['by_ref'] = true;
+ $n++;
+ }
if ($params[$param]['type'] === "resource" && $this->is_name($tokens[$n])) {
$params[$param]['subtype'] = $params[$param]['name'];
$params[$param]['name'] = $tokens[$n];
@@ -98,7 +106,7 @@
return true;
}
- function c_code(&$extension) {
+ function c_code($extension) {
$code = "";
$returns = explode(" ", $this->returns);
@@ -117,6 +125,9 @@
$code .= $param['subtype']." ";
}
if ($param['type'] !== 'void') {
+ if (isset($param['by_ref'])) {
+ $code .= "&";
+ }
$code .= $param['name'];
}
}
@@ -319,7 +330,11 @@
} else {
$xml .= " <methodparam>";
}
- $xml .= "<type>$param[type]</type><parameter>$param[name]</parameter>";
+ $xml .= "<type>$param[type]</type><parameter>";
+ if (isset($param['by_ref'])) {
+ $xml .= "&amp;";
+ }
+ $xml .= "$param[name]</parameter>";
$xml .= "</methodparam>\n";
}
}
@@ -337,10 +352,28 @@ $xml .=
</refsect1>
</refentry>
';
- $xml .= $this->docbook_editor_footer(4);
+ $xml .= $this->docbook_editor_settings(4);
return $xml;
}
+
+ function write_test($extension) {
+ $fp = fopen("{$extension->name}/tests/{$this->name}.phpt", "w");
+ fputs($fp,
+"--TEST--
+{$this->name}() function
+--SKIPIF--
+<?php if (!extension_loaded('{$extension->name}')) print 'skip'; ?>
+--POST--
+--GET--
+--FILE--
+<?php
+ echo 'no test case for {$this->name}() yet';
+?>
+--EXPECT--
+no test case for {$this->name}() yet");
+ fclose($fp);
+ }
}
?> \ No newline at end of file