1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "xfa/fxfa/fm2js/xfa_simpleexpression.h"
6
7 #include <memory>
8 #include <utility>
9
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "third_party/base/ptr_util.h"
12 #include "xfa/fxfa/fm2js/xfa_lexer.h"
13
TEST(FMCallExpression,more_than_32_arguments)14 TEST(FMCallExpression, more_than_32_arguments) {
15 // Use sign as it has 3 object parameters at positions 0, 5, and 6.
16 auto exp = pdfium::MakeUnique<CXFA_FMIdentifierExpression>(0, L"sign");
17
18 std::vector<std::unique_ptr<CXFA_FMSimpleExpression>> args;
19 for (size_t i = 0; i < 50; i++)
20 args.push_back(pdfium::MakeUnique<CXFA_FMSimpleExpression>(0, TOKnan));
21
22 CXFA_FMCallExpression callExp(0, std::move(exp), std::move(args), true);
23 CFX_WideTextBuf js;
24 callExp.ToJavaScript(js);
25
26 // Generate the result javascript string.
27 CFX_WideString result = L"sign(";
28 for (size_t i = 0; i < 50; i++) {
29 if (i > 0)
30 result += L", ";
31
32 result += L"foxit_xfa_formcalc_runtime.get_fm_";
33 // Object positions for sign() method.
34 if (i == 0 || i == 5 || i == 6)
35 result += L"jsobj()";
36 else
37 result += L"value()";
38 }
39 result += L")";
40
41 EXPECT_EQ(result.AsStringC(), js.AsStringC());
42 }
43