Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
Signed-off-by: Future-Outlier <[email protected]>
  • Loading branch information
Future-Outlier committed May 22, 2024
1 parent 4546eb4 commit a15ed6d
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions flytepropeller/pkg/compiler/validators/typing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,44 @@ func TestSimpleLiteralCasting(t *testing.T) {
assert.True(t, castable, "Integers should be castable to other integers")
})

t.Run("IntegerToPythonAny", func(t *testing.T) {
castable := AreTypesCastable(
&core.LiteralType{
Type: &core.LiteralType_Simple{Simple: core.SimpleType_INTEGER},
},
&core.LiteralType{
Type: &core.LiteralType_Blob{},
Metadata: &structpb.Struct{
Fields: map[string]*structpb.Value{
"python_class_name": {
Kind: &structpb.Value_StringValue{StringValue: "typing.Any"},
},
},
},
},
)
assert.True(t, castable, "Integers should be castable to Python Any")
})

t.Run("PythonAnyToInteger", func(t *testing.T) {
castable := AreTypesCastable(
&core.LiteralType{
Type: &core.LiteralType_Blob{},
Metadata: &structpb.Struct{
Fields: map[string]*structpb.Value{
"python_class_name": {
Kind: &structpb.Value_StringValue{StringValue: "typing.Any"},
},
},
},
},
&core.LiteralType{
Type: &core.LiteralType_Simple{Simple: core.SimpleType_INTEGER},
},
)
assert.True(t, castable, "Python Any should be castable to Integers")
})

t.Run("IntegerToFloat", func(t *testing.T) {
castable := AreTypesCastable(
&core.LiteralType{
Expand Down

0 comments on commit a15ed6d

Please sign in to comment.