summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp')
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp128
1 files changed, 78 insertions, 50 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp b/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp
index 0dba59c3bb..81fae08384 100644
--- a/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp
@@ -42,6 +42,16 @@ TEST(CXFA_FMParserTest, CommentOnlyIsError) {
TEST(CXFA_FMParserTest, CommentThenValue) {
const wchar_t ret[] =
L"(function() {\n"
+ L"let pfm_method_runner = function(obj, cb) {\n"
+ L" if (pfm_rt.is_ary(obj)) {\n"
+ L" let pfm_method_return = null;\n"
+ L" for (var idx = obj.length -1; idx > 1; idx--) {\n"
+ L" pfm_method_return = cb(obj[idx]);\n"
+ L" }\n"
+ L" return pfm_method_return;\n"
+ L" }\n"
+ L" return cb(obj);\n"
+ L"};\n"
L"var pfm_ret = null;\n"
L"pfm_ret = 12;\n"
L"return pfm_rt.get_val(pfm_ret);\n"
@@ -75,6 +85,16 @@ TEST(CXFA_FMParserTest, Parse) {
const wchar_t ret[] =
L"(function() {\n"
+ L"let pfm_method_runner = function(obj, cb) {\n"
+ L" if (pfm_rt.is_ary(obj)) {\n"
+ L" let pfm_method_return = null;\n"
+ L" for (var idx = obj.length -1; idx > 1; idx--) {\n"
+ L" pfm_method_return = cb(obj[idx]);\n"
+ L" }\n"
+ L" return pfm_method_return;\n"
+ L" }\n"
+ L" return cb(obj);\n"
+ L"};\n"
L"var pfm_ret = null;\n"
L"if (pfm_rt.is_obj(this))\n{\n"
L"pfm_rt.asgn_val_op(this, pfm_rt.Avg(pfm_rt.neg_op(3), 5, "
@@ -159,6 +179,16 @@ TEST(CXFA_FMParserTest, ParseFuncWithParams) {
const wchar_t ret[] = {
L"(function() {\n"
+ L"let pfm_method_runner = function(obj, cb) {\n"
+ L" if (pfm_rt.is_ary(obj)) {\n"
+ L" let pfm_method_return = null;\n"
+ L" for (var idx = obj.length -1; idx > 1; idx--) {\n"
+ L" pfm_method_return = cb(obj[idx]);\n"
+ L" }\n"
+ L" return pfm_method_return;\n"
+ L" }\n"
+ L" return cb(obj);\n"
+ L"};\n"
L"var pfm_ret = null;\n"
L"function MyFunction(param1, param2) {\n"
L"var pfm_ret = null;\n"
@@ -187,6 +217,16 @@ TEST(CXFA_FMParserTest, ParseFuncWithoutParams) {
const wchar_t ret[] = {
L"(function() {\n"
+ L"let pfm_method_runner = function(obj, cb) {\n"
+ L" if (pfm_rt.is_ary(obj)) {\n"
+ L" let pfm_method_return = null;\n"
+ L" for (var idx = obj.length -1; idx > 1; idx--) {\n"
+ L" pfm_method_return = cb(obj[idx]);\n"
+ L" }\n"
+ L" return pfm_method_return;\n"
+ L" }\n"
+ L" return cb(obj);\n"
+ L"};\n"
L"var pfm_ret = null;\n"
L"function MyFunction() {\n"
L"var pfm_ret = null;\n"
@@ -262,20 +302,22 @@ TEST(CXFA_FMParserTest, ParseCallSmall) {
const wchar_t input[] = {L"i.f(O)"};
const wchar_t ret[] = {
L"(function() {\n"
- L"var pfm_ret = null;\n"
- L"pfm_ret = pfm_rt.get_val((function () {\n"
- L"let pfm_cb = function(obj) {\n"
- L"return obj.f(pfm_rt.get_val(O));\n"
+ L"let pfm_method_runner = function(obj, cb) {\n"
+ L" if (pfm_rt.is_ary(obj)) {\n"
+ L" let pfm_method_return = null;\n"
+ L" for (var idx = obj.length -1; idx > 1; idx--) {\n"
+ L" pfm_method_return = cb(obj[idx]);\n"
+ L" }\n"
+ L" return pfm_method_return;\n"
+ L" }\n"
+ L" return cb(obj);\n"
L"};\n"
- L"if (pfm_rt.is_ary(i)) {\n"
- L"let method_return_value = null;\n"
- L"for (var index = i.length - 1; index > 1; index--) {\n"
- L"method_return_value = pfm_cb(i[index]);\n"
- L"}\n"
- L"return method_return_value;\n"
- L"} else {\n"
- L"return pfm_cb(i);\n"
- L"}}).call(this));\n"
+ L"var pfm_ret = null;\n"
+ L"pfm_ret = pfm_rt.get_val((function() {\n"
+ L" return pfm_method_runner(i, function(obj) {\n"
+ L" return obj.f(pfm_rt.get_val(O));\n"
+ L" });\n"
+ L"}).call(this));\n"
L"return pfm_rt.get_val(pfm_ret);\n"
L"}).call(this);"};
@@ -293,44 +335,30 @@ TEST(CXFA_FMParserTest, ParseCallBig) {
const wchar_t input[] = {L"i.f(O.e(O.e(O)))"};
const wchar_t ret[] = {
L"(function() {\n"
- L"var pfm_ret = null;\n"
- L"pfm_ret = pfm_rt.get_val((function () {\n"
- L"let pfm_cb = function(obj) {\n"
- L"return obj.f(pfm_rt.get_val((function () {\n"
- L"let pfm_cb = function(obj) {\n"
- L"return obj.e(pfm_rt.get_val((function () {\n"
- L"let pfm_cb = function(obj) {\n"
- L"return obj.e(pfm_rt.get_val(O));\n"
- L"};\n"
- L"if (pfm_rt.is_ary(O)) {\n"
- L"let method_return_value = null;\n"
- L"for (var index = O.length - 1; index > 1; index--) {\n"
- L"method_return_value = pfm_cb(O[index]);\n"
- L"}\n"
- L"return method_return_value;\n"
- L"} else {\n"
- L"return pfm_cb(O);\n"
- L"}}).call(this)));\n"
+ L"let pfm_method_runner = function(obj, cb) {\n"
+ L" if (pfm_rt.is_ary(obj)) {\n"
+ L" let pfm_method_return = null;\n"
+ L" for (var idx = obj.length -1; idx > 1; idx--) {\n"
+ L" pfm_method_return = cb(obj[idx]);\n"
+ L" }\n"
+ L" return pfm_method_return;\n"
+ L" }\n"
+ L" return cb(obj);\n"
L"};\n"
- L"if (pfm_rt.is_ary(O)) {\n"
- L"let method_return_value = null;\n"
- L"for (var index = O.length - 1; index > 1; index--) {\n"
- L"method_return_value = pfm_cb(O[index]);\n"
- L"}\n"
- L"return method_return_value;\n"
- L"} else {\n"
- L"return pfm_cb(O);\n"
- L"}}).call(this)));\n"
- L"};\n"
- L"if (pfm_rt.is_ary(i)) {\n"
- L"let method_return_value = null;\n"
- L"for (var index = i.length - 1; index > 1; index--) {\n"
- L"method_return_value = pfm_cb(i[index]);\n"
- L"}\n"
- L"return method_return_value;\n"
- L"} else {\n"
- L"return pfm_cb(i);\n"
- L"}}).call(this));\n"
+ L"var pfm_ret = null;\n"
+ L"pfm_ret = pfm_rt.get_val((function() {\n"
+ L" return pfm_method_runner(i, function(obj) {\n"
+ L" return obj.f(pfm_rt.get_val((function() {\n"
+ L" return pfm_method_runner(O, function(obj) {\n"
+ L" return obj.e(pfm_rt.get_val((function() {\n"
+ L" return pfm_method_runner(O, function(obj) {\n"
+ L" return obj.e(pfm_rt.get_val(O));\n"
+ L" });\n"
+ L"}).call(this)));\n"
+ L" });\n"
+ L"}).call(this)));\n"
+ L" });\n"
+ L"}).call(this));\n"
L"return pfm_rt.get_val(pfm_ret);\n"
L"}).call(this);"};