Remove Array::operator[](litstr)
Refactor the remaining uses of litstr-indexed Array, and get rid of the operator overload.
Esse commit está contido em:
@@ -273,6 +273,7 @@ class Array : protected SmartPtr<ArrayData> {
|
||||
const Variant operator[](double key) const;
|
||||
const Variant operator[](CStrRef key) const;
|
||||
const Variant operator[](CVarRef key) const;
|
||||
const Variant operator[](const char*) const = delete; // use CStrRef
|
||||
|
||||
Variant &lval(int64_t key) {
|
||||
if (!m_px) ArrayBase::operator=(ArrayData::Create());
|
||||
@@ -473,9 +474,6 @@ class Array : protected SmartPtr<ArrayData> {
|
||||
|
||||
void setEvalScalar() const;
|
||||
|
||||
//litstr overloads
|
||||
const Variant operator[](litstr key) const;
|
||||
|
||||
private:
|
||||
// helpers
|
||||
bool compare(CArrRef v2) const;
|
||||
|
||||
@@ -1495,11 +1495,6 @@ inline Variant uninit_null() {
|
||||
return Variant();
|
||||
}
|
||||
|
||||
//litstr overloads
|
||||
inline const Variant Array::operator[](litstr key) const {
|
||||
return (*this)[String(key)];
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
|
||||
@@ -23,28 +23,31 @@
|
||||
namespace HPHP { namespace Eval {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static const StaticString s_params("params");
|
||||
static const StaticString s_ref("ref");
|
||||
static const StaticString s_name("name");
|
||||
static const StaticString s_varg("varg");
|
||||
static const StaticString s_type("type");
|
||||
static const StaticString s_default("default");
|
||||
static const StaticString s_defaultext("defaultext");
|
||||
static const StaticString s_msg("msg");
|
||||
static const StaticString s_constants("constants");
|
||||
static const StaticString s_methods("methods");
|
||||
static const StaticString s_access("access");
|
||||
static const StaticString s_static("static");
|
||||
static const StaticString s_abstract("abstract");
|
||||
static const StaticString s_final("final");
|
||||
static const StaticString s_doc("doc");
|
||||
static const StaticString s_internal("internal");
|
||||
static const StaticString s_file("file");
|
||||
static const StaticString s_line1("line1");
|
||||
static const StaticString s_line2("line2");
|
||||
static const StaticString s_properties("properties");
|
||||
static const StaticString s_private_properties("private_properties");
|
||||
static const StaticString s_defaultText("defaultText");
|
||||
static const StaticString
|
||||
s_params("params"),
|
||||
s_ref("ref"),
|
||||
s_name("name"),
|
||||
s_varg("varg"),
|
||||
s_type("type"),
|
||||
s_default("default"),
|
||||
s_msg("msg"),
|
||||
s_constants("constants"),
|
||||
s_methods("methods"),
|
||||
s_access("access"),
|
||||
s_static("static"),
|
||||
s_abstract("abstract"),
|
||||
s_final("final"),
|
||||
s_doc("doc"),
|
||||
s_internal("internal"),
|
||||
s_file("file"),
|
||||
s_line1("line1"),
|
||||
s_line2("line2"),
|
||||
s_properties("properties"),
|
||||
s_private_properties("private_properties"),
|
||||
s_defaultText("defaultText"),
|
||||
s_parent("parent"),
|
||||
s_interfaces("interfaces"),
|
||||
s_interface("interface");
|
||||
|
||||
void CmdInfo::sendImpl(DebuggerThriftBuffer &thrift) {
|
||||
DebuggerCommand::sendImpl(thrift);
|
||||
@@ -423,19 +426,19 @@ bool CmdInfo::TryMethod(DebuggerClient *client, StringBuffer &sb, CArrRef info,
|
||||
subsymbol = subsymbol.substr(0, subsymbol.size() - 2);
|
||||
}
|
||||
|
||||
String key = FindSubSymbol(info["methods"], subsymbol);
|
||||
String key = FindSubSymbol(info[s_methods], subsymbol);
|
||||
if (!key.isNull()) {
|
||||
Array func = info["methods"][key].toArray();
|
||||
Array func = info[s_methods][key].toArray();
|
||||
PrintHeader(client, sb, func);
|
||||
sb.printf("%s %s%s%sfunction %s::%s%s(%s);\n",
|
||||
func[s_access].toString().data(),
|
||||
GetModifier(func, s_static).data(),
|
||||
GetModifier(func, s_final).data(),
|
||||
GetModifier(func, s_abstract).data(),
|
||||
info["name"].toString().data(),
|
||||
func["ref"].toBoolean() ? "&" : "",
|
||||
func["name"].toString().data(),
|
||||
GetParams(func["params"], func["varg"], true).data());
|
||||
info[s_name].toString().data(),
|
||||
func[s_ref].toBoolean() ? "&" : "",
|
||||
func[s_name].toString().data(),
|
||||
GetParams(func[s_params], func[s_varg], true).data());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -464,16 +467,16 @@ void CmdInfo::PrintInfo(DebuggerClient *client, StringBuffer &sb, CArrRef info,
|
||||
PrintHeader(client, sb, info);
|
||||
|
||||
StringBuffer parents;
|
||||
String parent = info["parent"].toString();
|
||||
String parent = info[s_parent].toString();
|
||||
if (!parent.empty()) {
|
||||
parents.append("extends ");
|
||||
parents.append(parent);
|
||||
parents.append(' ');
|
||||
}
|
||||
if (!info["interfaces"].toArray().empty()) {
|
||||
if (!info[s_interfaces].toArray().empty()) {
|
||||
parents.append("implements ");
|
||||
bool first = true;
|
||||
for (ArrayIter iter(info["interfaces"]); iter; ++iter) {
|
||||
for (ArrayIter iter(info[s_interfaces]); iter; ++iter) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
@@ -488,52 +491,52 @@ void CmdInfo::PrintInfo(DebuggerClient *client, StringBuffer &sb, CArrRef info,
|
||||
sb.printf("%s%s%s %s %s{\n",
|
||||
GetModifier(info, s_final).data(),
|
||||
GetModifier(info, s_abstract).data(),
|
||||
info["interface"].toBoolean() ? "interface" : "class",
|
||||
info["name"].toString().data(),
|
||||
info[s_interface].toBoolean() ? "interface" : "class",
|
||||
info[s_name].toString().data(),
|
||||
parent.data());
|
||||
|
||||
if (!info["constants"].toArray().empty()) {
|
||||
if (!info[s_constants].toArray().empty()) {
|
||||
sb.printf(" // constants\n");
|
||||
for (ArrayIter iter(info["constants"]); iter; ++iter) {
|
||||
for (ArrayIter iter(info[s_constants]); iter; ++iter) {
|
||||
sb.printf(" const %s = %s;\n",
|
||||
iter.first().toString().data(),
|
||||
DebuggerClient::FormatVariable(iter.second()).data());
|
||||
}
|
||||
}
|
||||
|
||||
if (!info["properties"].toArray().empty() ||
|
||||
!info["private_properties"].toArray().empty()) {
|
||||
if (!info[s_properties].toArray().empty() ||
|
||||
!info[s_private_properties].toArray().empty()) {
|
||||
sb.printf(" // properties\n");
|
||||
for (ArrayIter iter(info["properties"]); iter; ++iter) {
|
||||
for (ArrayIter iter(info[s_properties]); iter; ++iter) {
|
||||
Array prop = iter.second().toArray();
|
||||
sb.printf(" %s%s %s$%s;\n",
|
||||
prop["doc"].toBoolean() ? "[doc] " : "",
|
||||
prop["access"].toString().data(),
|
||||
prop[s_doc].toBoolean() ? "[doc] " : "",
|
||||
prop[s_access].toString().data(),
|
||||
GetModifier(prop, s_static).data(),
|
||||
prop["name"].toString().data());
|
||||
prop[s_name].toString().data());
|
||||
}
|
||||
for (ArrayIter iter(info["private_properties"]); iter; ++iter) {
|
||||
for (ArrayIter iter(info[s_private_properties]); iter; ++iter) {
|
||||
Array prop = iter.second().toArray();
|
||||
sb.printf(" %sprivate %s$%s;\n",
|
||||
prop["doc"].toBoolean() ? "[doc] " : "",
|
||||
prop[s_doc].toBoolean() ? "[doc] " : "",
|
||||
GetModifier(prop, s_static).data(),
|
||||
prop["name"].toString().data());
|
||||
prop[s_name].toString().data());
|
||||
}
|
||||
}
|
||||
|
||||
if (!info["methods"].toArray().empty()) {
|
||||
if (!info[s_methods].toArray().empty()) {
|
||||
sb.printf(" // methods\n");
|
||||
for (ArrayIter iter(info["methods"]); iter; ++iter) {
|
||||
for (ArrayIter iter(info[s_methods]); iter; ++iter) {
|
||||
Array func = iter.second().toArray();
|
||||
sb.printf(" %s%s %s%s%sfunction %s%s(%s);\n",
|
||||
func["doc"].toBoolean() ? "[doc] " : "",
|
||||
func["access"].toString().data(),
|
||||
func[s_doc].toBoolean() ? "[doc] " : "",
|
||||
func[s_access].toString().data(),
|
||||
GetModifier(func, s_static).data(),
|
||||
GetModifier(func, s_final).data(),
|
||||
GetModifier(func, s_abstract).data(),
|
||||
func["ref"].toBoolean() ? "&" : "",
|
||||
func["name"].toString().data(),
|
||||
GetParams(func["params"], func["varg"]).data());
|
||||
func[s_ref].toBoolean() ? "&" : "",
|
||||
func[s_name].toString().data(),
|
||||
GetParams(func[s_params], func[s_varg]).data());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,6 +121,12 @@ bool CmdList::listFileRange(DebuggerClient *client, int line,
|
||||
return false;
|
||||
}
|
||||
|
||||
static const StaticString
|
||||
s_methods("methods"),
|
||||
s_file("file"),
|
||||
s_line1("line2"),
|
||||
s_line2("line2");
|
||||
|
||||
bool CmdList::listFunctionOrClass(DebuggerClient *client) {
|
||||
assert(client->argCount() == 1);
|
||||
CmdInfoPtr cmdInfo(new CmdInfo());
|
||||
@@ -134,13 +140,13 @@ bool CmdList::listFunctionOrClass(DebuggerClient *client) {
|
||||
ArrayIter iter(info);
|
||||
Array funcInfo = iter.second();
|
||||
if (!subsymbol.empty()) {
|
||||
String key = CmdInfo::FindSubSymbol(funcInfo["methods"], subsymbol);
|
||||
String key = CmdInfo::FindSubSymbol(funcInfo[s_methods], subsymbol);
|
||||
if (key.isNull()) return false;
|
||||
funcInfo = funcInfo["methods"][key].toArray();
|
||||
funcInfo = funcInfo[s_methods][key].toArray();
|
||||
}
|
||||
String file = funcInfo["file"].toString();
|
||||
int line1 = funcInfo["line1"].toInt32();
|
||||
int line2 = funcInfo["line2"].toInt32();
|
||||
String file = funcInfo[s_file].toString();
|
||||
int line1 = funcInfo[s_line1].toInt32();
|
||||
int line2 = funcInfo[s_line2].toInt32();
|
||||
int line = line1 ? line1 : line2;
|
||||
if (file.empty() || !line) return false;
|
||||
client->setListLocation(file.data(), line - 1, false);
|
||||
|
||||
@@ -287,11 +287,11 @@ bool CmdMachine::onClient(DebuggerClient *client) {
|
||||
|
||||
bool CmdMachine::onServer(DebuggerProxy *proxy) {
|
||||
if (m_body == "rpc") {
|
||||
String host = m_rpcConfig["host"].toString();
|
||||
String host = m_rpcConfig[s_host].toString();
|
||||
if (host.empty()) {
|
||||
register_intercept("", false, uninit_null());
|
||||
} else {
|
||||
int port = m_rpcConfig["port"].toInt32();
|
||||
int port = m_rpcConfig[s_port].toInt32();
|
||||
LibEventHttpClient::SetCache(host.data(), port, 1);
|
||||
register_intercept("", "fb_rpc_intercept_handler", m_rpcConfig);
|
||||
}
|
||||
|
||||
@@ -1156,17 +1156,19 @@ String DebuggerClient::getPrintString() {
|
||||
return s;
|
||||
}
|
||||
|
||||
static const StaticString s_output_type("output_type");
|
||||
static const StaticString s_file("file");
|
||||
static const StaticString s_line_no("line_no");
|
||||
static const StaticString s_watch_values("watch_values");
|
||||
static const StaticString s_stacktrace("stacktrace");
|
||||
static const StaticString s_frame("frame");
|
||||
static const StaticString s_values("values");
|
||||
static const StaticString s_text("text");
|
||||
static const StaticString s_invalid("invalid");
|
||||
static const StaticString s_cmd("cmd");
|
||||
static const StaticString s_code_loc("code_loc");
|
||||
static const StaticString
|
||||
s_output_type("output_type"),
|
||||
s_file("file"),
|
||||
s_line("line"),
|
||||
s_line_no("line_no"),
|
||||
s_watch_values("watch_values"),
|
||||
s_stacktrace("stacktrace"),
|
||||
s_frame("frame"),
|
||||
s_values("values"),
|
||||
s_text("text"),
|
||||
s_invalid("invalid"),
|
||||
s_cmd("cmd"),
|
||||
s_code_loc("code_loc");
|
||||
|
||||
Array DebuggerClient::getOutputArray() {
|
||||
TRACE(2, "DebuggerClient::getOutputArray\n");
|
||||
@@ -2074,8 +2076,8 @@ void DebuggerClient::moveToFrame(int index, bool display /* = true */) {
|
||||
}
|
||||
CArrRef frame = m_stacktrace[m_frame];
|
||||
if (!frame.isNull()) {
|
||||
String file = frame["file"];
|
||||
int line = frame["line"].toInt32();
|
||||
String file = frame[s_file];
|
||||
int line = frame[s_line].toInt32();
|
||||
if (!file.empty() && line) {
|
||||
if (m_frame == 0) {
|
||||
m_listFile.clear();
|
||||
@@ -2091,11 +2093,11 @@ void DebuggerClient::moveToFrame(int index, bool display /* = true */) {
|
||||
}
|
||||
}
|
||||
|
||||
static const StaticString s_args("args");
|
||||
static const StaticString s_namespace("namespace");
|
||||
static const StaticString s_class("class");
|
||||
static const StaticString s_function("function");
|
||||
static const StaticString s_line("line");
|
||||
static const StaticString
|
||||
s_args("args"),
|
||||
s_namespace("namespace"),
|
||||
s_class("class"),
|
||||
s_function("function");
|
||||
|
||||
void DebuggerClient::printFrame(int index, CArrRef frame) {
|
||||
TRACE(2, "DebuggerClient::printFrame\n");
|
||||
|
||||
@@ -30,14 +30,16 @@
|
||||
namespace HPHP {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static const StaticString s_padding_top("padding_top");
|
||||
static const StaticString s_padding_right("padding_right");
|
||||
static const StaticString s_padding_bottom("padding_bottom");
|
||||
static const StaticString s_padding_left("padding_left");
|
||||
static const StaticString s_width("width");
|
||||
static const StaticString s_height("height");
|
||||
static const StaticString s_flush_left("flush_left");
|
||||
static const StaticString s_flush_right("flush_right");
|
||||
static const StaticString
|
||||
s_padding_top("padding_top"),
|
||||
s_padding_right("padding_right"),
|
||||
s_padding_bottom("padding_bottom"),
|
||||
s_padding_left("padding_left"),
|
||||
s_width("width"),
|
||||
s_height("height"),
|
||||
s_flush_left("flush_left"),
|
||||
s_flush_right("flush_right"),
|
||||
s_id("id");
|
||||
|
||||
namespace ImageSprite {
|
||||
|
||||
@@ -611,11 +613,11 @@ Object c_ImageSprite::t_loadimages(bool block /* = false */) {
|
||||
std::vector<ImageSprite::Block*>, \
|
||||
ImageSprite::BlockAreaComparator>
|
||||
|
||||
static const StaticString s_x("x");
|
||||
static const StaticString s_y("y");
|
||||
static const StaticString s_id("id");
|
||||
static const StaticString s_images("images");
|
||||
static const StaticString s_sprite("sprite");
|
||||
static const StaticString
|
||||
s_x("x"),
|
||||
s_y("y"),
|
||||
s_images("images"),
|
||||
s_sprite("sprite");
|
||||
|
||||
void c_ImageSprite::map() {
|
||||
if (same(m_current, true)) {
|
||||
@@ -1107,7 +1109,7 @@ String c_ImageSprite::t_css(CStrRef css_namespace,
|
||||
output += String("/* File: ") + path + " */\n";
|
||||
}
|
||||
|
||||
output += String(".") + css_namespace + "#i" + attr["id"] + "{";
|
||||
output += String(".") + css_namespace + "#i" + attr[s_id] + "{";
|
||||
if (verbose) output += "\n ";
|
||||
|
||||
output += "background-position:";
|
||||
|
||||
@@ -1354,10 +1354,12 @@ static Variant to_zval_object_ex(encodeTypePtr type, xmlNodePtr data,
|
||||
String clsname;
|
||||
if (pce) {
|
||||
ce = pce;
|
||||
} else if (!SOAP_GLOBAL(classmap).empty() && !type->type_str.empty() &&
|
||||
SOAP_GLOBAL(classmap).exists(String(type->type_str))) {
|
||||
clsname = SOAP_GLOBAL(classmap)[type->type_str.c_str()].toString();
|
||||
ce = clsname.data();
|
||||
} else if (!SOAP_GLOBAL(classmap).empty() && !type->type_str.empty()) {
|
||||
String type_str(type->type_str);
|
||||
if (SOAP_GLOBAL(classmap).exists(type_str)) {
|
||||
clsname = SOAP_GLOBAL(classmap)[type_str].toString();
|
||||
ce = clsname.data();
|
||||
}
|
||||
}
|
||||
|
||||
Variant ret;
|
||||
|
||||
@@ -257,22 +257,22 @@ bool TestCppBase::TestArray() {
|
||||
arr = Array::Create("name", 1);
|
||||
VERIFY(!arr.empty()); VERIFY(arr.size() == 1); VERIFY(arr.length() == 1);
|
||||
VERIFY(!arr.isNull());
|
||||
VERIFY((int)arr["name"] == 1);
|
||||
VS(arr, Array(ArrayInit(1).set("name", 1).create()));
|
||||
VERIFY((int)arr[s_name] == 1);
|
||||
VS(arr, Array(ArrayInit(1).set(s_name, 1).create()));
|
||||
|
||||
arr = Array::Create("name", "test");
|
||||
arr = Array::Create(s_name, "test");
|
||||
VERIFY(!arr.empty()); VERIFY(arr.size() == 1); VERIFY(arr.length() == 1);
|
||||
VERIFY(!arr.isNull());
|
||||
VERIFY(arr["name"] == "test");
|
||||
VS(arr, Array(ArrayInit(1).set("name", "test").create()));
|
||||
VERIFY(arr[s_name] == "test");
|
||||
VS(arr, Array(ArrayInit(1).set(s_name, "test").create()));
|
||||
|
||||
arrCopy = arr;
|
||||
arr = Array::Create("name", arr);
|
||||
arr = Array::Create(s_name, arr);
|
||||
VERIFY(!arr.empty()); VERIFY(arr.size() == 1); VERIFY(arr.length() == 1);
|
||||
VERIFY(!arr.isNull());
|
||||
VS(arr["name"], arrCopy);
|
||||
VERIFY(arr["name"].toArray().size() == 1);
|
||||
VS(arr, Array(ArrayInit(1).set("name", arrCopy).create()));
|
||||
VS(arr[s_name], arrCopy);
|
||||
VERIFY(arr[s_name].toArray().size() == 1);
|
||||
VS(arr, Array(ArrayInit(1).set(s_name, arrCopy).create()));
|
||||
}
|
||||
|
||||
// iteration
|
||||
|
||||
@@ -154,18 +154,25 @@ bool TestExtDatetime::test_date_format() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
static const StaticString
|
||||
s_warning_count("warning_count"),
|
||||
s_error_count("error_count"),
|
||||
s_warnings("warnings"),
|
||||
s_errors("errors"),
|
||||
s_sec("sec");
|
||||
|
||||
bool TestExtDatetime::test_date_get_last_errors() {
|
||||
Object dt = f_date_create("asdfasdf");
|
||||
Array errs = f_date_get_last_errors();
|
||||
VS(errs.size(), 4);
|
||||
|
||||
VS(errs["warning_count"], 1);
|
||||
Array err_warnings = errs["warnings"];
|
||||
VS(errs[s_warning_count], 1);
|
||||
Array err_warnings = errs[s_warnings];
|
||||
VS(err_warnings.size(), 1);
|
||||
VS(err_warnings[6], "Double timezone specification");
|
||||
|
||||
VS(errs["error_count"], 1);
|
||||
Array err_errors = errs["errors"];
|
||||
VS(errs[s_error_count], 1);
|
||||
Array err_errors = errs[s_errors];
|
||||
VS(err_errors.size(), 1);
|
||||
VS(err_errors[0], "The timezone could not be found in the database");
|
||||
|
||||
@@ -405,7 +412,7 @@ bool TestExtDatetime::test_getdate() {
|
||||
bool TestExtDatetime::test_gettimeofday() {
|
||||
Array ret = f_gettimeofday();
|
||||
VS(ret.size(), 4);
|
||||
VERIFY(more(ret["sec"], 1073504408));
|
||||
VERIFY(more(ret[s_sec], 1073504408));
|
||||
|
||||
VERIFY(more(f_gettimeofday(true), 1073504408.23910));
|
||||
return Count(true);
|
||||
@@ -638,15 +645,21 @@ bool TestExtDatetime::test_timezone_identifiers_list() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
static const StaticString
|
||||
s_country_code("country_code"),
|
||||
s_latitude("latitude"),
|
||||
s_longitude("longitude"),
|
||||
s_comments("comments");
|
||||
|
||||
bool TestExtDatetime::test_timezone_location_get() {
|
||||
TIMELIB_TEST_UNIMPL(2011.1,
|
||||
Object tz = f_timezone_open("Europe/Prague");
|
||||
Array loc = f_timezone_location_get(tz);
|
||||
VS(loc.size(), 4);
|
||||
VS(loc["country_code"].toString(), "CZ");
|
||||
VS((int)(loc["latitude"].toDoubleVal() * 100), 5008);
|
||||
VS((int)(loc["longitude"].toDoubleVal() * 100), 1443);
|
||||
VS(loc["comments"].toString(), "");
|
||||
VS(loc[s_country_code].toString(), "CZ");
|
||||
VS((int)(loc[s_latitude].toDoubleVal() * 100), 5008);
|
||||
VS((int)(loc[s_longitude].toDoubleVal() * 100), 1443);
|
||||
VS(loc[s_comments].toString(), "");
|
||||
return Count(true);
|
||||
);
|
||||
}
|
||||
|
||||
@@ -920,11 +920,14 @@ bool TestExtFile::test_chroot() {
|
||||
}
|
||||
|
||||
bool TestExtFile::test_dir() {
|
||||
static const StaticString s_handle("handle");
|
||||
static const StaticString s_test_ext_file_txt("test_ext_file.txt");
|
||||
static const StaticString s_path("path");
|
||||
Variant d = f_dir("test");
|
||||
VS(d.toArray()["path"], "test");
|
||||
VS(d.toArray()[s_path], "test");
|
||||
Variant entry;
|
||||
bool seen = false;
|
||||
while (!same(entry = f_readdir(d.toArray()["handle"]), false)) {
|
||||
while (!same(entry = f_readdir(d.toArray()[s_handle]), false)) {
|
||||
if (same(entry, "test_ext_file.txt")) {
|
||||
seen = true;
|
||||
}
|
||||
|
||||
@@ -49,8 +49,9 @@ bool TestExtFunction::RunTests(const std::string &which) {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TestExtFunction::test_get_defined_functions() {
|
||||
static const StaticString s_internal("internal");
|
||||
Array funcs = f_get_defined_functions();
|
||||
VERIFY(!funcs["internal"][0].toString().empty());
|
||||
VERIFY(!funcs[s_internal][0].toString().empty());
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -177,8 +177,9 @@ bool TestExtImagesprite::test_clear() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
static const StaticString s_width("width");
|
||||
static const StaticString s_height("height");
|
||||
static const StaticString
|
||||
s_width("width"),
|
||||
s_height("height");
|
||||
|
||||
bool TestExtImagesprite::test_loadDims() {
|
||||
sprite->t_addfile("test/images/php.gif");
|
||||
@@ -254,25 +255,21 @@ bool TestExtImagesprite::test_loadImages() {
|
||||
return Count(true);
|
||||
}
|
||||
bool TestExtImagesprite::test_map() {
|
||||
sprite->t_addfile("test/images/php.gif");
|
||||
static const StaticString
|
||||
s_images("images"),
|
||||
s_width("width"),
|
||||
s_height("height"),
|
||||
s_x("x"),
|
||||
s_y("y"),
|
||||
testpath("test/images/php.gif");
|
||||
|
||||
sprite->t_addfile(testpath);
|
||||
VS(sprite->m_current, false);
|
||||
Array map = sprite->t_mapping();
|
||||
VS(
|
||||
map["images"].toArray()["test/images/php.gif"].toArray()
|
||||
["width"].toInt32(),
|
||||
120);
|
||||
VS(
|
||||
map["images"].toArray()["test/images/php.gif"].toArray()
|
||||
["height"].toInt32(),
|
||||
67);
|
||||
VS(
|
||||
map["images"].toArray()["test/images/php.gif"].toArray()
|
||||
["x"].toInt32(),
|
||||
0);
|
||||
VS(
|
||||
map["images"].toArray()["test/images/php.gif"].toArray()
|
||||
["y"].toInt32(),
|
||||
0);
|
||||
VS(map[s_images].toArray()[testpath].toArray()[s_width].toInt32(), 120);
|
||||
VS(map[s_images].toArray()[testpath].toArray()[s_height].toInt32(), 67);
|
||||
VS(map[s_images].toArray()[testpath].toArray()[s_x].toInt32(), 0);
|
||||
VS(map[s_images].toArray()[testpath].toArray()[s_y].toInt32(), 0);
|
||||
VS(map[s_width].toInt32(), 121);
|
||||
VS(map[s_height].toInt32(), 68);
|
||||
VS(sprite->m_current, true);
|
||||
@@ -281,26 +278,15 @@ bool TestExtImagesprite::test_map() {
|
||||
Array dims = Array::Create();
|
||||
dims.set(s_width, 1);
|
||||
dims.set(s_height, 1);
|
||||
sprite->t_addfile("test/images/php.gif", dims);
|
||||
sprite->t_addfile(testpath, dims);
|
||||
VS(sprite->m_current, false);
|
||||
map = sprite->t_mapping();
|
||||
VS(
|
||||
map["images"].toArray()["test/images/php.gif"].toArray()
|
||||
["width"].toInt32(),
|
||||
1);
|
||||
VS(
|
||||
map["images"].toArray()["test/images/php.gif"].toArray()
|
||||
["height"].toInt32(),
|
||||
1);
|
||||
VS(
|
||||
map["images"].toArray()["test/images/php.gif"].toArray()
|
||||
["x"].toInt32(), 0);
|
||||
VS(
|
||||
map["images"].toArray()["test/images/php.gif"].toArray()
|
||||
["y"].toInt32(),
|
||||
0);
|
||||
VS(map["width"].toInt32(), 2);
|
||||
VS(map["height"].toInt32(), 2);
|
||||
VS(map[s_images].toArray()[testpath].toArray()[s_width].toInt32(), 1);
|
||||
VS(map[s_images].toArray()[testpath].toArray()[s_height].toInt32(), 1);
|
||||
VS(map[s_images].toArray()[testpath].toArray()[s_x].toInt32(), 0);
|
||||
VS(map[s_images].toArray()[testpath].toArray()[s_y].toInt32(), 0);
|
||||
VS(map[s_width].toInt32(), 2);
|
||||
VS(map[s_height].toInt32(), 2);
|
||||
VS(sprite->m_current, true);
|
||||
|
||||
return Count(true);
|
||||
|
||||
@@ -52,6 +52,7 @@ bool TestExtIpc::RunTests(const std::string &which) {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TestExtIpc::test_message_queue() {
|
||||
static const StaticString s_msg_qnum("msg_qnum");
|
||||
char filename[64];
|
||||
strcpy(filename, "/tmp/XXXXXX");
|
||||
close(mkstemp(filename));
|
||||
@@ -82,7 +83,7 @@ bool TestExtIpc::test_message_queue() {
|
||||
VERIFY(same(msg, "ok"));
|
||||
|
||||
Array ret = f_msg_stat_queue(queue);
|
||||
VS(ret["msg_qnum"], 0);
|
||||
VS(ret[s_msg_qnum], 0);
|
||||
f_msg_set_queue(queue, CREATE_MAP1("msg_perm.mode", 0666));
|
||||
|
||||
f_msg_remove_queue(queue);
|
||||
|
||||
@@ -324,19 +324,20 @@ bool TestExtOpenssl::test_openssl_pkey_free() {
|
||||
}
|
||||
|
||||
bool TestExtOpenssl::test_openssl_pkey_get_details() {
|
||||
static const StaticString s_bits("bits");
|
||||
{
|
||||
Variant fkey = f_file_get_contents("test/test_public.pem");
|
||||
Variant k = f_openssl_pkey_get_public(fkey);
|
||||
VERIFY(!same(k, false));
|
||||
VERIFY(!k.isNull());
|
||||
VS(f_openssl_pkey_get_details(k)["bits"], 1024);
|
||||
VS(f_openssl_pkey_get_details(k)[s_bits], 1024);
|
||||
}
|
||||
{
|
||||
Variant fkey = f_file_get_contents("test/test_private.pem");
|
||||
Variant k = f_openssl_pkey_get_private(fkey);
|
||||
VERIFY(!same(k, false));
|
||||
VERIFY(!k.isNull());
|
||||
VS(f_openssl_pkey_get_details(k)["bits"], 512);
|
||||
VS(f_openssl_pkey_get_details(k)[s_bits], 512);
|
||||
}
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
@@ -362,6 +362,15 @@ bool TestExtProcess::test_proc_close() {
|
||||
}
|
||||
|
||||
bool TestExtProcess::test_proc_get_status() {
|
||||
static const StaticString
|
||||
s_command("command"),
|
||||
s_pid("pid"),
|
||||
s_running("running"),
|
||||
s_signaled("signaled"),
|
||||
s_exitcode("exitcode"),
|
||||
s_termsig("termsig"),
|
||||
s_stopsig("stopsig");
|
||||
|
||||
Array descriptorspec =
|
||||
CREATE_MAP3(0, CREATE_VECTOR2("pipe", "r"),
|
||||
1, CREATE_VECTOR2("pipe", "w"),
|
||||
@@ -370,13 +379,13 @@ bool TestExtProcess::test_proc_get_status() {
|
||||
Variant process = f_proc_open(php_path, descriptorspec, ref(pipes));
|
||||
VERIFY(!same(process, false));
|
||||
Array ret = f_proc_get_status(process.toObject());
|
||||
VS(ret["command"], php_path);
|
||||
VERIFY(ret["pid"].toInt32() > 0);
|
||||
VERIFY(ret["running"]);
|
||||
VERIFY(!ret["signaled"]);
|
||||
VS(ret["exitcode"], -1);
|
||||
VS(ret["termsig"], 0);
|
||||
VS(ret["stopsig"], 0);
|
||||
VS(ret[s_command], php_path);
|
||||
VERIFY(ret[s_pid].toInt32() > 0);
|
||||
VERIFY(ret[s_running]);
|
||||
VERIFY(!ret[s_signaled]);
|
||||
VS(ret[s_exitcode], -1);
|
||||
VS(ret[s_termsig], 0);
|
||||
VS(ret[s_stopsig], 0);
|
||||
|
||||
{
|
||||
File *f = pipes[0].toObject().getTyped<File>();
|
||||
|
||||
@@ -115,9 +115,12 @@ bool TestExtSqlite3::test_sqlite3() {
|
||||
|
||||
db->t_close();
|
||||
|
||||
static const StaticString s_versionString("versionString");
|
||||
static const StaticString s_versionNumber("versionNumber");
|
||||
|
||||
// Since minor version can change frequently, just test the major version
|
||||
VS(db->t_version()["versionString"][0], "3");
|
||||
VERIFY((int64_t)db->t_version()["versionNumber"] >
|
||||
VS(db->t_version()[s_versionString][0], "3");
|
||||
VERIFY((int64_t)db->t_version()[s_versionNumber] >
|
||||
(int64_t)3000000);
|
||||
f_unlink(":memory:test");
|
||||
return Count(true);
|
||||
|
||||
@@ -59,23 +59,29 @@ bool TestExtUrl::test_base64_encode() {
|
||||
}
|
||||
|
||||
bool TestExtUrl::test_get_headers() {
|
||||
static const StaticString s_Connection("Connection");
|
||||
String url = "http://www.example.com";
|
||||
Array ret = f_get_headers(url);
|
||||
//VS(ret[0], "HTTP/1.1 200 OK");
|
||||
VERIFY(ret.size() > 0);
|
||||
ret = f_get_headers(url, 1);
|
||||
//VS(ret["Connection"], "close");
|
||||
VERIFY(!ret["Connection"].toString().empty());
|
||||
//VS(ret[s_Connection], "close");
|
||||
VERIFY(!ret[s_Connection].toString().empty());
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtUrl::test_get_meta_tags() {
|
||||
static const StaticString
|
||||
s_author("author"),
|
||||
s_keywords("keywords"),
|
||||
s_description("description"),
|
||||
s_geo_position("geo_position");
|
||||
Array ret = f_get_meta_tags("test/test_get_meta_tags.html");
|
||||
VS(ret.size(), 4);
|
||||
VS(ret["author"], "name");
|
||||
VS(ret["keywords"], "php documentation");
|
||||
VS(ret["description"], "a php manual");
|
||||
VS(ret["geo_position"], "49.33;-86.59");
|
||||
VS(ret[s_author], "name");
|
||||
VS(ret[s_keywords], "php documentation");
|
||||
VS(ret[s_description], "a php manual");
|
||||
VS(ret[s_geo_position], "49.33;-86.59");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
using namespace HPHP;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
static const StaticString
|
||||
s_result("result"),
|
||||
s_runId("runId");
|
||||
|
||||
bool TestLogger::initializeRun() {
|
||||
if (!doLog())
|
||||
@@ -51,12 +54,11 @@ bool TestLogger::initializeRun() {
|
||||
|
||||
Array response = postData(CREATE_MAP1("runData", dataArr));
|
||||
|
||||
if (!response["result"]) {
|
||||
if (!response[s_result]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
run_id = response["result"]["runId"];
|
||||
|
||||
run_id = response[s_result][s_runId];
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -70,7 +72,7 @@ bool TestLogger::finishRun() {
|
||||
"runData", CREATE_MAP1("stillRunning", false));
|
||||
|
||||
Array response = postData(data);
|
||||
if (response["result"])
|
||||
if (response[s_result])
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@@ -86,7 +88,7 @@ bool TestLogger::logTest(Array test) {
|
||||
"tests", CREATE_VECTOR1(test));
|
||||
|
||||
Array response = postData(data);
|
||||
if (response["result"])
|
||||
if (response[s_result])
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário