Don't use Aast.Any when marking expressions as type Tany
[hiphop-php.git] / hphp / test / ext / test_base.cpp
blob9f3e635596c84a11b7136f24143e811ea044805c
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #include "hphp/test/ext/test_base.h"
18 #include <sys/param.h>
19 #include "hphp/compiler/option.h"
20 #include "hphp/test/ext/test.h"
21 #include "hphp/runtime/base/comparisons.h"
22 #include "hphp/runtime/ext/array/ext_array.h"
23 #include "hphp/runtime/ext/std/ext_std_variable.h"
25 ///////////////////////////////////////////////////////////////////////////////
27 TestBase::TestBase() {
28 Option::KeepStatementsWithNoEffect = true;
31 bool TestBase::Count(bool result) {
32 if (result) {
33 Test::s_passed++;
34 pass_count++;
35 } else {
36 fail_count++;
39 Test::s_total++;
40 return result;
43 bool TestBase::CountSkip() {
44 skip_count++;
45 Test::s_skipped++;
46 Test::s_total++;
47 return true;
50 bool TestBase::VerifySame(const char *exp1, const char *exp2,
51 const Variant& v1, const Variant& v2) {
52 if (!same(v1, v2)) {
53 g_context->obEndAll();
54 printf("%s = \n", exp1); HHVM_FN(var_dump)(v1);
55 printf("%s = \n", exp2); HHVM_FN(var_dump)(v2);
56 return false;
58 return true;
61 bool TestBase::VerifyClose(const char *exp1, const char *exp2,
62 double v1, double v2) {
63 double diff = v1 > v2 ? v1 - v2 : v2 - v1;
64 if (diff > 0.00001) {
65 g_context->obEndAll();
66 printf("%s = \n", exp1); HHVM_FN(var_dump)(v1);
67 printf("%s = \n", exp2); HHVM_FN(var_dump)(v2);
68 return false;
70 return true;
73 bool TestBase::array_value_exists(const Variant& var, const Variant& value) {
74 bool found = !same(
75 Variant::attach(HHVM_FN(array_search)(value, var.toArray())),
76 false
78 if (!found) {
79 HHVM_FN(var_dump)(var);
81 return found;