|
| 1 | +open System.Collections.Generic |
| 2 | +open NonStructuralComparison |
| 3 | + |
| 4 | +let failures = HashSet<string>() |
| 5 | + |
| 6 | +let reportFailure (s: string) = |
| 7 | + stderr.Write " NO: " |
| 8 | + stderr.WriteLine s |
| 9 | + failures.Add s |> ignore |
| 10 | + |
| 11 | +let test testName x y = |
| 12 | + let result = HashIdentity.Structural.Equals(x, y) |
| 13 | + if result = false |
| 14 | + then |
| 15 | + stderr.WriteLine($"\n***** {testName}: Expected: 'true' Result: '{result}' = FAIL\n"); |
| 16 | + reportFailure testName |
| 17 | + |
| 18 | +module BasicTypes = |
| 19 | + test "test000" true true |
| 20 | + test "test001" 1y 1y |
| 21 | + test "test002" 1uy 1uy |
| 22 | + test "test003" 1s 1s |
| 23 | + test "test004" 1us 1us |
| 24 | + test "test005" 1 1 |
| 25 | + test "test006" 1u 1u |
| 26 | + test "test007" 1L 1L |
| 27 | + test "test008" 1UL 1UL |
| 28 | + test "test009" (nativeint 1) (nativeint 1) |
| 29 | + test "test010" (unativeint 1) (unativeint 1) |
| 30 | + test "test011" 'a' 'a' |
| 31 | + test "test012" "a" "a" |
| 32 | + test "test013" 1m 1m |
| 33 | + test "test014" 1.0 1.0 |
| 34 | + test "test015" 1.0f 1.0f |
| 35 | + |
| 36 | +module Arrays = |
| 37 | + test "test100" [|1|] [|1|] |
| 38 | + test "test101" [|1L|] [|1L|] |
| 39 | + test "test102" [|1uy|] [|1uy|] |
| 40 | + test "test103" [|box 1|] [|box 1|] |
| 41 | + |
| 42 | +module Structs = |
| 43 | + test "test200" struct (1, 1) struct (1, 1) |
| 44 | + test "test201" struct (1, 1, 1) struct (1, 1, 1) |
| 45 | + test "test202" struct (1, 1, 1, 1) struct (1, 1, 1, 1) |
| 46 | + test "test203" struct (1, 1, 1, 1, 1) struct (1, 1, 1, 1, 1) |
| 47 | + test "test204" struct (1, 1, 1, 1, 1, 1) struct (1, 1, 1, 1, 1, 1) |
| 48 | + test "test205" struct (1, 1, 1, 1, 1, 1, 1) struct (1, 1, 1, 1, 1, 1, 1) |
| 49 | + test "test206" struct (1, 1, 1, 1, 1, 1, 1, 1) struct (1, 1, 1, 1, 1, 1, 1, 1) |
| 50 | + |
| 51 | +module OptionsAndCo = |
| 52 | + open System |
| 53 | + |
| 54 | + test "test301" (Some 1) (Some 1) |
| 55 | + test "test302" (ValueSome 1) (ValueSome 1) |
| 56 | + test "test303" (Ok 1) (Ok 1) |
| 57 | + test "test304" (Nullable 1) (Nullable 1) |
| 58 | + |
| 59 | +module Enums = |
| 60 | + open System |
| 61 | + |
| 62 | + type SomeEnum = |
| 63 | + | Case0 = 0 |
| 64 | + | Case1 = 1 |
| 65 | + |
| 66 | + test "test401" (enum<SomeEnum>(1)) (enum<SomeEnum>(1)) |
| 67 | + test "test402" (enum<DayOfWeek>(1)) (enum<DayOfWeek>(1)) |
| 68 | + |
| 69 | +[<EntryPoint>] |
| 70 | +let main _ = |
| 71 | + match failures with |
| 72 | + | set when set.Count = 0 -> |
| 73 | + stdout.WriteLine "All tests passed" |
| 74 | + exit 0 |
| 75 | + | _ -> |
| 76 | + stdout.WriteLine "Some tests failed" |
| 77 | + exit 1 |
0 commit comments