Summary:The vast majority of `folly::dynamic` array initializations are
single-line and with no nested arrays, so we can fix them with a
syntactic codemod. This also fixes a couple of singletons.
For empty arrays:
```
codemod '((?:folly::)?)(dynamic\s+\w+\s*=\s*)({\s*})' '\1\2\1dynamic::array'
```
For non-empty ones:
```
codemod '((?:folly::)?)(dynamic\s+\w+\s*=\s*)(?:{\s*([^{}]+?)\s*})' '\1\2\1dynamic::array(\3)'
```
Reviewed By: igorsugak
Differential Revision:
D3030338
fb-gh-sync-id:
3e56704a6c6294d6f6270e42a1776d991a7938df
shipit-source-id:
3e56704a6c6294d6f6270e42a1776d991a7938df
// test dynamics with various layers of nested arrays.
TEST(Gen, Dynamic) {
- dynamic array1 = {1, 2};
+ dynamic array1 = dynamic::array(1, 2);
EXPECT_EQ(dynamic(3), from(array1) | sum);
dynamic array2 = {{1}, {1, 2}};
EXPECT_EQ(dynamic(4), from(array2) | rconcat | sum);