Make Field constructor functions generic (#8)
F# can upcast types to `obj` if those types are used in place. However, a `string seq` (`IEnumerable<string>` in C#) cannot be upcast to an `obj seq` (`IEnumerable<object>`) without mapping each item in the sequence. Making the `Field` constructor functions generic will allow them to take any object type, and these functions handle the conversion to `obj` (for `In` and `InArray`; others work transparently). Reviewed-on: #8
This commit was merged in pull request #8.
This commit is contained in:
@@ -97,14 +97,20 @@ let fieldTests = testList "Field" [
|
||||
test "In succeeds" {
|
||||
let field = Field.In "Here" [| 8; 16; 32 |]
|
||||
Expect.equal field.Name "Here" "Field name incorrect"
|
||||
Expect.equal field.Comparison (In [| 8; 16; 32 |]) "Comparison incorrect"
|
||||
match field.Comparison with
|
||||
| In values -> Expect.equal (List.ofSeq values) [ box 8; box 16; box 32 ] "Comparison incorrect"
|
||||
| it -> Expect.isTrue false $"Expected In, received %A{it}"
|
||||
Expect.isNone field.ParameterName "The default parameter name should be None"
|
||||
Expect.isNone field.Qualifier "The default table qualifier should be None"
|
||||
}
|
||||
test "InArray succeeds" {
|
||||
let field = Field.InArray "ArrayField" "table" [| "z" |]
|
||||
Expect.equal field.Name "ArrayField" "Field name incorrect"
|
||||
Expect.equal field.Comparison (InArray("table", [| "z" |])) "Comparison incorrect"
|
||||
match field.Comparison with
|
||||
| InArray (table, values) ->
|
||||
Expect.equal table "table" "Comparison table incorrect"
|
||||
Expect.equal (List.ofSeq values) [ box "z" ] "Comparison values incorrect"
|
||||
| it -> Expect.isTrue false $"Expected InArray, received %A{it}"
|
||||
Expect.isNone field.ParameterName "The default parameter name should be None"
|
||||
Expect.isNone field.Qualifier "The default table qualifier should be None"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user