-
Notifications
You must be signed in to change notification settings - Fork 418
Test cleanup #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Test cleanup #160
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
json_serializable/test/src/to_from_json_test_input.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
part of 'json_serializable_test_input.dart'; | ||
|
||
int _toInt(bool input) => 42; | ||
int _twoArgFunction(int a, int b) => 42; | ||
|
||
dynamic _toDynamic(dynamic input) => null; | ||
Object _toObject(Object input) => null; | ||
|
||
@JsonSerializable() | ||
class BadFromFuncReturnType { | ||
@JsonKey(fromJson: _toInt) | ||
String field; | ||
} | ||
|
||
@JsonSerializable() | ||
class InvalidFromFunc2Args { | ||
@JsonKey(fromJson: _twoArgFunction) | ||
String field; | ||
} | ||
|
||
@JsonSerializable() | ||
class InvalidFromFuncClassStatic { | ||
static Duration _staticFunc(int param) => null; | ||
|
||
@JsonKey(fromJson: _staticFunc) | ||
String field; | ||
} | ||
|
||
@JsonSerializable() | ||
class BadToFuncReturnType { | ||
@JsonKey(toJson: _toInt) | ||
String field; | ||
} | ||
|
||
@JsonSerializable() | ||
class InvalidToFunc2Args { | ||
@JsonKey(toJson: _twoArgFunction) | ||
String field; | ||
} | ||
|
||
@JsonSerializable() | ||
class InvalidToFuncClassStatic { | ||
static Duration _staticFunc(int param) => null; | ||
|
||
@JsonKey(toJson: _staticFunc) | ||
String field; | ||
} | ||
|
||
@JsonSerializable() | ||
class ObjectConvertMethods { | ||
@JsonKey(fromJson: _toObject, toJson: _toObject) | ||
String field; | ||
} | ||
|
||
@JsonSerializable() | ||
class DynamicConvertMethods { | ||
@JsonKey(fromJson: _toDynamic, toJson: _toDynamic) | ||
String field; | ||
} | ||
|
||
String _toString(String input) => null; | ||
|
||
@JsonSerializable() | ||
class TypedConvertMethods { | ||
@JsonKey(fromJson: _toString, toJson: _toString) | ||
String field; | ||
} | ||
|
||
String _fromDynamicMap(Map input) => null; | ||
String _fromDynamicList(List input) => null; | ||
String _fromDynamicIterable(Iterable input) => null; | ||
|
||
@JsonSerializable(createToJson: false) | ||
class FromDynamicCollection { | ||
@JsonKey(fromJson: _fromDynamicMap) | ||
String mapField; | ||
@JsonKey(fromJson: _fromDynamicList) | ||
String listField; | ||
@JsonKey(fromJson: _fromDynamicIterable) | ||
String iterableField; | ||
} | ||
|
||
String _noArgs() => null; | ||
|
||
@JsonSerializable(createToJson: false) | ||
class BadNoArgs { | ||
@JsonKey(fromJson: _noArgs) | ||
String field; | ||
} | ||
|
||
String _twoArgs(a, b) => null; | ||
|
||
@JsonSerializable(createToJson: false) | ||
class BadTwoRequiredPositional { | ||
@JsonKey(fromJson: _twoArgs) | ||
String field; | ||
} | ||
|
||
String _oneNamed({a}) => null; | ||
|
||
@JsonSerializable(createToJson: false) | ||
class BadOneNamed { | ||
@JsonKey(fromJson: _oneNamed) | ||
String field; | ||
} | ||
|
||
String _oneNormalOnePositional(a, [b]) => null; | ||
|
||
@JsonSerializable(createToJson: false) | ||
class OkayOneNormalOptionalPositional { | ||
@JsonKey(fromJson: _oneNormalOnePositional) | ||
String field; | ||
} | ||
|
||
String _oneNormalOptionalNamed(a, {b}) => null; | ||
|
||
@JsonSerializable(createToJson: false) | ||
class OkayOneNormalOptionalNamed { | ||
@JsonKey(fromJson: _oneNormalOptionalNamed) | ||
String field; | ||
} | ||
|
||
String _onlyOptionalPositional([a, b]) => null; | ||
|
||
@JsonSerializable(createToJson: false) | ||
class OkayOnlyOptionalPositional { | ||
@JsonKey(fromJson: _onlyOptionalPositional) | ||
String field; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ForString
... what String?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old name. Can fix it up in a follow-up CL