summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-06-12 13:22:55 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-12 13:22:55 +0000
commit755b0e5f71518488456e7cffc64fd7ba89692e68 (patch)
tree5e4013a7f7f7597bf4f2971dfaed5f155c1c992f /xfa/fxfa/fm2js
parentfb72726e51bfd0c7bfc61c9b354e2b60f46adac5 (diff)
downloadpdfium-755b0e5f71518488456e7cffc64fd7ba89692e68.tar.xz
[fm2js] Convert formcalc tests to use raw literals
This CL updates some of the formcal tests to use raw literals instead of escaping lots of things. Change-Id: I539063b6c98aae318147b7103a0fd84e6b76054f Reviewed-on: https://pdfium-review.googlesource.com/34190 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa/fm2js')
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmexpression_unittest.cpp37
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp420
2 files changed, 234 insertions, 223 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fmexpression_unittest.cpp b/xfa/fxfa/fm2js/cxfa_fmexpression_unittest.cpp
index defe563afa..7372a1e8a8 100644
--- a/xfa/fxfa/fm2js/cxfa_fmexpression_unittest.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmexpression_unittest.cpp
@@ -14,26 +14,44 @@
#include "third_party/base/ptr_util.h"
#include "xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.h"
+TEST(CXFA_FMExpressionTest, VarExpressionInitNull) {
+ CXFA_FMToJavaScriptDepth::Reset();
+ CFX_WideTextBuf accumulator;
+
+ CXFA_FMVarExpression(L"s", nullptr)
+ .ToJavaScript(&accumulator, ReturnType::kInfered);
+ EXPECT_STREQ(
+ LR"***(var s = "";
+)***",
+ accumulator.MakeString().c_str());
+}
+
TEST(CXFA_FMExpressionTest, VarExpressionInitBlank) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf accumulator;
- auto init = pdfium::MakeUnique<CXFA_FMStringExpression>(L"\"\"");
+ auto init = pdfium::MakeUnique<CXFA_FMStringExpression>(LR"("")");
CXFA_FMVarExpression(L"s", std::move(init))
.ToJavaScript(&accumulator, ReturnType::kInfered);
- EXPECT_STREQ(L"var s = \"\";\ns = pfm_rt.var_filter(s);\n",
- accumulator.MakeString().c_str());
+ EXPECT_STREQ(
+ LR"***(var s = "";
+s = pfm_rt.var_filter(s);
+)***",
+ accumulator.MakeString().c_str());
}
TEST(CXFA_FMExpressionTest, VarExpressionInitString) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf accumulator;
- auto init = pdfium::MakeUnique<CXFA_FMStringExpression>(L"\"foo\"");
+ auto init = pdfium::MakeUnique<CXFA_FMStringExpression>(LR"("foo")");
CXFA_FMVarExpression(L"s", std::move(init))
.ToJavaScript(&accumulator, ReturnType::kInfered);
- EXPECT_STREQ(L"var s = \"foo\";\ns = pfm_rt.var_filter(s);\n",
- accumulator.MakeString().c_str());
+ EXPECT_STREQ(
+ LR"***(var s = "foo";
+s = pfm_rt.var_filter(s);
+)***",
+ accumulator.MakeString().c_str());
}
TEST(CXFA_FMExpressionTest, VarExpressionInitNumeric) {
@@ -43,6 +61,9 @@ TEST(CXFA_FMExpressionTest, VarExpressionInitNumeric) {
auto init = pdfium::MakeUnique<CXFA_FMNumberExpression>(L"112");
CXFA_FMVarExpression(L"s", std::move(init))
.ToJavaScript(&accumulator, ReturnType::kInfered);
- EXPECT_STREQ(L"var s = 112;\ns = pfm_rt.var_filter(s);\n",
- accumulator.MakeString().c_str());
+ EXPECT_STREQ(
+ LR"***(var s = 112;
+s = pfm_rt.var_filter(s);
+)***",
+ accumulator.MakeString().c_str());
}
diff --git a/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp b/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp
index 5afacc095d..b6517c1466 100644
--- a/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp
@@ -22,7 +22,7 @@ TEST(CXFA_FMParserTest, Empty) {
CFX_WideTextBuf buf;
EXPECT_TRUE(ast->ToJavaScript(&buf));
// TODO(dsinclair): This is a little weird .....
- EXPECT_EQ(L"// comments only", buf.AsStringView());
+ EXPECT_STREQ(L"// comments only", buf.MakeString().c_str());
}
TEST(CXFA_FMParserTest, CommentOnlyIsError) {
@@ -36,26 +36,26 @@ TEST(CXFA_FMParserTest, CommentOnlyIsError) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf buf;
EXPECT_TRUE(ast->ToJavaScript(&buf));
- EXPECT_EQ(L"// comments only", buf.AsStringView());
+ EXPECT_STREQ(L"// comments only", buf.MakeString().c_str());
}
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"
- L"}).call(this);";
+ LR"***((function() {
+let pfm_method_runner = function(obj, cb) {
+ if (pfm_rt.is_ary(obj)) {
+ let pfm_method_return = null;
+ for (var idx = obj.length -1; idx > 1; idx--) {
+ pfm_method_return = cb(obj[idx]);
+ }
+ return pfm_method_return;
+ }
+ return cb(obj);
+};
+var pfm_ret = null;
+pfm_ret = 12;
+return pfm_rt.get_val(pfm_ret);
+}).call(this);)***";
auto parser = pdfium::MakeUnique<CXFA_FMParser>(L"; Just comment\n12");
std::unique_ptr<CXFA_FMAST> ast = parser->Parse();
@@ -65,76 +65,66 @@ TEST(CXFA_FMParserTest, CommentThenValue) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf buf;
EXPECT_TRUE(ast->ToJavaScript(&buf));
- EXPECT_EQ(ret, buf.AsStringView());
+ EXPECT_STREQ(ret, buf.MakeString().c_str());
}
TEST(CXFA_FMParserTest, Parse) {
const wchar_t input[] =
- L"$ = Avg (-3, 5, -6, 12, -13);\n"
- L"$ = Avg (Table2..Row[*].Cell1);\n"
- L"\n"
- L"if ($ ne -1)then\n"
- L" border.fill.color.value = \"255,64,64\";\n"
- L"elseif ($ ne -2) then\n"
- L" border.fill.color.value = \"128,128,128\";\n"
- L"else\n"
- L" border.fill.color.value = \"20,170,13\";\n"
- L"endif\n"
- L"\n"
- L"$";
+ LR"***($ = Avg (-3, 5, -6, 12, -13);
+$ = Avg (Table2..Row[*].Cell1);
+if ($ ne -1)then
+ border.fill.color.value = "255,64,64";
+elseif ($ ne -2) then
+ border.fill.color.value = "128,128,128";
+else
+ border.fill.color.value = "20,170,13";
+endif
+$)***";
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, "
- L"pfm_rt.neg_op(6), 12, pfm_rt.neg_op(13)));\n"
- L"}\n"
- L"if (pfm_rt.is_obj(this))\n{\n"
- L"pfm_rt.asgn_val_op(this, pfm_rt.Avg(pfm_rt.dot_acc(pfm_rt.dotdot_acc("
- L"Table2, \"Table2\", \"Row\", 1), \"\", \"Cell1\", 0, 0)));\n"
- L"}\n"
- L"if (pfm_rt.get_val(pfm_rt.neq_op(this, pfm_rt.neg_op(1))))\n{\n"
- L"if (pfm_rt.is_obj(pfm_rt.dot_acc(pfm_rt.dot_acc(pfm_rt.dot_acc("
- L"border, \"border\", \"fill\", 0, 0), \"\", \"color\", 0, 0), \"\", "
- L"\"value\", 0, 0)))\n{\n"
- L"pfm_rt.asgn_val_op(pfm_rt.dot_acc(pfm_rt.dot_acc("
- L"pfm_rt.dot_acc(border, \"border\", \"fill\", 0, 0), \"\", "
- L"\"color\", 0, 0), \"\", \"value\", 0, 0), \"255,64,64\");\n"
- L"}\n"
- L"}\nelse if (pfm_rt.get_val(pfm_rt.neq_op(this, pfm_rt.neg_op(2))))\n"
- L"{\n"
- L"if (pfm_rt.is_obj(pfm_rt.dot_acc(pfm_rt.dot_acc(pfm_rt.dot_acc(border, "
- L"\"border\", \"fill\", 0, 0), \"\", \"color\", 0, 0), \"\", \"value\", "
- L"0, 0)))\n"
- L"{\n"
- L"pfm_rt.asgn_val_op(pfm_rt.dot_acc(pfm_rt.dot_acc(pfm_rt.dot_acc(border,"
- L" \"border\", \"fill\", 0, 0), \"\", \"color\", 0, 0), \"\", \"value\", "
- L"0, 0), \"128,128,128\");\n"
- L"}\n"
- L"}\n"
- L"else {\n"
- L"if (pfm_rt.is_obj(pfm_rt.dot_acc(pfm_rt.dot_acc(pfm_rt.dot_acc("
- L"border, \"border\", \"fill\", 0, 0), \"\", \"color\", 0, 0), \"\", "
- L"\"value\", 0, 0)))\n{\n"
- L"pfm_rt.asgn_val_op(pfm_rt.dot_acc(pfm_rt.dot_acc("
- L"pfm_rt.dot_acc(border, \"border\", \"fill\", 0, 0), \"\", "
- L"\"color\", 0, 0), \"\", \"value\", 0, 0), \"20,170,13\");\n"
- L"}\n"
- L"}\n"
- L"pfm_ret = this;\n"
- L"return pfm_rt.get_val(pfm_ret);\n"
- L"}).call(this);";
+ LR"***((function() {
+let pfm_method_runner = function(obj, cb) {
+ if (pfm_rt.is_ary(obj)) {
+ let pfm_method_return = null;
+ for (var idx = obj.length -1; idx > 1; idx--) {
+ pfm_method_return = cb(obj[idx]);
+ }
+ return pfm_method_return;
+ }
+ return cb(obj);
+};
+var pfm_ret = null;
+if (pfm_rt.is_obj(this))
+{
+pfm_rt.asgn_val_op(this, pfm_rt.Avg(pfm_rt.neg_op(3), 5, pfm_rt.neg_op(6), 12, pfm_rt.neg_op(13)));
+}
+if (pfm_rt.is_obj(this))
+{
+pfm_rt.asgn_val_op(this, pfm_rt.Avg(pfm_rt.dot_acc(pfm_rt.dotdot_acc(Table2, "Table2", "Row", 1), "", "Cell1", 0, 0)));
+}
+if (pfm_rt.get_val(pfm_rt.neq_op(this, pfm_rt.neg_op(1))))
+{
+if (pfm_rt.is_obj(pfm_rt.dot_acc(pfm_rt.dot_acc(pfm_rt.dot_acc(border, "border", "fill", 0, 0), "", "color", 0, 0), "", "value", 0, 0)))
+{
+pfm_rt.asgn_val_op(pfm_rt.dot_acc(pfm_rt.dot_acc(pfm_rt.dot_acc(border, "border", "fill", 0, 0), "", "color", 0, 0), "", "value", 0, 0), "255,64,64");
+}
+}
+else if (pfm_rt.get_val(pfm_rt.neq_op(this, pfm_rt.neg_op(2))))
+{
+if (pfm_rt.is_obj(pfm_rt.dot_acc(pfm_rt.dot_acc(pfm_rt.dot_acc(border, "border", "fill", 0, 0), "", "color", 0, 0), "", "value", 0, 0)))
+{
+pfm_rt.asgn_val_op(pfm_rt.dot_acc(pfm_rt.dot_acc(pfm_rt.dot_acc(border, "border", "fill", 0, 0), "", "color", 0, 0), "", "value", 0, 0), "128,128,128");
+}
+}
+else {
+if (pfm_rt.is_obj(pfm_rt.dot_acc(pfm_rt.dot_acc(pfm_rt.dot_acc(border, "border", "fill", 0, 0), "", "color", 0, 0), "", "value", 0, 0)))
+{
+pfm_rt.asgn_val_op(pfm_rt.dot_acc(pfm_rt.dot_acc(pfm_rt.dot_acc(border, "border", "fill", 0, 0), "", "color", 0, 0), "", "value", 0, 0), "20,170,13");
+}
+}
+pfm_ret = this;
+return pfm_rt.get_val(pfm_ret);
+}).call(this);)***";
auto parser = pdfium::MakeUnique<CXFA_FMParser>(input);
std::unique_ptr<CXFA_FMAST> ast = parser->Parse();
@@ -156,9 +146,9 @@ TEST(CXFA_FMParserTest, MaxParseDepth) {
TEST(CFXA_FMParserTest, chromium752201) {
auto parser = pdfium::MakeUnique<CXFA_FMParser>(
- L"fTep a\n"
- L".#\n"
- L"fo@ =[=l");
+ LR"***(fTep a
+.#
+fo@ =[=l)***");
EXPECT_EQ(nullptr, parser->Parse());
EXPECT_TRUE(parser->HasError());
}
@@ -172,31 +162,31 @@ TEST(CXFA_FMParserTest, MultipleAssignmentIsNotAllowed) {
}
TEST(CXFA_FMParserTest, ParseFuncWithParams) {
- const wchar_t input[] = {
- L"func MyFunction(param1, param2) do\n"
- L" param1 * param2\n"
- L"endfunc"};
-
- 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"
- L"pfm_ret = pfm_rt.mul_op(param1, param2);\n"
- L"return pfm_ret;\n"
- L"}\n"
- L"return pfm_rt.get_val(pfm_ret);\n"
- L"}).call(this);"};
+ const wchar_t input[] =
+ LR"***(func MyFunction(param1, param2) do
+ param1 * param2
+endfunc)***";
+
+ const wchar_t ret[] =
+ LR"***((function() {
+let pfm_method_runner = function(obj, cb) {
+ if (pfm_rt.is_ary(obj)) {
+ let pfm_method_return = null;
+ for (var idx = obj.length -1; idx > 1; idx--) {
+ pfm_method_return = cb(obj[idx]);
+ }
+ return pfm_method_return;
+ }
+ return cb(obj);
+};
+var pfm_ret = null;
+function MyFunction(param1, param2) {
+var pfm_ret = null;
+pfm_ret = pfm_rt.mul_op(param1, param2);
+return pfm_ret;
+}
+return pfm_rt.get_val(pfm_ret);
+}).call(this);)***";
auto parser = pdfium::MakeUnique<CXFA_FMParser>(input);
std::unique_ptr<CXFA_FMAST> ast = parser->Parse();
@@ -206,35 +196,35 @@ TEST(CXFA_FMParserTest, ParseFuncWithParams) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf buf;
EXPECT_TRUE(ast->ToJavaScript(&buf));
- EXPECT_EQ(ret, buf.AsStringView());
+ EXPECT_STREQ(ret, buf.MakeString().c_str());
}
TEST(CXFA_FMParserTest, ParseFuncWithoutParams) {
- const wchar_t input[] = {
- L"func MyFunction() do\n"
- L" 42\n"
- L"endfunc"};
-
- 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"
- L"pfm_ret = 42;\n"
- L"return pfm_ret;\n"
- L"}\n"
- L"return pfm_rt.get_val(pfm_ret);\n"
- L"}).call(this);"};
+ const wchar_t input[] =
+ LR"***(func MyFunction() do
+ 42
+endfunc)***";
+
+ const wchar_t ret[] =
+ LR"***((function() {
+let pfm_method_runner = function(obj, cb) {
+ if (pfm_rt.is_ary(obj)) {
+ let pfm_method_return = null;
+ for (var idx = obj.length -1; idx > 1; idx--) {
+ pfm_method_return = cb(obj[idx]);
+ }
+ return pfm_method_return;
+ }
+ return cb(obj);
+};
+var pfm_ret = null;
+function MyFunction() {
+var pfm_ret = null;
+pfm_ret = 42;
+return pfm_ret;
+}
+return pfm_rt.get_val(pfm_ret);
+}).call(this);)***";
auto parser = pdfium::MakeUnique<CXFA_FMParser>(input);
std::unique_ptr<CXFA_FMAST> ast = parser->Parse();
@@ -244,14 +234,14 @@ TEST(CXFA_FMParserTest, ParseFuncWithoutParams) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf buf;
EXPECT_TRUE(ast->ToJavaScript(&buf));
- EXPECT_EQ(ret, buf.AsStringView());
+ EXPECT_STREQ(ret, buf.MakeString().c_str());
}
TEST(CXFA_FMParserTest, ParseFuncWithBadParamsList) {
- const wchar_t input[] = {
- L"func MyFunction(param1,) do\n"
- L" param1 * param2\n"
- L"endfunc"};
+ const wchar_t input[] =
+ LR"***(func MyFunction(param1,) do
+ param1 * param2
+endfunc)***";
auto parser = pdfium::MakeUnique<CXFA_FMParser>(input);
std::unique_ptr<CXFA_FMAST> ast = parser->Parse();
@@ -260,7 +250,7 @@ TEST(CXFA_FMParserTest, ParseFuncWithBadParamsList) {
}
TEST(CXFA_FMParserTest, ParseBadIfExpression) {
- const wchar_t input[] = {L"if ( then"};
+ const wchar_t input[] = L"if ( then";
auto parser = pdfium::MakeUnique<CXFA_FMParser>(input);
std::unique_ptr<CXFA_FMAST> ast = parser->Parse();
@@ -269,9 +259,9 @@ TEST(CXFA_FMParserTest, ParseBadIfExpression) {
}
TEST(CXFA_FMParserTest, ParseBadElseIfExpression) {
- const wchar_t input[] = {
- L"if ($ ne -1) then\n"
- L"elseif( then"};
+ const wchar_t input[] =
+ LR"***(if ($ ne -1) then"
+elseif( then)***";
auto parser = pdfium::MakeUnique<CXFA_FMParser>(input);
std::unique_ptr<CXFA_FMAST> ast = parser->Parse();
@@ -280,7 +270,7 @@ TEST(CXFA_FMParserTest, ParseBadElseIfExpression) {
}
TEST(CXFA_FMParserTest, ParseDepthWithWideTree) {
- const wchar_t input[] = {L"a <> b <> c <> d <> e <> f <> g <> h <> i <> j"};
+ const wchar_t input[] = L"a <> b <> c <> d <> e <> f <> g <> h <> i <> j";
{
auto parser = pdfium::MakeUnique<CXFA_FMParser>(input);
@@ -299,27 +289,27 @@ TEST(CXFA_FMParserTest, ParseDepthWithWideTree) {
}
TEST(CXFA_FMParserTest, ParseCallSmall) {
- const wchar_t input[] = {L"i.f(O)"};
- 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 = 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);"};
+ const wchar_t input[] = L"i.f(O)";
+ const wchar_t ret[] =
+ LR"***((function() {
+let pfm_method_runner = function(obj, cb) {
+ if (pfm_rt.is_ary(obj)) {
+ let pfm_method_return = null;
+ for (var idx = obj.length -1; idx > 1; idx--) {
+ pfm_method_return = cb(obj[idx]);
+ }
+ return pfm_method_return;
+ }
+ return cb(obj);
+};
+var pfm_ret = null;
+pfm_ret = pfm_rt.get_val((function() {
+ return pfm_method_runner(i, function(obj) {
+ return obj.f(pfm_rt.get_val(O));
+ });
+}).call(this));
+return pfm_rt.get_val(pfm_ret);
+}).call(this);)***";
auto parser = pdfium::MakeUnique<CXFA_FMParser>(input);
std::unique_ptr<CXFA_FMAST> ast = parser->Parse();
@@ -328,39 +318,39 @@ TEST(CXFA_FMParserTest, ParseCallSmall) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf buf;
EXPECT_TRUE(ast->ToJavaScript(&buf));
- EXPECT_EQ(ret, buf.AsStringView());
+ EXPECT_STREQ(ret, buf.MakeString().c_str());
}
TEST(CXFA_FMParserTest, ParseCallBig) {
- const wchar_t input[] = {L"i.f(O.e(O.e(O)))"};
- 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 = 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);"};
+ const wchar_t input[] = L"i.f(O.e(O.e(O)))";
+ const wchar_t ret[] =
+ LR"***((function() {
+let pfm_method_runner = function(obj, cb) {
+ if (pfm_rt.is_ary(obj)) {
+ let pfm_method_return = null;
+ for (var idx = obj.length -1; idx > 1; idx--) {
+ pfm_method_return = cb(obj[idx]);
+ }
+ return pfm_method_return;
+ }
+ return cb(obj);
+};
+var pfm_ret = null;
+pfm_ret = pfm_rt.get_val((function() {
+ return pfm_method_runner(i, function(obj) {
+ return obj.f(pfm_rt.get_val((function() {
+ return pfm_method_runner(O, function(obj) {
+ return obj.e(pfm_rt.get_val((function() {
+ return pfm_method_runner(O, function(obj) {
+ return obj.e(pfm_rt.get_val(O));
+ });
+}).call(this)));
+ });
+}).call(this)));
+ });
+}).call(this));
+return pfm_rt.get_val(pfm_ret);
+}).call(this);)***";
auto parser = pdfium::MakeUnique<CXFA_FMParser>(input);
std::unique_ptr<CXFA_FMAST> ast = parser->Parse();
@@ -369,29 +359,29 @@ TEST(CXFA_FMParserTest, ParseCallBig) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf buf;
EXPECT_TRUE(ast->ToJavaScript(&buf));
- EXPECT_EQ(ret, buf.AsStringView());
+ EXPECT_STREQ(ret, buf.MakeString().c_str());
}
TEST(CXFA_FMParserTest, ParseVar) {
- const wchar_t input[] = L"var s = \"\"\n";
+ const wchar_t input[] = LR"(var s = "")";
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"var s = \"\";\n"
- L"s = pfm_rt.var_filter(s);\n"
- L"pfm_ret = s;\n"
- L"return pfm_rt.get_val(pfm_ret);\n"
- L"}).call(this);";
+ LR"***((function() {
+let pfm_method_runner = function(obj, cb) {
+ if (pfm_rt.is_ary(obj)) {
+ let pfm_method_return = null;
+ for (var idx = obj.length -1; idx > 1; idx--) {
+ pfm_method_return = cb(obj[idx]);
+ }
+ return pfm_method_return;
+ }
+ return cb(obj);
+};
+var pfm_ret = null;
+var s = "";
+s = pfm_rt.var_filter(s);
+pfm_ret = s;
+return pfm_rt.get_val(pfm_ret);
+}).call(this);)***";
auto parser = pdfium::MakeUnique<CXFA_FMParser>(input);
std::unique_ptr<CXFA_FMAST> ast = parser->Parse();