]> granicus.if.org Git - php/commitdiff
Added test cases for ZEND_SIGNED_MULTIPLY_LONG()
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Thu, 17 Jan 2013 16:41:58 +0000 (17:41 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Thu, 17 Jan 2013 16:41:58 +0000 (17:41 +0100)
Before making changes to the implementation of
ZEND_SIGNED_MULTIPLY_LONG(), add some test cases
to make sure the various implementations remain
equivalent.

Zend/tests/zend_signed_multiply-32bit.phpt [new file with mode: 0644]
Zend/tests/zend_signed_multiply-64bit.phpt [new file with mode: 0644]

diff --git a/Zend/tests/zend_signed_multiply-32bit.phpt b/Zend/tests/zend_signed_multiply-32bit.phpt
new file mode 100644 (file)
index 0000000..0a42bd4
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+Zend signed multiply 32-bit
+--SKIPIF--
+<? if ((1 << 31) > 0) print "skip Running on 64-bit target"; ?>
+--FILE--
+<?php
+var_dump(0x8000 * -0xffff);
+var_dump(0x8001 * 0xfffe);
+var_dump(0x8001 * -0xffff);
+?>
+--EXPECTF--
+int(-2147450880)
+int(2147483646)
+float(-2147516415)
diff --git a/Zend/tests/zend_signed_multiply-64bit.phpt b/Zend/tests/zend_signed_multiply-64bit.phpt
new file mode 100644 (file)
index 0000000..86e5292
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+Zend signed multiply 64-bit
+--SKIPIF--
+<? if ((1 << 31) < 0) print "skip Running on 32-bit target"; ?>
+--FILE--
+<?php
+var_dump(0x80000000 * -0xffffffff);
+var_dump(0x80000001 * 0xfffffffe);
+var_dump(0x80000001 * -0xffffffff);
+?>
+--EXPECTF--
+int(-9223372034707292160)
+int(9223372036854775806)
+float(-9.2233720390023E+18)