From 30408a7a06516a32e2e1e90c8d501d79dde04fd4 Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Tue, 18 Oct 2016 17:26:55 -0700 Subject: [PATCH] CodeMod: dynamic-init-list-ctor Summary: CodeMod: `dynamic-init-list-ctor`. The `folly::dynamic::dynamic(std::initializer_list)` constructor is deprecated because its meaning is ambiguous and variable across compilers and compiler versions. This diff codemods uses of that constructor to use `folly::dynamic::array<...>(...)` instead. This codemod may not get 100%, but that's okay. Any amount helps. Reviewed By: ot Differential Revision: D4013979 fbshipit-source-id: c6873dbc8027b38e71a0f291466ed2d9bd204a53 --- folly/experimental/bser/test/BserTest.cpp | 11 +++++------ folly/gen/test/BaseTest.cpp | 8 ++++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/folly/experimental/bser/test/BserTest.cpp b/folly/experimental/bser/test/BserTest.cpp index 8534d536..e1ee70a3 100644 --- a/folly/experimental/bser/test/BserTest.cpp +++ b/folly/experimental/bser/test/BserTest.cpp @@ -34,7 +34,7 @@ static const dynamic roundtrips[] = { nullptr, 1.5, "hello", - {1, 2, 3}, + folly::dynamic::array(1, 2, 3), dynamic::object("key", "value")("otherkey", "otherval"), }; @@ -47,11 +47,10 @@ const uint8_t template_blob[] = "\x1e\x0c\x03\x19"; // and here's what it represents -static const dynamic template_dynamic = { +static const dynamic template_dynamic = folly::dynamic::array( dynamic::object("name", "fred")("age", 20), dynamic::object("name", "pete")("age", 30), - dynamic::object("name", nullptr)("age", 25), -}; + dynamic::object("name", nullptr)("age", 25)); TEST(Bser, RoundTrip) { dynamic decoded(nullptr); @@ -86,8 +85,8 @@ TEST(Bser, Template) { // Now check that we can generate this same data representation folly::bser::serialization_opts opts; - folly::bser::serialization_opts::TemplateMap templates = { - std::make_pair(&decoded, folly::dynamic{"name", "age"})}; + folly::bser::serialization_opts::TemplateMap templates = {std::make_pair( + &decoded, folly::dynamic(folly::dynamic::array("name", "age")))}; opts.templates = templates; str = folly::bser::toBser(decoded, opts); diff --git a/folly/gen/test/BaseTest.cpp b/folly/gen/test/BaseTest.cpp index f779c4ac..49c5c5cf 100644 --- a/folly/gen/test/BaseTest.cpp +++ b/folly/gen/test/BaseTest.cpp @@ -1002,9 +1002,13 @@ TEST(Gen, CopyCount) { TEST(Gen, Dynamic) { dynamic array1 = dynamic::array(1, 2); EXPECT_EQ(dynamic(3), from(array1) | sum); - dynamic array2 = {{1}, {1, 2}}; + dynamic array2 = folly::dynamic::array( + folly::dynamic::array(1), folly::dynamic::array(1, 2)); EXPECT_EQ(dynamic(4), from(array2) | rconcat | sum); - dynamic array3 = {{{1}}, {{1}, {1, 2}}}; + dynamic array3 = folly::dynamic::array( + folly::dynamic::array(folly::dynamic::array(1)), + folly::dynamic::array( + folly::dynamic::array(1), folly::dynamic::array(1, 2))); EXPECT_EQ(dynamic(5), from(array3) | rconcat | rconcat | sum); } -- 2.34.1