Esempio n. 1
0
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
if (strpos($argv[0], 'test_parser') !== false) {
    error_reporting(0);
    test_parser($argv[1]);
}
function test_parser($file)
{
    $tests = file($file);
    $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("file", "/tmp/error-output.txt", "w"));
    $results = array('OKAY' => 0, 'FAIL' => 0);
    $format = array('OKAY' => '', 'FAIL' => '', 'NORM' => '');
    foreach ($tests as $test) {
        $test_parts = explode('|', $test);
        $teste = trim($test_parts[2]);
        $ts_exp = trim($test_parts[0]);
        $ps_exp = trim($test_parts[1]);
        $process = proc_open("./tests/tester-parse-string \"{$teste}\"", $descriptorspec, $pipes);
        fwrite($pipes[0], $teste);
        fclose($pipes[0]);
Esempio n. 2
0
test_parser("No Straight", '?>?>?>?>?', "s3,s8,d10,c9,hj,h10,h6");
// flush
test_parser("Flush", 'a{5}', "s3,sj,s3,sj,sj,h7,hk");
test_parser("No Flush", 'a{5}', "c3,dj,s3,sj,sj,h7,hk");
// full house
test_parser("Full House", '1{3}2{2}', "s3,sj,d3,cj,hj,h7,hk");
test_parser("No Full House", '1{3}2{2}', "s5,sj,d3,cj,hj,h7,hk");
// four of a kind
test_parser("For of a Kind", '1{4}', "sj,hj,d3,c4,cj,h7,dj");
test_parser("No For of a Kind", '1{4}', "sj,hk,d3,c4,cj,h7,dj");
// straight flush
test_parser("Straight-Flush", 'a>a>a>a>a', "sk,sq,sj,s10,s9,h7,hq");
test_parser("No Straight-Flush", 'a>a>a>a>a', "sk,ca,s2,s3,s4,h7,hq");
// royal flush
test_parser("Royal-Flush", '[a>a>a>a>a', "sa,sq,sj,sk,s10,h7,hq");
test_parser("No Royal-Flush", '[a>a>a>a>a', "sk,sq,sj,s10,s9,h7,hq");
// dont run this file
exit;
// benchmark config
$configs = array('resources', 'teleportPoints', 'premium_price', 'company_quests', 'products');
$total = 0;
$count = 0;
foreach ($configs as $cfg) {
    $start = microtime(true);
    Config::getConfig($cfg);
    $stop = microtime(true) - $start;
    $count++;
    $total += $stop;
    echo "getConfig({$cfg}) took {$stop} seconds <br />";
}
echo "<h3>AVG: " . $total / $count . "</h3>";