Skip to content

Commit 4abc041

Browse files
committed
test: move related test inputs into part files
Makes it easier to manage test files
1 parent 37dc566 commit 4abc041

File tree

2 files changed

+135
-132
lines changed

2 files changed

+135
-132
lines changed

json_serializable/test/src/json_serializable_test_input.dart

Lines changed: 2 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
//ignore_for_file: avoid_unused_constructor_parameters, prefer_initializing_formals
66
import 'package:json_annotation/json_annotation.dart';
77

8+
part 'to_from_json_test_input.dart';
9+
810
@JsonSerializable()
911
const theAnswer = 42;
1012

@@ -212,135 +214,3 @@ class SuperType {
212214
int priceFraction(int other) =>
213215
superTypeViaCtor == null ? null : superTypeViaCtor ~/ other;
214216
}
215-
216-
//
217-
// to/from JSON function classes
218-
//
219-
220-
int _toInt(bool input) => 42;
221-
int _twoArgFunction(int a, int b) => 42;
222-
223-
dynamic _toDynamic(dynamic input) => null;
224-
Object _toObject(Object input) => null;
225-
226-
@JsonSerializable()
227-
class BadFromFuncReturnType {
228-
@JsonKey(fromJson: _toInt)
229-
String field;
230-
}
231-
232-
@JsonSerializable()
233-
class InvalidFromFunc2Args {
234-
@JsonKey(fromJson: _twoArgFunction)
235-
String field;
236-
}
237-
238-
@JsonSerializable()
239-
class InvalidFromFuncClassStatic {
240-
static Duration _staticFunc(int param) => null;
241-
242-
@JsonKey(fromJson: _staticFunc)
243-
String field;
244-
}
245-
246-
@JsonSerializable()
247-
class BadToFuncReturnType {
248-
@JsonKey(toJson: _toInt)
249-
String field;
250-
}
251-
252-
@JsonSerializable()
253-
class InvalidToFunc2Args {
254-
@JsonKey(toJson: _twoArgFunction)
255-
String field;
256-
}
257-
258-
@JsonSerializable()
259-
class InvalidToFuncClassStatic {
260-
static Duration _staticFunc(int param) => null;
261-
262-
@JsonKey(toJson: _staticFunc)
263-
String field;
264-
}
265-
266-
@JsonSerializable()
267-
class ObjectConvertMethods {
268-
@JsonKey(fromJson: _toObject, toJson: _toObject)
269-
String field;
270-
}
271-
272-
@JsonSerializable()
273-
class DynamicConvertMethods {
274-
@JsonKey(fromJson: _toDynamic, toJson: _toDynamic)
275-
String field;
276-
}
277-
278-
String _toString(String input) => null;
279-
280-
@JsonSerializable()
281-
class TypedConvertMethods {
282-
@JsonKey(fromJson: _toString, toJson: _toString)
283-
String field;
284-
}
285-
286-
String _fromDynamicMap(Map input) => null;
287-
String _fromDynamicList(List input) => null;
288-
String _fromDynamicIterable(Iterable input) => null;
289-
290-
@JsonSerializable(createToJson: false)
291-
class FromDynamicCollection {
292-
@JsonKey(fromJson: _fromDynamicMap)
293-
String mapField;
294-
@JsonKey(fromJson: _fromDynamicList)
295-
String listField;
296-
@JsonKey(fromJson: _fromDynamicIterable)
297-
String iterableField;
298-
}
299-
300-
String _noArgs() => null;
301-
302-
@JsonSerializable(createToJson: false)
303-
class BadNoArgs {
304-
@JsonKey(fromJson: _noArgs)
305-
String field;
306-
}
307-
308-
String _twoArgs(a, b) => null;
309-
310-
@JsonSerializable(createToJson: false)
311-
class BadTwoRequiredPositional {
312-
@JsonKey(fromJson: _twoArgs)
313-
String field;
314-
}
315-
316-
String _oneNamed({a}) => null;
317-
318-
@JsonSerializable(createToJson: false)
319-
class BadOneNamed {
320-
@JsonKey(fromJson: _oneNamed)
321-
String field;
322-
}
323-
324-
String _oneNormalOnePositional(a, [b]) => null;
325-
326-
@JsonSerializable(createToJson: false)
327-
class OkayOneNormalOptionalPositional {
328-
@JsonKey(fromJson: _oneNormalOnePositional)
329-
String field;
330-
}
331-
332-
String _oneNormalOptionalNamed(a, {b}) => null;
333-
334-
@JsonSerializable(createToJson: false)
335-
class OkayOneNormalOptionalNamed {
336-
@JsonKey(fromJson: _oneNormalOptionalNamed)
337-
String field;
338-
}
339-
340-
String _onlyOptionalPositional([a, b]) => null;
341-
342-
@JsonSerializable(createToJson: false)
343-
class OkayOnlyOptionalPositional {
344-
@JsonKey(fromJson: _onlyOptionalPositional)
345-
String field;
346-
}
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
part of 'json_serializable_test_input.dart';
6+
7+
int _toInt(bool input) => 42;
8+
int _twoArgFunction(int a, int b) => 42;
9+
10+
dynamic _toDynamic(dynamic input) => null;
11+
Object _toObject(Object input) => null;
12+
13+
@JsonSerializable()
14+
class BadFromFuncReturnType {
15+
@JsonKey(fromJson: _toInt)
16+
String field;
17+
}
18+
19+
@JsonSerializable()
20+
class InvalidFromFunc2Args {
21+
@JsonKey(fromJson: _twoArgFunction)
22+
String field;
23+
}
24+
25+
@JsonSerializable()
26+
class InvalidFromFuncClassStatic {
27+
static Duration _staticFunc(int param) => null;
28+
29+
@JsonKey(fromJson: _staticFunc)
30+
String field;
31+
}
32+
33+
@JsonSerializable()
34+
class BadToFuncReturnType {
35+
@JsonKey(toJson: _toInt)
36+
String field;
37+
}
38+
39+
@JsonSerializable()
40+
class InvalidToFunc2Args {
41+
@JsonKey(toJson: _twoArgFunction)
42+
String field;
43+
}
44+
45+
@JsonSerializable()
46+
class InvalidToFuncClassStatic {
47+
static Duration _staticFunc(int param) => null;
48+
49+
@JsonKey(toJson: _staticFunc)
50+
String field;
51+
}
52+
53+
@JsonSerializable()
54+
class ObjectConvertMethods {
55+
@JsonKey(fromJson: _toObject, toJson: _toObject)
56+
String field;
57+
}
58+
59+
@JsonSerializable()
60+
class DynamicConvertMethods {
61+
@JsonKey(fromJson: _toDynamic, toJson: _toDynamic)
62+
String field;
63+
}
64+
65+
String _toString(String input) => null;
66+
67+
@JsonSerializable()
68+
class TypedConvertMethods {
69+
@JsonKey(fromJson: _toString, toJson: _toString)
70+
String field;
71+
}
72+
73+
String _fromDynamicMap(Map input) => null;
74+
String _fromDynamicList(List input) => null;
75+
String _fromDynamicIterable(Iterable input) => null;
76+
77+
@JsonSerializable(createToJson: false)
78+
class FromDynamicCollection {
79+
@JsonKey(fromJson: _fromDynamicMap)
80+
String mapField;
81+
@JsonKey(fromJson: _fromDynamicList)
82+
String listField;
83+
@JsonKey(fromJson: _fromDynamicIterable)
84+
String iterableField;
85+
}
86+
87+
String _noArgs() => null;
88+
89+
@JsonSerializable(createToJson: false)
90+
class BadNoArgs {
91+
@JsonKey(fromJson: _noArgs)
92+
String field;
93+
}
94+
95+
String _twoArgs(a, b) => null;
96+
97+
@JsonSerializable(createToJson: false)
98+
class BadTwoRequiredPositional {
99+
@JsonKey(fromJson: _twoArgs)
100+
String field;
101+
}
102+
103+
String _oneNamed({a}) => null;
104+
105+
@JsonSerializable(createToJson: false)
106+
class BadOneNamed {
107+
@JsonKey(fromJson: _oneNamed)
108+
String field;
109+
}
110+
111+
String _oneNormalOnePositional(a, [b]) => null;
112+
113+
@JsonSerializable(createToJson: false)
114+
class OkayOneNormalOptionalPositional {
115+
@JsonKey(fromJson: _oneNormalOnePositional)
116+
String field;
117+
}
118+
119+
String _oneNormalOptionalNamed(a, {b}) => null;
120+
121+
@JsonSerializable(createToJson: false)
122+
class OkayOneNormalOptionalNamed {
123+
@JsonKey(fromJson: _oneNormalOptionalNamed)
124+
String field;
125+
}
126+
127+
String _onlyOptionalPositional([a, b]) => null;
128+
129+
@JsonSerializable(createToJson: false)
130+
class OkayOnlyOptionalPositional {
131+
@JsonKey(fromJson: _onlyOptionalPositional)
132+
String field;
133+
}

0 commit comments

Comments
 (0)