add bcmath tests

All the bad tests seem to be error mis-matches. I already changed one error message about arguments so I think I should just make all these too many too few errors match.
Esse commit está contido em:
ptarjan
2013-04-03 18:23:16 -07:00
commit de Sara Golemon
commit 0fbd3e35c7
17 arquivos alterados com 50 adições e 4 exclusões
@@ -0,0 +1,3 @@
<?php
echo bcdiv('1', '2', '3', '4');
?>
@@ -0,0 +1 @@
HipHop Warning: bcdiv() expects at most 3 parameters, 4 given in %s.php on line %d
@@ -0,0 +1,3 @@
<?php
echo bcmod('1', '2', '3');
?>
@@ -0,0 +1 @@
HipHop Warning: Missing argument 2 for bcmod() in %s.php on line %d
@@ -0,0 +1,3 @@
<?php
echo bcpowmod('1');
?>
@@ -0,0 +1 @@
HipHop Warning: bcpowmod() expects at least 3 parameters, 1 given in %s.php on line %d
@@ -0,0 +1,3 @@
<?php
echo bcpowmod('1', '2');
?>
@@ -0,0 +1 @@
HipHop Warning: bcpowmod() expects at least 3 parameters, 2 given in %s.php on line %d
@@ -0,0 +1,3 @@
<?php
echo bcpowmod('1', '2', '3', '4', '5');
?>
@@ -0,0 +1 @@
HipHop Warning: bcpowmod() expects at most 4 parameters, 5 given in %s.php on line %d
@@ -0,0 +1,3 @@
<?php
echo bcdiv('10.99', '0');
?>
@@ -0,0 +1 @@
HipHop Warning: Division by zero in hphp/test/zend/good/ext-bcmath/bcdiv_error1.php on line 2
@@ -0,0 +1,3 @@
<?php
echo bcsqrt('-9');
?>
@@ -0,0 +1 @@
HipHop Warning: Square root of negative number in hphp/test/zend/good/ext-bcmath/bcsqrt_error1.php on line 2
@@ -0,0 +1,6 @@
<?php
$var48 = bcscale(634314234334311);
$var67 = bcsqrt(false);
$var414 = bcadd(false,null,10);
die('ALIVE');
?>
@@ -0,0 +1 @@
ALIVE
+15 -4
Ver Arquivo
@@ -53,6 +53,9 @@ bad_tests = (
errors = (
# generic inconsistencies
('Variable passed to ([^\s]+)\(\) is not an array or object', 'Invalid operand type was used: expecting an array'),
('bcdiv\(\): ', ''),
('bcsqrt\(\): ', ''),
('bcpowmod\(\): ', ''),
# I can't do math with backreferences so write them out
('([^\s]+)\(\) expects exactly 1 parameter, 0 given', r'Missing argument 1 for \1()'),
@@ -83,6 +86,12 @@ parser.add_argument(
action='store_true',
help="leave around test/zend/all directory."
)
parser.add_argument(
"-v",
"--verbose",
action='store_true',
help="print out extra stuff."
)
args = parser.parse_args()
@@ -127,7 +136,7 @@ def walk(filename, source):
elif sections.has_key('EXPECTREGEX'):
exp = sections['EXPECTREGEX']
else:
print "Malformed test, no --EXPECT-- or --EXPECTF--: ", filename
print "Malformed test, no --EXPECT-- or --EXPECTF-- or --EXPECTREGEX--: ", filename
return
if sections.has_key('POST'):
@@ -253,13 +262,14 @@ for root, dirs, files in os.walk('test/zend/all'):
mkdir_p(os.path.dirname(bad_file))
def isOkDiff(original_name):
global args
for test in bad_tests:
if test in original_name:
return False
filename = original_name + '.diff'
# no diff file or is empty
if not os.path.exists(original_name + '.diff') or os.stat(filename)[6] == 0:
if (not os.path.exists(original_name + '.diff') or \
os.stat(original_name + '.diff')[6] == 0):
return True
wanted_re = file(original_name + '.exp').read().strip()
@@ -311,8 +321,9 @@ for root, dirs, files in os.walk('test/zend/all'):
wanted_re = wanted_re.replace('%f', '[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?')
wanted_re = wanted_re.replace('%c', '.')
# print repr(wanted_re), '\n', repr(output), '\n', re.match(wanted_re, output)
match = re.match(wanted_re, output)
if args.verbose:
print '\n', original_name, '\n', repr(wanted_re), '\n', repr(output), '\n', match is not None
return match and match.group() == output