Skip to content

Commit ea0a702

Browse files
David Tolnayfacebook-github-bot
David Tolnay
authored andcommitted
Sync exactprint tests from xplat thrift fixtures
Summary: Generated by `fbcode/common/hs/thrift/exactprint/tests/sync-fbthrift-tests.sh` This is to pick up the structured annotations from {D71245284} Reviewed By: diliop Differential Revision: D71245287 fbshipit-source-id: a75acec4dc02a7ba2080568a27c4df0a790033b1
1 parent 5a0eaae commit ea0a702

File tree

12 files changed

+65
-33
lines changed

12 files changed

+65
-33
lines changed

exactprint/tests/fbthrift-tests/constants/src/module.thrift

+1
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ const map<string, string> unicode_map = {"BG": "Bulgaria", "BH": "Bahrain", "BÉ
260260
const i64 maxIntDec = 9223372036854775807;
261261
const i64 maxIntOct = 0777777777777777777777;
262262
const i64 maxIntHex = 0x7FFFFFFFFFFFFFFF;
263+
// @lint-ignore THRIFTFORMAT — a bug in the formatter
263264
const i64 maxIntBin = 0b111111111111111111111111111111111111111111111111111111111111111;
264265
const double maxDub = 1.7976931348623157e308;
265266
const double minDub = 2.2250738585072014e-308;

exactprint/tests/fbthrift-tests/doctext/src/module.thrift

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* limitations under the License.
1919
*/
2020

21+
include "thrift/annotation/rust.thrift"
22+
2123
/** Constant foo */
2224
const string FOO = "foo";
2325

@@ -39,7 +41,8 @@ const i32 SHOUTY = 11;
3941
typedef string lanyard
4042

4143
/** Secret name */
42-
typedef i32 number (rust.newtype)
44+
@rust.NewType
45+
typedef i32 number
4346

4447
/**
4548
* DefinitionList doctext.

exactprint/tests/fbthrift-tests/hack_service/src/module2.thrift

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
include "module.thrift"
2222

23+
include "thrift/annotation/hack.thrift"
24+
2325
namespace hack hack_ns2
2426

2527
enum Status {
@@ -31,5 +33,8 @@ struct FBStruct {
3133
}
3234

3335
service TestService extends module.FooHackService {
36+
@hack.GenerateClientMethodsWithHeaders{}
3437
i32 ping(1: string str_arg) throws (1: module.ExTypedef ex);
38+
@hack.GenerateClientMethodsWithHeaders{}
39+
void voidMethod();
3540
}

exactprint/tests/fbthrift-tests/python_capi/src/containers.thrift

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ struct TemplateLists {
6363
4: list<fbvector_string> nested_small_vector;
6464
@cpp.Type{template = "folly::fbvector"}
6565
5: list<fbvector_fbvector_string> small_vector_tensor;
66-
// @cpp.Type{template = "std::list"}
67-
// 6: list<string> list_string;
66+
// @cpp.Type{template = "std::list"}
67+
// 6: list<string> list_string;
6868
} (cpp.noncomparable)
6969

7070
struct TemplateSets {

exactprint/tests/fbthrift-tests/rust-annotations/src/module.thrift

+4-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ struct T4 {
4848

4949
// --
5050

51+
@rust.NewType
5152
@rust.Type{name = "smallvec::SmallVec<[u8; 16]>"}
52-
typedef binary binary_t (rust.newtype)
53+
typedef binary binary_t
5354

5455
@rust.NewType
5556
typedef i64 Generation
@@ -185,7 +186,8 @@ service OneMethodOptOut {
185186
}
186187

187188
union Bar {
188-
1: i32 WithAnnotation (rust.name = "Annotated");
189+
@rust.Name{name = "Annotated"}
190+
1: i32 WithAnnotation;
189191
2: i32 WithoutAnnotation;
190192
}
191193

exactprint/tests/fbthrift-tests/rust-extra-derives/src/mod.thrift

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
* limitations under the License.
1919
*/
2020

21+
include "thrift/annotation/rust.thrift"
22+
23+
@rust.Derive{derives = ["Foo", "Bar"]}
2124
struct WithCustomDerives {
2225
1: bool a;
23-
} (rust.derive = "Foo, Bar")
26+
}

exactprint/tests/fbthrift-tests/rust-newtype-typedef/src/module.thrift

+21-14
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,24 @@
1818
* limitations under the License.
1919
*/
2020

21-
typedef map<i32, i32> MapType (
22-
rust.newtype,
23-
rust.type = "sorted_vector_map::SortedVectorMap",
24-
)
21+
include "thrift/annotation/rust.thrift"
2522

26-
typedef binary BinType (
27-
rust.newtype,
28-
rust.type = "smallvec::SmallVec<[u8; 16]>",
29-
)
23+
@rust.NewType
24+
@rust.Type{name = "sorted_vector_map::SortedVectorMap"}
25+
typedef map<i32, i32> MapType
3026

31-
typedef double (rust.type = "OrderedFloat<f64>") Double
27+
@rust.NewType
28+
@rust.Type{name = "smallvec::SmallVec<[u8; 16]>"}
29+
typedef binary BinType
3230

33-
typedef binary BytesType (rust.newtype, rust.type = "Bytes")
31+
@rust.Type{name = "OrderedFloat<f64>"}
32+
typedef double Double
3433

34+
@rust.NewType
35+
@rust.Type{name = "Bytes"}
36+
typedef binary BytesType
37+
38+
@rust.Ord
3539
struct MyStruct {
3640
1: MapType the_map;
3741
2: BinType the_bin;
@@ -40,9 +44,12 @@ struct MyStruct {
4044
5: binary_9564 inline_bytes;
4145
6: Double floaty;
4246
7: double_8056 doublefloaty;
43-
} (rust.ord)
47+
}
4448

4549
// The following were automatically generated and may benefit from renaming.
46-
typedef binary (rust.type = "smallvec::SmallVec<[u8; 32]>") binary_8247
47-
typedef binary (rust.type = "Bytes") binary_9564
48-
typedef double (rust.type = "OrderedFloat<f64>") double_8056
50+
@rust.Type{name = "smallvec::SmallVec<[u8; 32]>"}
51+
typedef binary binary_8247
52+
@rust.Type{name = "Bytes"}
53+
typedef binary binary_9564
54+
@rust.Type{name = "OrderedFloat<f64>"}
55+
typedef double double_8056

exactprint/tests/fbthrift-tests/rust-no_serde-derive/src/mod.thrift

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@
1818
* limitations under the License.
1919
*/
2020

21+
include "thrift/annotation/rust.thrift"
22+
23+
@rust.Serde{enabled = false}
2124
struct NoSerde {
2225
1: bool a;
23-
} (rust.serde = "false")
26+
}
2427

2528
struct Serde {
2629
1: bool a;

exactprint/tests/fbthrift-tests/rust-raw-identifiers/src/mod.thrift

+6-2
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@
1818
* limitations under the License.
1919
*/
2020

21+
include "thrift/annotation/rust.thrift"
22+
2123
struct ThereAreNoPascalCaseKeywords {
2224
1: bool return;
23-
2: bool super (rust.name = "super_");
25+
@rust.Name{name = "super_"}
26+
2: bool super;
2427
}
2528

2629
service Foo {
2730
void return(1: ThereAreNoPascalCaseKeywords bar);
28-
void super(1: ThereAreNoPascalCaseKeywords bar) (rust.name = "super_");
31+
@rust.Name{name = "super_"}
32+
void super(1: ThereAreNoPascalCaseKeywords bar);
2933
}

exactprint/tests/fbthrift-tests/rust-request-context/src/module.thrift

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ namespace android test.fixtures.basic
2222
namespace java test.fixtures.basic
2323
namespace java.swift test.fixtures.basic
2424

25+
include "thrift/annotation/rust.thrift"
26+
2527
enum MyEnum {
2628
MyValue1 = 0,
2729
MyValue2 = 1,
@@ -49,6 +51,7 @@ interaction MyInteraction {
4951
void ping();
5052
}
5153

54+
@rust.RequestContext
5255
service MyService {
5356
void ping();
5457
string getRandomData();
@@ -61,4 +64,4 @@ service MyService {
6164
MyDataItem, stream<MyStruct> streamByIdWithResponse(1: i64 id);
6265
performs MyInteraction;
6366
MyInteraction startPingInteraction();
64-
} (rust.request_context)
67+
}

exactprint/tests/fbthrift-tests/types/src/module.thrift

+5-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
include "included.thrift"
2222
include "thrift/annotation/cpp.thrift"
23+
include "thrift/annotation/rust.thrift"
2324
include "thrift/annotation/thrift.thrift"
2425

2526
package "apache.org/thrift/fixtures/types"
@@ -254,10 +255,10 @@ typedef TBinary (noop_annotation = "1") TBinary_8623
254255
typedef i32 (cpp.use_allocator = "1") i32_9314
255256
typedef list<i32> (cpp.use_allocator = "1") list_i32_9187
256257
typedef map<i32, i32> (cpp.use_allocator = "1") map_i32_i32_9565
257-
typedef map<i32, string> (
258-
rust.type = "sorted_vector_map::SortedVectorMap",
259-
) map_i32_string_1261
258+
@rust.Type{name = "sorted_vector_map::SortedVectorMap"}
259+
typedef map<i32, string> map_i32_string_1261
260260
typedef set<i32> (cpp.use_allocator = "1") set_i32_7070
261261
@cpp.Type{template = "folly::sorted_vector_set"}
262-
typedef set<i32> (rust.type = "sorted_vector_map::SortedVectorSet") set_i32_7194
262+
@rust.Type{name = "sorted_vector_map::SortedVectorSet"}
263+
typedef set<i32> set_i32_7194
263264
typedef string (cpp.use_allocator = "1") string_5252

exactprint/tests/fbthrift-tests/use_op_encode/src/module.thrift

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ include "thrift/annotation/thrift.thrift"
2525
package "facebook.com/thrift/compiler/test"
2626

2727
struct MyStruct {
28-
1: i32 def_field;
29-
2: optional i32 opt_field;
30-
3: required i32 req_field;
31-
@thrift.TerseWrite
32-
4: i32 terse_field;
28+
1: i32 def_field;
29+
2: optional i32 opt_field;
30+
3: required i32 req_field;
31+
@thrift.TerseWrite
32+
4: i32 terse_field;
3333
}

0 commit comments

Comments
 (0)