From ccf265cc6e689ef6246a1bf5aeb3287cccacd9db Mon Sep 17 00:00:00 2001 From: fangting Date: Mon, 12 May 2025 22:16:20 +0800 Subject: [PATCH] fix DT bug Signed-off-by: fangting Issue:#IC78LR --- .../test/testcases/js_closure_scope_test.h | 78 +++++++++++-------- 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/tooling/test/testcases/js_closure_scope_test.h b/tooling/test/testcases/js_closure_scope_test.h index 7ba2706b..86dcf607 100644 --- a/tooling/test/testcases/js_closure_scope_test.h +++ b/tooling/test/testcases/js_closure_scope_test.h @@ -22,6 +22,49 @@ namespace panda::ecmascript::tooling::test { class JsClosureScopeTest : public TestActions { public: + static bool validateInnerResult(const std::unique_ptr& innerResult) + { + bool found_v2_1 = false; + bool found_v2_2 = false; + std::string name; + std::string valueDes; + std::unique_ptr value; + for (size_t i = 0; i < 2; ++i) { + Result ret = innerResult->Get(i)->GetString("name", &name); + if (ret != Result::SUCCESS) { + return false; + } + + if (name == "v2_1") { + ret = innerResult->Get(i)->GetObject("value", &value); + if (ret != Result::SUCCESS) { + return false; + } + + std::string valueDes; + ret = value->GetString("description", &valueDes); + if (ret != Result::SUCCESS || valueDes != "2") { + return false; + } + found_v2_1 = true; + } else if (name == "v2_2"){ + ret = innerResult->Get(i)->GetObject("value", &value); + if (ret != Result::SUCCESS) { + return false; + } + + ret = value->GetString("description", &valueDes); + if (ret != Result::SUCCESS || valueDes != "3") { + return false; + } + found_v2_2 = true; + } else { + return false; + } + } + return found_v2_1 = false && found_v2_2; + } + JsClosureScopeTest() { testAction = { @@ -133,40 +176,7 @@ public: if (ret != Result::SUCCESS) { return false; } - - std::string name; - ret = innerResult->Get(0)->GetString("name", &name); - if (ret != Result::SUCCESS || name != "v2_2") { - return false; - } - - std::unique_ptr value; - ret = innerResult->Get(0)->GetObject("value", &value); - if (ret != Result::SUCCESS) { - return false; - } - - std::string valueDes; - ret = value->GetString("description", &valueDes); - if (ret != Result::SUCCESS || valueDes != "3") { - return false; - } - - ret = innerResult->Get(1)->GetString("name", &name); - if (ret != Result::SUCCESS || name != "v2_1") { - return false; - } - - ret = innerResult->Get(1)->GetObject("value", &value); - if (ret != Result::SUCCESS) { - return false; - } - - ret = value->GetString("description", &valueDes); - if (ret != Result::SUCCESS || valueDes != "2") { - return false; - } - return true; + return validateInnerResult(innerResult); }}, {SocketAction::SEND, "print 4"}, {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, [] (auto recv, auto, auto) -> bool { -- Gitee