trphoenix
2018-11-14 86910df0578149bf09eb93cf00cc6e7ac83fa3b7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// 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';
 
@ShouldThrow('Error with `@JsonKey` on `field`. '
    '`defaultValue` is `Symbol`, it must be a literal.')
@JsonSerializable()
class DefaultWithSymbol {
  @JsonKey(defaultValue: #symbol)
  Object field;
 
  DefaultWithSymbol();
}
 
int _function() => 42;
 
@ShouldThrow('Error with `@JsonKey` on `field`. '
    '`defaultValue` is `Function`, it must be a literal.')
@JsonSerializable()
class DefaultWithFunction {
  @JsonKey(defaultValue: _function)
  Object field;
 
  DefaultWithFunction();
}
 
@ShouldThrow('Error with `@JsonKey` on `field`. '
    '`defaultValue` is `Type`, it must be a literal.')
@JsonSerializable()
class DefaultWithType {
  @JsonKey(defaultValue: Object)
  Object field;
 
  DefaultWithType();
}
 
@ShouldThrow('Error with `@JsonKey` on `field`. '
    '`defaultValue` is `Duration`, it must be a literal.')
@JsonSerializable()
class DefaultWithConstObject {
  @JsonKey(defaultValue: Duration())
  Object field;
 
  DefaultWithConstObject();
}
 
enum Enum { value }
 
@ShouldThrow('Error with `@JsonKey` on `field`. '
    '`defaultValue` is `List > Enum`, it must be a literal.')
@JsonSerializable()
class DefaultWithNestedEnum {
  @JsonKey(defaultValue: [Enum.value])
  Object field;
 
  DefaultWithNestedEnum();
}
 
@ShouldThrow('Error with `@JsonKey` on `field`. '
    'Cannot use `defaultValue` on a field with `nullable` false.')
@JsonSerializable()
class DefaultWithNonNullableField {
  @JsonKey(defaultValue: 42, nullable: false)
  Object field;
 
  DefaultWithNonNullableField();
}
 
@ShouldThrow('Error with `@JsonKey` on `field`. '
    'Cannot use `defaultValue` on a field with `nullable` false.')
@JsonSerializable(nullable: false)
class DefaultWithNonNullableClass {
  @JsonKey(defaultValue: 42)
  Object field;
 
  DefaultWithNonNullableClass();
}