Till Westmann has proposed merging lp:~zorba-coders/zorba/bug-919438 into lp:zorba.
Requested reviews: Matthias Brantner (matthias-brantner) Till Westmann (tillw) Related bugs: Bug #919438 in Zorba: "assertion failed in var_expr::remove_set_expr during shutdown" https://bugs.launchpad.net/zorba/+bug/919438 For more details, see: https://code.launchpad.net/~zorba-coders/zorba/bug-919438/+merge/93093 added a new unit test for the plan serializer -- https://code.launchpad.net/~zorba-coders/zorba/bug-919438/+merge/93093 Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'test/unit/CMakeLists.txt' --- test/unit/CMakeLists.txt 2012-02-02 09:56:52 +0000 +++ test/unit/CMakeLists.txt 2012-02-14 22:20:26 +0000 @@ -14,6 +14,7 @@ # create the testing file and list of tests CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/guestbook_main.xq ${CMAKE_CURRENT_BINARY_DIR}/guestbook_main.xq) +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mini_http.xq ${CMAKE_CURRENT_BINARY_DIR}/mini_http.xq) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/guestbook.xq ${CMAKE_CURRENT_BINARY_DIR}/guestbook.xq) #belongs to test cxx_api_changes.cpp === added file 'test/unit/mini_http.xq' --- test/unit/mini_http.xq 1970-01-01 00:00:00 +0000 +++ test/unit/mini_http.xq 2012-02-14 22:20:26 +0000 @@ -0,0 +1,40 @@ +declare namespace http = "http://www.28msec.com/modules/http"; + +declare namespace ann = "http://www.zorba-xquery.com/annotations"; + +declare variable $http:var := ""; + +declare %ann:sequential function http:set-header( + $name as xs:string, + $value as xs:string) +as xs:string? +{ + let $lc-name := fn:lower-case($name) + return + if ($lc-name eq "status" or + $lc-name eq "set-cookie" or + $lc-name eq "content-type") + then + fn:error( + xs:QName("http:invalid-header-name"), + concat($name, ": invalid header name") + ) + else + http:set-header-impl($name, $value) +}; + +(:~ + : <p>Set a HTTP header in the response.</p> + : + : <p> + :` + : @return The empty-sequence is returned. + :) +declare %fn:private %ann:sequential function http:set-header-impl( + $name as xs:string, + $value as xs:string) +as xs:string? { + $http:var := "val"; +}; + +http:set-header("foo", "bar") === modified file 'test/unit/plan_serializer.cpp' --- test/unit/plan_serializer.cpp 2011-06-14 17:26:33 +0000 +++ test/unit/plan_serializer.cpp 2012-02-14 22:20:26 +0000 @@ -26,35 +26,59 @@ using namespace zorba; - -int -plan_serializer(int argc, char* argv[]) +bool +save_and_load(Zorba* aZorba, const char* aQueryFile) { - void* lStore = zorba::StoreManager::getStore(); - Zorba* lZorba = Zorba::getInstance(lStore); - try { - std::ifstream lIn("guestbook_main.xq"); + std::ifstream lIn(aQueryFile); std::ostringstream lOut; { - StaticContext_t lSctx = lZorba->createStaticContext(); - - XQuery_t lQuery = lZorba->compileQuery(lIn, lSctx); + StaticContext_t lSctx = aZorba->createStaticContext(); + XQuery_t lQuery = aZorba->compileQuery(lIn, lSctx); lQuery->saveExecutionPlan(lOut, ZORBA_USE_BINARY_ARCHIVE, SAVE_UNUSED_FUNCTIONS); } - { std::istringstream lIn(lOut.str()); - XQuery_t lQuery = lZorba->createQuery(); + XQuery_t lQuery = aZorba->createQuery(); lQuery->loadExecutionPlan(lIn); std::cout << lQuery << std::endl; } + return true; } catch (ZorbaException& e) { std::cerr << e << std::endl; + return false; + } +} + +bool +plan_serializer1(Zorba* aZorba) +{ + return save_and_load(aZorba, "guestbook_main.xq"); +} + +bool +plan_serializer2(Zorba* aZorba) +{ + return save_and_load(aZorba, "mini_http.xq"); +} + +int +plan_serializer(int argc, char* argv[]) +{ + void* lStore = zorba::StoreManager::getStore(); + Zorba* lZorba = Zorba::getInstance(lStore); + + std::cout << "executing test 1" << std::endl; + if (!plan_serializer1(lZorba)) return 1; - } + std::cout << std::endl; + + std::cout << "executing test 2" << std::endl; + if (!plan_serializer2(lZorba)) + return 2; + std::cout << std::endl; lZorba->shutdown(); zorba::StoreManager::shutdownStore(lStore);
-- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp