Move TestExtMath to php
Esse commit está contido em:
@@ -36,7 +36,6 @@
|
||||
#include "hphp/facebook/extensions/urlextraction/test_ext_urlextraction.h"
|
||||
#include "hphp/test/ext/test_ext_curl.h"
|
||||
#include "hphp/test/ext/test_ext_mailparse.h"
|
||||
#include "hphp/test/ext/test_ext_math.h"
|
||||
#include "hphp/test/ext/test_ext_mcrypt.h"
|
||||
#include "hphp/test/ext/test_ext_memcached.h"
|
||||
#include "hphp/test/ext/test_ext_mysql.h"
|
||||
|
||||
@@ -1,418 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| HipHop for PHP |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#include "hphp/test/ext/test_ext_math.h"
|
||||
#include "hphp/runtime/ext/ext_math.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TestExtMath::RunTests(const std::string &which) {
|
||||
bool ret = true;
|
||||
|
||||
RUN_TEST(test_pi);
|
||||
RUN_TEST(test_min);
|
||||
RUN_TEST(test_max);
|
||||
RUN_TEST(test_abs);
|
||||
RUN_TEST(test_is_finite);
|
||||
RUN_TEST(test_is_infinite);
|
||||
RUN_TEST(test_is_nan);
|
||||
RUN_TEST(test_ceil);
|
||||
RUN_TEST(test_floor);
|
||||
RUN_TEST(test_round);
|
||||
RUN_TEST(test_deg2rad);
|
||||
RUN_TEST(test_rad2deg);
|
||||
RUN_TEST(test_decbin);
|
||||
RUN_TEST(test_dechex);
|
||||
RUN_TEST(test_decoct);
|
||||
RUN_TEST(test_bindec);
|
||||
RUN_TEST(test_hexdec);
|
||||
RUN_TEST(test_octdec);
|
||||
RUN_TEST(test_base_convert);
|
||||
RUN_TEST(test_pow);
|
||||
RUN_TEST(test_exp);
|
||||
RUN_TEST(test_expm1);
|
||||
RUN_TEST(test_log10);
|
||||
RUN_TEST(test_log1p);
|
||||
RUN_TEST(test_log);
|
||||
RUN_TEST(test_cos);
|
||||
RUN_TEST(test_cosh);
|
||||
RUN_TEST(test_sin);
|
||||
RUN_TEST(test_sinh);
|
||||
RUN_TEST(test_tan);
|
||||
RUN_TEST(test_tanh);
|
||||
RUN_TEST(test_acos);
|
||||
RUN_TEST(test_acosh);
|
||||
RUN_TEST(test_asin);
|
||||
RUN_TEST(test_asinh);
|
||||
RUN_TEST(test_atan);
|
||||
RUN_TEST(test_atanh);
|
||||
RUN_TEST(test_atan2);
|
||||
RUN_TEST(test_hypot);
|
||||
RUN_TEST(test_fmod);
|
||||
RUN_TEST(test_sqrt);
|
||||
RUN_TEST(test_getrandmax);
|
||||
RUN_TEST(test_srand);
|
||||
RUN_TEST(test_rand);
|
||||
RUN_TEST(test_mt_getrandmax);
|
||||
RUN_TEST(test_mt_srand);
|
||||
RUN_TEST(test_mt_rand);
|
||||
RUN_TEST(test_lcg_value);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TestExtMath::test_pi() {
|
||||
VC(f_pi(), k_M_PI);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_min() {
|
||||
VS(f_min(4, 2, CREATE_VECTOR4(3, 1, 6, 7)), 1);
|
||||
VS(f_min(0, CREATE_VECTOR3(2, 4, 5)), 2);
|
||||
VS(f_min(1, 0, CREATE_VECTOR1("hello")), 0);
|
||||
VS(f_min(1, "hello", CREATE_VECTOR1(0)), "hello");
|
||||
VS(f_min(1, "hello", CREATE_VECTOR1(-1)), -1);
|
||||
VS(f_min(1, CREATE_VECTOR3(2, 4, 8),
|
||||
CREATE_VECTOR1(CREATE_VECTOR3(2, 5, 1))),
|
||||
CREATE_VECTOR3(2, 4, 8));
|
||||
VS(f_min(1, "string", CREATE_VECTOR2(CREATE_VECTOR3(2, 5, 7), 42)),
|
||||
"string");
|
||||
VS(f_min(1, CREATE_MAP1(1, "1236150163")), "1236150163");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_max() {
|
||||
VS(f_max(4, 2, CREATE_VECTOR4(3, 1, 6, 7)), 7);
|
||||
VS(f_max(0, CREATE_VECTOR3(2, 4, 5)), 5);
|
||||
VS(f_max(1, 0, CREATE_VECTOR1("hello")), 0);
|
||||
VS(f_max(1, "hello", CREATE_VECTOR1(0)), "hello");
|
||||
VS(f_max(1, "hello", CREATE_VECTOR1(-1)), "hello");
|
||||
VS(f_max(1, CREATE_VECTOR3(2, 4, 8),
|
||||
CREATE_VECTOR1(CREATE_VECTOR3(2, 5, 1))),
|
||||
CREATE_VECTOR3(2, 5, 1));
|
||||
VS(f_max(1, "string", CREATE_VECTOR2(CREATE_VECTOR3(2, 5, 7), 42)),
|
||||
CREATE_VECTOR3(2, 5, 7));
|
||||
VS(f_max(1, CREATE_MAP1(1, "1236150163")), "1236150163");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_abs() {
|
||||
VS(f_abs(-4.2), 4.2);
|
||||
VS(f_abs(5), 5);
|
||||
VS(f_abs(-5), 5);
|
||||
VS(f_abs("-4.2"), 4.2);
|
||||
VS(f_abs("5"), 5);
|
||||
VS(f_abs("-5"), 5);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_is_finite() {
|
||||
VERIFY(f_is_finite(5));
|
||||
VERIFY(!f_is_finite(f_log(0)));
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_is_infinite() {
|
||||
VERIFY(!f_is_infinite(5));
|
||||
VERIFY(f_is_infinite(f_log(0)));
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_is_nan() {
|
||||
VERIFY(f_is_nan(f_acos(1.01)));
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_ceil() {
|
||||
VS(f_ceil(4.3), 5.0);
|
||||
VS(f_ceil(9.999), 10.0);
|
||||
VS(f_ceil(-3.14), -3.0);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_floor() {
|
||||
VS(f_floor(4.3), 4.0);
|
||||
VS(f_floor(9.999), 9.0);
|
||||
VS(f_floor(-3.14), -4.0);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_round() {
|
||||
VS(f_round(3.4), 3.0);
|
||||
VS(f_round(3.5), 4.0);
|
||||
VS(f_round(3.6), 4.0);
|
||||
VS(f_round(3.6, 0), 4.0);
|
||||
VS(f_round(1.95583, 2), 1.96);
|
||||
VS(f_round(1241757, -3), 1242000.0);
|
||||
VS(f_round(5.045, 2), 5.05);
|
||||
VS(f_round(5.055, 2), 5.06);
|
||||
VS(f_round("3.4"), 3.0);
|
||||
VS(f_round("3.5"), 4.0);
|
||||
VS(f_round("3.6"), 4.0);
|
||||
VS(f_round("3.6", 0), 4.0);
|
||||
VS(f_round("1.95583", 2), 1.96);
|
||||
VS(f_round("1241757", -3), 1242000.0);
|
||||
VS(f_round("5.045", 2), 5.05);
|
||||
VS(f_round("5.055", 2), 5.06);
|
||||
|
||||
// ext/standard/tests/math/round_modes.phpt
|
||||
VS(f_round(2.5, 0, k_PHP_ROUND_HALF_UP), 3.0);
|
||||
VS(f_round(2.5, 0, k_PHP_ROUND_HALF_DOWN), 2.0);
|
||||
VS(f_round(2.5, 0, k_PHP_ROUND_HALF_EVEN), 2.0);
|
||||
VS(f_round(2.5, 0, k_PHP_ROUND_HALF_ODD), 3.0);
|
||||
VS(f_round(-2.5, 0, k_PHP_ROUND_HALF_UP), -3.0);
|
||||
VS(f_round(-2.5, 0, k_PHP_ROUND_HALF_DOWN), -2.0);
|
||||
VS(f_round(-2.5, 0, k_PHP_ROUND_HALF_EVEN), -2.0);
|
||||
VS(f_round(-2.5, 0, k_PHP_ROUND_HALF_ODD), -3.0);
|
||||
VS(f_round(3.5, 0, k_PHP_ROUND_HALF_UP), 4.0);
|
||||
VS(f_round(3.5, 0, k_PHP_ROUND_HALF_DOWN), 3.0);
|
||||
VS(f_round(3.5, 0, k_PHP_ROUND_HALF_EVEN), 4.0);
|
||||
VS(f_round(3.5, 0, k_PHP_ROUND_HALF_ODD), 3.0);
|
||||
VS(f_round(-3.5, 0, k_PHP_ROUND_HALF_UP), -4.0);
|
||||
VS(f_round(-3.5, 0, k_PHP_ROUND_HALF_DOWN), -3.0);
|
||||
VS(f_round(-3.5, 0, k_PHP_ROUND_HALF_EVEN), -4.0);
|
||||
VS(f_round(-3.5, 0, k_PHP_ROUND_HALF_ODD), -3.0);
|
||||
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_deg2rad() {
|
||||
VC(f_deg2rad(45), k_M_PI_4);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_rad2deg() {
|
||||
VC(f_rad2deg(k_M_PI_4), 45);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_decbin() {
|
||||
VS(f_decbin(12), "1100");
|
||||
VS(f_decbin(26), "11010");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_dechex() {
|
||||
VS(f_dechex(10), "a");
|
||||
VS(f_dechex(47), "2f");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_decoct() {
|
||||
VS(f_decoct(15), "17");
|
||||
VS(f_decoct(264), "410");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_bindec() {
|
||||
VS(f_bindec("110011"), 51);
|
||||
VS(f_bindec("000110011"), 51);
|
||||
VS(f_bindec("111"), 7);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_hexdec() {
|
||||
VS(f_hexdec("See"), 238);
|
||||
VS(f_hexdec("ee"), 238);
|
||||
VS(f_hexdec("that"), 10);
|
||||
VS(f_hexdec("a0"), 160);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_octdec() {
|
||||
VS(f_octdec("77"), 63);
|
||||
VS(f_octdec(f_decoct(45)), 45);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_base_convert() {
|
||||
VS(f_base_convert("A37334", 16, 2), "101000110111001100110100");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_pow() {
|
||||
VC(f_pow(2, 8), 256);
|
||||
VC(f_pow(-1, 20), 1);
|
||||
VS(f_pow(0, 0), 1);
|
||||
VERIFY(f_pow(2, 32).isInteger());
|
||||
VC(f_pow("2", "8"), 256);
|
||||
VC(f_pow("-1", "20"), 1);
|
||||
VS(f_pow("0", "0"), 1);
|
||||
VERIFY(f_pow("2", "32").isInteger());
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_exp() {
|
||||
VC(f_exp(12), 162754.791419);
|
||||
VC(f_exp(5.7), 298.86740096706);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_expm1() {
|
||||
VC(f_expm1(5.7), 297.8674);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_log10() {
|
||||
VS(f_log10(10), 1.0);
|
||||
VS(f_log10(100), 2.0);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_log1p() {
|
||||
VC(f_log1p(9), 2.302585092994);
|
||||
VC(f_log1p(99), 4.6051701859881);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_log() {
|
||||
VC(f_log(8), 2.0794415416798);
|
||||
VS(f_log(8, 2), 3.0);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_cos() {
|
||||
VC(f_cos(k_M_PI), -1);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_cosh() {
|
||||
VC(f_cosh(1.23), 1.8567610569853);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_sin() {
|
||||
VC(f_sin(f_deg2rad(90)), 1);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_sinh() {
|
||||
VC(f_sinh(1.23), 1.5644684793044);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_tan() {
|
||||
VC(f_tan(f_deg2rad(45)), 1);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_tanh() {
|
||||
VC(f_tanh(1.23), 0.84257932565893);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_acos() {
|
||||
VC(f_acos(-1), k_M_PI);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_acosh() {
|
||||
VC(f_acosh(1.8567610569853), 1.23);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_asin() {
|
||||
VC(f_asin(1), f_deg2rad(90));
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_asinh() {
|
||||
VC(f_asinh(1.5644684793044), 1.23);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_atan() {
|
||||
VC(f_atan(1), f_deg2rad(45));
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_atanh() {
|
||||
VC(f_atanh(0.84257932565893), 1.23);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_atan2() {
|
||||
VC(f_atan2(3, 4), 0.64350110879328);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_hypot() {
|
||||
VS(f_hypot(3, 4), 5.0);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_fmod() {
|
||||
VS(f_fmod(5.7, 1.3), 0.5);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_sqrt() {
|
||||
VS(f_sqrt(9), 3.0);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_getrandmax() {
|
||||
VS(f_getrandmax(), 2147483647);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_srand() {
|
||||
f_srand();
|
||||
f_srand(0);
|
||||
f_srand(1);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_rand() {
|
||||
f_rand();
|
||||
VERIFY(f_rand(5, 15) >= 5);
|
||||
VERIFY(f_rand(5, 15) <= 15);
|
||||
|
||||
int64_t n = f_rand(10000000000LL, 19999999999LL);
|
||||
VERIFY(n >= 10000000000LL);
|
||||
VERIFY(n <= 19999999999LL);
|
||||
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_mt_getrandmax() {
|
||||
VS(f_mt_getrandmax(), 2147483647);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_mt_srand() {
|
||||
f_mt_srand();
|
||||
f_mt_srand(0);
|
||||
f_mt_srand(1);
|
||||
|
||||
VERIFY(f_mt_rand(5, 15) == 11);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_mt_rand() {
|
||||
f_mt_rand();
|
||||
VERIFY(f_mt_rand(5, 15) >= 5);
|
||||
VERIFY(f_mt_rand(5, 15) <= 15);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMath::test_lcg_value() {
|
||||
VERIFY(f_lcg_value() >= 0);
|
||||
VERIFY(f_lcg_value() <= 1);
|
||||
return Count(true);
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| HipHop for PHP |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef incl_HPHP_TEST_EXT_MATH_H_
|
||||
#define incl_HPHP_TEST_EXT_MATH_H_
|
||||
|
||||
// >>>>>> Generated by idl.php. Do NOT modify. <<<<<<
|
||||
|
||||
#include "hphp/test/ext/test_cpp_ext.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class TestExtMath : public TestCppExt {
|
||||
public:
|
||||
virtual bool RunTests(const std::string &which);
|
||||
|
||||
bool test_pi();
|
||||
bool test_min();
|
||||
bool test_max();
|
||||
bool test_abs();
|
||||
bool test_is_finite();
|
||||
bool test_is_infinite();
|
||||
bool test_is_nan();
|
||||
bool test_ceil();
|
||||
bool test_floor();
|
||||
bool test_round();
|
||||
bool test_deg2rad();
|
||||
bool test_rad2deg();
|
||||
bool test_decbin();
|
||||
bool test_dechex();
|
||||
bool test_decoct();
|
||||
bool test_bindec();
|
||||
bool test_hexdec();
|
||||
bool test_octdec();
|
||||
bool test_base_convert();
|
||||
bool test_pow();
|
||||
bool test_exp();
|
||||
bool test_expm1();
|
||||
bool test_log10();
|
||||
bool test_log1p();
|
||||
bool test_log();
|
||||
bool test_cos();
|
||||
bool test_cosh();
|
||||
bool test_sin();
|
||||
bool test_sinh();
|
||||
bool test_tan();
|
||||
bool test_tanh();
|
||||
bool test_acos();
|
||||
bool test_acosh();
|
||||
bool test_asin();
|
||||
bool test_asinh();
|
||||
bool test_atan();
|
||||
bool test_atanh();
|
||||
bool test_atan2();
|
||||
bool test_hypot();
|
||||
bool test_fmod();
|
||||
bool test_sqrt();
|
||||
bool test_getrandmax();
|
||||
bool test_srand();
|
||||
bool test_rand();
|
||||
bool test_mt_getrandmax();
|
||||
bool test_mt_srand();
|
||||
bool test_mt_rand();
|
||||
bool test_lcg_value();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // incl_HPHP_TEST_EXT_MATH_H_
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
var_dump(abs(-4.2));
|
||||
var_dump(abs(5));
|
||||
var_dump(abs(-5));
|
||||
var_dump(abs("-4.2"));
|
||||
var_dump(abs("5"));
|
||||
var_dump(abs("-5"));
|
||||
@@ -0,0 +1,6 @@
|
||||
float(4.2)
|
||||
int(5)
|
||||
int(5)
|
||||
float(4.2)
|
||||
int(5)
|
||||
int(5)
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
function VC($x, $y) {
|
||||
var_dump(abs($x - $y) < 0.00001);
|
||||
}
|
||||
|
||||
var_dump(pi());
|
||||
var_dump(M_PI);
|
||||
|
||||
var_dump(is_finite(5));
|
||||
var_dump(is_finite(log(0)));
|
||||
var_dump(is_nan(acos(1.01)));
|
||||
|
||||
VC(deg2rad(45), M_PI_4);
|
||||
VC(rad2deg(M_PI_4), 45);
|
||||
|
||||
var_dump(decbin(12));
|
||||
var_dump(decbin(26));
|
||||
var_dump(dechex(10));
|
||||
var_dump(dechex(47));
|
||||
|
||||
var_dump(decoct(15));
|
||||
var_dump(decoct(264));
|
||||
|
||||
var_dump(bindec("110011"));
|
||||
var_dump(bindec("000110011"));
|
||||
var_dump(bindec("111"));
|
||||
|
||||
var_dump(hexdec("See"));
|
||||
var_dump(hexdec("ee"));
|
||||
var_dump(hexdec("that"));
|
||||
var_dump(hexdec("a0"));
|
||||
|
||||
var_dump(octdec("77"));
|
||||
var_dump(octdec(decoct(45)));
|
||||
|
||||
var_dump(base_convert("A37334", 16, 2));
|
||||
|
||||
|
||||
VC(pow(2, 8), 256);
|
||||
VC(pow(-1, 20), 1);
|
||||
var_dump(pow(0, 0));
|
||||
var_dump(is_int(pow(2, 32)));
|
||||
VC(pow("2", "8"), 256);
|
||||
VC(pow("-1", "20"), 1);
|
||||
var_dump(pow("0", "0"));
|
||||
var_dump(is_int(pow("2", "32")));
|
||||
|
||||
VC(exp(12), 162754.791419);
|
||||
VC(exp(5.7), 298.86740096706);
|
||||
|
||||
VC(expm1(5.7), 297.8674);
|
||||
|
||||
var_dump(log10(10));
|
||||
var_dump(log10(100));
|
||||
|
||||
VC(log1p(9), 2.302585092994);
|
||||
VC(log1p(99), 4.6051701859881);
|
||||
|
||||
VC(log(8), 2.0794415416798);
|
||||
var_dump(log(8, 2));
|
||||
|
||||
VC(cos(M_PI), -1);
|
||||
VC(cosh(1.23), 1.8567610569853);
|
||||
VC(sin(deg2rad(90)), 1);
|
||||
VC(sinh(1.23), 1.5644684793044);
|
||||
VC(tan(deg2rad(45)), 1);
|
||||
VC(tanh(1.23), 0.84257932565893);
|
||||
VC(acos(-1), M_PI);
|
||||
VC(acosh(1.8567610569853), 1.23);
|
||||
VC(asin(1), deg2rad(90));
|
||||
VC(asinh(1.5644684793044), 1.23);
|
||||
VC(atan(1), deg2rad(45));
|
||||
VC(atanh(0.84257932565893), 1.23);
|
||||
VC(atan2(3, 4), 0.64350110879328);
|
||||
var_dump(hypot(3, 4));
|
||||
var_dump(fmod(5.7, 1.3));
|
||||
var_dump(sqrt(9));
|
||||
var_dump(getrandmax());
|
||||
|
||||
var_dump(mt_getrandmax());
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
float(3.1415926535898)
|
||||
float(3.1415926535898)
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
string(4) "1100"
|
||||
string(5) "11010"
|
||||
string(1) "a"
|
||||
string(2) "2f"
|
||||
string(2) "17"
|
||||
string(3) "410"
|
||||
int(51)
|
||||
int(51)
|
||||
int(7)
|
||||
int(238)
|
||||
int(238)
|
||||
int(10)
|
||||
int(160)
|
||||
int(63)
|
||||
int(45)
|
||||
string(24) "101000110111001100110100"
|
||||
bool(true)
|
||||
bool(true)
|
||||
int(1)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
int(1)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
float(1)
|
||||
float(2)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
float(3)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
float(5)
|
||||
float(0.5)
|
||||
float(3)
|
||||
int(2147483647)
|
||||
int(2147483647)
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
var_dump(max(array(3, 1, 6, 7)));
|
||||
var_dump(max(array(2, 4, 5)));
|
||||
var_dump(max(0, array("hello")));
|
||||
var_dump(max("hello", array(0)));
|
||||
var_dump(max("hello", array(-1)));
|
||||
var_dump(max(array(2, 4, 8), array(array(2, 5, 1))));
|
||||
var_dump(max("string", array(array(2, 5, 7), 42)));
|
||||
var_dump(max(array(1 => "1236150163")));
|
||||
@@ -0,0 +1,36 @@
|
||||
int(7)
|
||||
int(5)
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(5) "hello"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(-1)
|
||||
}
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(2)
|
||||
[1]=>
|
||||
int(4)
|
||||
[2]=>
|
||||
int(8)
|
||||
}
|
||||
array(2) {
|
||||
[0]=>
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(2)
|
||||
[1]=>
|
||||
int(5)
|
||||
[2]=>
|
||||
int(7)
|
||||
}
|
||||
[1]=>
|
||||
int(42)
|
||||
}
|
||||
string(10) "1236150163"
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
var_dump(min(array(3, 1, 6, 7)));
|
||||
var_dump(min(array(2, 4, 5)));
|
||||
var_dump(min(0, array("hello")));
|
||||
var_dump(min("hello", array(0)));
|
||||
var_dump(min("hello", array(-1)));
|
||||
var_dump(min(array(2, 4, 8), array(array(2, 5, 1))));
|
||||
var_dump(min("string", array(array(2, 5, 7), 42)));
|
||||
var_dump(min(array(1 => "1236150163")));
|
||||
@@ -0,0 +1,18 @@
|
||||
int(1)
|
||||
int(2)
|
||||
int(0)
|
||||
string(5) "hello"
|
||||
string(5) "hello"
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(2)
|
||||
[1]=>
|
||||
int(5)
|
||||
[2]=>
|
||||
int(1)
|
||||
}
|
||||
}
|
||||
string(6) "string"
|
||||
string(10) "1236150163"
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
var_dump(ceil(4.3));
|
||||
var_dump(ceil(9.999));
|
||||
var_dump(ceil(-3.14));
|
||||
|
||||
var_dump(floor(4.3));
|
||||
var_dump(floor(9.999));
|
||||
var_dump(floor(-3.14));
|
||||
|
||||
var_dump(round(3.4));
|
||||
var_dump(round(3.5));
|
||||
var_dump(round(3.6));
|
||||
var_dump(round(3.6, 0));
|
||||
var_dump(round(1.95583, 2));
|
||||
var_dump(round(1241757, -3));
|
||||
var_dump(round(5.045, 2));
|
||||
var_dump(round(5.055, 2));
|
||||
var_dump(round("3.4"));
|
||||
var_dump(round("3.5"));
|
||||
var_dump(round("3.6"));
|
||||
var_dump(round("3.6", 0));
|
||||
var_dump(round("1.95583", 2));
|
||||
var_dump(round("1241757", -3));
|
||||
var_dump(round("5.045", 2));
|
||||
var_dump(round("5.055", 2));
|
||||
|
||||
// ext/standard/tests/math/round_modes.phpt
|
||||
var_dump(round(2.5, 0, PHP_ROUND_HALUP));
|
||||
var_dump(round(2.5, 0, PHP_ROUND_HALDOWN));
|
||||
var_dump(round(2.5, 0, PHP_ROUND_HALEVEN));
|
||||
var_dump(round(2.5, 0, PHP_ROUND_HALODD));
|
||||
var_dump(round(-2.5, 0, PHP_ROUND_HALUP));
|
||||
var_dump(round(-2.5, 0, PHP_ROUND_HALDOWN));
|
||||
var_dump(round(-2.5, 0, PHP_ROUND_HALEVEN));
|
||||
var_dump(round(-2.5, 0, PHP_ROUND_HALODD));
|
||||
var_dump(round(3.5, 0, PHP_ROUND_HALUP));
|
||||
var_dump(round(3.5, 0, PHP_ROUND_HALDOWN));
|
||||
var_dump(round(3.5, 0, PHP_ROUND_HALEVEN));
|
||||
var_dump(round(3.5, 0, PHP_ROUND_HALODD));
|
||||
var_dump(round(-3.5, 0, PHP_ROUND_HALUP));
|
||||
var_dump(round(-3.5, 0, PHP_ROUND_HALDOWN));
|
||||
var_dump(round(-3.5, 0, PHP_ROUND_HALEVEN));
|
||||
var_dump(round(-3.5, 0, PHP_ROUND_HALODD));
|
||||
@@ -0,0 +1,38 @@
|
||||
float(5)
|
||||
float(10)
|
||||
float(-3)
|
||||
float(4)
|
||||
float(9)
|
||||
float(-4)
|
||||
float(3)
|
||||
float(4)
|
||||
float(4)
|
||||
float(4)
|
||||
float(1.96)
|
||||
float(1242000)
|
||||
float(5.05)
|
||||
float(5.06)
|
||||
float(3)
|
||||
float(4)
|
||||
float(4)
|
||||
float(4)
|
||||
float(1.96)
|
||||
float(1242000)
|
||||
float(5.05)
|
||||
float(5.06)
|
||||
float(3)
|
||||
float(3)
|
||||
float(3)
|
||||
float(3)
|
||||
float(-3)
|
||||
float(-3)
|
||||
float(-3)
|
||||
float(-3)
|
||||
float(4)
|
||||
float(4)
|
||||
float(4)
|
||||
float(4)
|
||||
float(-4)
|
||||
float(-4)
|
||||
float(-4)
|
||||
float(-4)
|
||||
Referência em uma Nova Issue
Bloquear um usuário