From e6052a08c176d1245708c76554d673fa20c30328 Mon Sep 17 00:00:00 2001 From: Jordan DeLong Date: Fri, 14 Jun 2013 20:33:03 -0700 Subject: [PATCH] Move TestExtXml{,Reader,Writer} to php --- hphp/test/ext/test_ext.h | 3 - hphp/test/ext/test_ext_xml.cpp | 190 ------------- hphp/test/ext/test_ext_xml.h | 58 ---- hphp/test/ext/test_ext_xmlreader.cpp | 46 ---- hphp/test/ext/test_ext_xmlreader.h | 36 --- hphp/test/ext/test_ext_xmlwriter.cpp | 291 -------------------- hphp/test/ext/test_ext_xmlwriter.h | 77 ------ hphp/test/slow/ext_xml/xml.php | 23 ++ hphp/test/slow/ext_xml/xml.php.expect | 43 +++ hphp/test/slow/ext_xml/xmlreader.php | 14 + hphp/test/slow/ext_xml/xmlreader.php.expect | 3 + hphp/test/slow/ext_xml/xmlwriter.php | 22 ++ hphp/test/slow/ext_xml/xmlwriter.php.expect | 9 + 13 files changed, 114 insertions(+), 701 deletions(-) delete mode 100644 hphp/test/ext/test_ext_xml.cpp delete mode 100644 hphp/test/ext/test_ext_xml.h delete mode 100644 hphp/test/ext/test_ext_xmlreader.cpp delete mode 100644 hphp/test/ext/test_ext_xmlreader.h delete mode 100644 hphp/test/ext/test_ext_xmlwriter.cpp delete mode 100644 hphp/test/ext/test_ext_xmlwriter.h create mode 100644 hphp/test/slow/ext_xml/xml.php create mode 100644 hphp/test/slow/ext_xml/xml.php.expect create mode 100644 hphp/test/slow/ext_xml/xmlreader.php create mode 100644 hphp/test/slow/ext_xml/xmlreader.php.expect create mode 100644 hphp/test/slow/ext_xml/xmlwriter.php create mode 100644 hphp/test/slow/ext_xml/xmlwriter.php.expect diff --git a/hphp/test/ext/test_ext.h b/hphp/test/ext/test_ext.h index f78c576a0..caff1ce20 100644 --- a/hphp/test/ext/test_ext.h +++ b/hphp/test/ext/test_ext.h @@ -71,9 +71,6 @@ #include "hphp/test/ext/test_ext_string.h" #include "hphp/test/ext/test_ext_url.h" #include "hphp/test/ext/test_ext_variable.h" -#include "hphp/test/ext/test_ext_xml.h" -#include "hphp/test/ext/test_ext_xmlreader.h" -#include "hphp/test/ext/test_ext_xmlwriter.h" #include "hphp/test/ext/test_ext_zlib.h" #endif // incl_EXT_LIST_TEST_EXT_H_ diff --git a/hphp/test/ext/test_ext_xml.cpp b/hphp/test/ext/test_ext_xml.cpp deleted file mode 100644 index cfbfae674..000000000 --- a/hphp/test/ext/test_ext_xml.cpp +++ /dev/null @@ -1,190 +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_xml.h" -#include "hphp/runtime/ext/ext_xml.h" - -/////////////////////////////////////////////////////////////////////////////// - -bool TestExtXml::RunTests(const std::string &which) { - bool ret = true; - - RUN_TEST(test_xml_parser_create); - RUN_TEST(test_xml_parser_free); - RUN_TEST(test_xml_parse); - RUN_TEST(test_xml_parse_into_struct); - RUN_TEST(test_xml_parser_create_ns); - RUN_TEST(test_xml_parser_get_option); - RUN_TEST(test_xml_parser_set_option); - RUN_TEST(test_xml_set_character_data_handler); - RUN_TEST(test_xml_set_default_handler); - RUN_TEST(test_xml_set_element_handler); - RUN_TEST(test_xml_set_processing_instruction_handler); - RUN_TEST(test_xml_set_start_namespace_decl_handler); - RUN_TEST(test_xml_set_end_namespace_decl_handler); - RUN_TEST(test_xml_set_unparsed_entity_decl_handler); - RUN_TEST(test_xml_set_external_entity_ref_handler); - RUN_TEST(test_xml_set_notation_decl_handler); - RUN_TEST(test_xml_set_object); - RUN_TEST(test_xml_get_current_byte_index); - RUN_TEST(test_xml_get_current_column_number); - RUN_TEST(test_xml_get_current_line_number); - RUN_TEST(test_xml_get_error_code); - RUN_TEST(test_xml_error_string); - RUN_TEST(test_utf8_decode); - RUN_TEST(test_utf8_encode); - - return ret; -} - -/////////////////////////////////////////////////////////////////////////////// - -bool TestExtXml::test_xml_parser_create() { - //VCB("simple&note"; - Variant p = f_xml_parser_create(); - Variant vals, index; - f_xml_parse_into_struct(p, simple, ref(vals), ref(index)); - f_xml_parser_free(p); - VS(f_print_r(index.rvalAt(String("PARA")),1), - "Array\n(\n [0] => 0\n [1] => 2\n)\n"); - VS(f_print_r(index.rvalAt(String("NOTE")),1), - "Array\n(\n [0] => 1\n)\n"); - VS(f_print_r(vals.rvalAt(0),1), - "Array\n(\n [tag] => PARA\n [type] => open\n [level] => 1\n)\n"); - VS(f_print_r(vals.rvalAt(1),1), - "Array\n(\n [tag] => NOTE\n [type] => complete\n [level] => 2\n" - " [attributes] => Array\n (\n [ATTRIB1] => foo\n" - " )\n\n [value] => simple¬e\n)\n"); - VS(f_print_r(vals.rvalAt(2),1), - "Array\n(\n [tag] => PARA\n [type] => close\n [level] => 1\n)\n"); - return true; -} - -bool TestExtXml::test_xml_parser_create_ns() { - //VCB(">>>>> Generated by idl.php. Do NOT modify. <<<<<< - -#include "hphp/test/ext/test_cpp_ext.h" - -/////////////////////////////////////////////////////////////////////////////// - -class TestExtXml : public TestCppExt { - public: - virtual bool RunTests(const std::string &which); - - bool test_xml_parser_create(); - bool test_xml_parser_free(); - bool test_xml_parse(); - bool test_xml_parse_into_struct(); - bool test_xml_parser_create_ns(); - bool test_xml_parser_get_option(); - bool test_xml_parser_set_option(); - bool test_xml_set_character_data_handler(); - bool test_xml_set_default_handler(); - bool test_xml_set_element_handler(); - bool test_xml_set_processing_instruction_handler(); - bool test_xml_set_start_namespace_decl_handler(); - bool test_xml_set_end_namespace_decl_handler(); - bool test_xml_set_unparsed_entity_decl_handler(); - bool test_xml_set_external_entity_ref_handler(); - bool test_xml_set_notation_decl_handler(); - bool test_xml_set_object(); - bool test_xml_get_current_byte_index(); - bool test_xml_get_current_column_number(); - bool test_xml_get_current_line_number(); - bool test_xml_get_error_code(); - bool test_xml_error_string(); - bool test_utf8_decode(); - bool test_utf8_encode(); -}; - -/////////////////////////////////////////////////////////////////////////////// - -#endif // incl_HPHP_TEST_EXT_XML_H_ diff --git a/hphp/test/ext/test_ext_xmlreader.cpp b/hphp/test/ext/test_ext_xmlreader.cpp deleted file mode 100644 index 3ecc0570b..000000000 --- a/hphp/test/ext/test_ext_xmlreader.cpp +++ /dev/null @@ -1,46 +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_xmlreader.h" -#include "hphp/runtime/ext/ext_xmlreader.h" - -IMPLEMENT_SEP_EXTENSION_TEST(Xmlreader); -/////////////////////////////////////////////////////////////////////////////// - -bool TestExtXmlreader::RunTests(const std::string &which) { - bool ret = true; - - RUN_TEST(test_XMLReader); - RUN_TEST(test_XMLReader_getattribute); - - return ret; -} - -/////////////////////////////////////////////////////////////////////////////// - -bool TestExtXmlreader::test_XMLReader() { - return Count(true); -} - -bool TestExtXmlreader::test_XMLReader_getattribute() { - p_XMLReader reader(NEWOBJ(c_XMLReader)()); - reader->t_xml(""); - reader->t_read(); - VS(reader->t_getattribute("x"), uninit_null()); - VS(reader->t_getattribute("y"), String("")); - VS(reader->t_getattribute("z"), String("1")); - return Count(true); -} diff --git a/hphp/test/ext/test_ext_xmlreader.h b/hphp/test/ext/test_ext_xmlreader.h deleted file mode 100644 index 60177ac9d..000000000 --- a/hphp/test/ext/test_ext_xmlreader.h +++ /dev/null @@ -1,36 +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_XMLREADER_H_ -#define incl_HPHP_TEST_EXT_XMLREADER_H_ - -// >>>>>> Generated by idl.php. Do NOT modify. <<<<<< - -#include "hphp/test/ext/test_cpp_ext.h" - -/////////////////////////////////////////////////////////////////////////////// - -class TestExtXmlreader : public TestCppExt { - public: - virtual bool RunTests(const std::string &which); - - bool test_XMLReader(); - bool test_XMLReader_getattribute(); -}; - -/////////////////////////////////////////////////////////////////////////////// - -#endif // incl_HPHP_TEST_EXT_XMLREADER_H_ diff --git a/hphp/test/ext/test_ext_xmlwriter.cpp b/hphp/test/ext/test_ext_xmlwriter.cpp deleted file mode 100644 index 169eec399..000000000 --- a/hphp/test/ext/test_ext_xmlwriter.cpp +++ /dev/null @@ -1,291 +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_xmlwriter.h" -#include "hphp/runtime/ext/ext_xmlwriter.h" - -/////////////////////////////////////////////////////////////////////////////// - -bool TestExtXmlwriter::RunTests(const std::string &which) { - bool ret = true; - - RUN_TEST(test_xmlwriter_open_memory); - RUN_TEST(test_xmlwriter_open_uri); - RUN_TEST(test_xmlwriter_set_indent_string); - RUN_TEST(test_xmlwriter_set_indent); - RUN_TEST(test_xmlwriter_start_document); - RUN_TEST(test_xmlwriter_start_element); - RUN_TEST(test_xmlwriter_start_element_ns); - RUN_TEST(test_xmlwriter_write_element_ns); - RUN_TEST(test_xmlwriter_write_element); - RUN_TEST(test_xmlwriter_end_element); - RUN_TEST(test_xmlwriter_full_end_element); - RUN_TEST(test_xmlwriter_start_attribute_ns); - RUN_TEST(test_xmlwriter_start_attribute); - RUN_TEST(test_xmlwriter_write_attribute_ns); - RUN_TEST(test_xmlwriter_write_attribute); - RUN_TEST(test_xmlwriter_end_attribute); - RUN_TEST(test_xmlwriter_start_cdata); - RUN_TEST(test_xmlwriter_write_cdata); - RUN_TEST(test_xmlwriter_end_cdata); - RUN_TEST(test_xmlwriter_start_comment); - RUN_TEST(test_xmlwriter_write_comment); - RUN_TEST(test_xmlwriter_end_comment); - RUN_TEST(test_xmlwriter_end_document); - RUN_TEST(test_xmlwriter_start_pi); - RUN_TEST(test_xmlwriter_write_pi); - RUN_TEST(test_xmlwriter_end_pi); - RUN_TEST(test_xmlwriter_text); - RUN_TEST(test_xmlwriter_write_raw); - RUN_TEST(test_xmlwriter_start_dtd); - RUN_TEST(test_xmlwriter_write_dtd); - RUN_TEST(test_xmlwriter_start_dtd_element); - RUN_TEST(test_xmlwriter_write_dtd_element); - RUN_TEST(test_xmlwriter_end_dtd_element); - RUN_TEST(test_xmlwriter_start_dtd_attlist); - RUN_TEST(test_xmlwriter_write_dtd_attlist); - RUN_TEST(test_xmlwriter_end_dtd_attlist); - RUN_TEST(test_xmlwriter_start_dtd_entity); - RUN_TEST(test_xmlwriter_write_dtd_entity); - RUN_TEST(test_xmlwriter_end_dtd_entity); - RUN_TEST(test_xmlwriter_end_dtd); - RUN_TEST(test_xmlwriter_flush); - RUN_TEST(test_xmlwriter_output_memory); - - return ret; -} - -/////////////////////////////////////////////////////////////////////////////// - -bool TestExtXmlwriter::test_xmlwriter_open_memory() { - Variant xml = f_xmlwriter_open_memory(); - VERIFY(f_xmlwriter_set_indent(xml, true)); - VERIFY(f_xmlwriter_set_indent_string(xml, " ")); - VERIFY(f_xmlwriter_start_document(xml, "1.0", "utf-8")); - VERIFY(f_xmlwriter_start_element(xml, "node")); - VERIFY(f_xmlwriter_write_attribute(xml, "name", "value")); - VERIFY(f_xmlwriter_write_element(xml, "subnode", "some text")); - VERIFY(f_xmlwriter_end_element(xml)); - VERIFY(f_xmlwriter_end_document(xml)); - String out = f_xmlwriter_flush(xml); - VS(out, "\n\n some text\n\n"); - return Count(true); -} - -bool TestExtXmlwriter::test_xmlwriter_open_uri() { - //VCB(">>>>> Generated by idl.php. Do NOT modify. <<<<<< - -#include "hphp/test/ext/test_cpp_ext.h" - -/////////////////////////////////////////////////////////////////////////////// - -class TestExtXmlwriter : public TestCppExt { - public: - virtual bool RunTests(const std::string &which); - - bool test_xmlwriter_open_memory(); - bool test_xmlwriter_open_uri(); - bool test_xmlwriter_set_indent_string(); - bool test_xmlwriter_set_indent(); - bool test_xmlwriter_start_document(); - bool test_xmlwriter_start_element(); - bool test_xmlwriter_start_element_ns(); - bool test_xmlwriter_write_element_ns(); - bool test_xmlwriter_write_element(); - bool test_xmlwriter_end_element(); - bool test_xmlwriter_full_end_element(); - bool test_xmlwriter_start_attribute_ns(); - bool test_xmlwriter_start_attribute(); - bool test_xmlwriter_write_attribute_ns(); - bool test_xmlwriter_write_attribute(); - bool test_xmlwriter_end_attribute(); - bool test_xmlwriter_start_cdata(); - bool test_xmlwriter_write_cdata(); - bool test_xmlwriter_end_cdata(); - bool test_xmlwriter_start_comment(); - bool test_xmlwriter_write_comment(); - bool test_xmlwriter_end_comment(); - bool test_xmlwriter_end_document(); - bool test_xmlwriter_start_pi(); - bool test_xmlwriter_write_pi(); - bool test_xmlwriter_end_pi(); - bool test_xmlwriter_text(); - bool test_xmlwriter_write_raw(); - bool test_xmlwriter_start_dtd(); - bool test_xmlwriter_write_dtd(); - bool test_xmlwriter_start_dtd_element(); - bool test_xmlwriter_write_dtd_element(); - bool test_xmlwriter_end_dtd_element(); - bool test_xmlwriter_start_dtd_attlist(); - bool test_xmlwriter_write_dtd_attlist(); - bool test_xmlwriter_end_dtd_attlist(); - bool test_xmlwriter_start_dtd_entity(); - bool test_xmlwriter_write_dtd_entity(); - bool test_xmlwriter_end_dtd_entity(); - bool test_xmlwriter_end_dtd(); - bool test_xmlwriter_flush(); - bool test_xmlwriter_output_memory(); - bool test_xmlwriter(); -}; - -/////////////////////////////////////////////////////////////////////////////// - -#endif // incl_HPHP_TEST_EXT_XMLWRITER_H_ diff --git a/hphp/test/slow/ext_xml/xml.php b/hphp/test/slow/ext_xml/xml.php new file mode 100644 index 000000000..74901bf24 --- /dev/null +++ b/hphp/test/slow/ext_xml/xml.php @@ -0,0 +1,23 @@ +simple&note"; +$p = xml_parser_create(); +xml_parse_into_struct($p, $simple, $vals, $index); +xml_parser_free($p); + +var_dump($index["PARA"]); +var_dump($index["NOTE"]); +var_dump($vals[0]); +var_dump($vals[1]); +var_dump($vals[2]); + + diff --git a/hphp/test/slow/ext_xml/xml.php.expect b/hphp/test/slow/ext_xml/xml.php.expect new file mode 100644 index 000000000..738a02097 --- /dev/null +++ b/hphp/test/slow/ext_xml/xml.php.expect @@ -0,0 +1,43 @@ +bool(true) +bool(true) +array(2) { + [0]=> + int(0) + [1]=> + int(2) +} +array(1) { + [0]=> + int(1) +} +array(3) { + ["tag"]=> + string(4) "PARA" + ["type"]=> + string(4) "open" + ["level"]=> + int(1) +} +array(5) { + ["tag"]=> + string(4) "NOTE" + ["type"]=> + string(8) "complete" + ["level"]=> + int(2) + ["attributes"]=> + array(1) { + ["ATTRIB1"]=> + string(3) "foo" + } + ["value"]=> + string(11) "simple¬e" +} +array(3) { + ["tag"]=> + string(4) "PARA" + ["type"]=> + string(5) "close" + ["level"]=> + int(1) +} diff --git a/hphp/test/slow/ext_xml/xmlreader.php b/hphp/test/slow/ext_xml/xmlreader.php new file mode 100644 index 000000000..3584fed9d --- /dev/null +++ b/hphp/test/slow/ext_xml/xmlreader.php @@ -0,0 +1,14 @@ +xml(""); +$reader->read(); +VS($reader->getattribute("x"), null); +VS($reader->getattribute("y"), ""); +VS($reader->getattribute("z"), "1"); diff --git a/hphp/test/slow/ext_xml/xmlreader.php.expect b/hphp/test/slow/ext_xml/xmlreader.php.expect new file mode 100644 index 000000000..14c72c273 --- /dev/null +++ b/hphp/test/slow/ext_xml/xmlreader.php.expect @@ -0,0 +1,3 @@ +bool(true) +bool(true) +bool(true) diff --git a/hphp/test/slow/ext_xml/xmlwriter.php b/hphp/test/slow/ext_xml/xmlwriter.php new file mode 100644 index 000000000..0a3270b5c --- /dev/null +++ b/hphp/test/slow/ext_xml/xmlwriter.php @@ -0,0 +1,22 @@ +\n\n some text\n\n"); diff --git a/hphp/test/slow/ext_xml/xmlwriter.php.expect b/hphp/test/slow/ext_xml/xmlwriter.php.expect new file mode 100644 index 000000000..53973d643 --- /dev/null +++ b/hphp/test/slow/ext_xml/xmlwriter.php.expect @@ -0,0 +1,9 @@ +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true)