@@ -36,6 +36,58 @@ func TestDisjunctionToType_WithNonDisjunctionObjects_HasNoImpact(t *testing.T) {
36
36
runDisjunctionPass (t , objects , objects )
37
37
}
38
38
39
+ func TestDisjunctionToType_WithDisjunctionOfTypeAndNull_AsAnObject (t * testing.T ) {
40
+ // Prepare test input
41
+ objects := []ast.Object {
42
+ ast .NewObject ("ScalarWithNull" , ast .NewDisjunction ([]ast.Type {
43
+ ast .String (),
44
+ ast .Null (),
45
+ })),
46
+ ast .NewObject ("RefWithNull" , ast .NewDisjunction ([]ast.Type {
47
+ ast .NewRef ("SomeType" ),
48
+ ast .Null (),
49
+ })),
50
+ }
51
+
52
+ expectedObjects := []ast.Object {
53
+ ast .NewObject ("ScalarWithNull" , ast .String (ast .Nullable ())),
54
+ ast .NewObject ("RefWithNull" , ast .NewRef ("SomeType" , ast .Nullable ())),
55
+ }
56
+
57
+ // Call the compiler pass
58
+ runDisjunctionPass (t , objects , expectedObjects )
59
+ }
60
+
61
+ func TestDisjunctionToType_WithDisjunctionOfTypeAndNull_AsAStructField (t * testing.T ) {
62
+ // Prepare test input
63
+ objects := []ast.Object {
64
+ ast .NewObject ("StructWithScalarWithNull" , ast .NewStruct (
65
+ ast .NewStructField ("Field" , ast .NewDisjunction ([]ast.Type {
66
+ ast .String (),
67
+ ast .Null (),
68
+ })),
69
+ )),
70
+ ast .NewObject ("StructWithRefWithNull" , ast .NewStruct (
71
+ ast .NewStructField ("Field" , ast .NewDisjunction ([]ast.Type {
72
+ ast .NewRef ("SomeType" ),
73
+ ast .Null (),
74
+ })),
75
+ )),
76
+ }
77
+
78
+ expectedObjects := []ast.Object {
79
+ ast .NewObject ("StructWithScalarWithNull" , ast .NewStruct (
80
+ ast .NewStructField ("Field" , ast .String (ast .Nullable ())),
81
+ )),
82
+ ast .NewObject ("StructWithRefWithNull" , ast .NewStruct (
83
+ ast .NewStructField ("Field" , ast .NewRef ("SomeType" , ast .Nullable ())),
84
+ )),
85
+ }
86
+
87
+ // Call the compiler pass
88
+ runDisjunctionPass (t , objects , expectedObjects )
89
+ }
90
+
39
91
func TestDisjunctionToType_WithDisjunctionOfScalars_AsAnObject (t * testing.T ) {
40
92
// Prepare test input
41
93
objects := []ast.Object {
0 commit comments