diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj
index d84f43e1acf..85239d5a3c0 100644
--- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj
+++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj
@@ -207,6 +207,7 @@
+
@@ -223,6 +224,7 @@
+
diff --git a/tests/FSharp.Compiler.ComponentTests/Signatures/SigGenerationRoundTripTests.fs b/tests/FSharp.Compiler.ComponentTests/Signatures/SigGenerationRoundTripTests.fs
new file mode 100644
index 00000000000..0b4be741d50
--- /dev/null
+++ b/tests/FSharp.Compiler.ComponentTests/Signatures/SigGenerationRoundTripTests.fs
@@ -0,0 +1,34 @@
+module FSharp.Compiler.ComponentTests.Signatures.SigGenerationRoundTripTests
+
+open Xunit
+open FSharp.Test
+open FSharp.Test.Compiler
+open System.IO
+
+let testCasesDir = Path.Combine(__SOURCE_DIRECTORY__,"TestCasesForGenerationRoundTrip")
+let allTestCases =
+ Directory.EnumerateFiles(testCasesDir)
+ |> Seq.toArray
+ |> Array.map Path.GetFileName
+ |> Array.map (fun f -> [|f :> obj|])
+
+[]
+[]
+let ``Generate and compile`` implFileName =
+ let implContents = File.ReadAllText (Path.Combine(testCasesDir,implFileName))
+
+ let generatedSignature =
+ Fs implContents
+ |> withLangVersionPreview
+ |> withDefines ["TESTS_AS_APP";"COMPILED"]
+ |> printSignatures
+
+ Fsi generatedSignature
+ |> withAdditionalSourceFile (FsSource implContents)
+ |> withLangVersionPreview
+ |> withDefines ["TESTS_AS_APP";"COMPILED"]
+ |> ignoreWarnings
+ |> asExe
+ |> compile
+ |> shouldSucceed
+
diff --git a/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/access-minimal-repro.fsx b/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/access-minimal-repro.fsx
new file mode 100644
index 00000000000..830c81fb47d
--- /dev/null
+++ b/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/access-minimal-repro.fsx
@@ -0,0 +1,8 @@
+module Core_access
+
+[]
+type MyClassPropertyGetters =
+ member internal x.InstInternal = 12
+ member private x.InstPrivate = 12
+ member public x.InstPublic = 12
+ member x.InstDefault = 12
diff --git a/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/access.fsx b/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/access.fsx
new file mode 100644
index 00000000000..6c067a82125
--- /dev/null
+++ b/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/access.fsx
@@ -0,0 +1,287 @@
+module Core_access
+
+#light
+let failures = ref []
+
+let report_failure (s : string) =
+ stderr.Write" NO: "
+ stderr.WriteLine s
+ failures.Value <- failures.Value @ [s]
+
+let test (s : string) b =
+ stderr.Write(s)
+ if b then stderr.WriteLine " OK"
+ else report_failure (s)
+
+(*--------------------*)
+
+// Test cases for bug://1562
+// Checking that generated signature can be compiled against the file.
+
+type internal typInternal = | AAA1
+type private typPrivate = | AAA2
+type public typPublic = | AAA3
+type typDefault = | AAA4
+type internal rrr = | AAA
+
+let internal ValInternal = 1212
+let private ValPrivate = 1212
+let public ValPublic = 1212
+let ValDefault = 1212
+
+[]
+type MyClassFields =
+ val internal fieldInternal : int
+ val private fieldPrivate : int
+ val public fieldPublic : int
+
+[]
+type MyClassMutableFields =
+ val mutable internal mfieldInternal : int
+ val mutable private mfieldPrivate : int
+ val mutable public mfieldPublic : int
+
+[]
+type MyClassStaticMembers =
+ static member internal SInternal = 12
+ static member private SPrivate = 12
+ static member public SPublic = 12
+ static member SDefault = 12
+ static member internal SMInternal() = 12
+ static member private SMPrivate() = 12
+ static member public SMPublic() = 12
+ static member SMDefault() = 12
+
+[]
+type MyClassPropertiyGetters =
+ member internal x.InstInternal = 12
+ member private x.InstPrivate = 12
+ member public x.InstPublic = 12
+ member x.InstDefault = 12
+
+type MyClassExplicitCtors =
+ val v : int
+ internal new(x) = { v = x }
+ private new(x,y) = { v = x + y}
+ public new(x,y,z) = { v = x + y + z}
+
+type MyClassExplicitCtors2 =
+ new() = {}
+ internal new(x) = let v : int = x in {}
+ private new(x,y) = let v : int = x + y in {}
+ public new(x,y,z) = let v : int = x + y + z in {}
+
+[]
+type MyClassPropertyGetSetterMatrix =
+ //--
+ member obj.PropGetSetInternalInternal
+ with internal get() = 1
+ and internal set(x:int) = ()
+ member obj.PropGetSetInternalPrivate
+ with internal get() = 1
+ and private set(x:int) = ()
+ member obj.PropGetSetInternalPublic
+ with internal get() = 1
+ and public set(x:int) = ()
+ //--
+ member obj.PropGetSetPrivateInternal
+ with private get() = 1
+ and internal set(x:int) = ()
+ member obj.PropGetSetPrivatePrivate
+ with private get() = 1
+ and private set(x:int) = ()
+ member obj.PropGetSetPrivatePublic
+ with private get() = 1
+ and public set(x:int) = ()
+ //--
+ member obj.PropGetSetPublicInternal
+ with public get() = 1
+ and internal set(x:int) = ()
+ member obj.PropGetSetPublicPrivate
+ with public get() = 1
+ and private set(x:int) = ()
+ member obj.PropGetSetPublicPublic
+ with public get() = 1
+ and public set(x:int) = ()
+
+[]
+type MyClassImplicitCtorInternal internal() =
+ member obj.Res = 12
+
+[]
+type MyClassImplicitCtorPrivate private() =
+ member obj.Res = 12
+
+module internal ModInternal = begin end
+module private ModPrivate = begin end
+module public ModPublic = begin end
+
+type recordRepInternal = internal { rfA1 : int }
+type recordRepPrivate = private { rfA2 : int }
+type recordRepPublic = public { rfA3 : int }
+
+type dtypeRepInternal = internal | AA1 | BB1
+type dtypeRepPrivate = private | AA2 | BB2
+type dtypeRepPublic = public | AA3 | BB3
+
+type internal dtypeRepPublic2 = private | AA3 | BB3
+type private dtypeRepPublic3 = internal | AA3 | BB3
+
+type internal dtypeRepPublic4 =
+ private
+ | AA3
+ | BB3
+
+module internal M =
+ module private PP =
+ type dtypeRepPublic5 =
+ | AA3
+ | BB3
+
+module private M2 =
+ module internal P =
+ let vv = 12
+
+
+module RestrictedRecordsAndUnionsUsingPrivateAndInternalTypes =
+
+ module public Test1 =
+
+ type internal Data =
+ {
+ Datum: int
+ }
+
+ type public Datum =
+ internal
+ {
+ Thing: Data
+ }
+
+ type public Datum2 =
+ internal | A of Data * Data | B of Data
+
+ module public Test2 =
+
+ type internal Data =
+ {
+ Datum: int
+ }
+
+ type internal Datum =
+ {
+ Thing: Data
+ }
+
+ type internal Datum2 =
+ | A of Data * Data | B of Data
+
+ module public Test3 =
+
+ type public Data =
+ internal
+ {
+ Datum: int
+ }
+
+ type internal Datum =
+ {
+ Thing: Data
+ }
+
+ type internal Datum2 =
+ internal | A of Data * Data | B of Data
+
+
+ module public Test4 =
+
+ type internal Data =
+ {
+ Datum: int
+ }
+
+ type public Datum =
+ internal
+ {
+ Thing: Data
+ }
+
+ type public Datum2 =
+ internal | A of Data * Data | B of Data
+
+
+ module public Test5 =
+
+ type private Data =
+ {
+ Datum: int
+ }
+
+ type public Datum =
+ private
+ {
+ Thing: Data
+ }
+
+ type public Datum2 =
+ private | A of Data * Data | B of Data
+
+
+ module Test6 =
+ module internal HelperModule =
+
+ type public Data =
+ private
+ {
+ Datum: int
+ }
+
+ let internal handle (data:Data): int = data.Datum
+
+ module public Module =
+
+ type public Data =
+ private
+ {
+ Thing: HelperModule.Data
+ }
+
+ let public getInt (data:Data): int = HelperModule.handle data.Thing
+
+ module Test7 =
+ module internal HelperModule =
+
+ type Data =
+ {
+ Datum: int
+ }
+
+ let handle (data:Data): int = data.Datum
+
+ module Module =
+
+ type Data =
+ internal
+ {
+ Thing: HelperModule.Data
+ }
+
+ let getInt (data:Data): int = HelperModule.handle data.Thing
+
+
+ (*--------------------*)
+
+#if TESTS_AS_APP
+let RUN() = failures.Value
+#else
+let aa =
+ match failures.Value with
+ | [] ->
+ stdout.WriteLine "Test Passed"
+ System.IO.File.WriteAllText("test.ok","ok")
+ exit 0
+ | _ ->
+ stdout.WriteLine "Test Failed"
+ exit 1
+#endif
+
diff --git a/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/array.fsx b/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/array.fsx
new file mode 100644
index 00000000000..82914ce60f6
--- /dev/null
+++ b/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/array.fsx
@@ -0,0 +1,1151 @@
+// #Conformance #Arrays #Stress #Structs #Mutable #ControlFlow #LetBindings
+#if TESTS_AS_APP
+module Core_array
+#endif
+
+let mutable failures = []
+let report_failure (s) =
+ stderr.WriteLine " NO"; failures <- s :: failures
+let test s b = if not b then (stderr.Write(s:string); report_failure(s) )
+let check s b1 b2 = test s (b1 = b2)
+
+
+(* TEST SUITE FOR Array *)
+
+let test_make_get_set_length () =
+ let arr = Array.create 3 0 in
+ test "fewoih" (Array.get arr 0 = 0);
+ test "vvrew0" (Array.get arr 2 = 0);
+ ignore (Array.set arr 0 4);
+ test "vsdiuvs" (Array.get arr 0 = 4);
+ test "vropivrwe" (Array.length arr = 3)
+
+let test_const () =
+ let arr = [| 4;3;2 |] in
+ test "sdvjk2" (Array.get arr 0 = 4);
+ test "cedkj" (Array.get arr 2 = 2);
+ ignore (Array.set arr 0 4);
+ test "ds9023" (Array.get arr 0 = 4);
+ test "sdio2" (Array.length arr = 3)
+
+let test_const_empty () =
+ let arr = [| |] in
+ test "sdio2" (Array.length arr = 0)
+
+let test_map () =
+ let arr = Array.map (fun x -> x + 1) ( [| 4;3;2 |]) in
+ test "test2927: sdvjk2" (Array.get arr 0 = 5);
+ test "test2927: cedkj" (Array.get arr 2 = 3)
+
+let test_iter () =
+ Array.iter (fun x -> test "fuo" (x <= 4)) ( [| 4;3;2 |])
+
+let test_iteri () =
+ let arr = [| 4;3;2 |] in
+ Array.iteri (fun i x -> test "fuo" (arr.[i] = x)) arr
+
+let test_mapi () =
+ let arr = [| 4;3;2 |] in
+ let arr2 = Array.mapi (fun i x -> test "dwqfuo" (arr.[i] = x); i + x) arr in
+ test "test2927: sdvjk2" (Array.get arr2 0 = 4);
+ test "test2927: cedkj" (Array.get arr2 2 = 4)
+
+let test_isEmpty () =
+ test "isEmpty a" (Array.isEmpty [||])
+ test "isEmpty b" (Array.isEmpty <| Array.create 0 42)
+ test "isEmpty c" <| not (Array.isEmpty <| [| 1 |])
+ test "isEmpty d" (Array.isEmpty <| Array.empty)
+
+let test_create () =
+ let arr = Array.create 10 10
+ for i in 0 .. 9 do
+ test "test_create" (arr.[i] = 10)
+
+let test_concat () =
+ let make n = [| for i in n .. n + 9 -> i |]
+ let arr = [| for i in 0..+10..50 -> make i|]
+ test "concat a" (Array.concat arr = [|0..59|])
+
+ let arr2 = [| for i in 0..50 -> [||] |]
+ test "concat b" (Array.concat arr2 = [| |])
+
+ let arr3 = [| [||]; [||]; [|1; 2|]; [||] |]
+ test "concat c" (Array.concat arr3 = [|1; 2|])
+
+let test_sub () =
+ test "sub a" (Array.sub [|0..100|] 10 20 = [|10..29|])
+ test "sub b" (Array.sub [|0..100|] 0 101 = [|0..100|])
+ test "sub c" (Array.sub [|0..100|] 0 1 = [|0|])
+ test "sub d" (Array.sub [|0..100|] 0 0 = [||])
+
+let test_fold2 () =
+ test "fold2 a"
+ (Array.fold2 (fun i j k -> i+j+k) 100 [|1;2;3|] [|1;2;3|] = 112)
+
+ test "fold2_b"
+ (Array.fold2 (fun i j k -> i-j-k) 100 [|1;2;3|] [|1;2;3|] = 100-12)
+
+let test_foldBack2 () =
+ test "foldBack2 a"
+ (Array.foldBack2 (fun i j k -> i+j+k) [|1;2;3|] [|1;2;3|] 100 = 112)
+
+ test "foldBack2_b"
+ (Array.foldBack2 (fun i j k -> k-i-j) [|1;2;3|] [|1;2;3|] 100 = 100-12)
+
+let test_scan () =
+ test "scan"
+ (Array.scan (+) 0 [|1..5|] = [|0; 1; 3; 6; 10; 15|])
+
+ test "scanBack"
+ (Array.scanBack (+) [|1..5|] 0 = [|15; 14; 12; 9; 5; 0|])
+
+let test_iter2 () =
+ let c = ref -1
+ Array.iter2 (fun x y -> c.Value <- c.Value + 1; test "iter2" (c.Value = x && c.Value = y)) [|0..100|] [|0..100|]
+ test "iter2" (c.Value = 100)
+
+let test_iteri2 () =
+ let c = ref 0
+ Array.iteri2 (fun i j k -> c.Value <- c.Value+i+j+k) [|1;2;3|] [|10;20;30|]
+ test "iteri2" (c.Value = 6+60+3)
+
+let test_map2 () =
+ test "map2"
+ (Array.map2 (+) [|0..100|] [|0..100|] = [|0..+2..200|])
+
+let test_mapi2 () =
+ test "mapi2 a"
+ (Array.mapi2 (fun i j k -> i+j+k) [|1..10|] [|1..10|] = [|2..+3..29|])
+
+ test "mapi2_b"
+ (try Array.mapi2 (fun i j k -> i+j+k) [||] [|1..10|] |> ignore; false
+ with _ -> true)
+
+let test_exists () =
+ test "exists a"
+ ([|1..100|] |> Array.exists ((=) 50))
+
+ test "exists b" <| not
+ ([|1..100|] |> Array.exists ((=) 150))
+
+let test_forall () =
+ test "forall a"
+ ([|1..100|] |> Array.forall (fun x -> x < 150))
+
+ test "forall b" <| not
+ ([|1..100|] |> Array.forall (fun x -> x < 80))
+
+let test_exists2 () =
+ test "exists2 a" <| Array.exists2 (=)
+ [|1; 2; 3; 4; 5; 6|]
+ [|2; 3; 4; 5; 6; 6|]
+
+ test "exists2 b" <| not (Array.exists2 (=)
+ [|1; 2; 3; 4; 5; 6|]
+ [|2; 3; 4; 5; 6; 7|])
+
+let test_forall2 () =
+ test "forall2 a"
+ (Array.forall2 (=) [|1..10|] [|1..10|])
+
+ test "forall2_b" <| not
+ (Array.forall2 (=) [|1;2;3;4;5|] [|1;2;3;0;5|])
+
+let test_filter () =
+ test "filter a"
+ (Array.filter (fun x -> x % 2 = 0) [|0..100|] = [|0..+2..100|])
+
+ test "filter b"
+ (Array.filter (fun x -> false) [|0..100|] = [||])
+
+ test "filter c"
+ (Array.filter (fun x -> true) [|0..100|] = [|0..100|])
+
+
+let test_partition () =
+ let p1, p2 = Array.partition (fun x -> x % 2 = 0) [|0..100|]
+ test "partition"
+ (p1 = [|0..+2..100|] && p2 = [|1..+2..100|])
+
+let test_choose () =
+ test "choose"
+ (Array.choose (fun x -> if x % 2 = 0 then Some (x/2) else None) [|0..100|] = [|0..50|])
+
+let test_find () =
+ test "find a"
+ ([|1..100|] |> Array.find (fun x -> x > 50) = 51)
+
+ test "find b"
+ (try [|1..100|] |> Array.find (fun x -> x > 180) |> ignore; false
+ with _ -> true)
+
+module Array =
+ let findIndexi f (array : array<_>) =
+ let len = array.Length
+ let rec go n =
+ if n >= len then
+ failwith "fail"
+ elif f n array.[n] then
+ n
+ else
+ go (n+1)
+ go 0
+
+ let tryFindIndexi f (array : array<_>) =
+ let len = array.Length
+ let rec go n = if n >= len then None elif f n array.[n] then Some n else go (n+1)
+ go 0
+
+let test_findIndex () =
+ test "findIndex a"
+ (Array.findIndex (fun i -> i >= 4) [|0..10|] = 4)
+
+ test "findIndex b"
+ (try Array.findIndex (fun i -> i >= 20) [|0..10|] |> ignore; false
+ with _ -> true)
+
+ test "findIndexi a"
+ (Array.findIndexi (=) [|1; 2; 3; 3; 2; 1|] = 3)
+
+ test "findIndexi b"
+ (try Array.findIndexi (=) [|1..10|] |> ignore; false
+ with _ -> true)
+
+let test_tryfind () =
+ test "tryFind"
+ ([|1..100|] |> Array.tryFind (fun x -> x > 50) = Some 51)
+
+ test "tryFind b"
+ ([|1..100|] |> Array.tryFind (fun x -> x > 180) = None)
+
+ test "tryfind_index a"
+ (Array.tryFindIndex (fun x -> x = 4) [|0..10|] = Some 4)
+
+ test "tryfind_index b"
+ (Array.tryFindIndex (fun x -> x = 42) [|0..10|] = None)
+
+ test "tryFindIndexi a"
+ (Array.tryFindIndexi (=) [|1;2;3;4;4;3;2;1|] = Some 4)
+
+ test "tryFindIndexi b"
+ (Array.tryFindIndexi (=) [|1..10|] = None)
+
+let test_first () =
+ test "first a"
+ ([|1..100|] |> Array.tryPick (fun x -> if x > 50 then Some (x*x) else None) = Some (51*51))
+
+ test "first b"
+ ([|1..100|] |> Array.tryPick (fun x -> None) = None)
+
+ test "first c"
+ ([||] |> Array.tryPick (fun _ -> Some 42) = None)
+
+let test_sort () =
+
+ test "sort a" (Array.sort [||] = [||])
+ test "sort b" (Array.sort [|1|] = [|1|])
+ test "sort c" (Array.sort [|1;2|] = [|1;2|])
+ test "sort d" (Array.sort [|2;1|] = [|1;2|])
+ test "sort e" (Array.sort [|1..1000|] = [|1..1000|])
+ test "sort f" (Array.sort [|1000..-1..1|] = [|1..1000|])
+
+let test_sort_by () =
+
+ test "Array.sortBy a" (Array.sortBy int [||] = [||])
+ test "Array.sortBy b" (Array.sortBy int [|1|] = [|1|])
+ test "Array.sortBy c" (Array.sortBy int [|1;2|] = [|1;2|])
+ test "Array.sortBy d" (Array.sortBy int [|2;1|] = [|1;2|])
+ test "Array.sortBy e" (Array.sortBy int [|1..1000|] = [|1..1000|])
+ test "Array.sortBy f" (Array.sortBy int [|1000..-1..1|] = [|1..1000|])
+
+ let testGen s f =
+ test ("Array.sortBy a "+s) (Array.sortBy f [||] = [||])
+ test ("Array.sortBy b "+s) (Array.sortBy f [|1|] = [|1|])
+ test ("Array.sortBy c "+s) (Array.sortBy f [|1;2|] = [|1;2|])
+ test ("Array.sortBy d "+s) (Array.sortBy f [|2;1|] = [|1;2|])
+ test ("Array.sortBy e "+s) (Array.sortBy f [|1..1000|] = [|1..1000|])
+ test ("Array.sortBy f "+s) (Array.sortBy f [|1000..-1..1|] = [|1..1000|])
+
+ // All these projects from integers preserve the expected key ordering for the tests in 'testGen()'
+ testGen "int" int
+ testGen "uint32" uint32
+ testGen "int16" int16
+ testGen "uint16" uint16
+ testGen "int64" int64
+ testGen "uint64" uint64
+ testGen "nativeint" nativeint
+ testGen "unativeint" unativeint
+ testGen "float" float
+ testGen "float32" float32
+ testGen "decimal" decimal
+
+ test "Array.sortBy g" (Array.sortBy int [|"4";"2";"3";"1";"5"|] = [|"1";"2";"3";"4";"5"|])
+ test "Array.sortBy h" (Array.sortBy abs [|1;-2;5;-4;0;-6;3|] = [|0;1;-2;3;-4;5;-6|])
+ test "Array.sortBy i" (Array.sortBy String.length [|"a";"abcd";"ab";"";"abc"|] = [|"";"a";"ab";"abc";"abcd"|])
+
+
+let test_list_stableSortBy() =
+ for lo in 0 .. 100 do
+ for hi in lo .. 100 do
+ test (sprintf "vre9u0rejkn, lo = %d, hi = %d" lo hi) (List.sortBy snd [ for i in lo .. hi -> (i, i % 17) ] = [ for key in 0 .. 16 do for i in lo .. hi do if i % 17 = key then yield (i, i % 17) ])
+
+test_list_stableSortBy()
+
+
+[]
+type Key =
+ | Key of int * int
+ interface System.IComparable with
+ member x.CompareTo(yobj:obj) =
+ match yobj with
+ | :? Key as y ->
+ let (Key(y1,y2)) = y in
+ let (Key(x1,x2)) = x in
+ compare x2 y2
+ | _ -> failwith "failure"
+
+ override x.Equals(yobj) =
+ match yobj with
+ | :? Key as y ->
+ let (Key(y1,y2)) = y in
+ let (Key(x1,x2)) = x in
+ x2 = y2
+ | _ -> false
+
+ override x.GetHashCode() =
+ let (Key(x1,x2)) = x in
+ hash x2
+
+let test_list_stableSort() =
+ for lo in 0 .. 100 do
+ for hi in lo .. 100 do
+ test (sprintf "vre9u0rejkn, lo = %d, hi = %d" lo hi) (List.sort [ for i in lo .. hi -> Key(i, i % 17) ] = [ for key in 0 .. 16 do for i in lo .. hi do if i % 17 = key then yield Key(i, i % 17) ])
+
+test_list_stableSort()
+
+let test_list_stableSortByNonIntegerKey() =
+ for lo in 0 .. 100 do
+ for hi in lo .. 100 do
+ test (sprintf "vre9u0rejkn, lo = %d, hi = %d" lo hi) (List.sortBy (fun (Key(a,b)) -> Key(0,b)) [ for i in lo .. hi -> Key(i, i % 17) ] = [ for key in 0 .. 16 do for i in lo .. hi do if i % 17 = key then yield Key(i, i % 17) ])
+
+test_list_stableSortByNonIntegerKey()
+
+
+let test_zip () =
+ test "zip"
+ (Array.zip [|1..10|] [|1..10|] = [|for i in 1..10 -> i, i|])
+
+ let unzip1, unzip2 = Array.unzip <| [|for i in 1..10 -> i, i+1|]
+ test "unzip" (unzip1 = [|1..10|] && unzip2 = [|2..11|])
+
+let test_zip3 () =
+ test "zip3"
+ (Array.zip3 [|1..10|] [|1..10|] [|1..10|] = [|for i in 1..10 -> i, i, i|])
+
+ let unzip1, unzip2, unzip3 = Array.unzip3 <| [|for i in 1..10 -> i, i+1, i+2|]
+ test "unzip3" (unzip1 = [|1..10|] && unzip2 = [|2..11|] && unzip3 = [|3..12|])
+
+
+let test_rev () =
+ test "rev a"
+ (Array.rev [|0..100|] = [|100..-1 ..0|])
+
+ test "rev b"
+ (Array.rev [|1|] = [|1|])
+
+ test "rev c"
+ (Array.rev [||] = [||])
+
+ test "rev d"
+ (Array.rev [|1; 2|] = [|2; 1|])
+
+let test_sum () =
+ test "sum a" (Array.sum [||] = 0)
+ test "sum b" (Array.sum [|42|] = 42)
+ test "sum c" (Array.sum [|42;-21|] = 21)
+ test "sum d" (Array.sum [|1..1000|] = (1000*1001) / 2)
+ test "sum e" (Array.sum [|1.;2.;3.|] = 6.)
+ test "sum f" (Array.sum [|1.;2.;infinity;3.|] = infinity)
+
+let test_sum_by () =
+ test "sum_by a" (Array.sumBy int [||] = 0)
+ test "sum_by b" (Array.sumBy int [|42|] = 42)
+ test "sum_by c" (Array.sumBy int [|42;-21|] = 21)
+ test "sum_by d" (Array.sumBy int [|1..1000|] = (1000*1001) / 2)
+ test "sum_by e" (Array.sumBy float [|1.;2.;3.|] = 6.)
+ test "sum_by f" (Array.sumBy float [|1.;2.;infinity;3.|] = infinity)
+ test "sum_by g" (Array.sumBy abs [|1; -2; 3; -4|] = 10)
+ test "sum_by h" (Array.sumBy String.length [|"abcd";"efg";"hi";"j";""|] = 10)
+
+let test_average () =
+ test "average a1" (try Array.average ([||]: float array) |> ignore; false with :? System.ArgumentException -> true)
+ test "average a2" (try Array.average ([||]: float32 array) |> ignore; false with :? System.ArgumentException -> true)
+ test "average a3" (try Array.average ([||]: decimal array) |> ignore; false with :? System.ArgumentException -> true)
+ test "average a4" (Array.average [|0.|] = 0.)
+ test "average b" (Array.average [|4.|] = 4.)
+ test "average c" (Array.average [|4.;6.|] = 5.)
+
+ test "average_by a1" (try Array.averageBy id ([||]: float array) |> ignore; false with :? System.ArgumentException -> true)
+ test "average_by a2" (try Array.averageBy id ([||]: float32 array) |> ignore; false with :? System.ArgumentException -> true)
+ test "average_by a3" (try Array.averageBy id ([||]: decimal array) |> ignore; false with :? System.ArgumentException -> true)
+ test "average_by a4" (Array.averageBy float [|0..1000|] = 500.)
+ test "average_by b" (Array.averageBy (String.length >> float) [|"ab";"cdef"|] = 3.)
+
+let test_min () =
+ test "min a" (Array.min [|42|] = 42)
+ test "min b" (Array.min [|42;21|] = 21)
+ test "min c" (Array.min [|'a';'b'|] = 'a')
+
+ test "max a" (Array.max [|42|] = 42)
+ test "max b" (Array.max [|42;21|] = 42)
+ test "max c" (Array.max [|'a';'b'|] = 'b')
+
+let test_min_by () =
+ test "min_by a" (Array.minBy int [|42|] = 42)
+ test "min_by b" (Array.minBy abs [|-42;-21|] = -21)
+ test "min_by c" (Array.minBy int [|'a';'b'|] = 'a')
+
+ test "max_by a" (Array.maxBy int [|42|] = 42)
+ test "max_by b" (Array.maxBy abs [|-42;-21|] = -42)
+ test "max_by c" (Array.maxBy int [|'a';'b'|] = 'b')
+
+let test_seq () =
+ test "to_seq" (Array.ofSeq [1..100] = [|1..100|])
+ test "to_seq" ([|1..100|] |> Array.toSeq |> Array.ofSeq = [|1..100|])
+
+
+let test_zero_create () =
+ let arr = Array.zeroCreate 3 in
+ ignore (Array.set arr 0 4);
+ ignore (Array.set arr 1 3);
+ ignore (Array.set arr 2 2);
+ test "fewoih" (Array.get arr 0 = 4);
+ test "vvrew0" (Array.get arr 1 = 3);
+ test "vvrew0" (Array.get arr 2 = 2)
+
+let test_zero_create_2 () =
+ let arr = Array.zeroCreate 0 in
+ test "sdio2" (Array.length arr = 0)
+
+let test_init () =
+ let arr = Array.init 4 (fun x -> x + 1) in
+ test "test2927: sdvjk2" (Array.get arr 0 = 1);
+ test "test2927: cedkj" (Array.get arr 2 = 3)
+
+let test_init_empty () =
+ let arr = Array.init 0 (fun x -> x + 1) in
+ test "test2927: sdvjk2" (Array.length arr = 0)
+
+let test_append () =
+ let arr = Array.append ( [| "4";"3" |]) ( [| "2" |]) in
+ test "test2928: sdvjk2" (Array.get arr 0 = "4");
+ test "test2928: cedkj" (Array.get arr 2 = "2");
+ test "test2928: cedkj" (Array.length arr = 3)
+
+let test_append_empty () =
+ let arr = Array.append ( [| |]) ( [| |]) in
+ test "test2928: cedkj" (Array.length arr = 0)
+
+let test_fill () =
+ let arr = [| "4";"3";"2" |] in
+ Array.fill arr 1 2 "1";
+ test "test2929: sdvjk2" (Array.get arr 0 = "4");
+ test "test2929: cedkj" (Array.get arr 2 = "1")
+
+let test_copy () =
+ let arr = [| "4";"3";"2" |] in
+ let arr2 = Array.copy arr in
+ test "test2929: sdvjk2" (Array.get arr2 0 = "4");
+ test "test2929: cedkj" (Array.get arr2 2 = "2");
+ test "feio" (not (LanguagePrimitives.PhysicalEquality arr arr2))
+
+let test_blit () =
+ let arr = [| "4";"3";"2";"0" |] in
+ let arr2 = [| "4";"3";"-1"; "-1" |] in
+ Array.blit arr 1 arr2 2 2;
+ test "test2930: sdvjk2" (Array.get arr2 0 = "4");
+ test "test2930: cedkj" (Array.get arr2 1 = "3");
+ test "test2930: ceddwkj" (Array.get arr2 2 = "3");
+ test "test2930: ceqwddkj" (Array.get arr2 3 = "2")
+
+let test_of_list () =
+ let arr = Array.ofList [ "4";"3";"2";"0" ] in
+ test "test2931: sdvjk2" (Array.get arr 0 = "4");
+ test "test2931: cedkj" (Array.get arr 1 = "3");
+ test "test2931: ceddwkj" (Array.get arr 2 = "2");
+ test "test2931: ceqwddkj" (Array.get arr 3 = "0")
+
+let test_to_list () =
+ test "test2932" (Array.toList ( [| "4";"3";"2";"0" |]) = [ "4";"3";"2";"0" ])
+
+let test_to_list_of_list () =
+ test "test2933" (Array.toList (Array.ofList [ "4";"3";"2";"0" ]) = [ "4";"3";"2";"0" ])
+
+let test_fold_left () =
+ let arr = Array.ofList [ 4;3;2;1 ] in
+ test "test2931: sdvjk2few" (Array.fold (fun x y -> x/y) (5*4*3*2*1) arr = 5)
+
+let test_fold_right () =
+ let arr = Array.ofList [ 4;3;2;1 ] in
+ test "test2931: sdvjk2ew" (Array.foldBack (fun y x -> x/y) arr (6*4*3*2*1) = 6)
+
+let test_reduce_left () =
+ test "test2931: array.reduce" (Array.reduce (fun x y -> x/y) [|5*4*3*2; 4;3;2;1|] = 5)
+
+let test_reduce_right () =
+ let arr = Array.ofList [ 4;3;2;1;5 ] in
+ test "test2931: array.reduceBack" (Array.reduceBack (fun y x -> x/y) [|4;3;2;1; 5*4*3*2|] = 5)
+
+
+let _ = test_make_get_set_length ()
+let _ = test_const ()
+let _ = test_const_empty ()
+let _ = test_map ()
+let _ = test_mapi ()
+let _ = test_iter ()
+let _ = test_iteri ()
+let _ = test_mapi ()
+let _ = test_isEmpty ()
+let _ = test_create ()
+let _ = test_concat ()
+let _ = test_sub ()
+let _ = test_fold2 ()
+let _ = test_foldBack2 ()
+let _ = test_scan ()
+let _ = test_iter2 ()
+let _ = test_iteri2 ()
+let _ = test_iter ()
+let _ = test_map2 ()
+let _ = test_mapi2 ()
+let _ = test_exists ()
+let _ = test_forall ()
+let _ = test_iter ()
+let _ = test_exists2 ()
+let _ = test_forall2 ()
+let _ = test_filter ()
+let _ = test_partition ()
+let _ = test_choose ()
+let _ = test_find ()
+let _ = test_findIndex ()
+let _ = test_tryfind ()
+let _ = test_first ()
+let _ = test_sort ()
+let _ = test_sort_by ()
+let _ = test_zip ()
+let _ = test_zip3 ()
+let _ = test_rev ()
+let _ = test_sum ()
+let _ = test_sum_by ()
+let _ = test_average ()
+let _ = test_min ()
+let _ = test_min_by ()
+let _ = test_seq ()
+let _ = test_zero_create ()
+let _ = test_zero_create_2 ()
+let _ = test_append ()
+let _ = test_append_empty ()
+let _ = test_init ()
+let _ = test_init_empty ()
+let _ = test_fill ()
+let _ = test_blit ()
+let _ = test_of_list ()
+let _ = test_to_list ()
+let _ = test_to_list_of_list ()
+let _ = test_copy ()
+let _ = test_iter ()
+let _ = test_iteri ()
+let _ = test_fold_left ()
+let _ = test_fold_right ()
+let _ = test_reduce_left ()
+let _ = test_reduce_right ()
+
+module Array2Tests = begin
+
+ let test_make_get_set_length () =
+ let arr = Array2D.create 3 4 0 in
+ test "fewoih1" (Array2D.get arr 0 0 = 0);
+ test "fewoih2" (Array2D.get arr 0 1 = 0);
+ test "vvrew03" (Array2D.get arr 2 2 = 0);
+ test "vvrew04" (Array2D.get arr 2 3 = 0);
+
+ ignore (Array2D.set arr 0 2 4);
+ test "vsdiuvs5" (Array2D.get arr 0 2 = 4);
+ arr.[0,2] <- 2;
+
+ test "vsdiuvs6" (arr.[0,2] = 2);
+ test "vropivrwe7" (Array2D.length1 arr = 3);
+ test "vropivrwe8" (Array2D.length2 arr = 4)
+
+ let a = Array2D.init 10 10 (fun i j -> i,j)
+ let b = Array2D.init 2 2 (fun i j -> i+1,j+1)
+ //test "a2_sub"
+ // (Array2D.sub a 1 1 2 2 = b)
+
+
+ Array2D.blit b 0 0 a 0 0 2 2
+ //test "a2_blit"
+ // (Array2D.sub a 0 0 2 2 = b)
+
+ let _ = test_make_get_set_length ()
+
+
+end
+
+module ArrayNonZeroBasedTestsSlice =
+ let runTest () =
+ let arr = (Array2D.initBased 5 4 3 2 (fun i j -> (i,j)))
+ test "fewoih1" (arr.[6,*] = [|(6, 4); (6, 5)|])
+ test "fewoih2" (arr.[*,*].[1,*] = [|(6, 4); (6, 5)|])
+ test "fewoih3" (arr.[*,5] = [|(5, 5); (6, 5); (7, 5)|])
+ test "fewoih4" (arr.[*,*].[*,1] = [|(5, 5); (6, 5); (7, 5)|])
+ test "fewoih5" (arr.GetLowerBound(0) = 5)
+ test "fewoih6" (arr.GetLowerBound(1) = 4)
+ test "fewoih7" (arr.[*,*].GetLowerBound(0) = 0)
+ test "fewoih8" (arr.[*,*].GetLowerBound(1) = 0)
+ test "fewoih9" (arr.[*,*].[0..,1] = [|(5, 5); (6, 5); (7, 5)|])
+ test "fewoih10" (arr.[*,*].[1..,1] = [|(6, 5); (7, 5)|])
+ let arr2d =
+ let arr = Array2D.zeroCreateBased 5 4 3 2
+ for i in 5..7 do for j in 4..5 do arr.[i,j] <- (i,j)
+ arr
+ let arr2d2 =
+ let arr = Array2D.zeroCreate 3 2
+ for i in 0..2 do for j in 0..1 do arr.[i,j] <- (j,i)
+ arr
+ test "fewoih11" (arr2d.[6..6,5] = [|(6, 5)|])
+ test "fewoih11" (arr2d.[..6,5] = [|(5, 5); (6, 5)|])
+ test "fewoih11" (arr2d.[6..,5] = [|(6, 5); (7, 5)|])
+ test "fewoih12" (arr2d.[*,*].[1..,1] = [|(6, 5); (7, 5)|])
+ arr2d.[*,*] <- arr2d2
+ test "fewoih13" (arr2d.[*,*].[0..0,1] = [|(1, 0)|])
+ test "fewoih13" (arr2d.[*,*].[1..,1] = [|(1, 1); (1, 2)|])
+ test "fewoih13" (arr2d.[*,*].[1,1..] = [|(1, 1)|])
+ test "fewoih13" (arr2d.[*,*].[1,0..0] = [|(0, 1)|])
+ let arr3d =
+ let arr = System.Array.CreateInstance(typeof, [| 3;2;1 |], [|5;4;3|]) :?> (int*int*int)[,,]
+ for i in 5..7 do for j in 4..5 do for k in 3..3 do arr.[i,j,k] <- (i,j,k)
+ arr
+ let arr3d2 =
+ let arr = System.Array.CreateInstance(typeof, [| 3;2;1 |]) :?> (int*int*int)[,,]
+ for i in 0..2 do for j in 0..1 do for k in 0..0 do arr.[i,j,k] <- (k,j,i)
+ arr
+
+ test "fewoih14" (arr3d.[5,4,3] = (5,4,3))
+ test "fewoih15" (arr3d.[*,*,*].[0,0,0] = (5,4,3))
+ arr3d.[*,*,*] <- arr3d2
+ test "fewoih16" (arr3d.[5,4,3] = (0,0,0))
+ test "fewoih16" (arr3d.[5,5,3] = (0,1,0))
+ test "fewoih16" (arr3d.[6,5,3] = (0,1,1))
+ let _ = runTest()
+
+module Array3Tests = begin
+
+ let test_make_get_set_length () =
+ let arr = Array3D.create 3 4 5 0 in
+ test "fewoih1" (Array3D.get arr 0 0 0 = 0);
+ test "fewoih2" (Array3D.get arr 0 1 0 = 0);
+ test "vvrew03" (Array3D.get arr 2 2 2 = 0);
+ test "vvrew04" (Array3D.get arr 2 3 4 = 0);
+ ignore (Array3D.set arr 0 2 3 4);
+ test "vsdiuvs5" (Array3D.get arr 0 2 3 = 4);
+ arr.[0,2,3] <- 2;
+ test "vsdiuvs6" (arr.[0,2,3] = 2);
+ arr.[0,2,3] <- 3;
+ test "vsdiuvs" (arr.[0,2,3] = 3);
+ test "vropivrwe7" (Array3D.length1 arr = 3);
+ test "vropivrwe8" (Array3D.length2 arr = 4);
+ test "vropivrwe9" (Array3D.length3 arr = 5)
+
+ let _ = test_make_get_set_length ()
+
+end
+
+module Array4Tests = begin
+
+ let test_make_get_set_length () =
+ let arr = Array4D.create 3 4 5 6 0 in
+ arr.[0,2,3,4] <- 2;
+ test "vsdiuvsq" (arr.[0,2,3,4] = 2);
+ arr.[0,2,3,4] <- 3;
+ test "vsdiuvsw" (arr.[0,2,3,4] = 3);
+ test "vsdiuvsw" (Array4D.get arr 0 2 3 4 = 3);
+ Array4D.set arr 0 2 3 4 5;
+ test "vsdiuvsw" (Array4D.get arr 0 2 3 4 = 5);
+ test "vropivrwee" (Array4D.length1 arr = 3);
+ test "vropivrwer" (Array4D.length2 arr = 4);
+ test "vropivrwet" (Array4D.length3 arr = 5)
+ test "vropivrwey" (Array4D.length4 arr = 6)
+
+ let test_init () =
+ let arr = Array4D.init 3 4 5 6 (fun i j k m -> i+j+k+m) in
+ test "vsdiuvs1" (arr.[0,2,3,4] = 9);
+ test "vsdiuvs2" (arr.[0,2,3,3] = 8);
+ test "vsdiuvs3" (arr.[0,0,0,0] = 0);
+ arr.[0,2,3,4] <- 2;
+ test "vsdiuvs4" (arr.[0,2,3,4] = 2);
+ arr.[0,2,3,4] <- 3;
+ test "vsdiuvs5" (arr.[0,2,3,4] = 3);
+ test "vropivrwe1" (Array4D.length1 arr = 3);
+ test "vropivrwe2" (Array4D.length2 arr = 4);
+ test "vropivrwe3" (Array4D.length3 arr = 5)
+ test "vropivrwe4" (Array4D.length4 arr = 6)
+
+ let _ = test_make_get_set_length ()
+ let _ = test_init ()
+
+end
+
+// nb. PERF TESTING ONLY WITH v2.0 (GENERICS)
+#if PERF
+let test_map_perf () =
+ let arr1 = [| 4;3;2 |] in
+ let res = ref (Array.map (fun x -> x + 1) arr1) in
+ for i = 1 to 20000000 do
+ res := Array.map (fun x -> x + 1) arr1
+ done;
+ test "test2927: sdvjk2" (Array.get !res 0 = 5)
+
+let _ = test_map_perf()
+#endif
+
+module SeqCacheAllTest =
+ let s2 =
+ let count = ref 0
+ let s = Seq.cache (seq { for i in 0 .. 10 -> (count.Value <- count.Value + 1; i) }) :> seq<_>
+ let test0 = (count.Value = 0)
+ let e1 = s.GetEnumerator()
+ let test1 = (count.Value = 0)
+ printf "test1 = %b\n" test1;
+ for i = 1 to 1 do (e1.MoveNext() |> ignore; e1.Current |> ignore)
+ let test2 = (count.Value = 1)
+ printf "test2 = %b\n" test2;
+ let e2 = s.GetEnumerator()
+ for i = 1 to 5 do (e2.MoveNext() |> ignore; e2.Current |> ignore)
+ let test3 = (count.Value = 5)
+ printf "test3 = %b\n" test3;
+ let e3 = s.GetEnumerator()
+ for i = 1 to 5 do (e3.MoveNext() |> ignore; e3.Current |> ignore)
+ let test4 = (count.Value = 5)
+ printf "test4 = %b\n" test4;
+ let e4 = s.GetEnumerator()
+ for i = 1 to 3 do (e4.MoveNext() |> ignore; e4.Current |> ignore)
+ let test5 = (count.Value = 5)
+ printf "test5 = %b\n" test5;
+
+ let test6 = [ for x in s -> x ] = [ 0 .. 10 ]
+ printf "test6 = %b\n" test6;
+ for x in s do ()
+ let test7 = (count.Value = 11)
+ let test8 = [ for x in s -> x ] = [ 0 .. 10 ]
+ let test9 = count.Value = 11
+ test "test0" test0
+ test "test1" test1
+ test "test2" test2
+ test "test3" test3
+ test "test4" test4
+ test "test5" test5
+ test "test6" test6
+ test "test7" test7
+ test "test8" test8
+ test "test9" test9
+
+
+module ArrayStructMutation =
+ module Array1D =
+ module Test1 =
+ []
+ type T =
+ val mutable i : int
+ let a = Array.create 10 Unchecked.defaultof
+ a.[0].i <- 27
+ check "wekvw0301" 27 a.[0].i
+
+
+ module Test2 =
+
+ []
+ type T =
+ val mutable public i : int
+ member public this.Set i = this.i <- i
+ let a = Array.create 10 Unchecked.defaultof
+ a.[0].Set 27
+ a.[2].Set 27
+ check "wekvw0302" 27 a.[0].i
+ check "wekvw0303" 27 a.[2].i
+
+ module Array2D =
+ module Test1 =
+ []
+ type T =
+ val mutable i : int
+ let a = Array2D.create 10 10 Unchecked.defaultof
+ a.[0,0].i <- 27
+ check "wekvw0304" 27 a.[0,0].i
+
+
+ module Test2 =
+
+ []
+ type T =
+ val mutable public i : int
+ member public this.Set i = this.i <- i
+ let a = Array2D.create 10 10 Unchecked.defaultof
+ a.[0,0].Set 27
+ a.[0,2].Set 27
+ check "wekvw0305" 27 a.[0,0].i
+ check "wekvw0306" 27 a.[0,2].i
+
+
+ module Array3D =
+ module Test1 =
+ []
+ type T =
+ val mutable i : int
+ let a = Array3D.create 10 10 10 Unchecked.defaultof
+ a.[0,0,0].i <- 27
+ a.[0,2,3].i <- 27
+ check "wekvw0307" 27 a.[0,0,0].i
+ check "wekvw0308" 27 a.[0,2,3].i
+
+
+ module Test2 =
+
+ []
+ type T =
+ val mutable public i : int
+ member public this.Set i = this.i <- i
+ let a = Array3D.create 10 10 10 Unchecked.defaultof
+ a.[0,0,0].Set 27
+ a.[0,2,3].Set 27
+ check "wekvw0309" 27 a.[0,0,0].i
+ check "wekvw030q" 27 a.[0,2,3].i
+
+ module Array4D =
+ module Test1 =
+ []
+ type T =
+ val mutable i : int
+ let a = Array4D.create 10 10 10 10 Unchecked.defaultof
+ a.[0,0,0,0].i <- 27
+ a.[0,2,3,4].i <- 27
+ check "wekvw030w" 27 a.[0,0,0,0].i
+ check "wekvw030e" 27 a.[0,2,3,4].i
+
+
+ module Test2 =
+
+ []
+ type T =
+ val mutable public i : int
+ member public this.Set i = this.i <- i
+ let a = Array4D.create 10 10 10 10 Unchecked.defaultof
+ a.[0,0,0,0].Set 27
+ a.[0,2,3,4].Set 27
+ check "wekvw030r" 27 a.[0,0,0,0].i
+ check "wekvw030t" 27 a.[0,2,3,4].i
+
+module LoopTests =
+ let loop3 a N =
+ let mutable x = 0 in
+ // In this loop, the types of 'a' and 'N' are not known prior to the loop
+ for i in (min a a) .. N do
+ x <- x + 1
+ done;
+ check (sprintf "clkrerev90-%A" (a,N)) x (if N < a then 0 else N - a + 1)
+
+
+ do loop3 0 10
+ do loop3 0 0
+ do loop3 0 -1
+ do loop3 10 9
+
+ let loop4 a N =
+ let mutable x = 0 in
+ for i in OperatorIntrinsics.RangeInt32 a 1 N do
+ x <- x + 1
+ done;
+ check (sprintf "clkrerev91-%A" (a,N)) x (if N < a then 0 else N - a + 1)
+
+ do loop4 0 10
+ do loop4 0 0
+ do loop4 0 -1
+ do loop4 10 9
+
+ let loop5 a N =
+ let mutable x = 0 in
+ // In this loop, the types of 'a' and 'N' are not known prior to the loop
+ for i in (min a a) .. 2 .. (min N N) do
+ x <- x + 1
+ done;
+ check (sprintf "clkrerev92-%A" (a,N)) x ((if N < a then 0 else N - a + 2) / 2)
+
+ do loop5 0 10
+ do loop5 0 0
+ do loop5 0 -1
+ do loop5 10 9
+
+
+ let loop6 a N =
+ let mutable x = 0 in
+ // In this loop, the types of 'a' and 'N' are not known prior to the loop
+ for i in (min a a) .. 200 .. (min N N) do
+ x <- x + 1
+ done;
+ check (sprintf "clkrerev93-%A" (a,N)) x ((if N < a then 0 else N - a + 200) / 200)
+
+ do loop6 0 10
+ do loop6 0 0
+ do loop6 0 -1
+ do loop6 10 9
+
+
+ let loop7 a step N =
+ let mutable x = 0 in
+ // In this loop, the types of 'a' and 'N' are not known prior to the loop
+ for i in (min a a) .. step .. (min N N) do
+ x <- x + 1
+ done;
+ check (sprintf "clkrerev95-%A" (a,step,N)) x (if step < 0 then (if a < N then 0 else (a - N + abs step) / abs step) else (if N < a then 0 else N - a + step) / step)
+
+ do loop7 0 1 10
+ do loop7 0 -1 0
+ do loop7 0 2 -1
+ do loop7 10 -2 9
+
+ let loop8 a N =
+ let mutable x = 0 in
+ // In this loop, the types of 'a' and 'N' are not known prior to the loop
+ for i in (min a a) .. -1 .. (min N N) do
+ x <- x + 1
+ done;
+ check (sprintf "clkrerev96-%A" (a,N)) x (abs (if a < N then 0 else (a - N + 1) / 1))
+
+ do loop8 0 10
+ do loop8 0 0
+ do loop8 0 -1
+ do loop8 10 9
+
+// Some more adhoc testing - the use of 'min' gives rise to a let binding in optimized code
+module MoreLoopTestsWithLetBindings =
+ let loop3 a N =
+ let mutable x = 0 in
+ // In this loop, the types of 'a' and 'N' are not known prior to the loop
+ for i in (min a a) .. (min N N) do
+ x <- x + 1
+ done;
+ check (sprintf "ffclkrerev90-%A" (a,N)) x (if N < a then 0 else N - a + 1)
+
+
+ do loop3 0 10
+ do loop3 0 0
+ do loop3 0 -1
+ do loop3 10 9
+ do for start in -3 .. 3 do for finish in -3 .. 3 do loop3 start finish
+
+ let loop4 a N =
+ let mutable x = 0 in
+ for i in OperatorIntrinsics.RangeInt32 a 1 N do
+ x <- x + 1
+ done;
+ check (sprintf "ffclkrerev91-%A" (a,N)) x (if N < a then 0 else N - a + 1)
+
+ do loop4 0 10
+ do loop4 0 0
+ do loop4 0 -1
+ do loop4 10 9
+ do for start in -3 .. 3 do for finish in -3 .. 3 do loop4 start finish
+
+ let loop5 a N =
+ let mutable x = 0 in
+ // In this loop, the types of 'a' and 'N' are not known prior to the loop
+ for i in (min a a) .. 2 .. (min N N) do
+ x <- x + 1
+ done;
+ check (sprintf "ffclkrerev92-%A" (a,N)) x ((if N < a then 0 else N - a + 2) / 2)
+
+ do loop5 0 10
+ do loop5 0 0
+ do loop5 0 -1
+ do loop5 10 9
+ do for start in -3 .. 3 do for finish in -3 .. 3 do loop5 start finish
+
+
+ let loop6 a N =
+ let mutable x = 0 in
+ // In this loop, the types of 'a' and 'N' are not known prior to the loop
+ for i in (min a a) .. 200 .. (min N N) do
+ x <- x + 1
+ done;
+ check (sprintf "ffclkrerev93-%A" (a,N)) x ((if N < a then 0 else N - a + 200) / 200)
+
+ do loop6 0 10
+ do loop6 0 0
+ do loop6 0 -1
+ do loop6 10 9
+ do for start in -3 .. 3 do for finish in -3 .. 3 do loop6 start finish
+
+
+ let loop7 a step N =
+ let mutable x = 0 in
+ // In this loop, the types of 'a' and 'N' are not known prior to the loop
+ for i in (min a a) .. step .. (min N N) do
+ x <- x + 1
+ done;
+ check (sprintf "ffclkrerev95-%A" (a,step,N)) x (if step < 0 then (if a < N then 0 else (a - N + abs step) / abs step) else (if N < a then 0 else N - a + step) / step)
+
+ do loop7 0 1 10
+ do loop7 0 -1 0
+ do loop7 0 2 -1
+ do loop7 10 -2 9
+ do for start in -3 .. 3 do for finish in -3 .. 3 do for step in [-2; -1; 1; 2] do loop7 start step finish
+
+ let loop8 a N =
+ let mutable x = 0 in
+ // In this loop, the types of 'a' and 'N' are not known prior to the loop
+ for i in (min a a) .. -1 .. (min N N) do
+ x <- x + 1
+ done;
+ check (sprintf "ffclkrerev96-%A" (a,N)) x (abs (if a < N then 0 else (a - N + 1) / 1))
+
+ do loop8 0 10
+ do loop8 0 0
+ do loop8 0 -1
+ do loop8 10 9
+ do for start in -3 .. 3 do for finish in -3 .. 3 do loop8 start finish
+
+module bug872632 =
+ type MarkerStyle =
+ | None = 0
+ | Square = 1
+ | Circle = 2
+ | Diamond = 3
+ | Triangle = 4
+ | Triangle1 = 10
+ | Cross = 5
+ | Star4 = 6
+ | Star5 = 7
+ | Star6 = 8
+ | Star10 = 9
+
+
+
+ module Foo =
+ let x = [|
+ MarkerStyle.Circle
+ MarkerStyle.Cross
+ MarkerStyle.Star6
+ MarkerStyle.Diamond
+ MarkerStyle.Square
+ MarkerStyle.Star10
+ MarkerStyle.Triangle
+ MarkerStyle.Triangle1
+ |]
+
+ do check "bug872632" Foo.x.Length 8
+
+module CheckUnionTypesAreSealed =
+ open System
+#if NETCOREAPP
+ open System.Reflection
+ type System.Type with
+ member this.IsSealed
+ with get () = this.GetTypeInfo().IsSealed
+#endif
+
+ do check "vwllfewlkefw1" (typedefof>.IsSealed) true
+ do check "vwllfewlkefw2" (typedefof>.IsSealed) true
+ type X1 = A | B
+ do check "vwllfewlkefw3" (typedefof.IsSealed) true
+ type X2 = A | B of string
+ do check "vwllfewlkefw4" (typedefof.IsSealed) false
+ type X3 = A | B | C
+ do check "vwllfewlkefw5" (typedefof.IsSealed) true
+ type X4 = A | B | C | D | E | F | G | H | I
+ do check "vwllfewlkefw5" (typedefof.IsSealed) true
+
+ []
+ type SetTree<'T> =
+ | SetEmpty
+ | SetNode of 'T * SetTree<'T> * SetTree<'T>
+ do check "vwllfewlkefw6" (typedefof>.IsSealed) true
+
+ type SetTree2<'T> =
+ | SetEmpty
+ | SetNode of 'T * SetTree2<'T> * SetTree2<'T>
+ do check "vwllfewlkefw6" (typedefof>.IsSealed) false
+
+module manyIndexes =
+ open System
+
+ // Bug in F# 3.1: Indexer Properties was incorrectly limited to 4 arguments. There were no limits in previous versions of F#, and shouldn't be in future versions
+ // Repro code for bug in F# 3.1. This compiles perfectly in F# 3.0
+
+ // ----------------------------------------------------------------------------
+ type Test () =
+ /// Variable number of arguments with indexer property
+ member x.Item with get ([] objs: obj[]) = objs
+
+ /// PASS: Variable number of arguments with member function
+ member x.Foo ([] objs: obj[]) = objs
+
+ // ----------------------------------------------------------------------------
+ let CompileIndexerTest =
+ let test = Test ()
+
+ // No problems with method having vaiable number of parameters
+ let u1 = test.Foo(null, null, null, null)
+ let u2 = test.Foo(null, null, null, null, null)
+ let u3 = test.Foo(null, null, null, null, null, null, null, null, null)
+
+ // Bug was that the indexer Property was limited to 4 parameters (Issue introduced by matrix slicing code)
+ let u4 = test.[null]
+ let u5 = test.[null, null]
+ let u6 = test.[null, null, null]
+ let u7 = test.[null, null, null, null]
+ let u8 = test.[null, null, null, null, null] // Ensure that F# 3.1 is not unhappy with more than 4 arguments
+ let u9 = test.[null, null, null, null, null, null, null, null, null, null, null, null, null] // Ensure that F# 3.1 is not unhappy with many more than 4 arguments, 13 arguments would be really unlucky
+ 0
+
+
+#if !NETCOREAPP
+module bug6447 =
+ let a = System.Array.CreateInstance(typeof, [|1|], [|1|])
+ let a1 = System.Array.CreateInstance(typeof, [|1|], [|3|])
+ let a2 = System.Array.CreateInstance(typeof, [|3|], [|1|])
+
+ do check "bug6447_bound1" a a
+ do check "bug6447_bound3" a1 a1
+ do check "bug6447_bound1_3" a2 a2
+ do check "bug6447_a_lt_a" (Unchecked.compare a a) 0
+ do check "bug6447_a_eq_a1" (Unchecked.equals a a1) false
+ do check "bug6447_a_lt_a1" (Unchecked.compare a a1) -1
+ do check "bug6447_a_lt_a1" (Unchecked.compare a1 a) 1
+ do check "bug6447_a_eq_a2" (Unchecked.equals a a2) false
+ do check "bug6447_a_lt_a2" (Unchecked.compare a a2) -1
+ do check "bug6447_a_lt_a2" (Unchecked.compare a2 a) 1
+ do check "bug6447_a1_eq_a2" (Unchecked.equals a1 a2) false
+ do check "bug6447_a1_gt_a2" (Unchecked.compare a2 a1) 1
+ do check "bug6447_a1_lt_a2" (Unchecked.compare a1 a2) -1
+ do check "bug6447_a1_lt_a2" (Unchecked.compare a2 a1) 1
+ do check "bug6447_a2_eq_a1" (Unchecked.equals a2 a1) false
+ do check "bug6447_a2_gt_a2" (Unchecked.compare a2 a1) 1
+ do check "bug6447_a2_lt_a1" (Unchecked.compare a1 a2) -1
+ do check "bug6447_hash_a" (hash a) 631
+ do check "bug6447_hash_a1" (hash a1) 1893
+ do check "bug6447_hash_a2" (hash a2) 10727
+#endif
+
+#if TESTS_AS_APP
+let RUN() = failures
+#else
+let aa =
+ match failures with
+ | [] ->
+ stdout.WriteLine "Test Passed"
+ System.IO.File.WriteAllText("test.ok","ok")
+ exit 0
+ | _ ->
+ stdout.WriteLine "Test Failed"
+ exit 1
+#endif
+
diff --git a/tests/fsharp/core/classStructInterface/test.fsx b/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/class_struct_interface.fsx
similarity index 100%
rename from tests/fsharp/core/classStructInterface/test.fsx
rename to tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/class_struct_interface.fsx
diff --git a/tests/fsharp/core/functionTypes/test.fs b/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/function_types.fs
similarity index 100%
rename from tests/fsharp/core/functionTypes/test.fs
rename to tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/function_types.fs
diff --git a/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/generic_measures.fsx b/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/generic_measures.fsx
new file mode 100644
index 00000000000..58980f9d51f
--- /dev/null
+++ b/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/generic_measures.fsx
@@ -0,0 +1,74 @@
+module Core_genericMeasures
+
+[]
+[]
+ type C<'T> () =
+ member val P = 1 with get,set
+
+[] type t
+[] type t2
+let f1 (_ : int) = ()
+let f2 (_ : float) = ()
+let f3 (_ : int<_>) = ()
+let f4 (_ : float<_>) = ()
+let f5 (_ : C<'a>) = ()
+let f6 (xs : list<'a>) =
+ match box xs with
+ | null -> failwith "unexpected null list"
+ | _ -> if List.length xs <> 0 then failwith "expected empty list"
+let f7 (xs : list<'a>) =
+ match box xs with
+ | null -> failwith "unexpected null list"
+ | _ -> if List.length xs <> 0 then failwith "expected empty list"
+
+let foo() =
+ let a = 0<_>
+ let b = 0.0<_>
+ let c = null : C>
+ let c2 = c : C>
+ let d = null : C>
+ let e = [] : list>
+ let f = [] : list>
+ let g = null : C * _>
+ let h = null : C<_ * int<_> * _>
+ let i : List> = List.empty
+ let j : List> = List.empty
+ let k : List> = j
+
+ f1 a
+ f2 b
+ f3 a
+ f4 b
+ f5 c
+ f5 c2
+ f5 d
+ f6 e
+ f6 f
+ f5 g
+ f5 h
+ f6 i
+ f6 j
+ f7 (i : List>)
+ f7 (i : List>)
+ f7 (j : List>)
+ f7 (j : List>)
+ f7 (k : List>)
+ f7 (k : List>)
+
+[]
+type T =
+ static member Foo(_ : int) = ()
+ static member Foo1(_ : int<_>) = ()
+
+ static member Bar() =
+ let x = 0<_>
+ T.Foo(x)
+
+ static member Baz() =
+ let x = 0<_>
+ T.Foo1(x)
+
+let RunAll() =
+ foo()
+ T.Bar()
+ T.Baz()
\ No newline at end of file
diff --git a/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/innerpoly.fsx b/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/innerpoly.fsx
new file mode 100644
index 00000000000..140c584ed79
--- /dev/null
+++ b/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/innerpoly.fsx
@@ -0,0 +1,448 @@
+// #Conformance #Regression #LetBindings #TypeInference
+#if TESTS_AS_APP
+module Core_innerpoly
+#endif
+
+let failures = ref []
+
+let report_failure (s : string) =
+ stderr.Write" NO: "
+ stderr.WriteLine s
+ failures.Value <- failures.Value @ [s]
+
+let test (s : string) b =
+ stderr.Write(s)
+ if b then stderr.WriteLine " OK"
+ else report_failure (s)
+
+let check s b1 b2 = test s (b1 = b2)
+
+module TestNullIsGeneralizeable = begin
+
+ open System.Collections.Generic
+ let nullList : List<'a> = null
+
+ // check this is generic
+
+ let v1 = (nullList : List)
+ let v2 = (nullList : List)
+end
+
+let f (x:'a) =
+ let rec g1 y z = g2 y z
+ and g2 y z = g1 y z in
+ g1 "a" 1, g1 1 "a", g2 "a" "b", g2 3 4
+
+
+#if OCAML_RECORD_FIELDS
+type z = { x : 'a. int -> 'a }
+
+let z2 = { x = (fun x -> failwith "a") }
+
+let f3 (x:int) = failwith "a"
+let z3 = { x = f3 }
+
+let f2 n =
+ let z2 = { x = (fun (x:int) -> failwith (string_of_int (x+n))) } in
+ let f3 (x:int) = failwith "a" in
+ z2
+
+let _ : string = try (f2 3).x(3) ^ "unused" with Failure _ -> ""
+#endif
+
+
+
+
+let id x = x
+
+type ('a,'b) r = {a : 'a list; b: 'b list list }
+type ('a,'b) r2 = R2 of 'a list * 'b list list
+
+let () =
+ // yes folks, OCaml and F# support let-polymorphism for non-trivial patterns such as these
+ let a,b = None,None in
+ let _ = (a : int option) in
+ let _ = (a : string option) in
+ let _ = (b : int option) in
+ let _ = (b : string option) in
+ let f (x:'a) (y:'b) =
+ let _ = (a : 'a option) in
+ let _ = (a : 'b option) in
+ let _ = (b : 'a option) in
+ let _ = (b : 'b option) in
+ () in
+ f 1 "a";
+ f 1 1;
+ let {a=a;b=b} = {a=[];b=[[]]} in
+ let _ = (a : int list) in
+ let _ = (a : string list) in
+ let _ = (b : int list list) in
+ let _ = (b : string list list) in
+ let f (x:'a) (y:'b) =
+ let _ = (a : 'a list) in
+ let _ = (a : 'a list) in
+ let _ = (b : 'b list list) in
+ let _ = (b : 'b list list) in
+ () in
+ f 1 "a";
+ f 1 1;
+ let (R2(a,b)) = R2 ([],[[]]) in
+ let _ = (a : int list) in
+ let _ = (a : string list) in
+ let _ = (b : int list list) in
+ let _ = (b : string list list) in
+ let f (x:'a) (y:'b) =
+ let _ = (a : 'a list) in
+ let _ = (a : 'a list) in
+ let _ = (b : 'b list list) in
+ let _ = (b : 'b list list) in
+ () in
+ f 1 "a";
+ f 1 1;
+ let (R2((a as a2),(b as b2))) = R2 ([],[[]]) in
+ let _ = (a2 : int list) in
+ let _ = (a2 : string list) in
+ let _ = (b2 : int list list) in
+ let _ = (b2 : string list list) in
+ let f (x:'a) (y:'b) =
+ let _ = (a2 : 'a list) in
+ let _ = (a2 : 'a list) in
+ let _ = (b2 : 'b list list) in
+ let _ = (b2 : 'b list list) in
+ () in
+ f 1 "a";
+ f 1 1;
+ // possibly-failing versions of the above
+
+ let [(a,b)] = [(None,None)] in
+ let _ = (a : int option) in
+ let _ = (a : string option) in
+ let _ = (b : int option) in
+ let _ = (b : string option) in
+ let f (x:'a) (y:'b) =
+ let _ = (a : 'a option) in
+ let _ = (a : 'b option) in
+ let _ = (b : 'a option) in
+ let _ = (b : 'b option) in
+ () in
+ f 1 "a";
+ f 1 1;
+ let [{a=a;b=b}] = [{a=[];b=[[]]}] in
+ let _ = (a : int list) in
+ let _ = (a : string list) in
+ let _ = (b : int list list) in
+ let _ = (b : string list list) in
+ let f (x:'a) (y:'b) =
+ let _ = (a : 'a list) in
+ let _ = (a : 'a list) in
+ let _ = (b : 'b list list) in
+ let _ = (b : 'b list list) in
+ () in
+ f 1 "a";
+ f 1 1;
+ let [(R2(a,b))] = [R2 ([],[[]])] in
+ let _ = (a : int list) in
+ let _ = (a : string list) in
+ let _ = (b : int list list) in
+ let _ = (b : string list list) in
+ let f (x:'a) (y:'b) =
+ let _ = (a : 'a list) in
+ let _ = (a : 'a list) in
+ let _ = (b : 'b list list) in
+ let _ = (b : 'b list list) in
+ () in
+ f 1 "a";
+ f 1 1;
+ let [(R2((a as a2),(b as b2)))] = [R2 ([],[[]])] in
+ let _ = (a2 : int list) in
+ let _ = (a2 : string list) in
+ let _ = (b2 : int list list) in
+ let _ = (b2 : string list list) in
+ let f (x:'a) (y:'b) =
+ let _ = (a2 : 'a list) in
+ let _ = (a2 : 'a list) in
+ let _ = (b2 : 'b list list) in
+ let _ = (b2 : 'b list list) in
+ () in
+ f 1 "a";
+ f 1 1;
+ ()
+
+
+
+let _ =
+ let f x = x in
+ f (printfn "%s") "Hello, world!\n";
+ f (printfn "%d") 3;
+ f (printfn "%s") "Hello, world!\n"
+
+let test5365() =
+ let f x = x in
+ f (printfn "%s") "Hello, world!\n";
+ f (printfn "%d") 3;
+ f (printfn "%s") "Hello, world!\n"
+
+do test5365()
+do test5365()
+
+module TestOptimizationOfTypeFunctionsWithSideEffects = begin
+ let mutable count = 0
+ let f<'a> = count <- (count + 1); count
+
+
+ do test "eoeo23c1" (f = 1)
+ do test "eoeo23c2" (f = 2)
+ do test "eoeo23c3" (f = 3)
+
+ let x1 = f
+
+ do test "eoeo23c4" (x1 = 4)
+ do test "eoeo23c5" (x1 = 4)
+end
+
+module Bug1126BenjaminTeuber = begin
+ let Run() =
+ // put in the declaration and the error vanishes
+ let PrintAll (values(* : int seq*)) =
+ for value in values do
+ printf "%i" value
+ done
+ let CallPrintAll (values : int seq) =
+ printfn "Caling Sum" ;
+ values |> PrintAll in
+ printfn "Done" ;
+ let MyFun () =
+ let mySeq = [5 ; 5] |> List.toSeq in
+ mySeq |> CallPrintAll in
+ MyFun()
+
+ do Run()
+end
+
+module FSharp_1_0_Bug1024 = begin
+ let mutable count = 1
+ let x<'a> = (count <- count + 1); typeof<'a>
+
+ do test "vnwo9wu1" (count = 1)
+ let z0<'a> = x<'a>
+ do test "vnwo9wu1" (count = 1)
+ let z1 = x
+ do test "vnwo9wu2" (count = 2)
+ let z2 = x
+ do test "vnwo9wu3" (count = 3)
+
+end
+module FSharp_1_0_Bug1024B = begin
+ let mutable count = 1
+ let r<'a> = (count <- count + 1); ref ([] : 'a list)
+ do test "vnwo9wu1" (count = 1)
+ let x1 = r
+
+ do test "vnwo9wu1" (count = 2)
+ let z0 = x1
+ do test "vnwo9wu1" (count = 2)
+ let (z1,z2) = (x1,x1)
+ do test "vnwo9wu2" (count = 2)
+ let z3 = x1
+ do test "vnwo9wu3" (count = 2)
+
+end
+
+
+
+module CheckGenericInnerMethodWithClassConstraint = begin
+ let Main() =
+ // null Seq
+ let func x = null
+ let initFinite = Seq.init 3 func
+ let expectedNullSeq = seq [ null;null;null]
+ printfn "%A" initFinite
+
+ Main()
+end
+
+module CheckGenericInnerMethodWithNullableConstraint = begin
+ let Main() =
+ // null Seq
+ let func x = System.Nullable(2)
+ let initFinite = Seq.init 3 func
+ printfn "%A" initFinite
+
+ Main()
+end
+
+module CheckGenericInnerMethodWithNullConstraintMicro = begin
+ let Main() =
+ // null Seq
+ let func (x:int) : 'T when 'T : null = Unchecked.defaultof<'T>
+ let initFinite = Seq.init 3 func
+ printfn "%A" initFinite
+
+ Main()
+end
+
+module CheckGenericInnerMethodWithStructConstraintMicro = begin
+ let Main() =
+ // null Seq
+ let func (x:int) : 'T when 'T : struct = Unchecked.defaultof<'T>
+ let initFinite = Seq.init 3 func
+
+
+ printfn "%A" initFinite
+
+ Main()
+end
+
+module CheckGenericInnerMethodWithClassConstraintMicro = begin
+ let Main() =
+ // null Seq
+ let func (x:int) : 'T when 'T : not struct = Unchecked.defaultof<'T>
+ let initFinite = Seq.init 3 func
+
+ printfn "%A" initFinite
+
+ Main()
+end
+
+module CheckGenericInnerMethodWithUnmanagedConstraintMicro = begin
+ let Main() =
+ // null Seq
+ let func (x:int) : 'T when 'T : unmanaged = Unchecked.defaultof<'T>
+ let initFinite = Seq.init 3 func
+ printfn "%A" initFinite
+
+ Main()
+end
+
+module CheckGenericInnerMethodWithDefaultCtorConstraintMicro = begin
+ let Main() =
+ // null Seq
+ let func (x:int) : 'T when 'T : (new : unit -> 'T) = Unchecked.defaultof<'T>
+ let initFinite = Seq.init 3 func
+
+
+ printfn "%A" initFinite
+
+ Main()
+end
+
+
+module CheckGenericInnerMethodWithEnumConstraintMicro = begin
+ let Main() =
+ // null Seq
+ let func (x:int) : 'T when 'T : enum = Unchecked.defaultof<'T>
+ let initFinite = Seq.init 3 func
+ printfn "%A" initFinite
+
+ Main()
+end
+
+module CheckGenericInnerMethodWithDelegateConstraintMicro = begin
+ let Main() =
+ // null Seq
+ let func (x:int) : 'T when 'T : delegate = Unchecked.defaultof<'T>
+ let initFinite = Seq.init 3 func
+ printfn "%A" initFinite
+
+ Main()
+end
+
+module CheckExplicitSignatureWhichHidesDefaultConstraint_DevDiv2_FSharp_95481 = begin
+
+ let inline sincos< ^t when ^t : (static member Sin : ^t -> ^t)
+ and ^t : (static member Cos : ^t -> ^t)> (a: ^t) =
+ let y = sin a
+ let x = cos a
+ y, x
+
+end
+
+// try a "let rec"
+module CheckExplicitSignatureWhichHidesDefaultConstraint_DevDiv2_FSharp_95481_Variation1 = begin
+
+ let rec inline sincos< ^t when ^t : (static member Sin : ^t -> ^t)
+ and ^t : (static member Cos : ^t -> ^t)> (a: ^t) =
+ let y = sin a
+ let x = cos a
+ y, x
+
+
+end
+
+module CheckExplicitSignatureWhichHidesDefaultConstraint_DevDiv2_FSharp_95481_Variation2 = begin
+
+ let inline sincos (a: ^t) =
+ let y = sin a
+ let x = cos a
+ y, x
+
+end
+
+module InnerGenericBindingsInComputationExpressions = begin
+ let f() =
+ let r = [|
+ let N x = System.Nullable<_>(x)
+ for i in 1..3 do
+ yield N i
+ |]
+ r
+ f()
+end
+
+module LocalTypeFunctionRequiredForWitnessPassingOfGenericInnerFunctionsConstrainedByMemberConstraints =
+ let inline clamp16 v = uint16 (max 0. (min 65535. v))
+ let inline clamp8 v = uint8 (max 0. (min 255. v))
+ []
+ type Clampage =
+ static member inline FromFloat (_ : byte, _ : Clampage) = fun (x : float) -> clamp8 x
+ static member inline FromFloat (_ : uint16, _ : Clampage) = fun (x : float) -> clamp16 x
+
+ static member inline Invoke (x: float) : 'Num =
+ let inline call2 (a: ^a, b: ^b) = ((^a or ^b) : (static member FromFloat : _*_ -> _) (b, a))
+ let inline call (a: 'a) = fun (x: 'x) -> call2 (a, Unchecked.defaultof<'r>) x : 'r
+ call Unchecked.defaultof x
+
+ let inline clamp x = Clampage.Invoke x
+ let x1 : byte = clamp 3.0
+ let x2 : uint16 = clamp 3.0
+ let x3 : byte = clamp 257.0
+ check "clecqwe1" x1 3uy
+ check "clecqwe2" x2 3us
+ check "clecqwe3" x3 255uy
+
+// Same as the above but capturing an extra constrained free type variable 'Free
+module LocalTypeFunctionRequiredForWitnessPassingOfGenericInnerFunctionsConstrainedByMemberConstraints2 =
+ let inline clamp16 v = uint16 (max 0. (min 65535. v))
+ let inline clamp8 v = uint8 (max 0. (min 255. v))
+ []
+ type Clampage =
+ static member inline FromFloat (_ : byte, _ : Clampage) = fun (x : float) -> clamp8 x
+ static member inline FromFloat (_ : uint16, _ : Clampage) = fun (x : float) -> clamp16 x
+
+ static member inline Invoke (x: float) (free: 'Free) : 'Num * 'Free =
+ let inline call2 (a: ^a, b: ^b) = ((^a or ^b) : (static member FromFloat : _*_ -> _) (b, a))
+ let inline call (a: 'a) = (fun (x: 'x) -> call2 (a, Unchecked.defaultof<'r>) x : 'r), free + free
+ let f, info = call Unchecked.defaultof
+ f x, info
+
+ let inline clamp x free = Clampage.Invoke x free
+ let (x1a1: byte, x1a2: int64) = clamp 3.0 1L
+ let (x1b1: uint16, x1b2: string) = clamp 3.0 "abc"
+ check "clecqwea1" x1a1 3uy
+ check "clecqwea2" x1a2 2L
+ check "clecqwea3" x1b1 3us
+ check "clecqwea4" x1b2 "abcabc"
+
+module Bug10408 =
+ let test x =
+ match x with
+ | [| |] -> x
+ | _ -> x
+
+module Bug11620A =
+
+ let createService (metadata: 'T) : 'Data when 'Data :> System.IComparable = Unchecked.defaultof<'Data>
+
+ let getCreateServiceCallback<'T> (thing: 'T) =
+ let getService () : 'Data = createService thing
+ (fun () -> getService)
\ No newline at end of file
diff --git a/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/libtest.fsx b/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/libtest.fsx
new file mode 100644
index 00000000000..49a199b5ff3
--- /dev/null
+++ b/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/libtest.fsx
@@ -0,0 +1,5660 @@
+// #Regression #Conformance #Regression #Exceptions #Constants #LetBindings #Lists #Collections #Stress #Sequences #Optimizations #Records #Unions
+#if TESTS_AS_APP
+module Core_libtest
+#endif
+
+let (!) (r: 'T ref) = r.Value
+let (:=) (r: 'T ref) (v: 'T) = r.Value <- v
+let incr (r: int ref) = r.Value <- r.Value + 1
+let decr (r: int ref) = r.Value <- r.Value - 1
+
+#nowarn "62"
+#nowarn "44"
+
+let failures = ref []
+let reportFailure s =
+ stdout.WriteLine "\n................TEST FAILED...............\n"; failures.Value <- failures.Value @ [s]
+
+let check s e r =
+ if r = e then stdout.WriteLine (s^": YES")
+ else (stdout.WriteLine ("\n***** "^s^": FAIL\n"); reportFailure s)
+
+let test s b =
+ if b then ( (* stdout.WriteLine ("passed: " + s) *) )
+ else (stderr.WriteLine ("failure: " + s);
+ reportFailure s)
+
+
+let format_uint64 outc formatc width left_justify add_zeros num_prefix_if_pos (n:uint64) =
+ let _ = match formatc with 'd' | 'i' | 'u' -> 10UL | 'o' -> 8UL | 'x' | 'X'-> 16UL | _ -> failwith "invalid value" in
+ failwith "hello"
+
+
+(*---------------------------------------------------------------------------
+!* Exceptions
+ *--------------------------------------------------------------------------- *)
+
+let myFunc x y =
+ if x > y then stdout.WriteLine "greater";
+ if x < y then stdout.WriteLine "less";
+ try
+ if x = y then stdout.WriteLine "equal";
+ failwith "fail";
+ reportFailure "ABCDE"
+ with Failure s ->
+ stdout.WriteLine "caught!";
+
+let _ = myFunc 1 4
+let _ = myFunc "a" "b"
+let _ = myFunc "c" "b"
+let _ = myFunc "c" "c"
+let _ =
+ myFunc
+ begin
+ try
+ failwith "string1";
+ with Failure s ->
+ s;
+ end
+ begin
+ try
+ failwith "string2";
+ with Failure s ->
+ s;
+ end
+
+let _ =
+ myFunc
+ begin
+ try
+ begin
+ try
+ failwith "yes";
+ with e ->
+ reraise (); failwith "no"
+ end
+ with Failure "yes" -> "yes"
+ end
+ begin
+ try
+ begin
+ try
+ failwith "yes";
+ with e ->
+ reraise (); failwith "no"
+ end
+ with Failure "yes" -> "yes"
+ end
+
+
+//---------------------------------------------------------------------------
+// Basic operations
+//---------------------------------------------------------------------------
+
+#if INVARIANT_CULTURE_STRING_COMPARISON
+// These check we are using InvariantCulture string comparison, not Ordinal comparison
+let _ = check "vknwwer41" (";" > "0") false
+let _ = check "vknwwer42" (";" >= "0") false
+let _ = check "vknwwer43" (";" = "0") false
+let _ = check "vknwwer44" (";" <> "0") true
+let _ = check "vknwwer53" (";" <= "0") true
+let _ = check "vknwwer54" (";" < "0") true
+let _ = check "vknwwer55" (compare ";" "0") -1
+let _ = check "vknwwer55" (compare "0" ";") 1
+
+(*
+// check consistency with characters
+let _ = check "vknwwer41" (';' > '0') false
+let _ = check "vknwwer42" (';' >= '0') false
+let _ = check "vknwwer43" (';' = '0') false
+let _ = check "vknwwer44" (';' <> '0') true
+let _ = check "vknwwer53" (';' <= '0') true
+let _ = check "vknwwer54" (';' < '0') true
+let _ = check "vknwwer55" (compare ';' '0') -1
+let _ = check "vknwwer55" (compare '0' ';') 1
+*)
+
+// check consistency with lists of strings
+let _ = check "vknwwer41" ([";"] > ["0"]) false
+let _ = check "vknwwer42" ([";"] >= ["0"]) false
+let _ = check "vknwwer43" ([";"] = ["0"]) false
+let _ = check "vknwwer44" ([";"] <> ["0"]) true
+let _ = check "vknwwer53" ([";"] <= ["0"]) true
+let _ = check "vknwwer54" ([";"] < ["0"]) true
+let _ = check "vknwwer55" (compare [";"] ["0"]) -1
+let _ = check "vknwwer55" (compare ["0"] [";"]) 1
+
+(*
+// check consistency with lists of chars
+let _ = check "vknwwer41" ([';'] > ['0']) false
+let _ = check "vknwwer42" ([';'] >= ['0']) false
+let _ = check "vknwwer43" ([';'] = ['0']) false
+let _ = check "vknwwer44" ([';'] <> ['0']) true
+let _ = check "vknwwer53" ([';'] <= ['0']) true
+let _ = check "vknwwer54" ([';'] < ['0']) true
+let _ = check "vknwwer55" (compare [';'] ['0']) -1
+let _ = check "vknwwer55" (compare ['0'] [';']) 1
+*)
+#endif
+
+let getObjectHashCode (x:'a) = (box x).GetHashCode()
+let (===) (x:'a) (y:'a) = (box x).Equals(box y)
+
+let _ = stdout.WriteLine "90erw9"
+let _ = if true && true then stdout.WriteLine "YES" else reportFailure "intial test"
+let _ = if true && false then reportFailure "basic test 1" else stdout.WriteLine "YES"
+let _ = if false && true then reportFailure "basic test 2" else stdout.WriteLine "YES"
+let _ = if false && false then reportFailure "basic test 3" else stdout.WriteLine "YES"
+let _ = if true || true then stdout.WriteLine "YES" else reportFailure "basic test Q1"
+let _ = if true || false then stdout.WriteLine "YES" else reportFailure "basic test Q2"
+let _ = if false || true then stdout.WriteLine "YES" else reportFailure "basic test Q3"
+let _ = if false || false then reportFailure "basic test 4" else stdout.WriteLine "YES"
+
+let _ = stdout.WriteLine "vwlkew0"
+let _ = if true && true then stdout.WriteLine "YES" else reportFailure "basic test Q4"
+let _ = if true && false then reportFailure "basic test 5" else stdout.WriteLine "YES"
+let _ = if false && true then reportFailure "basic test 6" else stdout.WriteLine "YES"
+let _ = if false && false then reportFailure "basic test 7" else stdout.WriteLine "YES"
+let _ = if true || true then stdout.WriteLine "YES" else reportFailure "basic test Q5"
+let _ = if true || false then stdout.WriteLine "YES" else reportFailure "basic test Q6"
+let _ = if false || true then stdout.WriteLine "YES" else reportFailure "basic test Q7"
+let _ = if false || false then reportFailure "basic test 8" else stdout.WriteLine "YES"
+
+let _ = stdout.WriteLine "vr90vr90"
+let truE () = (stdout.WriteLine "."; true)
+let falsE () = (stdout.WriteLine "."; false)
+let _ = if truE() && truE() then stdout.WriteLine "YES" else reportFailure "basic test Q8"
+let _ = if truE() && falsE() then reportFailure "basic test 9" else stdout.WriteLine "YES"
+let _ = if falsE() && truE() then reportFailure "basic test 10" else stdout.WriteLine "YES"
+let _ = if falsE() && falsE() then reportFailure "basic test 11" else stdout.WriteLine "YES"
+let _ = if truE() || truE() then stdout.WriteLine "YES" else reportFailure "basic test Q9"
+let _ = if truE() || falsE() then stdout.WriteLine "YES" else reportFailure "basic test Q10"
+let _ = if falsE() || truE() then stdout.WriteLine "YES" else reportFailure "basic test Q11"
+let _ = if falsE() || falsE() then reportFailure "basic test 12" else stdout.WriteLine "YES"
+
+let _ = stdout.WriteLine "tgbri123d: "
+let truERR () = (reportFailure "basic test 13" ; true)
+let falsERR () = (reportFailure "basic test 14" ; false)
+let _ = if false && truERR() then reportFailure "basic test 15" else stdout.WriteLine "YES"
+let _ = if false && falsERR() then reportFailure "basic test 16" else stdout.WriteLine "YES"
+let _ = if true || truERR() then stdout.WriteLine "YES" else reportFailure "basic test Q12"
+let _ = if true || falsERR() then stdout.WriteLine "YES" else reportFailure "basic test Q13"
+
+let _ = stdout.WriteLine "d298c123d: "
+let _ = if falsE() && truERR() then reportFailure "basic test 17" else stdout.WriteLine "YES"
+let _ = if falsE() && falsERR() then reportFailure "basic test 18" else stdout.WriteLine "YES"
+let _ = if truE() || truERR() then stdout.WriteLine "YES" else reportFailure "basic test Q14"
+let _ = if truE() || falsERR() then stdout.WriteLine "YES" else reportFailure "basic test Q15"
+
+let _ = stdout.WriteLine "ddwqd123d: "
+let _ = if falsE() && truERR() then reportFailure "basic test 19" else stdout.WriteLine "YES"
+let _ = if falsE() && falsERR() then reportFailure "basic test 20" else stdout.WriteLine "YES"
+let _ = if truE() || truERR() then stdout.WriteLine "YES" else reportFailure "basic test Q16"
+let _ = if truE() || falsERR() then stdout.WriteLine "YES" else reportFailure "basic test Q17"
+
+
+let _ = stdout.WriteLine "d3wq123d: "
+let _ = if 1 = 1 then stdout.WriteLine "YES" else reportFailure "basic test Q18"
+let _ = if 1 === 1 then stdout.WriteLine "YES" else reportFailure "basic test Q19"
+let _ = if 1 < 2 then stdout.WriteLine "YES" else reportFailure "basic test Q20"
+let _ = if 2 > 1 then stdout.WriteLine "YES" else reportFailure "basic test Q21"
+let _ = if 2 >= 2 then stdout.WriteLine "YES" else reportFailure "basic test Q22"
+let _ = if 1 <= 2 then stdout.WriteLine "YES" else reportFailure "basic test Q23"
+let _ = if 2 <= 2 then stdout.WriteLine "YES" else reportFailure "basic test Q24"
+let _ = if 'c' < 'd' then stdout.WriteLine "YES" else reportFailure "basic test Q25"
+let _ = if 'c' <= 'c' then stdout.WriteLine "YES" else reportFailure "basic test Q26"
+let _ = if 'c' < 'c' then reportFailure "basic test 21" else stdout.WriteLine "YES"
+
+let printString (s:string) = System.Console.Write s
+let printInt (i:int) = System.Console.Write (string i)
+let printNewLine () = System.Console.WriteLine ()
+
+type fpclass =
+ | CaseA
+ | CaseB
+ | CaseC
+ | CaseD
+
+let _ = printString "d3123d: "; if CaseA = CaseA then stdout.WriteLine "YES" else reportFailure "basic test Q27"
+(*let _ = if FP_subnormal = FP_subnormal then stdout.WriteLine "YES" else reportFailure "basic test Q28" *)
+let _ = if CaseB = CaseB then stdout.WriteLine "YES" else reportFailure "basic test Q29"
+let _ = if CaseB === CaseB then stdout.WriteLine "YES" else reportFailure "basic test Q30"
+let _ = if CaseC = CaseC then stdout.WriteLine "YES" else reportFailure "basic test Q31"
+let _ = if CaseD = CaseD then stdout.WriteLine "YES" else reportFailure "basic test Q32"
+let _ = if CaseD === CaseD then stdout.WriteLine "YES" else reportFailure "basic test Q33"
+let _ = if CaseA <= CaseA then stdout.WriteLine "YES" else reportFailure "basic test Q34"
+(* let _ = if FP_subnormal <= FP_subnormal then stdout.WriteLine "YES" else reportFailure "basic test Q35"*)
+let _ = if CaseB <= CaseB then stdout.WriteLine "YES" else reportFailure "basic test Q36"
+let _ = if CaseC <= CaseC then stdout.WriteLine "YES" else reportFailure "basic test Q37"
+let _ = if CaseD <= CaseD then stdout.WriteLine "YES" else reportFailure "basic test Q38"
+let _ = if CaseA >= CaseA then stdout.WriteLine "YES" else reportFailure "basic test Q39"
+(* let _ = if FP_subnormal >= FP_subnormal then stdout.WriteLine "YES" else reportFailure "basic test Q40" *)
+let _ = if CaseB >= CaseB then stdout.WriteLine "YES" else reportFailure "basic test Q41"
+let _ = if CaseC >= CaseC then stdout.WriteLine "YES" else reportFailure "basic test Q42"
+let _ = if CaseD >= CaseD then stdout.WriteLine "YES" else reportFailure "basic test Q43"
+
+let _ = printString "d1t43: "; if CaseA < CaseA then reportFailure "basic test 22" else stdout.WriteLine "YES"
+(* let _ = if CaseA < FP_subnormal then stdout.WriteLine "YES" else reportFailure "basic test Q44"*)
+let _ = if CaseA < CaseB then stdout.WriteLine "YES" else reportFailure "basic test Q45"
+let _ = if CaseA < CaseC then stdout.WriteLine "YES" else reportFailure "basic test Q46"
+let _ = if CaseA < CaseD then stdout.WriteLine "YES" else reportFailure "basic test Q47"
+
+(* let _ = printString "er321: "; if FP_subnormal < CaseA then reportFailure "basic test Q48" else stdout.WriteLine "YES"
+let _ = if FP_subnormal < FP_subnormal then reportFailure "basic test Q49" else stdout.WriteLine "YES"
+let _ = if FP_subnormal < CaseB then stdout.WriteLine "YES" else reportFailure "basic test Q50"
+let _ = if FP_subnormal < CaseC then stdout.WriteLine "YES" else reportFailure "basic test Q51"
+let _ = if FP_subnormal < CaseD then stdout.WriteLine "YES" else reportFailure "basic test Q52" *)
+
+let _ = printString "ff23f2: ";if CaseB < CaseA then reportFailure "basic test 23" else stdout.WriteLine "YES"
+(* let _ = if CaseB < FP_subnormal then reportFailure "basic test Q53" else stdout.WriteLine "YES" *)
+let _ = if CaseB < CaseB then reportFailure "basic test 24" else stdout.WriteLine "YES"
+let _ = if CaseB < CaseC then stdout.WriteLine "YES" else reportFailure "basic test Q54"
+let _ = if CaseB < CaseD then stdout.WriteLine "YES" else reportFailure "basic test Q55"
+
+let _ = printString "f2234g54: ";if CaseC < CaseA then reportFailure "basic test 25" else stdout.WriteLine "YES"
+(* let _ = if CaseC < FP_subnormal then reportFailure "basic test Q56" else stdout.WriteLine "YES" *)
+let _ = if CaseC < CaseB then reportFailure "basic test 26" else stdout.WriteLine "YES"
+let _ = if CaseC < CaseC then reportFailure "basic test 27" else stdout.WriteLine "YES"
+let _ = if CaseC < CaseD then stdout.WriteLine "YES" else reportFailure "basic test Q57"
+
+let _ = printString "dw432b4: "; if CaseD < CaseA then reportFailure "basic test 28" else stdout.WriteLine "YES"
+(* let _ = if CaseD < FP_subnormal then reportFailure "basic test Q58" else stdout.WriteLine "YES" *)
+let _ = if CaseD < CaseB then reportFailure "basic test 29" else stdout.WriteLine "YES"
+let _ = if CaseD < CaseC then reportFailure "basic test 30" else stdout.WriteLine "YES"
+let _ = if CaseD < CaseD then reportFailure "basic test 31" else stdout.WriteLine "YES"
+
+let _ = printString "fdew093 "; if 1 < 2 then stdout.WriteLine "YES" else reportFailure "basic test Q59"
+let _ = if 1 < 1 then reportFailure "basic test 32" else stdout.WriteLine "YES"
+let _ = if 1 < 0 then reportFailure "basic test 33" else stdout.WriteLine "YES"
+let _ = if -1 < 0 then stdout.WriteLine "YES" else reportFailure "basic test Q60"
+let _ = if -1 < 1 then stdout.WriteLine "YES" else reportFailure "basic test Q61"
+
+let _ = stdout.WriteLine "dwqfwe3t:"
+let _ = printInt (compare "abc" "def"); printNewLine()
+let _ = printInt (compare "def" "abc"); printNewLine()
+let _ = printInt (compare "abc" "abc"); printNewLine()
+let _ = printInt (compare "aaa" "abc"); printNewLine()
+let _ = printInt (compare "abc" "aaa"); printNewLine()
+let _ = printInt (compare "longlonglong" "short"); printNewLine()
+let _ = printInt (compare "short" "longlonglong"); printNewLine()
+let _ = printInt (compare "" "a"); printNewLine()
+let _ = printInt (compare "a" ""); printNewLine()
+
+let _ = printString "grfwe3t "
+let _ = if "abc" < "def" then stdout.WriteLine "YES" else reportFailure "basic test Q62"
+let _ = if "def" < "abc" then reportFailure "basic test 34" else stdout.WriteLine "YES"
+let _ = if "abc" < "abc" then reportFailure "basic test 35" else stdout.WriteLine "YES"
+let _ = if "aaa" < "abc" then stdout.WriteLine "YES" else reportFailure "basic test Q63"
+let _ = if "abc" < "aaa" then reportFailure "basic test 36" else stdout.WriteLine "YES"
+let _ = if "longlonglong" < "short" then stdout.WriteLine "YES" else reportFailure "basic test Q64"
+let _ = if "short" < "longlonglong" then reportFailure "basic test 37" else stdout.WriteLine "YES"
+let _ = if "" < "a" then stdout.WriteLine "YES" else reportFailure "basic test Q65"
+let _ = if "a" < "" then reportFailure "basic test 38" else stdout.WriteLine "YES"
+
+let _ = printString "df32v4 "
+let _ = if "abc" = "def" then reportFailure "basic test 39" else stdout.WriteLine "YES"
+let _ = if "abc" === "def" then reportFailure "basic test 40" else stdout.WriteLine "YES"
+let _ = if "def" = "abc" then reportFailure "basic test 41" else stdout.WriteLine "YES"
+let _ = if "def" === "abc" then reportFailure "basic test 42" else stdout.WriteLine "YES"
+let _ = if "abc" = "abc" then stdout.WriteLine "YES" else reportFailure "basic test Q66"
+let _ = if "abc" === "abc" then stdout.WriteLine "YES" else reportFailure "basic test Q67"
+let _ = if "aaa" = "abc" then reportFailure "basic test 43" else stdout.WriteLine "YES"
+let _ = if "aaa" === "abc" then reportFailure "basic test 44" else stdout.WriteLine "YES"
+let _ = if "abc" = "aaa" then reportFailure "basic test 45" else stdout.WriteLine "YES"
+let _ = if "abc" === "aaa" then reportFailure "basic test 46" else stdout.WriteLine "YES"
+let _ = if "longlonglong" = "short" then reportFailure "basic test 47" else stdout.WriteLine "YES"
+let _ = if "longlonglong" === "short" then reportFailure "basic test 48" else stdout.WriteLine "YES"
+let _ = if "short" = "longlonglong" then reportFailure "basic test 49" else stdout.WriteLine "YES"
+let _ = if "short" === "longlonglong" then reportFailure "basic test 50" else stdout.WriteLine "YES"
+let _ = if "" = "" then stdout.WriteLine "YES" else reportFailure "basic test Q68"
+let _ = if "" === "" then stdout.WriteLine "YES" else reportFailure "basic test Q69"
+let _ = if "" = "a" then reportFailure "basic test 51" else stdout.WriteLine "YES"
+let _ = if "" === "a" then reportFailure "basic test 52" else stdout.WriteLine "YES"
+let _ = if "a" = "" then reportFailure "basic test 53" else stdout.WriteLine "YES"
+let _ = if "a" === "" then reportFailure "basic test 54" else stdout.WriteLine "YES"
+
+
+
+
+type abcde = A of int | B of abcde | C of string | D | E
+let _ = printString "32432465: "; if A 1 = A 1 then stdout.WriteLine "YES" else reportFailure "basic test Q70"
+let _ = if B E = B E then stdout.WriteLine "YES" else reportFailure "basic test Q71"
+let _ = if B E === B E then stdout.WriteLine "YES" else reportFailure "basic test Q72"
+let _ = if C "3" = C "3" then stdout.WriteLine "YES" else reportFailure "basic test Q73"
+let _ = if C "3" === C "3" then stdout.WriteLine "YES" else reportFailure "basic test Q74"
+let _ = if D = D then stdout.WriteLine "YES" else reportFailure "basic test Q75"
+let _ = if D === D then stdout.WriteLine "YES" else reportFailure "basic test Q76"
+let _ = if E = E then stdout.WriteLine "YES" else reportFailure "basic test Q77"
+let _ = if E === E then stdout.WriteLine "YES" else reportFailure "basic test Q78"
+let _ = printString "320-vrklm: "; if A 1 <= A 1 then stdout.WriteLine "YES" else reportFailure "basic test Q79"
+let _ = if B E <= B E then stdout.WriteLine "YES" else reportFailure "basic test Q80"
+let _ = if C "3" <= C "3" then stdout.WriteLine "YES" else reportFailure "basic test Q81"
+let _ = if D <= D then stdout.WriteLine "YES" else reportFailure "basic test Q82"
+let _ = if E <= E then stdout.WriteLine "YES" else reportFailure "basic test Q83"
+let _ = printString "9032c32nij: "; if A 1 >= A 1 then stdout.WriteLine "YES" else reportFailure "basic test Q84"
+let _ = if B E >= B E then stdout.WriteLine "YES" else reportFailure "basic test Q85"
+let _ = if C "3" >= C "3" then stdout.WriteLine "YES" else reportFailure "basic test Q86"
+let _ = if D >= D then stdout.WriteLine "YES" else reportFailure "basic test Q87"
+let _ = if E >= E then stdout.WriteLine "YES" else reportFailure "basic test Q88"
+
+
+let _ = printString "98vriu32: ";if A 1 < A 1 then reportFailure "basic test Q89" else stdout.WriteLine "YES"
+let _ = if A 1 < B E then stdout.WriteLine "YES" else reportFailure "basic test Q90"
+let _ = if A 1 < C "3" then stdout.WriteLine "YES" else reportFailure "basic test Q91"
+let _ = if A 1 < D then stdout.WriteLine "YES" else reportFailure "basic test Q92"
+let _ = if A 1 < E then stdout.WriteLine "YES" else reportFailure "basic test Q93"
+
+let _ = if B E < A 1 then reportFailure "basic test 55" else stdout.WriteLine "YES"
+let _ = if B E < B E then reportFailure "basic test 56" else stdout.WriteLine "YES"
+let _ = if B E < C "3" then stdout.WriteLine "YES" else reportFailure "basic test Q94"
+let _ = if B E < D then stdout.WriteLine "YES" else reportFailure "basic test Q95"
+let _ = if B E < E then stdout.WriteLine "YES" else reportFailure "basic test Q96"
+
+let _ = if C "3" < A 1 then reportFailure "basic test 57" else stdout.WriteLine "YES"
+let _ = if C "3" < B E then reportFailure "basic test 58" else stdout.WriteLine "YES"
+let _ = if C "3" < C "3" then reportFailure "basic test 59" else stdout.WriteLine "YES"
+let _ = if C "3" < D then stdout.WriteLine "YES" else reportFailure "basic test Q97"
+let _ = if C "3" < E then stdout.WriteLine "YES" else reportFailure "basic test Q99"
+
+let _ = if D < A 1 then reportFailure "basic test 60" else stdout.WriteLine "YES"
+let _ = if D < B E then reportFailure "basic test 61" else stdout.WriteLine "YES"
+let _ = if D < C "3" then reportFailure "basic test 62" else stdout.WriteLine "YES"
+let _ = if D < D then reportFailure "basic test 63" else stdout.WriteLine "YES"
+let _ = if D < E then stdout.WriteLine "YES" else reportFailure "basic test Q100"
+
+let _ = if E < A 1 then reportFailure "basic test 64" else stdout.WriteLine "YES"
+let _ = if E < B E then reportFailure "basic test 65" else stdout.WriteLine "YES"
+let _ = if E < C "3" then reportFailure "basic test 66" else stdout.WriteLine "YES"
+let _ = if E < D then reportFailure "basic test 67" else stdout.WriteLine "YES"
+let _ = if E < E then reportFailure "basic test 68" else stdout.WriteLine "YES"
+
+
+(* We put this test in as well as ILX uses a different rep. past 4 non-nullary constructors *)
+type abcde2 = Z2 | A2 of int | B2 of abcde2 | C2 of string | D2 of string
+let _ = printString "32432ew465: "; if A2 1 = A2 1 then stdout.WriteLine "YES" else reportFailure "basic test Q101"
+let _ = printString "32432ew465: "; if A2 1 === A2 1 then stdout.WriteLine "YES" else reportFailure "basic test Q102"
+let _ = if B2 Z2 = B2 Z2 then stdout.WriteLine "YES" else reportFailure "basic test Q103"
+let _ = if B2 Z2 === B2 Z2 then stdout.WriteLine "YES" else reportFailure "basic test Q104"
+let _ = if C2 "3" = C2 "3" then stdout.WriteLine "YES" else reportFailure "basic test Q105"
+let _ = if C2 "3" === C2 "3" then stdout.WriteLine "YES" else reportFailure "basic test Q106"
+let _ = if D2 "a" = D2 "a" then stdout.WriteLine "YES" else reportFailure "basic test Q107"
+let _ = if D2 "a" === D2 "a" then stdout.WriteLine "YES" else reportFailure "basic test Q108"
+let _ = if Z2 = Z2 then stdout.WriteLine "YES" else reportFailure "basic test Q109"
+let _ = if Z2 === Z2 then stdout.WriteLine "YES" else reportFailure "basic test Q110"
+let _ = printString "3vwa20-vrklm: "; if A2 1 <= A2 1 then stdout.WriteLine "YES" else reportFailure "basic test Q111"
+let _ = if B2 Z2 <= B2 Z2 then stdout.WriteLine "YES" else reportFailure "basic test Q112"
+let _ = if C2 "3" <= C2 "3" then stdout.WriteLine "YES" else reportFailure "basic test Q113"
+let _ = if D2 "a" <= D2 "a" then stdout.WriteLine "YES" else reportFailure "basic test Q114"
+let _ = if Z2 <= Z2 then stdout.WriteLine "YES" else reportFailure "basic test Q115"
+let _ = printString "9vaw032c32nij: "; if A2 1 >= A2 1 then stdout.WriteLine "YES" else reportFailure "basic test Q116"
+let _ = if B2 Z2 >= B2 Z2 then stdout.WriteLine "YES" else reportFailure "basic test Q117"
+let _ = if C2 "3" >= C2 "3" then stdout.WriteLine "YES" else reportFailure "basic test Q118"
+let _ = if D2 "a" >= D2 "a" then stdout.WriteLine "YES" else reportFailure "basic test Q119"
+let _ = if Z2 >= Z2 then stdout.WriteLine "YES" else reportFailure "basic test Q120"
+
+let _ = printString "vae98vriu32: "
+
+let _ = if Z2 < A2 1 then stdout.WriteLine "YES" else reportFailure "basic test Q121"
+let _ = if Z2 < B2 Z2 then stdout.WriteLine "YES" else reportFailure "basic test Q122"
+let _ = if Z2 < C2 "3" then stdout.WriteLine "YES" else reportFailure "basic test Q123"
+let _ = if Z2 < D2 "a" then stdout.WriteLine "YES" else reportFailure "basic test Q124"
+let _ = if Z2 < Z2 then reportFailure "basic test 69" else stdout.WriteLine "YES"
+
+let _ = printString "vae98312332: "
+
+let _ = if None < None then reportFailure "basic test 70" else stdout.WriteLine "YES"
+let _ = if None > None then reportFailure "basic test 71" else stdout.WriteLine "YES"
+let _ = if [] < [] then reportFailure "basic test 72" else stdout.WriteLine "YES"
+let _ = if [] > [] then reportFailure "basic test 73" else stdout.WriteLine "YES"
+let _ = if None <= None then stdout.WriteLine "YES" else reportFailure "basic test Q125"
+let _ = if None >= None then stdout.WriteLine "YES" else reportFailure "basic test Q126"
+let _ = if [] <= [] then stdout.WriteLine "YES" else reportFailure "basic test Q127"
+let _ = if [] >= [] then stdout.WriteLine "YES" else reportFailure "basic test Q128"
+
+let _ = printString "rege98312332: "
+
+let _ = if A2 1 < Z2 then reportFailure "basic test 74" else stdout.WriteLine "YES"
+let _ = if A2 1 < A2 1 then reportFailure "basic test 75" else stdout.WriteLine "YES"
+let _ = if A2 1 < B2 Z2 then stdout.WriteLine "YES" else reportFailure "basic test Q129"
+let _ = if A2 1 < C2 "3" then stdout.WriteLine "YES" else reportFailure "basic test Q130"
+let _ = if A2 1 < D2 "a" then stdout.WriteLine "YES" else reportFailure "basic test Q131"
+
+let _ = printString "328we32: "
+
+let _ = if B2 Z2 < Z2 then reportFailure "basic test 76" else stdout.WriteLine "YES"
+let _ = if B2 Z2 < A2 1 then reportFailure "basic test 77" else stdout.WriteLine "YES"
+let _ = if B2 Z2 < B2 Z2 then reportFailure "basic test 78" else stdout.WriteLine "YES"
+let _ = if B2 Z2 < C2 "3" then stdout.WriteLine "YES" else reportFailure "basic test Q132"
+let _ = if B2 Z2 < D2 "a" then stdout.WriteLine "YES" else reportFailure "basic test Q133"
+
+let _ = printString "ewknjs232: "
+
+let _ = if C2 "3" < Z2 then reportFailure "basic test 79" else stdout.WriteLine "YES"
+let _ = if C2 "3" < A2 1 then reportFailure "basic test 80" else stdout.WriteLine "YES"
+let _ = if C2 "3" < B2 Z2 then reportFailure "basic test 81" else stdout.WriteLine "YES"
+let _ = if C2 "3" < C2 "3" then reportFailure "basic test 82" else stdout.WriteLine "YES"
+let _ = if C2 "3" < D2 "a" then stdout.WriteLine "YES" else reportFailure "basic test Q134"
+
+let _ = printString "v30js232: "
+
+let _ = if D2 "a" < Z2 then reportFailure "basic test 83" else stdout.WriteLine "YES"
+let _ = if D2 "a" < A2 1 then reportFailure "basic test 84" else stdout.WriteLine "YES"
+let _ = if D2 "a" < B2 Z2 then reportFailure "basic test 85" else stdout.WriteLine "YES"
+let _ = if D2 "a" < C2 "3" then reportFailure "basic test 86" else stdout.WriteLine "YES"
+let _ = if D2 "a" < D2 "a" then reportFailure "basic test 87" else stdout.WriteLine "YES"
+
+let _ = printString "erv9232: "
+
+exception E1 of int
+exception E2 of int
+exception E3 of int * exn
+let _ = printString "exception equality 1"; if (E1(1) = E1(1)) then stdout.WriteLine "YES" else reportFailure "basic test Q135"
+let _ = printString "exception equality 2"; if (E1(1) <> E2(1)) then stdout.WriteLine "YES" else reportFailure "basic test Q136"
+
+let _ = printString "exception equality 3"; if (E3(1,E1(2)) = E3(1,E1(2))) then stdout.WriteLine "YES" else reportFailure "basic test Q137"
+let _ = printString "exception equality 4"; if (E3(1,E1(2)) <> E3(1,E2(2))) then stdout.WriteLine "YES" else reportFailure "basic test Q138"
+
+
+let _ = printString "match []? "; if (match [] with [] -> true | _ -> false) then stdout.WriteLine "YES" else reportFailure "basic test Q139"
+let _ = printString "[] = []? "; if ([] = []) then stdout.WriteLine "YES" else reportFailure "basic test Q140"
+
+let _ = printString "2033elk "
+let _ = if 1 = 0 then reportFailure "basic test 88" else stdout.WriteLine "YES"
+let _ = if 0 = 1 then reportFailure "basic test 89" else stdout.WriteLine "YES"
+let _ = if -1 = -1 then stdout.WriteLine "YES" else reportFailure "basic test Q141"
+
+let _ = printString "209fedq3lk "
+let _ = if 1 = 0 then reportFailure "basic test 90" else stdout.WriteLine "YES"
+let _ = if 1 === 0 then reportFailure "basic test 91" else stdout.WriteLine "YES"
+let _ = if 0 = 1 then reportFailure "basic test 92" else stdout.WriteLine "YES"
+let _ = if 0 === 1 then reportFailure "basic test 93" else stdout.WriteLine "YES"
+let _ = if -1 = -1 then stdout.WriteLine "YES" else reportFailure "basic test Q142"
+let _ = if -1 === -1 then stdout.WriteLine "YES" else reportFailure "basic test Q143"
+let _ = if 1 = 1 then stdout.WriteLine "YES" else reportFailure "basic test Q144"
+let _ = if 1 === 1 then stdout.WriteLine "YES" else reportFailure "basic test Q145"
+let _ = if (LanguagePrimitives.PhysicalEquality CaseB CaseC) then reportFailure "basic test 94" else stdout.WriteLine "YES"
+let _ = if (CaseB === CaseC) then reportFailure "basic test 95" else stdout.WriteLine "YES"
+
+let _ = if (LanguagePrimitives.PhysicalEquality (ref 1) (ref 1)) then reportFailure "basic test 96" else stdout.WriteLine "YES"
+
+
+type abc = A | B | C
+
+
+do test "cwewvewho5" (match box(None: int option) with :? option as v -> (v = None) | _ -> false)
+
+
+do test "cwewe0981" (LanguagePrimitives.IntrinsicFunctions.UnboxGeneric(box(1)) = 1 )
+do test "cwewe0982" ((try ignore(LanguagePrimitives.IntrinsicFunctions.UnboxGeneric(box(1))); false with :? System.InvalidCastException -> true))
+do test "cwewe0983" ((try ignore(LanguagePrimitives.IntrinsicFunctions.UnboxGeneric(null)); false with :? System.NullReferenceException -> true))
+do test "cwewe0984" (LanguagePrimitives.IntrinsicFunctions.UnboxGeneric(box("a")) = "a")
+do test "cwewe0985" (LanguagePrimitives.IntrinsicFunctions.UnboxGeneric(null) = null)
+do test "cwewe0986" (LanguagePrimitives.IntrinsicFunctions.UnboxGeneric(box(None: int option)) = None)
+do test "cwewe0987" (LanguagePrimitives.IntrinsicFunctions.UnboxGeneric(box(None: int option)) = None)
+do test "cwewe0988" (LanguagePrimitives.IntrinsicFunctions.UnboxGeneric(box([]: int list)) = [])
+do test "cwewe0989" ((try ignore(LanguagePrimitives.IntrinsicFunctions.UnboxGeneric(null)); false with :? System.NullReferenceException -> true))
+do test "cwewe0980" ((try ignore(LanguagePrimitives.IntrinsicFunctions.UnboxGeneric(null)); false with :? System.NullReferenceException -> true))
+
+do test "cwewe0981" (unbox(box(1)) = 1 )
+do test "cwewe0982" ((try ignore(unbox(box(1))); false with :? System.InvalidCastException -> true))
+do test "cwewe0983" ((try ignore(unbox(null)); false with :? System.NullReferenceException -> true))
+do test "cwewe0984" (unbox(box("a")) = "a")
+do test "cwewe0985" (unbox(null) = null)
+do test "cwewe0986" (unbox(box(None: int option)) = None)
+do test "cwewe0987" (unbox(box(None: int option)) = None)
+do test "cwewe0988" (unbox(box([]: int list)) = [])
+do test "cwewe0989" ((try ignore(unbox(null)); false with :? System.NullReferenceException -> true))
+do test "cwewe0980" ((try ignore(unbox(null)); false with :? System.NullReferenceException -> true))
+
+do test "cwewe098q" (LanguagePrimitives.IntrinsicFunctions.UnboxFast(box(1)) = 1)
+do test "cwewe098w" ((try ignore(LanguagePrimitives.IntrinsicFunctions.UnboxFast(box(1))); false with :? System.InvalidCastException -> true))
+do test "cwewe098e" ((try ignore(LanguagePrimitives.IntrinsicFunctions.UnboxFast(null)); false with :? System.NullReferenceException -> true))
+do test "cwewe098r" (LanguagePrimitives.IntrinsicFunctions.UnboxFast(box("a")) = "a")
+do test "cwewe098t" (LanguagePrimitives.IntrinsicFunctions.UnboxFast(null) = null)
+do test "cwewe098y" (LanguagePrimitives.IntrinsicFunctions.UnboxFast(box(None: int option)) = None)
+do test "cwewe098u" (LanguagePrimitives.IntrinsicFunctions.UnboxFast(box(None: int option)) = None)
+//These don't qualify for the quick entry
+// unbox_quick(box([]: int list)) = []
+// (try ignore(unbox_quick(null)); false with :? System.NullReferenceException -> true)
+// (try ignore(unbox_quick(null)); false with :? System.NullReferenceException -> true)
+
+
+do test "cwewe098a" (LanguagePrimitives.IntrinsicFunctions.TypeTestGeneric(box(1)) )
+do test "cwewe098s" (not(LanguagePrimitives.IntrinsicFunctions.TypeTestGeneric(null)))
+do test "cwewe098d" (LanguagePrimitives.IntrinsicFunctions.TypeTestGeneric(box("a")) )
+do test "cwewe098f" (not(LanguagePrimitives.IntrinsicFunctions.TypeTestGeneric(null)))
+do test "cwewe098g" (LanguagePrimitives.IntrinsicFunctions.TypeTestGeneric(box(None: int option)) )
+do test "cwewe098h" (LanguagePrimitives.IntrinsicFunctions.TypeTestGeneric(box(None: int option)) )
+do test "cwewe098j" (LanguagePrimitives.IntrinsicFunctions.TypeTestGeneric(box([]: int list)) )
+do test "cwewe098k" (not(LanguagePrimitives.IntrinsicFunctions.TypeTestGeneric(null)))
+do test "cwewe098l" (not(LanguagePrimitives.IntrinsicFunctions.TypeTestGeneric(null)))
+
+do test "cwewe098z" (LanguagePrimitives.IntrinsicFunctions.TypeTestFast(box(1)) )
+do test "cwewe098x" (not(LanguagePrimitives.IntrinsicFunctions.TypeTestFast(null)))
+do test "cwewe098c" (LanguagePrimitives.IntrinsicFunctions.TypeTestFast(box("a")) )
+do test "cwewe098v" (not(LanguagePrimitives.IntrinsicFunctions.TypeTestFast(null)))
+do test "cwewe098b" (LanguagePrimitives.IntrinsicFunctions.TypeTestFast(box([]: int list)) )
+do test "cwewe098n" (not(LanguagePrimitives.IntrinsicFunctions.TypeTestFast(null)))
+do test "cwewe098m" (not(LanguagePrimitives.IntrinsicFunctions.TypeTestFast(null)))
+
+(*
+let istype<'a>(obj:obj) = (obj :? 'a)
+let _ =
+ test "cwewe098z" (istype(box(1)) );
+ test "cwewe098x" (not(istype(null)));
+ test "cwewe098c" (istype(box("a")) );
+ test "cwewe098v" (not(istype(null)));
+ test "cwewe098b" (istype(box([]: int list)) );
+ test "cwewe098n" (not(istype(null)));
+ test "cwewe098m" (not(istype(null)));
+ ()
+
+*)
+
+do test "cwewvewho1" (match box(1) with :? int as v -> v = 1 | _ -> true)
+do test "cwewvewho2" (match (null:obj) with :? int -> false | _ -> true)
+do test "cwewvewho3" (match box("a") with :? string as v -> v = "a" | _ -> true)
+do test "cwewvewho4" (match (null:obj) with :? string -> false | _ -> true)
+do test "cwewvewho5" (match box(None: int option) with :? option as v -> (v = None) | _ -> false)
+do test "cwewvewho6" (match (null:obj) with :? option as v -> (v = None) | _ -> false)
+do test "cwewvewho7" (match box(None: int option) with :? option as v -> (v = None) | _ -> false)
+do test "cwewvewho8" (match (null:obj) with :? option as v -> (v = None) | _ -> false)
+do test "cwewvewho9" (match box(Some 3) with :? option as v -> (v = Some(3)) | _ -> false)
+do test "cwewvewho0" (match box(Some 3) with :? option -> false | _ -> true)
+do test "cwewvewho-" (match box([3]) with :? list as v -> (v = [3]) | _ -> false)
+do test "cwewvewhoa" (match box([3]) with :? list as v -> false | _ -> true)
+
+do test "cwewvewhos" (match (null:obj) with :? list as v -> false | _ -> true)
+
+let pattest<'a> (obj:obj) fail (succeed : 'a -> bool) = match obj with :? 'a as x -> succeed x | _ -> fail()
+
+do test "cwewvewhoq" (pattest (box(1)) (fun () -> false) (fun v -> v = 1))
+do test "cwewvewhow" (pattest (null) (fun () -> true ) (fun _ -> false))
+do test "cwewvewhoe" (pattest(box("a")) (fun () -> false) (fun v -> v = "a"))
+do test "cwewvewhor" (pattest(null) (fun () -> true) (fun _ -> false))
+do test "cwewvewhot" (pattest (box(None: int option)) (fun () -> false) (function None -> true | _ -> false))
+do test "cwewvewhoy" (pattest (null) (fun () -> false) (function None -> true | _ -> false))
+do test "cwewvewhou" (pattest(box(None: int option)) (fun () -> false) (function None -> true | _ -> false))
+do test "cwewvewhoi" (pattest(null) (fun () -> false) (function None -> true | _ -> false))
+do test "cwewvewhoo" (pattest (box(Some 3)) (fun () -> false) (function Some 3 -> true | _ -> false))
+do test "cwewvewhop" (pattest(box(Some 3)) (fun () -> true) (fun _ -> false))
+do test "cwewvewhog" (pattest (box(["1"])) (fun () -> false) (fun _ -> true))
+do test "cwewvewhoj" (pattest null (fun () -> true) (fun _ -> false))
+
+
+
+
+
+let _ = printString "string list structural equality (1): "; if ["abc"] = ["def"] then reportFailure "basic test Q146" else stdout.WriteLine "YES"
+let _ = printString "string list object equality (1): "; if ["abc"] === ["def"] then reportFailure "basic test Q147" else stdout.WriteLine "YES"
+let _ = printString "string list structural equality (2): "; if ["abc"] = ["abc"] then stdout.WriteLine "YES" else reportFailure "basic test Q148"
+let _ = printString "string list object equality (2): "; if ["abc"] === ["abc"] then stdout.WriteLine "YES" else reportFailure "basic test Q149"
+let _ = printString "hash respects equality (1): "; if hash [] = hash [] then stdout.WriteLine "YES" else reportFailure "basic test Q150"
+let _ = printString "hash respects equality (2): "; if hash [1] = hash [1] then stdout.WriteLine "YES" else reportFailure "basic test Q151"
+let _ = printString "hash respects equality (1a): "; if hash A = hash A then stdout.WriteLine "YES" else reportFailure "basic test Q152"
+let _ = printString "hash respects equality (3): "; if hash ["abc"] = hash ["abc"] then stdout.WriteLine "YES" else reportFailure "basic test Q153"
+let _ = printString "hash respects equality (4): "; if hash ("abc","def") = hash ("abc","def") then stdout.WriteLine "YES" else reportFailure "basic test Q154"
+let _ = printString "hash respects equality (4a): "; if hash (A,"def") = hash (A,"def") then stdout.WriteLine "YES" else reportFailure "basic test Q155"
+let _ = printString "hash respects equality (4b): "; if hash ([],"def") = hash ([],"def") then stdout.WriteLine "YES" else reportFailure "basic test Q156"
+let _ = printString "hash respects equality (4c): "; if hash ([],[]) = hash ([],[]) then stdout.WriteLine "YES" else reportFailure "basic test Q157"
+let _ = printString "hash respects equality (4d): "; if hash (A,B) = hash (A,B) then stdout.WriteLine "YES" else reportFailure "basic test Q158"
+let _ = printString "hash respects equality (5): "; if hash ("abc","def","efg") = hash ("abc","def","efg") then stdout.WriteLine "YES" else reportFailure "basic test Q159"
+let _ = printString "hash respects equality (6): "; if hash ("abc","def","efg","") = hash ("abc","def","efg","") then stdout.WriteLine "YES" else reportFailure "basic test Q160"
+let _ = printString "hash respects equality (7): "; if hash ("abc","def","efg","","q") = hash ("abc","def","efg","","q") then stdout.WriteLine "YES" else reportFailure "basic test Q161"
+let _ = printString "hash respects equality (8): "; if hash ("abc","def","efg","","q","r") = hash ("abc","def","efg","","q","r") then stdout.WriteLine "YES" else reportFailure "basic test Q162"
+let _ = printString "hash respects equality (9): "; if hash ("abc","def","efg","","q","r","s") = hash ("abc","def","efg","","q","r","s") then stdout.WriteLine "YES" else reportFailure "basic test Q163"
+let _ = printString "hash respects equality (int array,10): "; if hash [| 1 |] = hash [| 1 |] then stdout.WriteLine "YES" else reportFailure "basic test Q164"
+let _ = printString "hash respects equality (string array,11): "; if hash [| "a" |] = hash [| "a" |] then stdout.WriteLine "YES" else reportFailure "basic test Q165"
+let _ = printString "hash respects equality (string array,12): "; if hash [| "a";"b" |] = hash [| "a";"b" |] then stdout.WriteLine "YES" else reportFailure "basic test Q166"
+let _ = printString "hash respects equality (byte array,12): "; if hash "abc"B = hash "abc"B then stdout.WriteLine "YES" else reportFailure "basic test Q167"
+let _ = printString "hash respects equality (byte array,12): "; if hash ""B = hash ""B then stdout.WriteLine "YES" else reportFailure "basic test Q169"
+let _ = printString "hash respects equality (byte array,12): "; if hash [| |] = hash [| |] then stdout.WriteLine "YES" else reportFailure "basic test Q170"
+
+
+let _ = printString "hash is interesting (1): "; if hash "abc" = hash "def" then reportFailure "basic test Q171" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (2): "; if hash 0 = hash 1 then reportFailure "basic test Q172" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (3): "; if hash [0] = hash [1] then reportFailure "basic test Q173" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (4): "; if hash (0,3) = hash (1,3) then reportFailure "basic test Q174" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (5): "; if hash {contents=3} = hash {contents=4} then reportFailure "basic test Q175" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (6): "; if hash [0;1;2] = hash [0;1;3] then reportFailure "basic test Q176" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (7): "; if hash [0;1;2;3;4;5] = hash [0;1;2;3;4;6] then reportFailure "basic test Q177" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (7): "; if hash [0;1;2;3;4] = hash [0;1;2;3;6] then reportFailure "basic test Q178" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (7): "; if hash [0;1;2;3;4;5;6;7] = hash [0;1;2;3;4;5;6;8] then reportFailure "basic test Q179" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (8): "; if hash [0;1;2;3;4;5;6;7;8] = hash [0;1;2;3;4;5;6;7;9] then reportFailure "basic test Q180" else stdout.WriteLine "YES"
+
+let _ = printString "hash is interesting (9): "; if hash [[0];[1];[2]] = hash [[0];[1];[3]] then reportFailure "basic test Q181" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (10): "; if hash [[0];[1];[2];[3];[4];[5]] = hash [[0];[1];[2];[3];[4];[6]] then reportFailure "basic test Q182" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (11): "; if hash [[0];[1];[2];[3];[4];[5];[6]] = hash [[0];[1];[2];[3];[4];[5];[7]] then reportFailure "basic test Q183" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (bytearray 1): "; if hash "abc"B = hash "abd"B then reportFailure "basic test Q184" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (string array 1): "; if hash [| "abc"; "e" |] = hash [| "abc"; "d" |] then reportFailure "basic test Q185" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (intarray 1): "; if hash [| 3; 4 |] = hash [| 3; 5 |] then reportFailure "basic test Q186" else stdout.WriteLine "YES"
+
+(* F# compiler does many special tricks to get fast type-specific structural hashing. *)
+(* A compiler could only work out that the following hash is type-specific if it inlines *)
+(* the whole function, which is very unlikely. *)
+let genericHash x =
+ stdout.WriteLine "genericHash - hopefully not inlined\n";
+ let mutable r = 0 in
+ for i = 1 to 100 do r <- r + 1; done;
+ for i = 1 to 100 do r <- r + 1; done;
+ for i = 1 to 100 do r <- r + 1; done;
+ for i = 1 to 100 do r <- r + 1; done;
+ (r - 400) + hash x
+
+#if MONO // See https://github.com/fsharp/fsharp/issues/188
+#else
+
+type T = T of int * int
+
+
+let hashes =
+ [hash (T(1, 1)) ;
+ hash (T(4, -1)) ;
+ hash (T(2, 0)) ;
+ hash (T(0, 1)) ;
+ hash (T(-2, 2)) ]
+
+let _ = check "df390enj" (hashes |> Set.ofList |> Set.toList |> List.length) hashes.Length
+
+let _ = printString "type specific hash matches generic hash (1): "; if hash [] = genericHash [] then stdout.WriteLine "YES" else reportFailure "basic test Q187"
+let _ = printString "type specific hash matches generic hash (2): "; if hash [1] = genericHash [1] then stdout.WriteLine "YES" else reportFailure "basic test Q188"
+let _ = printString "type specific hash matches generic hash (1a): "; if hash A = genericHash A then stdout.WriteLine "YES" else reportFailure "basic test Q189"
+let _ = printString "type specific hash matches generic hash (3): "; if hash ["abc"] = genericHash ["abc"] then stdout.WriteLine "YES" else reportFailure "basic test Q190"
+let _ = printString "type specific hash matches generic hash (4): "; if hash ("abc","def") = genericHash ("abc","def") then stdout.WriteLine "YES" else reportFailure "basic test Q191"
+let _ = printString "type specific hash matches generic hash (4a): "; if hash (A,"def") = genericHash (A,"def") then stdout.WriteLine "YES" else reportFailure "basic test Q192"
+let _ = printString "type specific hash matches generic hash (4b): "; if hash ([],"def") = genericHash ([],"def") then stdout.WriteLine "YES" else reportFailure "basic test Q193"
+let _ = printString "type specific hash matches generic hash (4c): "; if hash ([],[]) = genericHash ([],[]) then stdout.WriteLine "YES" else reportFailure "basic test Q194"
+let _ = printString "type specific hash matches generic hash (4d): "; if hash (A,B) = genericHash (A,B) then stdout.WriteLine "YES" else reportFailure "basic test Q195"
+let _ = printString "type specific hash matches generic hash (5): "; if hash ("abc","def","efg") = genericHash ("abc","def","efg") then stdout.WriteLine "YES" else reportFailure "basic test Q196"
+let _ = printString "type specific hash matches generic hash (6): "; if hash ("abc","def","efg","") = genericHash ("abc","def","efg","") then stdout.WriteLine "YES" else reportFailure "basic test Q197"
+let _ = printString "type specific hash matches generic hash (7): "; if hash ("abc","def","efg","","q") = genericHash ("abc","def","efg","","q") then stdout.WriteLine "YES" else reportFailure "basic test Q198"
+let _ = printString "type specific hash matches generic hash (8): "; if hash ("abc","def","efg","","q","r") = genericHash ("abc","def","efg","","q","r") then stdout.WriteLine "YES" else reportFailure "basic test Q199"
+let _ = printString "type specific hash matches generic hash (9): "; if hash ("abc","def","efg","","q","r","s") = genericHash ("abc","def","efg","","q","r","s") then stdout.WriteLine "YES" else reportFailure "basic test Q200"
+let _ = printString "type specific hash matches generic hash (int array,10): "; if hash [| 1 |] = genericHash [| 1 |] then stdout.WriteLine "YES" else reportFailure "basic test Q201"
+let _ = printString "type specific hash matches generic hash (string array,11): "; if hash [| "a" |] = genericHash [| "a" |] then stdout.WriteLine "YES" else reportFailure "basic test Q202"
+let _ = printString "type specific hash matches generic hash (string array,12): "; if hash [| "a";"b" |] = genericHash [| "a";"b" |] then stdout.WriteLine "YES" else reportFailure "basic test Q203"
+let _ = printString "type specific hash matches generic hash (byte array,12): "; if hash "abc"B = genericHash "abc"B then stdout.WriteLine "YES" else reportFailure "basic test Q204"
+let _ = printString "type specific hash matches generic hash (byte array,12): "; if hash ""B = genericHash ""B then stdout.WriteLine "YES" else reportFailure "basic test Q205"
+let _ = printString "type specific hash matches generic hash (byte array,12): "; if hash [| |] = genericHash [| |] then stdout.WriteLine "YES" else reportFailure "basic test Q206"
+#endif
+
+
+(*---------------------------------------------------------------------------
+!* check the same for GetHashCode
+ *--------------------------------------------------------------------------- *)
+
+
+let _ = printString "hash 1 = "; printInt (getObjectHashCode 1); printNewLine()
+let _ = printString "hash [] = "; printInt (getObjectHashCode []); printNewLine()
+let _ = printString "hash [1] = "; printInt (getObjectHashCode [1]); printNewLine()
+let _ = printString "hash [2] = "; printInt (getObjectHashCode [2]); printNewLine()
+let r3339 = ref 1
+let _ = printString "hash 2 = "; printInt (getObjectHashCode 2); printNewLine()
+let _ = printString "hash 6 = "; printInt (getObjectHashCode 6); printNewLine()
+let _ = printString "hash \"abc\" = "; printInt (getObjectHashCode "abc"); printNewLine()
+let _ = printString "hash \"abd\" = "; printInt (getObjectHashCode "abd"); printNewLine()
+let _ = printString "hash \"\" = "; printInt (getObjectHashCode ""); printNewLine()
+
+
+let _ = printString "hash respects equality (1): "; if getObjectHashCode [] = getObjectHashCode [] then stdout.WriteLine "YES" else reportFailure "basic test Q207"
+let _ = printString "hash respects equality (2): "; if getObjectHashCode [1] = getObjectHashCode [1] then stdout.WriteLine "YES" else reportFailure "basic test Q208"
+let _ = printString "hash respects equality (1a): "; if getObjectHashCode A = getObjectHashCode A then stdout.WriteLine "YES" else reportFailure "basic test Q209"
+let _ = printString "hash respects equality (3): "; if getObjectHashCode ["abc"] = getObjectHashCode ["abc"] then stdout.WriteLine "YES" else reportFailure "basic test Q210"
+let _ = printString "hash respects equality (4): "; if getObjectHashCode ("abc","def") = getObjectHashCode ("abc","def") then stdout.WriteLine "YES" else reportFailure "basic test Q211"
+let _ = printString "hash respects equality (4a): "; if getObjectHashCode (A,"def") = getObjectHashCode (A,"def") then stdout.WriteLine "YES" else reportFailure "basic test Q212"
+let _ = printString "hash respects equality (4b): "; if getObjectHashCode ([],"def") = getObjectHashCode ([],"def") then stdout.WriteLine "YES" else reportFailure "basic test Q213"
+let _ = printString "hash respects equality (4c): "; if getObjectHashCode ([],[]) = getObjectHashCode ([],[]) then stdout.WriteLine "YES" else reportFailure "basic test Q214"
+let _ = printString "hash respects equality (4d): "; if getObjectHashCode (A,B) = getObjectHashCode (A,B) then stdout.WriteLine "YES" else reportFailure "basic test Q215"
+let _ = printString "hash respects equality (5): "; if getObjectHashCode ("abc","def","efg") = getObjectHashCode ("abc","def","efg") then stdout.WriteLine "YES" else reportFailure "basic test Q216"
+let _ = printString "hash respects equality (6): "; if getObjectHashCode ("abc","def","efg","") = getObjectHashCode ("abc","def","efg","") then stdout.WriteLine "YES" else reportFailure "basic test Q217"
+let _ = printString "hash respects equality (7): "; if getObjectHashCode ("abc","def","efg","","q") = getObjectHashCode ("abc","def","efg","","q") then stdout.WriteLine "YES" else reportFailure "basic test Q218"
+let _ = printString "hash respects equality (8): "; if getObjectHashCode ("abc","def","efg","","q","r") = getObjectHashCode ("abc","def","efg","","q","r") then stdout.WriteLine "YES" else reportFailure "basic test Q219"
+let _ = printString "hash respects equality (9): "; if getObjectHashCode ("abc","def","efg","","q","r","s") = getObjectHashCode ("abc","def","efg","","q","r","s") then stdout.WriteLine "YES" else reportFailure "basic test Q220"
+
+(* NOTE: GetHashCode guarantees do not apply to mutable data structures
+
+let _ = printString "hash respects equality (int array,10): "; if getObjectHashCode [| 1 |] = getObjectHashCode [| 1 |] then stdout.WriteLine "YES" else reportFailure "basic test Q221"
+let _ = printString "hash respects equality (string array,11): "; if getObjectHashCode [| "a" |] = getObjectHashCode [| "a" |] then stdout.WriteLine "YES" else reportFailure "basic test Q222"
+let _ = printString "hash respects equality (string array,12): "; if getObjectHashCode [| "a";"b" |] = getObjectHashCode [| "a";"b" |] then stdout.WriteLine "YES" else reportFailure "basic test Q223"
+let _ = printString "hash respects equality (byte array,12): "; if getObjectHashCode "abc"B = getObjectHashCode "abc"B then stdout.WriteLine "YES" else reportFailure "basic test Q224"
+let _ = printString "hash respects equality (byte array,12): "; if getObjectHashCode ""B = getObjectHashCode ""B then stdout.WriteLine "YES" else reportFailure "basic test Q225"
+*)
+
+
+let _ = printString "hash is interesting (1): "; if getObjectHashCode "abc" = getObjectHashCode "def" then reportFailure "basic test Q226" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (2): "; if getObjectHashCode 0 = getObjectHashCode 1 then reportFailure "basic test Q227" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (3): "; if getObjectHashCode [0] = getObjectHashCode [1] then reportFailure "basic test Q228" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (4): "; if getObjectHashCode (0,3) = getObjectHashCode (1,3) then reportFailure "basic test Q229" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (6): "; if getObjectHashCode [0;1;2] = getObjectHashCode [0;1;3] then reportFailure "basic test Q230" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (7): "; if getObjectHashCode [0;1;2;3;4;5] = getObjectHashCode [0;1;2;3;4;6] then reportFailure "basic test Q231" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (7): "; if getObjectHashCode [0;1;2;3;4] = getObjectHashCode [0;1;2;3;6] then reportFailure "basic test Q232" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (7): "; if getObjectHashCode [0;1;2;3;4;5;6;7] = getObjectHashCode [0;1;2;3;4;5;6;8] then reportFailure "basic test Q233" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (8): "; if getObjectHashCode [0;1;2;3;4;5;6;7;8] = getObjectHashCode [0;1;2;3;4;5;6;7;9] then reportFailure "basic test Q234" else stdout.WriteLine "YES"
+
+let _ = printString "hash is interesting (9): "; if getObjectHashCode [[0];[1];[2]] = getObjectHashCode [[0];[1];[3]] then reportFailure "basic test Q235" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (10): "; if getObjectHashCode [[0];[1];[2];[3];[4];[5]] = getObjectHashCode [[0];[1];[2];[3];[4];[6]] then reportFailure "basic test Q236" else stdout.WriteLine "YES"
+let _ = printString "hash is interesting (11): "; if getObjectHashCode [[0];[1];[2];[3];[4];[5];[6]] = getObjectHashCode [[0];[1];[2];[3];[4];[5];[7]] then reportFailure "basic test Q237" else stdout.WriteLine "YES"
+
+let _ = printString "type specific hash matches generic hash (1): "; if getObjectHashCode [] = genericHash [] then stdout.WriteLine "YES" else reportFailure "basic test Q238"
+let _ = printString "type specific hash matches generic hash (2): "; if getObjectHashCode [1] = genericHash [1] then stdout.WriteLine "YES" else reportFailure "basic test Q239"
+let _ = printString "type specific hash matches generic hash (1a): "; if getObjectHashCode A = genericHash A then stdout.WriteLine "YES" else reportFailure "basic test Q240"
+let _ = printString "type specific hash matches generic hash (3): "; if getObjectHashCode ["abc"] = genericHash ["abc"] then stdout.WriteLine "YES" else reportFailure "basic test Q241"
+let _ = printString "type specific hash matches generic hash (4): "; if getObjectHashCode ("abc","def") = genericHash ("abc","def") then stdout.WriteLine "YES" else reportFailure "basic test Q242"
+let _ = printString "type specific hash matches generic hash (4a): "; if getObjectHashCode (A,"def") = genericHash (A,"def") then stdout.WriteLine "YES" else reportFailure "basic test Q243"
+let _ = printString "type specific hash matches generic hash (4b): "; if getObjectHashCode ([],"def") = genericHash ([],"def") then stdout.WriteLine "YES" else reportFailure "basic test Q244"
+let _ = printString "type specific hash matches generic hash (4c): "; if getObjectHashCode ([],[]) = genericHash ([],[]) then stdout.WriteLine "YES" else reportFailure "basic test Q245"
+let _ = printString "type specific hash matches generic hash (4d): "; if getObjectHashCode (A,B) = genericHash (A,B) then stdout.WriteLine "YES" else reportFailure "basic test Q246"
+let _ = printString "type specific hash matches generic hash (5): "; if getObjectHashCode ("abc","def","efg") = genericHash ("abc","def","efg") then stdout.WriteLine "YES" else reportFailure "basic test Q247"
+let _ = printString "type specific hash matches generic hash (6): "; if getObjectHashCode ("abc","def","efg","") = genericHash ("abc","def","efg","") then stdout.WriteLine "YES" else reportFailure "basic test Q248"
+let _ = printString "type specific hash matches generic hash (7): "; if getObjectHashCode ("abc","def","efg","","q") = genericHash ("abc","def","efg","","q") then stdout.WriteLine "YES" else reportFailure "basic test Q249"
+let _ = printString "type specific hash matches generic hash (8): "; if getObjectHashCode ("abc","def","efg","","q","r") = genericHash ("abc","def","efg","","q","r") then stdout.WriteLine "YES" else reportFailure "basic test Q250"
+let _ = printString "type specific hash matches generic hash (9): "; if getObjectHashCode ("abc","def","efg","","q","r","s") = genericHash ("abc","def","efg","","q","r","s") then stdout.WriteLine "YES" else reportFailure "basic test Q251"
+
+
+(*---------------------------------------------------------------------------
+!* check we can resolve overlapping constructor names using type names
+ *--------------------------------------------------------------------------- *)
+
+module OverlappingCOnstructorNames =
+
+ type XY = X | Y
+ type YZ = Y | Z
+
+ let x0 = X
+ let x1 = XY.X
+ let y0 = Y
+ let y1 = XY.Y
+ let y2 = YZ.Y
+ let z0 = Z
+ let z2 = YZ.Z
+
+
+ let f xy =
+ match xy with
+ | XY.X -> "X"
+ | XY.Y -> "Y"
+
+ let g yz =
+ match yz with
+ | YZ.Y -> "X"
+ | YZ.Z -> "Y"
+
+
+(*---------------------------------------------------------------------------
+!* Equality tests over structured values for data likely to contain
+ * values represented by "null"
+ *--------------------------------------------------------------------------- *)
+
+let _ = printString "tuple inequality null test (1): "; if (1,2) = (1,3) then reportFailure "basic test Q252" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (2): "; if ([],2) = ([],1) then reportFailure "basic test Q253" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (3): "; if (1,[]) = (2,[]) then reportFailure "basic test Q254" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (4): "; if (1,2,3) = (1,2,4) then reportFailure "basic test Q255" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (5): "; if ([],2,3) = ([],2,4) then reportFailure "basic test Q256" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (6): "; if (1,[],2) = (1,[],3) then reportFailure "basic test Q257" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (7): "; if (1,2,[]) = (1,3,[]) then reportFailure "basic test Q258" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (8): "; if (1,2,3,4) = (1,2,3,5) then reportFailure "basic test Q259" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (9): "; if ([],2,3,4) = ([],2,4,4) then reportFailure "basic test Q260" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (10): "; if (1,[],3,4) = (1,[],3,5) then reportFailure "basic test Q261" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (11): "; if (1,2,[],4) = (1,2,[],5) then reportFailure "basic test Q262" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (12): "; if (1,2,3,[]) = (1,2,4,[]) then reportFailure "basic test Q263" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (13): "; if (1,2,3,4,5) = (1,2,3,4,6) then reportFailure "basic test Q264" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (14): "; if ([],2,3,4,5) = ([],2,3,5,5) then reportFailure "basic test Q265" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (15): "; if (1,[],3,4,5) = (1,[],3,6,5) then reportFailure "basic test Q266" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (16): "; if (1,2,[],4,5) = (1,2,[],3,5) then reportFailure "basic test Q267" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (17): "; if (1,2,3,[],5) = (1,2,3,[],6) then reportFailure "basic test Q268" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (18): "; if (1,2,3,4,[]) = (1,7,3,4,[]) then reportFailure "basic test Q269" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (19): "; if (1,2,3,4,5,6) = (1,2,3,4,5,7) then reportFailure "basic test Q270" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (20): "; if ([],2,3,4,5,6) = ([],2,3,4,5,7) then reportFailure "basic test Q271" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (21): "; if (1,[],3,4,5,6) = (1,[],3,4,5,7) then reportFailure "basic test Q272" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (22): "; if (1,2,[],4,5,6) = (1,2,[],4,5,7) then reportFailure "basic test Q273" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (23): "; if (1,2,3,[],5,6) = (1,2,3,[],5,7) then reportFailure "basic test Q274" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (24): "; if (1,2,3,4,[],6) = (1,2,3,4,[],7) then reportFailure "basic test Q275" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (25): "; if (1,2,3,4,5,[]) = (1,2,3,4,6,[]) then reportFailure "basic test Q276" else stdout.WriteLine "YES"
+
+let _ = printString "tuple equality null test (1): "; if (1,2) = (1,2) then stdout.WriteLine "YES" else reportFailure "basic test Q277"
+let _ = printString "tuple equality null test (2): "; if ([],2) = ([],2) then stdout.WriteLine "YES" else reportFailure "basic test Q278"
+let _ = printString "tuple equality null test (3): "; if (1,[]) = (1,[]) then stdout.WriteLine "YES" else reportFailure "basic test Q279"
+let _ = printString "tuple equality null test (4): "; if (1,2,3) = (1,2,3) then stdout.WriteLine "YES" else reportFailure "basic test Q280"
+let _ = printString "tuple equality null test (5): "; if ([],2,3) = ([],2,3) then stdout.WriteLine "YES" else reportFailure "basic test Q281"
+let _ = printString "tuple equality null test (6): "; if (1,[],2) = (1,[],2) then stdout.WriteLine "YES" else reportFailure "basic test Q282"
+let _ = printString "tuple equality null test (7): "; if (1,2,[]) = (1,2,[]) then stdout.WriteLine "YES" else reportFailure "basic test Q283"
+let _ = printString "tuple equality null test (8): "; if (1,2,3,4) = (1,2,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q284"
+let _ = printString "tuple equality null test (9): "; if ([],2,3,4) = ([],2,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q285"
+let _ = printString "tuple equality null test (10): "; if (1,[],3,4) = (1,[],3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q286"
+let _ = printString "tuple equality null test (11): "; if (1,2,[],4) = (1,2,[],4) then stdout.WriteLine "YES" else reportFailure "basic test Q287"
+let _ = printString "tuple equality null test (12): "; if (1,2,3,[]) = (1,2,3,[]) then stdout.WriteLine "YES" else reportFailure "basic test Q288"
+let _ = printString "tuple equality null test (13): "; if (1,2,3,4,5) = (1,2,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q289"
+let _ = printString "tuple equality null test (14): "; if ([],2,3,4,5) = ([],2,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q290"
+let _ = printString "tuple equality null test (15): "; if (1,[],3,4,5) = (1,[],3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q291"
+let _ = printString "tuple equality null test (16): "; if (1,2,[],4,5) = (1,2,[],4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q292"
+let _ = printString "tuple equality null test (17): "; if (1,2,3,[],5) = (1,2,3,[],5) then stdout.WriteLine "YES" else reportFailure "basic test Q293"
+let _ = printString "tuple equality null test (18): "; if (1,2,3,4,[]) = (1,2,3,4,[]) then stdout.WriteLine "YES" else reportFailure "basic test Q294"
+let _ = printString "tuple equality null test (19): "; if (1,2,3,4,5,6) = (1,2,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q295"
+let _ = printString "tuple equality null test (20): "; if ([],2,3,4,5,6) = ([],2,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q296"
+let _ = printString "tuple equality null test (21): "; if (1,[],3,4,5,6) = (1,[],3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q297"
+let _ = printString "tuple equality null test (22): "; if (1,2,[],4,5,6) = (1,2,[],4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q298"
+let _ = printString "tuple equality null test (23): "; if (1,2,3,[],5,6) = (1,2,3,[],5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q299"
+let _ = printString "tuple equality null test (24): "; if (1,2,3,4,[],6) = (1,2,3,4,[],6) then stdout.WriteLine "YES" else reportFailure "basic test Q300"
+let _ = printString "tuple equality null test (25): "; if (1,2,3,4,5,[]) = (1,2,3,4,5,[]) then stdout.WriteLine "YES" else reportFailure "basic test Q301"
+
+let _ = printString "tuple inequality null test (a1): "; if (1,2) = (1,3) then reportFailure "basic test Q302" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a2): "; if (A,2) = (A,1) then reportFailure "basic test Q303" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a3): "; if (1,A) = (2,A) then reportFailure "basic test Q304" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a4): "; if (1,2,3) = (1,2,4) then reportFailure "basic test Q305" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a5): "; if (A,2,3) = (A,2,4) then reportFailure "basic test Q306" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a6): "; if (1,A,2) = (1,A,3) then reportFailure "basic test Q307" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a7): "; if (1,2,A) = (1,3,A) then reportFailure "basic test Q308" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a8): "; if (1,2,3,4) = (1,2,3,5) then reportFailure "basic test Q309" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a9): "; if (A,2,3,4) = (A,2,4,4) then reportFailure "basic test Q310" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a10): "; if (1,A,3,4) = (1,A,3,5) then reportFailure "basic test Q311" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a11): "; if (1,2,A,4) = (1,2,A,5) then reportFailure "basic test Q312" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a12): "; if (1,2,3,A) = (1,2,4,A) then reportFailure "basic test Q313" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a13): "; if (1,2,3,4,5) = (1,2,3,4,6) then reportFailure "basic test Q314" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a14): "; if (A,2,3,4,5) = (A,2,3,5,5) then reportFailure "basic test Q315" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a15): "; if (1,A,3,4,5) = (1,A,3,6,5) then reportFailure "basic test Q316" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a16): "; if (1,2,A,4,5) = (1,2,A,3,5) then reportFailure "basic test Q317" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a17): "; if (1,2,3,A,5) = (1,2,3,A,6) then reportFailure "basic test Q318" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a18): "; if (1,2,3,4,A) = (1,7,3,4,A) then reportFailure "basic test Q319" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a19): "; if (1,2,3,4,5,6) = (1,2,3,4,5,7) then reportFailure "basic test Q320" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a20): "; if (A,2,3,4,5,6) = (A,2,3,4,5,7) then reportFailure "basic test Q321" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a21): "; if (1,A,3,4,5,6) = (1,A,3,4,5,7) then reportFailure "basic test Q322" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a22): "; if (1,2,A,4,5,6) = (1,2,A,4,5,7) then reportFailure "basic test Q323" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a23): "; if (1,2,3,A,5,6) = (1,2,3,A,5,7) then reportFailure "basic test Q324" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a24): "; if (1,2,3,4,A,6) = (1,2,3,4,A,7) then reportFailure "basic test Q325" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (a25): "; if (1,2,3,4,5,A) = (1,2,3,4,6,A) then reportFailure "basic test Q326" else stdout.WriteLine "YES"
+
+let _ = printString "tuple equality null test (a1): "; if (1,2) = (1,2) then stdout.WriteLine "YES" else reportFailure "basic test Q327"
+let _ = printString "tuple equality null test (a2): "; if (A,2) = (A,2) then stdout.WriteLine "YES" else reportFailure "basic test Q328"
+let _ = printString "tuple equality null test (a3): "; if (1,A) = (1,A) then stdout.WriteLine "YES" else reportFailure "basic test Q329"
+let _ = printString "tuple equality null test (a4): "; if (1,2,3) = (1,2,3) then stdout.WriteLine "YES" else reportFailure "basic test Q330"
+let _ = printString "tuple equality null test (a5): "; if (A,2,3) = (A,2,3) then stdout.WriteLine "YES" else reportFailure "basic test Q331"
+let _ = printString "tuple equality null test (a6): "; if (1,A,2) = (1,A,2) then stdout.WriteLine "YES" else reportFailure "basic test Q332"
+let _ = printString "tuple equality null test (a7): "; if (1,2,A) = (1,2,A) then stdout.WriteLine "YES" else reportFailure "basic test Q333"
+let _ = printString "tuple equality null test (a8): "; if (1,2,3,4) = (1,2,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q334"
+let _ = printString "tuple equality null test (a9): "; if (A,2,3,4) = (A,2,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q335"
+let _ = printString "tuple equality null test (a10): "; if (1,A,3,4) = (1,A,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q336"
+let _ = printString "tuple equality null test (a11): "; if (1,2,A,4) = (1,2,A,4) then stdout.WriteLine "YES" else reportFailure "basic test Q337"
+let _ = printString "tuple equality null test (a12): "; if (1,2,3,A) = (1,2,3,A) then stdout.WriteLine "YES" else reportFailure "basic test Q338"
+let _ = printString "tuple equality null test (a13): "; if (1,2,3,4,5) = (1,2,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q339"
+let _ = printString "tuple equality null test (a14): "; if (A,2,3,4,5) = (A,2,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q340"
+let _ = printString "tuple equality null test (a15): "; if (1,A,3,4,5) = (1,A,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q341"
+let _ = printString "tuple equality null test (a16): "; if (1,2,A,4,5) = (1,2,A,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q342"
+let _ = printString "tuple equality null test (a17): "; if (1,2,3,A,5) = (1,2,3,A,5) then stdout.WriteLine "YES" else reportFailure "basic test Q343"
+let _ = printString "tuple equality null test (a18): "; if (1,2,3,4,A) = (1,2,3,4,A) then stdout.WriteLine "YES" else reportFailure "basic test Q344"
+let _ = printString "tuple equality null test (a19): "; if (1,2,3,4,5,6) = (1,2,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q345"
+let _ = printString "tuple equality null test (a20): "; if (A,2,3,4,5,6) = (A,2,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q346"
+let _ = printString "tuple equality null test (a21): "; if (1,A,3,4,5,6) = (1,A,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q347"
+let _ = printString "tuple equality null test (a22): "; if (1,2,A,4,5,6) = (1,2,A,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q348"
+let _ = printString "tuple equality null test (a23): "; if (1,2,3,A,5,6) = (1,2,3,A,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q349"
+let _ = printString "tuple equality null test (a24): "; if (1,2,3,4,A,6) = (1,2,3,4,A,6) then stdout.WriteLine "YES" else reportFailure "basic test Q350"
+let _ = printString "tuple equality null test (a25): "; if (1,2,3,4,5,A) = (1,2,3,4,5,A) then stdout.WriteLine "YES" else reportFailure "basic test Q351"
+
+let _ = printString "tuple inequality null test (b1): "; if (1,2) = (1,3) then reportFailure "basic test Q351" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b2): "; if (B,2) = (B,1) then reportFailure "basic test Q352" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b3): "; if (1,B) = (2,B) then reportFailure "basic test Q353" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b4): "; if (1,2,3) = (1,2,4) then reportFailure "basic test Q354" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b5): "; if (B,2,3) = (B,2,4) then reportFailure "basic test Q355" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b6): "; if (1,B,2) = (1,B,3) then reportFailure "basic test Q356" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b7): "; if (1,2,B) = (1,3,B) then reportFailure "basic test Q357" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b8): "; if (1,2,3,4) = (1,2,3,5) then reportFailure "basic test Q358" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b9): "; if (B,2,3,4) = (B,2,4,4) then reportFailure "basic test Q359" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b10): "; if (1,B,3,4) = (1,B,3,5) then reportFailure "basic test Q360" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b11): "; if (1,2,B,4) = (1,2,B,5) then reportFailure "basic test Q361" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b12): "; if (1,2,3,B) = (1,2,4,B) then reportFailure "basic test Q362" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b13): "; if (1,2,3,4,5) = (1,2,3,4,6) then reportFailure "basic test Q363" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b14): "; if (B,2,3,4,5) = (B,2,3,5,5) then reportFailure "basic test Q364" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b15): "; if (1,B,3,4,5) = (1,B,3,6,5) then reportFailure "basic test Q365" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b16): "; if (1,2,B,4,5) = (1,2,B,3,5) then reportFailure "basic test Q366" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b17): "; if (1,2,3,B,5) = (1,2,3,B,6) then reportFailure "basic test Q367" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b18): "; if (1,2,3,4,B) = (1,7,3,4,B) then reportFailure "basic test Q368" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b19): "; if (1,2,3,4,5,6) = (1,2,3,4,5,7) then reportFailure "basic test Q369" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b20): "; if (B,2,3,4,5,6) = (B,2,3,4,5,7) then reportFailure "basic test Q370" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b21): "; if (1,B,3,4,5,6) = (1,B,3,4,5,7) then reportFailure "basic test Q371" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b22): "; if (1,2,B,4,5,6) = (1,2,B,4,5,7) then reportFailure "basic test Q372" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b23): "; if (1,2,3,B,5,6) = (1,2,3,B,5,7) then reportFailure "basic test Q373" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b24): "; if (1,2,3,4,B,6) = (1,2,3,4,B,7) then reportFailure "basic test Q374" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b25): "; if (1,2,3,4,5,B) = (1,2,3,4,6,B) then reportFailure "basic test Q375" else stdout.WriteLine "YES"
+
+let _ = printString "tuple equality null test (b1): "; if (1,2) = (1,2) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b2): "; if (B,2) = (B,2) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b3): "; if (1,B) = (1,B) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b4): "; if (1,2,3) = (1,2,3) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b5): "; if (B,2,3) = (B,2,3) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b6): "; if (1,B,2) = (1,B,2) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b7): "; if (1,2,B) = (1,2,B) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b8): "; if (1,2,3,4) = (1,2,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b9): "; if (B,2,3,4) = (B,2,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b10): "; if (1,B,3,4) = (1,B,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b11): "; if (1,2,B,4) = (1,2,B,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b12): "; if (1,2,3,B) = (1,2,3,B) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b13): "; if (1,2,3,4,5) = (1,2,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b14): "; if (B,2,3,4,5) = (B,2,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b15): "; if (1,B,3,4,5) = (1,B,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b16): "; if (1,2,B,4,5) = (1,2,B,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b17): "; if (1,2,3,B,5) = (1,2,3,B,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b18): "; if (1,2,3,4,B) = (1,2,3,4,B) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b19): "; if (1,2,3,4,5,6) = (1,2,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b20): "; if (B,2,3,4,5,6) = (B,2,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b21): "; if (1,B,3,4,5,6) = (1,B,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b22): "; if (1,2,B,4,5,6) = (1,2,B,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b23): "; if (1,2,3,B,5,6) = (1,2,3,B,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b24): "; if (1,2,3,4,B,6) = (1,2,3,4,B,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b25): "; if (1,2,3,4,5,B) = (1,2,3,4,5,B) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+
+let _ = printString "tuple inequality null test (b1): "; if (1,2) = (1,3) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b2): "; if (C,2) = (C,1) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b3): "; if (1,C) = (2,C) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b4): "; if (1,2,3) = (1,2,4) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b5): "; if (C,2,3) = (C,2,4) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b6): "; if (1,C,2) = (1,C,3) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b7): "; if (1,2,C) = (1,3,C) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b8): "; if (1,2,3,4) = (1,2,3,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b9): "; if (C,2,3,4) = (C,2,4,4) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b10): "; if (1,C,3,4) = (1,C,3,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b11): "; if (1,2,C,4) = (1,2,C,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b12): "; if (1,2,3,C) = (1,2,4,C) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b13): "; if (1,2,3,4,5) = (1,2,3,4,6) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b14): "; if (C,2,3,4,5) = (C,2,3,5,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b15): "; if (1,C,3,4,5) = (1,C,3,6,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b16): "; if (1,2,C,4,5) = (1,2,C,3,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b17): "; if (1,2,3,C,5) = (1,2,3,C,6) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b18): "; if (1,2,3,4,C) = (1,7,3,4,C) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b19): "; if (1,2,3,4,5,6) = (1,2,3,4,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b20): "; if (C,2,3,4,5,6) = (C,2,3,4,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b21): "; if (1,C,3,4,5,6) = (1,C,3,4,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b22): "; if (1,2,C,4,5,6) = (1,2,C,4,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b23): "; if (1,2,3,C,5,6) = (1,2,3,C,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b24): "; if (1,2,3,4,C,6) = (1,2,3,4,C,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple inequality null test (b25): "; if (1,2,3,4,5,C) = (1,2,3,4,6,C) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+
+let _ = printString "tuple equality null test (b1): "; if (1,2) = (1,2) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b2): "; if (C,2) = (C,2) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b3): "; if (1,C) = (1,C) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b4): "; if (1,2,3) = (1,2,3) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b5): "; if (C,2,3) = (C,2,3) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b6): "; if (1,C,2) = (1,C,2) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b7): "; if (1,2,C) = (1,2,C) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b8): "; if (1,2,3,4) = (1,2,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b9): "; if (C,2,3,4) = (C,2,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b10): "; if (1,C,3,4) = (1,C,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b11): "; if (1,2,C,4) = (1,2,C,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b12): "; if (1,2,3,C) = (1,2,3,C) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b13): "; if (1,2,3,4,5) = (1,2,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b14): "; if (C,2,3,4,5) = (C,2,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b15): "; if (1,C,3,4,5) = (1,C,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b16): "; if (1,2,C,4,5) = (1,2,C,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b17): "; if (1,2,3,C,5) = (1,2,3,C,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b18): "; if (1,2,3,4,C) = (1,2,3,4,C) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b19): "; if (1,2,3,4,5,6) = (1,2,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b20): "; if (C,2,3,4,5,6) = (C,2,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b21): "; if (1,C,3,4,5,6) = (1,C,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b22): "; if (1,2,C,4,5,6) = (1,2,C,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b23): "; if (1,2,3,C,5,6) = (1,2,3,C,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b24): "; if (1,2,3,4,C,6) = (1,2,3,4,C,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple equality null test (b25): "; if (1,2,3,4,5,C) = (1,2,3,4,5,C) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+
+
+
+let _ = printString "tuple object inequality null test (1): "; if (1,2) === (1,3) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (2): "; if ([],2) === ([],1) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (3): "; if (1,[]) === (2,[]) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (4): "; if (1,2,3) === (1,2,4) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (5): "; if ([],2,3) === ([],2,4) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (6): "; if (1,[],2) === (1,[],3) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (7): "; if (1,2,[]) === (1,3,[]) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (8): "; if (1,2,3,4) === (1,2,3,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (9): "; if ([],2,3,4) === ([],2,4,4) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (10): "; if (1,[],3,4) === (1,[],3,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (11): "; if (1,2,[],4) === (1,2,[],5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (12): "; if (1,2,3,[]) === (1,2,4,[]) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (13): "; if (1,2,3,4,5) === (1,2,3,4,6) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (14): "; if ([],2,3,4,5) === ([],2,3,5,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (15): "; if (1,[],3,4,5) === (1,[],3,6,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (16): "; if (1,2,[],4,5) === (1,2,[],3,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (17): "; if (1,2,3,[],5) === (1,2,3,[],6) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (18): "; if (1,2,3,4,[]) === (1,7,3,4,[]) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (19): "; if (1,2,3,4,5,6) === (1,2,3,4,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (20): "; if ([],2,3,4,5,6) === ([],2,3,4,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (21): "; if (1,[],3,4,5,6) === (1,[],3,4,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (22): "; if (1,2,[],4,5,6) === (1,2,[],4,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (23): "; if (1,2,3,[],5,6) === (1,2,3,[],5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (24): "; if (1,2,3,4,[],6) === (1,2,3,4,[],7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (25): "; if (1,2,3,4,5,[]) === (1,2,3,4,6,[]) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+
+let _ = printString "tuple object equality null test (1): "; if (1,2) === (1,2) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (2): "; if ([],2) === ([],2) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (3): "; if (1,[]) === (1,[]) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (4): "; if (1,2,3) === (1,2,3) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (5): "; if ([],2,3) === ([],2,3) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (6): "; if (1,[],2) === (1,[],2) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (7): "; if (1,2,[]) === (1,2,[]) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (8): "; if (1,2,3,4) === (1,2,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (9): "; if ([],2,3,4) === ([],2,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (10): "; if (1,[],3,4) === (1,[],3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (11): "; if (1,2,[],4) === (1,2,[],4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (12): "; if (1,2,3,[]) === (1,2,3,[]) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (13): "; if (1,2,3,4,5) === (1,2,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (14): "; if ([],2,3,4,5) === ([],2,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (15): "; if (1,[],3,4,5) === (1,[],3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (16): "; if (1,2,[],4,5) === (1,2,[],4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (17): "; if (1,2,3,[],5) === (1,2,3,[],5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (18): "; if (1,2,3,4,[]) === (1,2,3,4,[]) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (19): "; if (1,2,3,4,5,6) === (1,2,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (20): "; if ([],2,3,4,5,6) === ([],2,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (21): "; if (1,[],3,4,5,6) === (1,[],3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (22): "; if (1,2,[],4,5,6) === (1,2,[],4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (23): "; if (1,2,3,[],5,6) === (1,2,3,[],5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (24): "; if (1,2,3,4,[],6) === (1,2,3,4,[],6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (25): "; if (1,2,3,4,5,[]) === (1,2,3,4,5,[]) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+
+let _ = printString "tuple object inequality null test (a1): "; if (1,2) === (1,3) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a2): "; if (A,2) === (A,1) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a3): "; if (1,A) === (2,A) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a4): "; if (1,2,3) === (1,2,4) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a5): "; if (A,2,3) === (A,2,4) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a6): "; if (1,A,2) === (1,A,3) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a7): "; if (1,2,A) === (1,3,A) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a8): "; if (1,2,3,4) === (1,2,3,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a9): "; if (A,2,3,4) === (A,2,4,4) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a10): "; if (1,A,3,4) === (1,A,3,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a11): "; if (1,2,A,4) === (1,2,A,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a12): "; if (1,2,3,A) === (1,2,4,A) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a13): "; if (1,2,3,4,5) === (1,2,3,4,6) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a14): "; if (A,2,3,4,5) === (A,2,3,5,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a15): "; if (1,A,3,4,5) === (1,A,3,6,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a16): "; if (1,2,A,4,5) === (1,2,A,3,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a17): "; if (1,2,3,A,5) === (1,2,3,A,6) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a18): "; if (1,2,3,4,A) === (1,7,3,4,A) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a19): "; if (1,2,3,4,5,6) === (1,2,3,4,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a20): "; if (A,2,3,4,5,6) === (A,2,3,4,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a21): "; if (1,A,3,4,5,6) === (1,A,3,4,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a22): "; if (1,2,A,4,5,6) === (1,2,A,4,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a23): "; if (1,2,3,A,5,6) === (1,2,3,A,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a24): "; if (1,2,3,4,A,6) === (1,2,3,4,A,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (a25): "; if (1,2,3,4,5,A) === (1,2,3,4,6,A) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+
+let _ = printString "tuple object equality null test (a1): "; if (1,2) === (1,2) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a2): "; if (A,2) === (A,2) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a3): "; if (1,A) === (1,A) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a4): "; if (1,2,3) === (1,2,3) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a5): "; if (A,2,3) === (A,2,3) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a6): "; if (1,A,2) === (1,A,2) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a7): "; if (1,2,A) === (1,2,A) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a8): "; if (1,2,3,4) === (1,2,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a9): "; if (A,2,3,4) === (A,2,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a10): "; if (1,A,3,4) === (1,A,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a11): "; if (1,2,A,4) === (1,2,A,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a12): "; if (1,2,3,A) === (1,2,3,A) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a13): "; if (1,2,3,4,5) === (1,2,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a14): "; if (A,2,3,4,5) === (A,2,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a15): "; if (1,A,3,4,5) === (1,A,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a16): "; if (1,2,A,4,5) === (1,2,A,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a17): "; if (1,2,3,A,5) === (1,2,3,A,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a18): "; if (1,2,3,4,A) === (1,2,3,4,A) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a19): "; if (1,2,3,4,5,6) === (1,2,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a20): "; if (A,2,3,4,5,6) === (A,2,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a21): "; if (1,A,3,4,5,6) === (1,A,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a22): "; if (1,2,A,4,5,6) === (1,2,A,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a23): "; if (1,2,3,A,5,6) === (1,2,3,A,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a24): "; if (1,2,3,4,A,6) === (1,2,3,4,A,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (a25): "; if (1,2,3,4,5,A) === (1,2,3,4,5,A) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+
+let _ = printString "tuple object inequality null test (b1): "; if (1,2) === (1,3) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b2): "; if (B,2) === (B,1) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b3): "; if (1,B) === (2,B) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b4): "; if (1,2,3) === (1,2,4) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b5): "; if (B,2,3) === (B,2,4) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b6): "; if (1,B,2) === (1,B,3) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b7): "; if (1,2,B) === (1,3,B) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b8): "; if (1,2,3,4) === (1,2,3,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b9): "; if (B,2,3,4) === (B,2,4,4) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b10): "; if (1,B,3,4) === (1,B,3,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b11): "; if (1,2,B,4) === (1,2,B,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b12): "; if (1,2,3,B) === (1,2,4,B) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b13): "; if (1,2,3,4,5) === (1,2,3,4,6) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b14): "; if (B,2,3,4,5) === (B,2,3,5,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b15): "; if (1,B,3,4,5) === (1,B,3,6,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b16): "; if (1,2,B,4,5) === (1,2,B,3,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b17): "; if (1,2,3,B,5) === (1,2,3,B,6) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b18): "; if (1,2,3,4,B) === (1,7,3,4,B) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b19): "; if (1,2,3,4,5,6) === (1,2,3,4,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b20): "; if (B,2,3,4,5,6) === (B,2,3,4,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b21): "; if (1,B,3,4,5,6) === (1,B,3,4,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b22): "; if (1,2,B,4,5,6) === (1,2,B,4,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b23): "; if (1,2,3,B,5,6) === (1,2,3,B,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b24): "; if (1,2,3,4,B,6) === (1,2,3,4,B,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b25): "; if (1,2,3,4,5,B) === (1,2,3,4,6,B) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+
+let _ = printString "tuple object equality null test (b1): "; if (1,2) === (1,2) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b2): "; if (B,2) === (B,2) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b3): "; if (1,B) === (1,B) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b4): "; if (1,2,3) === (1,2,3) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b5): "; if (B,2,3) === (B,2,3) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b6): "; if (1,B,2) === (1,B,2) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b7): "; if (1,2,B) === (1,2,B) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b8): "; if (1,2,3,4) === (1,2,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b9): "; if (B,2,3,4) === (B,2,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b10): "; if (1,B,3,4) === (1,B,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b11): "; if (1,2,B,4) === (1,2,B,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b12): "; if (1,2,3,B) === (1,2,3,B) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b13): "; if (1,2,3,4,5) === (1,2,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b14): "; if (B,2,3,4,5) === (B,2,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b15): "; if (1,B,3,4,5) === (1,B,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b16): "; if (1,2,B,4,5) === (1,2,B,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b17): "; if (1,2,3,B,5) === (1,2,3,B,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b18): "; if (1,2,3,4,B) === (1,2,3,4,B) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b19): "; if (1,2,3,4,5,6) === (1,2,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b20): "; if (B,2,3,4,5,6) === (B,2,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b21): "; if (1,B,3,4,5,6) === (1,B,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b22): "; if (1,2,B,4,5,6) === (1,2,B,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b23): "; if (1,2,3,B,5,6) === (1,2,3,B,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b24): "; if (1,2,3,4,B,6) === (1,2,3,4,B,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b25): "; if (1,2,3,4,5,B) === (1,2,3,4,5,B) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+
+let _ = printString "tuple object inequality null test (b1): "; if (1,2) === (1,3) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b2): "; if (C,2) === (C,1) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b3): "; if (1,C) === (2,C) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b4): "; if (1,2,3) === (1,2,4) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b5): "; if (C,2,3) === (C,2,4) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b6): "; if (1,C,2) === (1,C,3) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b7): "; if (1,2,C) === (1,3,C) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b8): "; if (1,2,3,4) === (1,2,3,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b9): "; if (C,2,3,4) === (C,2,4,4) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b10): "; if (1,C,3,4) === (1,C,3,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b11): "; if (1,2,C,4) === (1,2,C,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b12): "; if (1,2,3,C) === (1,2,4,C) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b13): "; if (1,2,3,4,5) === (1,2,3,4,6) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b14): "; if (C,2,3,4,5) === (C,2,3,5,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b15): "; if (1,C,3,4,5) === (1,C,3,6,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b16): "; if (1,2,C,4,5) === (1,2,C,3,5) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b17): "; if (1,2,3,C,5) === (1,2,3,C,6) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b18): "; if (1,2,3,4,C) === (1,7,3,4,C) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b19): "; if (1,2,3,4,5,6) === (1,2,3,4,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b20): "; if (C,2,3,4,5,6) === (C,2,3,4,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b21): "; if (1,C,3,4,5,6) === (1,C,3,4,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b22): "; if (1,2,C,4,5,6) === (1,2,C,4,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b23): "; if (1,2,3,C,5,6) === (1,2,3,C,5,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b24): "; if (1,2,3,4,C,6) === (1,2,3,4,C,7) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+let _ = printString "tuple object inequality null test (b25): "; if (1,2,3,4,5,C) === (1,2,3,4,6,C) then reportFailure "basic test Q" else stdout.WriteLine "YES"
+
+let _ = printString "tuple object equality null test (b1): "; if (1,2) === (1,2) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b2): "; if (C,2) === (C,2) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b3): "; if (1,C) === (1,C) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b4): "; if (1,2,3) === (1,2,3) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b5): "; if (C,2,3) === (C,2,3) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b6): "; if (1,C,2) === (1,C,2) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b7): "; if (1,2,C) === (1,2,C) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b8): "; if (1,2,3,4) === (1,2,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b9): "; if (C,2,3,4) === (C,2,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b10): "; if (1,C,3,4) === (1,C,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b11): "; if (1,2,C,4) === (1,2,C,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b12): "; if (1,2,3,C) === (1,2,3,C) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b13): "; if (1,2,3,4,5) === (1,2,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b14): "; if (C,2,3,4,5) === (C,2,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b15): "; if (1,C,3,4,5) === (1,C,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b16): "; if (1,2,C,4,5) === (1,2,C,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b17): "; if (1,2,3,C,5) === (1,2,3,C,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b18): "; if (1,2,3,4,C) === (1,2,3,4,C) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b19): "; if (1,2,3,4,5,6) === (1,2,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b20): "; if (C,2,3,4,5,6) === (C,2,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b21): "; if (1,C,3,4,5,6) === (1,C,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b22): "; if (1,2,C,4,5,6) === (1,2,C,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b23): "; if (1,2,3,C,5,6) === (1,2,3,C,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b24): "; if (1,2,3,4,C,6) === (1,2,3,4,C,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "tuple object equality null test (b25): "; if (1,2,3,4,5,C) === (1,2,3,4,5,C) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+
+
+let _ = printString "ref equality test (b25): "; if ref 1 = ref 1 then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "ref equality test (b25): "; if ref 1 <> ref 2 then stdout.WriteLine "YES" else reportFailure "basic test Q"
+
+let _ = printString "compaure nativeint test (b25): "; if compare [0n] [1n] = -(compare [1n] [0n]) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "compaure nativeint test (b25): "; if compare [0un] [1un] = -(compare [1un] [0un]) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "compaure nativeint test (b25): "; if compare [0un] [0un] = 0 then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "compaure nativeint test (b25): "; if compare [0n] [0n] = 0 then stdout.WriteLine "YES" else reportFailure "basic test Q"
+
+
+(*---------------------------------------------------------------------------
+!* Equality tests over structured values for data likely to contain
+ * values represented by "null"
+ *--------------------------------------------------------------------------- *)
+
+type ('a,'b) a2 = A2 of 'a * 'b
+type ('a,'b,'c) a3 = A3 of 'a * 'b * 'c
+type ('a,'b,'c,'d) a4 = A4 of 'a * 'b * 'c * 'd
+type ('a,'b,'c,'d,'e) a5 = A5 of 'a * 'b * 'c * 'd * 'e
+type ('a,'b,'c,'d,'e,'f) a6 = A6 of 'a * 'b * 'c * 'd * 'e * 'f
+let _ = printString "data equality null test (1): "; if A2 (1,2) = A2 (1,2) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (2): "; if A2 ([],2) = A2 ([],2) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (3): "; if A2 (1,[]) = A2 (1,[]) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (4): "; if A3(1,2,3) = A3(1,2,3) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (5): "; if A3([],2,3) = A3([],2,3) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (6): "; if A3(1,[],2) = A3(1,[],2) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (7): "; if A3(1,2,[]) = A3(1,2,[]) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (8): "; if A4(1,2,3,4) = A4(1,2,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (9): "; if A4([],2,3,4) = A4([],2,3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (10): "; if A4(1,[],3,4) = A4(1,[],3,4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (11): "; if A4(1,2,[],4) = A4(1,2,[],4) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (12): "; if A4(1,2,3,[]) = A4(1,2,3,[]) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (13): "; if A5(1,2,3,4,5) = A5(1,2,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (14): "; if A5([],2,3,4,5) = A5([],2,3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (15): "; if A5(1,[],3,4,5) = A5(1,[],3,4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (16): "; if A5(1,2,[],4,5) = A5(1,2,[],4,5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (17): "; if A5(1,2,3,[],5) = A5(1,2,3,[],5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (18): "; if A5(1,2,3,4,[]) = A5(1,2,3,4,[]) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (19): "; if A6(1,2,3,4,5,6) = A6(1,2,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (20): "; if A6([],2,3,4,5,6) = A6([],2,3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (21): "; if A6(1,[],3,4,5,6) = A6(1,[],3,4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (22): "; if A6(1,2,[],4,5,6) = A6(1,2,[],4,5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (23): "; if A6(1,2,3,[],5,6) = A6(1,2,3,[],5,6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (24): "; if A6(1,2,3,4,[],6) = A6(1,2,3,4,[],6) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "data equality null test (25): "; if A6(1,2,3,4,5,[]) = A6(1,2,3,4,5,[]) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+
+let _ = printString "map test (1): "; if List.map (fun x -> x+1) [] = [] then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "map test (2): "; if List.map (fun x -> x+1) [1] = [2] then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "map test (3): "; if List.map (fun x -> x+1) [2;1] = [3;2] then stdout.WriteLine "YES" else reportFailure "basic test Q"
+
+let _ = printString "append test (1): "; if [2] @ [] = [2] then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "append test (2): "; if [] @ [2] = [2] then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "append test (3): "; if [2] @ [1] = [2;1] then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "append test (4): "; if [3;2] @ [1] = [3;2;1] then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "append test (5): "; if [3;2] @ [1;0] = [3;2;1;0] then stdout.WriteLine "YES" else reportFailure "basic test Q"
+
+let _ = printString "concat test (1): "; if List.concat [[2]] = [2] then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "concat test (2): "; if List.concat [[]] = [] then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "concat test (3): "; if List.concat [[2];[1]] = [2;1] then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "combine test (1): "; if List.zip [] [] = [] then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "combine test (2): "; if List.zip [1] [2] = [(1,2)] then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "combine test (3): "; if List.zip [1.0;2.0] [2.0;3.0] = [(1.0,2.0);(2.0,3.0)] then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "split test (1): "; if List.unzip [(1.0,2.0);(2.0,3.0)] = ([1.0;2.0],[2.0;3.0]) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "split test (2): "; if List.unzip [] = ([],[]) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+
+let _ = printfn "reduce test"; if List.reduce (fun x y -> x/y) [5*4*3*2; 4;3;2;1] = 5 then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printfn "reduceBack test"; if List.reduceBack (fun y x -> x/y) [4;3;2;1; 5*4*3*2] = 5 then stdout.WriteLine "YES" else reportFailure "basic test Q"
+
+
+(*---------------------------------------------------------------------------
+!* List library
+ *--------------------------------------------------------------------------- *)
+
+
+let pri s l = printString s; printString ": "; List.iter printInt l; printNewLine ()
+
+let _ = pri "none" [1;2;3;4;5;6]
+let _ = pri "rev" (List.rev [6;5;4;3;2;1])
+let _ = pri "@" ([1;2;3] @ [4;5;6])
+let _ = pri "map" (List.map (fun x -> x + 1) ([1;2;3]))
+let _ = pri "concat" (List.concat [[1;2]; [3;4]; [5;6]])
+
+let prs s l = printString s; printString ": "; List.iter printString l; printNewLine ()
+let _ = prs "none" ["1";"2";"3";"4";"5";"6"]
+let _ = prs "rev" (List.rev ["6";"5";"4";"3";"2";"1"])
+let _ = prs "map" (List.map (fun x -> x ^ ".0") (["1";"2";"3"]))
+let _ = prs "@" (["1";"2";"3"] @ ["4";"5";"6"])
+let _ = prs "concat" (List.concat [["1";"2"]; ["3";"4"]; ["5";"6"]])
+
+let _ = test "List.empty" (List.empty |> List.length = 0)
+let _ = test "List.empty" (List.empty = [])
+let _ = test "List.head" (List.head [1..4] = 1)
+let _ = test "List.head" (try List.head []; false with _ -> true)
+let _ = test "List.tail" (List.tail [1..10] = [2..10])
+let _ = test "List.tail" (try List.tail []; false with _ -> true)
+let _ = test "List.init" (List.init 20 (fun x -> x+1) = [1..20])
+let _ = test "List.fold2" (List.fold2 (fun i j k -> i+j+k) 100 [1;2;3] [1;2;3] = 112)
+let _ = test "List.fold2" (List.fold2 (fun i j k -> i-j-k) 100 [1;2;3] [1;2;3] = 100-12)
+let _ = test "List.foldBack2" (List.foldBack2 (fun i j k -> i+j+k) [1;2;3] [1;2;3] 100 = 112)
+let _ = test "List.foldBack2" (List.foldBack2 (fun i j k -> k-i-j) [1;2;3] [1;2;3] 100 = 100-12)
+
+let _ = test "List.scan" (List.scan (+) 0 [1..5] = [0; 1; 3; 6; 10; 15])
+
+let _ = test "List.scanBack" (List.scanBack (+) [1..5] 0 = [15; 14; 12; 9; 5; 0])
+
+let _ = test "List.tryFindIndex" (List.tryFindIndex (fun x -> x = 4) [0..10] = Some 4)
+
+let _ = test "List.tryfind_index_b" (List.tryFindIndex (fun x -> x = 42) [0..10] = None)
+
+
+let mutable c = -1
+do List.iter (fun x -> c <- (c + 1); test "List.iter" (x = c)) [0..100]
+let _ = test "List.iter" (c = 100)
+
+let _ = test "List.map" ([1..100] |> List.map ((+) 1) = [2..101])
+
+let _ = test "List.mapi" ([0..100] |> List.mapi (+) = [0..+2..200])
+
+do c <- -1
+do List.iteri (fun i x -> c <- (c+1); test "List.iteri" (x = c && i = c)) [0..100]
+let _ = test "List.iteri" (c = 100)
+
+let _ = test "List.exists" ([1..100] |> List.exists ((=) 50))
+
+let _ = test "List.exists b" <| not ([1..100] |> List.exists ((=) 150))
+
+let _ = test "List.forall" ([1..100] |> List.forall (fun x -> x < 150))
+
+let _ = test "List.forall b" <| not ([1..100] |> List.forall (fun x -> x < 80))
+
+let _ = test "List.find" ([1..100] |> List.find (fun x -> x > 50) = 51)
+
+let _ = test "List.find b" (try [1..100] |> List.find (fun x -> x > 180) |> ignore; false with _ -> true)
+
+let _ = test "List.tryPick" ([1..100] |> List.tryPick (fun x -> if x > 50 then Some (x*x) else None) = Some (51*51))
+
+let _ = test "List.tryPick b" ([1..100] |> List.tryPick (fun x -> None) = None)
+
+let _ = test "List.tryPick c" ([] |> List.tryPick (fun _ -> Some 42) = None)
+
+let _ = test "List.tryFind" ([1..100] |> List.tryFind (fun x -> x > 50) = Some 51)
+
+let _ = test "List.tryFind b" ([1..100] |> List.tryFind (fun x -> x > 180) = None)
+
+do c <- -1
+do List.iter2 (fun x y -> c <- c + 1; test "List.iter2" (c = x && c = y)) [0..100] [0..100]
+let _ = test "List.iter2" (c = 100)
+
+let _ = test "List.map2" (List.map2 (+) [0..100] [0..100] = [0..+2..200])
+
+let _ = test "List.choose" (List.choose (fun x -> if x % 2 = 0 then Some (x/2) else None) [0..100] = [0..50])
+
+let _ = test "List.filter" (List.filter (fun x -> x % 2 = 0) [0..100] = [0..+2..100])
+
+let _ = test "List.filter b" (List.filter (fun x -> false) [0..100] = [])
+
+let _ = test "List.filter c" (List.filter (fun x -> true) [0..100] = [0..100])
+
+let p1, p2 = List.partition (fun x -> x % 2 = 0) [0..100]
+let _ = test "List.partition" (p1 = [0..+2..100] && p2 = [1..+2..100])
+
+let _ = test "List.rev" (List.rev [0..100] = [100..-1 ..0])
+
+let _ = test "List.rev b" (List.rev [1] = [1])
+
+let _ = test "List.rev c" (List.rev [] = [])
+
+let _ = test "List.rev d" (List.rev [1; 2] = [2; 1])
+
+
+
+module MinMaxAverageSum =
+ do test "ceijoe9cewz" (Seq.sum [] = 0)
+ do test "ceijoe9cewx" (Seq.sum [1;2;3] = 6)
+ do test "ceijoe9cewv" (Seq.sum [0.0;1.0] = 1.0)
+ do test "ceijoe9cewc" (Seq.average [1.0;2.0;3.0] = 2.0)
+ do test "ceijoe9cewb" (Seq.averageBy id [1.0;2.0;3.0] = 2.0)
+ do test "ceijoe9cewn" (Seq.averageBy id [1.0M;2.0M;3.0M] = 2.0M)
+ do test "ceijoe9cewm" (Seq.sum [System.Int32.MinValue;System.Int32.MaxValue] = -1)
+ do test "ceijoe9cewaa" (Seq.sum [System.Int32.MaxValue;System.Int32.MinValue] = -1)
+ do test "ceijoe9cewss" (Seq.sum [System.Int32.MinValue;1;-1] = System.Int32.MinValue)
+ //printfn "res = %g" (Seq.averageBy id [])
+ //printfn "res = %g" (Seq.average { 0.0 .. 100000.0 })
+
+ do test "ceijoe9cew1dd" (Seq.min [1;2;3] = 1)
+ do test "ceijoe9cew2ff" (Seq.min [3;2;1] = 1)
+
+ do test "ceijoe9cew3gg" (Seq.max [1;2;3] = 3)
+ do test "ceijoe9cew4hh" (Seq.max [3;2;1] = 3)
+
+
+ do test "ceijoe9cew5jj" (Seq.min [1.0;2.0;3.0] = 1.0)
+ do test "ceijoe9cew6kk" (Seq.min [3.0;2.0;1.0] = 1.0)
+
+ do test "ceijoe9cew7" (Seq.max [1.0;2.0;3.0] = 3.0)
+ do test "ceijoe9cew8" (Seq.max [3.0;2.0;1.0] = 3.0)
+
+ do test "ceijoe9cew9" (Seq.min [1.0M;2.0M;3.0M] = 1.0M)
+ do test "ceijoe9cewq" (Seq.min [3.0M;2.0M;1.0M] = 1.0M)
+
+ do test "ceijoe9ceww" (Seq.max [1.0M;2.0M;3.0M] = 3.0M)
+ do test "ceijoe9cewe" (Seq.max [3.0M;2.0M;1.0M] = 3.0M)
+
+ do test "ceijoe9cewz" (List.sum [] = 0)
+ do test "ceijoe9cewx" (List.sum [1;2;3] = 6)
+ do test "ceijoe9cewv" (List.sum [0.0;1.0] = 1.0)
+ do test "ceijoe9cewc" (List.average [1.0;2.0;3.0] = 2.0)
+ do test "ceijoe9cewb" (List.averageBy id [1.0;2.0;3.0] = 2.0)
+ do test "ceijoe9cewn" (List.averageBy id [1.0M;2.0M;3.0M] = 2.0M)
+ do test "ceijoe9cewm" (List.sum [System.Int32.MinValue;System.Int32.MaxValue] = -1)
+ do test "ceijoe9cewaa" (List.sum [System.Int32.MaxValue;System.Int32.MinValue] = -1)
+ do test "ceijoe9cewss" (List.sum [System.Int32.MinValue;1;-1] = System.Int32.MinValue)
+ //printfn "res = %g" (List.averageBy id [])
+ //printfn "res = %g" (List.average { 0.0 .. 100000.0 })
+
+ do test "ceijoe9cew1dd" (List.min [1;2;3] = 1)
+ do test "ceijoe9cew2ff" (List.min [3;2;1] = 1)
+
+ do test "ceijoe9cew3gg" (List.max [1;2;3] = 3)
+ do test "ceijoe9cew4hh" (List.max [3;2;1] = 3)
+
+
+ do test "ceijoe9cew5jj" (List.min [1.0;2.0;3.0] = 1.0)
+ do test "ceijoe9cew6kk" (List.min [3.0;2.0;1.0] = 1.0)
+
+ do test "ceijoe9cew7" (List.max [1.0;2.0;3.0] = 3.0)
+ do test "ceijoe9cew8" (List.max [3.0;2.0;1.0] = 3.0)
+
+ do test "ceijoe9cew9" (List.min [1.0M;2.0M;3.0M] = 1.0M)
+ do test "ceijoe9cewq" (List.min [3.0M;2.0M;1.0M] = 1.0M)
+
+ do test "ceijoe9ceww" (List.max [1.0M;2.0M;3.0M] = 3.0M)
+ do test "ceijoe9cewe" (List.max [3.0M;2.0M;1.0M] = 3.0M)
+
+
+
+module Pow =
+ do test "cnod90km1" (pown 2.0 -3 = 0.125)
+ do test "cnod90km2" (pown 2.0 -2 = 0.25)
+ do test "cnod90km3" (pown 2.0 -1 = 0.5)
+ do test "cnod90km4" (pown 2.0 0 = 1.0)
+ do test "cnod90km5" (pown 2.0 1 = 2.0)
+ do test "cnod90km6" (pown 2.0 2 = 4.0)
+ do test "cnod90km7" (pown 2.0 3 = 8.0)
+ do test "cnod90km8" (pown 2.0 4 = 16.0)
+ do test "cnod90km9" (pown 2.0 5 = 32.0)
+
+ do for exp in -5 .. 5 do
+ test "cnod90kma" (pown 0.5 exp = 0.5 ** float exp);
+ test "cnod90kmb" (pown 1.0 exp = 1.0 ** float exp);
+ test "cnod90kmc" (pown 2.0 exp = 2.0 ** float exp);
+#if MONO
+#else
+ test "cnod90kmd" (pown 3.0 exp = 3.0 ** float exp)
+#endif
+ done
+
+ do for exp in [ 5 .. -1 .. -5 ] @ [System.Int32.MinValue;System.Int32.MaxValue] do
+ // check powers of 0
+ printfn "exp = %d" exp;
+ test "cnod90kme" (pown 0.0f exp = (if exp = 0 then 1.0f else if exp < 0 then infinityf else 0.0f));
+ test "cnod90kmf" (pown 0.0 exp = (if exp = 0 then 1.0 else if exp < 0 then infinity else 0.0));
+ if exp >= 0 then (
+ test "cnod90kmg" (pown 0 exp = (if exp = 0 then 1 else 0));
+ test "cnod90kmh" (pown 0u exp = (if exp = 0 then 1u else 0u));
+ test "cnod90kmi" (pown 0us exp = (if exp = 0 then 1us else 0us));
+ test "cnod90kmj" (pown 0s exp = (if exp = 0 then 1s else 0s));
+ test "cnod90kmk" (pown 0L exp = (if exp = 0 then 1L else 0L));
+ test "cnod90kml" (pown 0UL exp = (if exp = 0 then 1UL else 0UL));
+ test "cnod90kmm" (pown 0n exp = (if exp = 0 then 1n else 0n));
+ test "cnod90kmn" (pown 0un exp = (if exp = 0 then 1un else 0un));
+ test "cnod90kmo" (pown 0y exp = (if exp = 0 then 1y else 0y));
+ test "cnod90kmp" (pown 0uy exp = (if exp = 0 then 1uy else 0uy));
+ test "cnod90kmq" (pown 0M exp = (if exp = 0 then 1M else 0M));
+ ) else (
+ test "cnod90kmgE" (try pown 0 exp; false with :? System.DivideByZeroException -> true);
+ test "cnod90kmhE" (try pown 0u exp; false with :? System.DivideByZeroException -> true);
+ test "cnod90kmiE" (try pown 0us exp; false with :? System.DivideByZeroException -> true);
+ test "cnod90kmjE" (try pown 0s exp; false with :? System.DivideByZeroException -> true);
+ test "cnod90kmE" (try pown 0L exp; false with :? System.DivideByZeroException -> true);
+ test "cnod90kmhE" (try pown 0UL exp; false with :? System.DivideByZeroException -> true);
+ test "cnod90kmtE" (try pown 0n exp; false with :? System.DivideByZeroException -> true);
+ test "cnod90kmhrE" (try pown 0un exp; false with :? System.DivideByZeroException -> true);
+ test "cnod90kmheE" (try pown 0y exp; false with :? System.DivideByZeroException -> true);
+ test "cnod90kmhfrE" (try pown 0uy exp; false with :? System.DivideByZeroException -> true);
+ test "cnod90kmhvreE" (try pown 0M exp; false with :? System.DivideByZeroException -> true);
+ );
+
+ // check powerrs of -1
+ test "cnod90kmr" (pown -1.0f exp = (if exp % 2 = 0 then 1.0f else -1.0f));
+ test "cnod90kms" (pown -1.0 exp = (if exp % 2 = 0 then 1.0 else -1.0));
+ test "cnod90kmt" (pown -1.0M exp = (if exp % 2 = 0 then 1.0M else -1.0M));
+ test "cnod90kmu" (pown -1 exp = (if exp % 2 = 0 then 1 else -1));
+ test "cnod90kmv" (pown -1L exp = (if exp % 2 = 0 then 1L else -1L));
+ test "cnod90kmw" (pown -1s exp = (if exp % 2 = 0 then 1s else -1s));
+ test "cnod90kmx" (pown -1y exp = (if exp % 2 = 0 then 1y else -1y));
+ test "cnod90kmy" (pown -1n exp = (if exp % 2 = 0 then 1n else -1n));
+ test "cnod90kmz" (pown 1.0f exp = 1.0f);
+ test "cnod90kmaa" (pown 1.0 exp = 1.0)
+ done
+
+ do for baseIdx in [-5 .. 5] do
+ // check x^0
+ test "cnod90kmbb2" (pown (float32 baseIdx) 0 = 1.0f);
+ test "cnod90kmcc2" (pown (float baseIdx) 0 = 1.0);
+ test "cnod90kmcc3" (pown (decimal baseIdx) 0 = 1M);
+ test "cnod90kmcc4" (pown (nativeint baseIdx) 0 = 1n);
+ test "cnod90kmcc5" (pown (unativeint baseIdx) 0 = 1un);
+ test "cnod90kmcc6" (pown (int64 baseIdx) 0 = 1L);
+ test "cnod90kmcc7" (pown (uint64 baseIdx) 0 = 1UL);
+ test "cnod90kmcc8" (pown (int32 baseIdx) 0 = 1);
+ test "cnod90kmcc9" (pown (uint32 baseIdx) 0 = 1u);
+ test "cnod90kmcca" (pown (int16 baseIdx) 0 = 1s);
+ test "cnod90kmccs" (pown (uint16 baseIdx) 0 = 1us);
+ test "cnod90kmccd" (pown (byte baseIdx) 0 = 1uy);
+ test "cnod90kmccf" (pown (sbyte baseIdx) 0 = 1y);
+
+ // check x^1
+ test "cnod90kmbb21" (pown (float32 baseIdx) 1 = (float32 baseIdx));
+ test "cnod90kmbb22" (pown (decimal baseIdx) 1 = (decimal baseIdx));
+ test "cnod90kmbb23" (pown (nativeint baseIdx) 1 = (nativeint baseIdx));
+ test "cnod90kmbb24" (pown (float baseIdx) 1 = (float baseIdx));
+ test "cnod90kmbb25" (pown (unativeint baseIdx) 1 = (unativeint baseIdx));
+ test "cnod90kmbb26" (pown (int64 baseIdx) 1 = (int64 baseIdx));
+ test "cnod90kmbb27" (pown (uint64 baseIdx) 1 = (uint64 baseIdx));
+ test "cnod90kmbb28" (pown (uint16 baseIdx) 1 = (uint16 baseIdx));
+ test "cnod90kmbb29" (pown (int16 baseIdx) 1 = (int16 baseIdx));
+ test "cnod90kmbb2q" (pown (byte baseIdx) 1 = (byte baseIdx));
+ test "cnod90kmbb2w" (pown (sbyte baseIdx) 1 = (sbyte baseIdx));
+
+ // check x^2
+ test "cnod90kmbb11" (pown (float32 baseIdx) 2 = (float32 baseIdx) * (float32 baseIdx));
+ test "cnod90kmbb12" (pown (decimal baseIdx) 2 = (decimal baseIdx) * (decimal baseIdx));
+ test "cnod90kmbb13" (pown (nativeint baseIdx) 2 = (nativeint baseIdx) * (nativeint baseIdx));
+ test "cnod90kmbb14" (pown (float baseIdx) 2 = (float baseIdx) * (float baseIdx));
+ test "cnod90kmbb16" (pown (int64 baseIdx) 2 = (int64 baseIdx) * (int64 baseIdx));
+ test "cnod90kmbb19" (pown (int16 baseIdx) 2 = (int16 baseIdx) * (int16 baseIdx));
+ test "cnod90kmbb1b" (pown (sbyte baseIdx) 2 = (sbyte baseIdx) * (sbyte baseIdx));
+ if baseIdx >= 0 then (
+ test "cnod90kmbb15" (pown (unativeint baseIdx) 2 = (unativeint baseIdx) * (unativeint baseIdx));
+ test "cnod90kmbb17" (pown (uint64 baseIdx) 2 = (uint64 baseIdx) * (uint64 baseIdx));
+ test "cnod90kmbb18" (pown (uint16 baseIdx) 2 = (uint16 baseIdx) * (uint16 baseIdx));
+ test "cnod90kmbb1a" (pown (byte baseIdx) 2 = (byte baseIdx) * (byte baseIdx));
+ )
+ done
+
+
+module TakeUntilSkipWhile =
+
+ do test "oewvjrrovvr1" ([ ] |> Seq.takeWhile (fun x -> x <= 5) |> Seq.toList = [ ])
+ do test "oewvjrrovvr2" ([ 1 ] |> Seq.takeWhile (fun x -> x <= 5) |> Seq.toList = [ 1 ])
+ do test "oewvjrrovvr3" ([ 1;2;3;4;5 ] |> Seq.takeWhile (fun x -> x <= 5) |> Seq.toList = [ 1..5 ])
+ do test "oewvjrrovvr4" ([ 1;2;3;4;5;6 ] |> Seq.takeWhile (fun x -> x <= 5) |> Seq.toList = [ 1..5 ])
+ do test "oewvjrrovvr5" ([ 1;2;3;4;5;6;7 ] |> Seq.takeWhile (fun x -> x <= 5) |> Seq.toList = [ 1..5 ])
+ do test "oewvjrrovvr6" ([ 1;2;3;4;5;6;5;4;3;2;1 ] |> Seq.takeWhile (fun x -> x <= 5) |> Seq.toList = [ 1..5 ])
+
+ do test "oewvjrrovvr7" ([ 1;2;3;4;5 ] |> Seq.skipWhile (fun x -> x <= 5) |> Seq.toList = [ ])
+ do test "oewvjrrovvr8" ([ 1;2;3;4;5;6 ] |> Seq.skipWhile (fun x -> x <= 5) |> Seq.toList = [ 6 ])
+ do test "oewvjrrovvr9" ([ 1;2;3;4;5;6;7 ] |> Seq.skipWhile (fun x -> x <= 5) |> Seq.toList = [ 6;7 ])
+ do test "oewvjrrovvra" ([ 1;2;3;4;5;6;5;4;3;2;1 ] |> Seq.skipWhile (fun x -> x <= 5) |> Seq.toList = [ 6;5;4;3;2;1 ])
+
+
+
+(*---------------------------------------------------------------------------
+!* Infinite data structure tests
+ *--------------------------------------------------------------------------- *)
+
+(*
+type ilist = Cons of int * ilist
+
+let test () = let rec list = Cons (1,list) in list
+
+let test2 () = let rec list2 = (1 :: list2) in list2
+let pri2 s l = printString s; printString ": "; List.iter printInt l; printNewLine ()
+let _ = pri2 "infinite list" (test2())
+
+let pri3 s l = printString s; printString ": "; List.iter printInt l; printNewLine ()
+let test3 () = let rec list3 = (1 :: list4) and list4 = 2::list3 in list3
+let _ = pri3 "infinite list" (test3())
+*
+type r4 = { cells: r4 list; tag: int }
+
+let rec pri4a x = printInt x.tag; pri4b x.cells
+and pri4b l = iter pri4a l
+
+let test4 () =
+ let rec r1 = { cells = list3; tag = 1}
+ and r2 = { cells = list4; tag = 2}
+ and list3 = r2 :: list4
+ and list4 = r1::list3 in
+ r1
+
+let _ = pri4a(test4())
+*)
+
+
+(*---------------------------------------------------------------------------
+!* Perf tests
+ *--------------------------------------------------------------------------- *)
+
+
+let listtest1 () =
+ let pri2 s l = printString s; printString ": "; List.iter printInt l; printNewLine () in
+ let mutable r = [] in
+ for i = 1 to 100 do
+ r <- i :: r;
+ for j = 1 to 100 do
+ let _ = List.rev r in ()
+ done;
+ done;
+ pri2 "list: " r
+
+let _ = listtest1()
+
+(*
+let pri s l = printString s; printString ": "; List.iter printInt l; printNewLine ()
+ let irev (l : int list) =
+ let res = ref [] in
+ let curr = ref l in
+ while (match curr.contents with [] -> false | _ -> true) do
+ match curr.contents with
+ (h::t) -> res.contents <- h :: !res; curr.contents <- t;
+ done;
+ !res
+let r = ref []
+let _ =
+ for i = 1 to 100 do
+ r := i :: r.contents;
+ for j = 1 to 100 do
+ let _ = irev r.contents in ()
+ done;
+ done
+let _ = pri "list: " r.contents
+*)
+
+
+(*
+let pri s l = printString s; printString ": "; List.iter printInt l; printNewLine ()
+type iiref= { mutable icontents: int list}
+let iiref x = { icontents = x }
+let (!!!!) r = r.icontents
+let (<--) r x = r.icontents <- x
+
+let irev l =
+ let res = iiref [] in
+ let curr = iiref l in
+ while (match !!!!curr with [] -> false | _ -> true) do
+ match !!!!curr with
+ (h::t) -> res <-- h :: !!!!res; curr <-- t;
+ done;
+ !!!!res
+
+let r = iiref []
+let test() =
+ for i = 1 to 600 do
+ r <-- i :: !!!!r;
+ for j = 1 to 600 do
+ let _ = irev !!!!r in ()
+ done;
+ done
+let _ = test()
+let _ = pri "list: " !!!!r
+*)
+
+
+(*
+type ilist = Nil | Cons of int * ilist
+let rec iiter f = function Nil -> () | Cons (h,t) -> (f h; iiter f t)
+let pri s l = printString s; printString ": "; iiter printInt l; printNewLine ()
+type iref= { mutable icontents: ilist}
+let iref x = { icontents = x }
+let (!!!!) r = r.icontents
+let (<--) r x = r.icontents <- x
+
+let irev l =
+ let res = iref Nil in
+ let curr = iref l in
+ while (match !!!!curr with Nil -> false | _ -> true) do
+ match !!!!curr with
+ Cons(h,t) -> res <-- Cons (h, !!!!res); curr <-- t;
+ done;
+ !!!!res
+
+let r = iref Nil
+let test() =
+ for i = 1 to 600 do
+ r <-- Cons (i,!!!!r);
+ for j = 1 to 600 do
+ let _ = irev !!!!r in ()
+ done;
+ done
+let _ = test()
+let _ = pri "list: " !!!!r
+*)
+
+(*
+type flist = Nil | Cons of float * flist
+let rec fiter f = function Nil -> () | Cons (h,t) -> (f h; fiter f t)
+let pri s l = printString s; printString ": "; fiter print_float l; printNewLine ()
+type fref= { mutable fcontents: flist}
+let fref x = { fcontents = x }
+let (!!!!) r = r.fcontents
+let (<--) r x = r.fcontents <- x
+
+let frev l =
+ let res = fref Nil in
+ let curr = fref l in
+ while (match !!!!curr with Nil -> false | _ -> true) do
+ match !!!!curr with
+ Cons(h,t) -> res <-- Cons (h, !!!!res); curr <-- t;
+ done;
+ !!!!res
+
+let r = fref Nil
+let test() =
+ for i = 1 to 600 do
+ r <-- Cons (float i,!!!!r);
+ for j = 1 to 600 do
+ let _ = frev !!!!r in ()
+ done;
+ done
+let _ = test()
+let _ = pri "list: " !!!!r
+*)
+
+
+(* let rec not_inlined b = if b then not_inlined false else b *)
+let not_inlined x = x
+let inlined (x1:int) (x2:int) (x3:int) (x4:int) (x5:int) =
+ let not_eliminated = not_inlined 1 in
+ let not_eliminated2 = not_inlined 2 in
+ not_eliminated
+let test2() =
+ let eliminated_to_value = inlined 1 1 1 1 1 in
+ let not_eliminated = not_inlined 2 in
+ eliminated_to_value
+
+let _ = test2()
+
+let ldexp22 (x:float) (n:int) = x * (2.0 ** float n)
+
+(*
+let rec fold_right2 : ('a -> 'b -> 'c -> 'c) -> 'a list -> 'b list -> 'c -> 'c
+let rec for_all : ('a -> bool) -> 'a list -> bool
+let rec exists : ('a -> bool) -> 'a list -> bool
+let rec for_all2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
+let rec exists2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
+let rec mem : 'a -> 'a list -> bool
+let rec memq : 'a -> 'a list -> bool
+let rec find : ('a -> bool) -> 'a list -> 'a
+let rec filter : ('a -> bool) -> 'a list -> 'a list
+let rec find_all : ('a -> bool) -> 'a list -> 'a list
+let rec partition : ('a -> bool) -> 'a list -> 'a list * 'a list
+let rec assoc : 'a -> ('a * 'b) list -> 'b
+let rec assq : 'a -> ('a * 'b) list -> 'b
+let rec mem_assoc : 'a -> ('a * 'b) list -> bool
+let rec mem_assq : 'a -> ('a * 'b) list -> bool
+let rec remove_assoc : 'a -> ('a * 'b) list -> ('a * 'b) list
+let rec remove_assq : 'a -> ('a * 'b) list -> ('a * 'b) list
+let rec split : ('a * 'b) list -> 'a list * 'b list
+let rec combine : 'a list -> 'b list -> ('a * 'b) list
+let rec sort : ('a -> 'a -> int) -> 'a list -> 'a list
+let rec stable_sort : ('a -> 'a -> int) -> 'a list -> 'a list
+*)
+
+let g x = match x with 2.0 -> 3.0
+
+let _ = g 2.0
+let _ = g (1.0 + 1.0)
+
+
+type u16 = U16 of int
+type i32 = I32 of int32
+type bytes = Bytes of string
+
+type assembly_name = string (* uses exact comparisons. TODO: ECMA Partition 2 is inconsistent about this. *)
+type module_name = string (* uses exact comparisons. TODO: ECMA Partition 2 is inconsistent about this. *)
+type locale = (* should use case-insensitive comparison *)
+ | Locale_bytes of bytes (* unicode *)
+ | Locale_string of string
+
+type assembly_ref =
+ { assemRefName: assembly_name;
+ assemRefHash: bytes option;
+ (* Note: only one of the following two are ever present. *)
+ assemRefPublicKeyToken: bytes option;
+ assemRefPublicKey: bytes option;
+ assemRefVersion: (i32 * i32 * i32 * i32) option;
+ assemRefLocale: locale option }
+
+type modul_ref =
+ { modulRefName: module_name;
+ modulRefNoMetadata: bool; (* only for file references *)
+ modulRefHash: bytes option; (* only for file references *)
+ }
+
+type scope_ref =
+ | ScopeRef of assembly_ref * modul_ref option
+
+(* TODO: check the array types that are relevant for binding etc. *)
+type array_bounds = ((i32 * i32 option) list) option
+type type_ref =
+ | TypeRef of (scope_ref * string list * string)
+ | TypeRef_array of array_bounds * bool
+
+type typ =
+ | Type_void (* -- Used only in return and pointer types. *)
+ | Type_value of type_spec (* -- Unboxed types, including built-in types. *)
+ | Type_boxed of type_spec (* -- Nb. used for both boxed value classes *)
+ (* and classes. *)
+ | Type_ptr of typ (* -- Unmanaged pointers. Nb. the type is *)
+ (* effectively for tools and for binding *)
+ (* only, not by the verifier. *)
+ | Type_byref of typ (* -- Managed pointers. *)
+ | Type_typedref
+ | Type_fptr of callsig (* -- Code pointers. *)
+ | Type_modified of (* -- Custom modifiers. *)
+ bool * (* -- True if modifier is "required" *)
+ typ * (* -- the class of the custom modifier *)
+ typ (* -- the type being modified *)
+
+(* MS-ILX *) | Type_unit (* -- empty value *)
+(* MS-ILX *) | Type_forall of genparam * typ (* -- indexed outside-in *)
+(* MS-ILX *) | Type_tyvar of u16 (* -- reference a generic arg *)
+(* MS-ILX *) | Type_tyrepvar of u16
+(* MS-ILX *) | Type_func of typ list * typ
+
+and type_spec = TypeSpec of type_ref (* MS-ILX *) * genactuals
+and callsig = Callsig of callconv * typ list * typ
+
+(* MS-ILX *) (* ----------------------------------------------------------
+(* MS-ILX *) * Generic parameters, i.e. parameters reified statically.
+(* MS-ILX *) * Currently only two kinds of parameters are supported in
+(* MS-ILX *) * the term structure: types and type representations.
+(* MS-ILX *) * Type representations are only used internally.
+(* MS-ILX *) * --------------------------------------------------------- *)
+(* MS-ILX *)
+(* MS-ILX *) and genparams = genparam list
+(* MS-ILX *) and genactuals = genactual list
+(* MS-ILX *) and genactual =
+(* MS-ILX *) | GenActual_type of typ
+(* MS-ILX *) | GenActual_tyrep of typ
+(* MS-ILX *) and genparam =
+(* MS-ILX *) | GenFormal_type
+(* MS-ILX *) | GenFormal_tyrep of exn
+(* MS-ILX *) (* For compiler use only. *)
+(* MS-ILX *) (* We use exn as an annotation here. *)
+(* MS-ILX *) (* Types are still used as actuals for type-reps *)
+
+
+(* --------------------------------------------------------------------
+!* Calling conventions. These are used in method pointer types.
+ * -------------------------------------------------------------------- *)
+
+and bcallconv =
+ | CC_cdecl
+ | CC_stdcall
+ | CC_thiscall
+ | CC_fastcall
+ | CC_default
+ | CC_vararg
+
+and hasthis =
+ | CC_instance
+ | CC_instance_explicit
+ | CC_static
+
+and callconv = Callconv of hasthis * bcallconv
+
+let mk_empty_gactuals = ([]: genactuals)
+let mk_mono_tspec tref = TypeSpec (tref, mk_empty_gactuals)
+let mscorlib_assembly_name = "mscorlib"
+let mscorlib_module_name = "CommonLanguageRuntimeLibrary"
+let mk_simple_assref n =
+ { assemRefName=n;
+ assemRefHash=None;
+ assemRefPublicKeyToken=None;
+ assemRefPublicKey=None;
+ assemRefVersion=None;
+ assemRefLocale=None; }
+let mscorlib_aref = mk_simple_assref mscorlib_assembly_name
+let mscorlib_scoref = ScopeRef(mscorlib_aref,None)
+let mk_nested_tref (scope,l,nm) = TypeRef (scope,l,nm)
+let mk_tref (scope,nm) = mk_nested_tref (scope,[],nm)
+
+let tname_Object1 = "System.Object"
+let tref_Object1 = mk_tref (mscorlib_scoref,tname_Object1)
+let tspec_Object1 = mk_mono_tspec tref_Object1
+let typ_Object1 = Type_boxed tspec_Object1
+
+let tname_Object2 = "System.Object"
+let tref_Object2 = mk_tref (mscorlib_scoref,tname_Object2)
+let tspec_Object2 = mk_mono_tspec tref_Object2
+let typ_Object2 = Type_boxed tspec_Object2
+
+
+
+let _ = printString "advanced equality test (1): "; if tname_Object1 = tname_Object2 then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "advanced equality test (9): "; if (mscorlib_scoref,[],tname_Object1) =(mscorlib_scoref,[],tname_Object2) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "advanced equality test (10): "; if tref_Object1 = tref_Object2 then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "advanced equality test (11): "; if typ_Object1 = typ_Object2 then stdout.WriteLine "YES" else reportFailure "basic test Q"
+
+
+let _ = printString "array equality test (1): "; if [| 1 |] = [| 1 |] then stdout.WriteLine "YES" else reportFailure "basic test Q"
+
+let _ = printString "arr equality test (4): "; if [| |] = [| |] then stdout.WriteLine "YES" else reportFailure "basic test Q"
+let _ = printString "arr hash-respects-equality test (4): "; if hash [| |] = hash [| |] then stdout.WriteLine "YES" else reportFailure "basic test Q"
+
+let _ = printString "array equality test (1): "; if [| 1 |] = [| 1 |] then stdout.WriteLine "YES" else reportFailure "basic test Q"
+
+
+
+(*
+let f x =
+ let g a b c d = (a=1) && (b = 2) && (c = 3) && (d = 4) && (x = 5) in
+ let bigcheck h (a:int) (b:int) (c:int) (d:int) =
+ h a b c d &&
+ h a b c d &&
+ (let f1 = h a in
+ let f2 = f1 b in
+ let f3 = f2 c in
+ f3 d) &&
+ (let f1 = h a b in
+ let f2 = f1 c in
+ f2 d) &&
+ (let f1 = h a b c in
+ f1 d) &&
+ (let f1 = h a in
+ let f2 = f1 b c in
+ f2 d) &&
+ (let f1 = h a in
+ let f2 = f1 b in
+ f2 c d) &&
+ (let f1 = h a b in
+ f1 c d) &&
+ (let f1 = h a in
+ f1 b c d) in
+ bigcheck g 1 2 3 4
+
+let _ = if (f 5) then stdout.WriteLine "YES" else reportFailure "basic test Q"
+
+
+let sort_test cmp ans =
+ for i0 = 0 to 5 do
+ for i1 = 0 to 5 do
+ for i2 = 0 to 5 do
+ for i3 = 0 to 5 do
+ for i4 = 0 to 5 do
+ for i5 = 0 to 5 do
+ if i0 <> i1 && i0 <> i2 && i0 <> i3 && i0 <> i4 && i0 <> i5 &
+ i1 <> i2 && i1 <> i3 && i1 <> i4 && i1 <> i5 &
+ i2 <> i3 && i2 <> i4 && i2 <> i5 &
+ i3 <> i4 && i3 <> i5 &
+ i4 <> i5 then
+ let a = Array.create 6 0 in
+ a.(i0) <- 0;
+ a.(i1) <- 1;
+ a.(i2) <- 2;
+ a.(i3) <- 3;
+ a.(i4) <- 4;
+ a.(i5) <- 5;
+ (* list sort *)
+ let l = Array.toList a in
+ let res = List.sortWith cmp l in
+ if (res<> ans) then begin
+ let printInt n = printString (string_of_int n) in
+ printString "List.sort ";
+ printInt a.(0);
+ printInt a.[1];
+ printInt a.[2];
+ printInt a.(3);
+ printInt a.(4);
+ printInt a.(5);
+ printString " = ";
+ let resa = Array.ofList res in
+ printInt resa.(i0);
+ printInt resa.(i1);
+ printInt resa.(i2);
+ printInt resa.(i3);
+ printInt resa.(i4);
+ printInt resa.(i5);
+ reportFailure "unlabelled test"
+ end;
+ (* array sort *)
+ let resa = Array.copy a in
+ Array.sortInPlaceWith cmp resa; (* mutates resa array *)
+ let res = Array.toList resa in
+ if (res<> ans) then begin
+ let printInt n = printString (string_of_int n) in
+ printString "Array.sort ";
+ printInt a.(0);
+ printInt a.[1];
+ printInt a.[2];
+ printInt a.(3);
+ printInt a.(4);
+ printInt a.(5);
+ printString " = ";
+ (* recall Array.list_of resa = res *)
+ printInt resa.(i0);
+ printInt resa.(i1);
+ printInt resa.(i2);
+ printInt resa.(i3);
+ printInt resa.(i4);
+ printInt resa.(i5);
+ reportFailure "unlabelled test"
+ end
+ done;
+ done;
+ done;
+ done;
+ done;
+ done
+
+let _ = sort_test compare [0;1;2;3;4;5]
+let _ = sort_test (fun x y -> -(compare x y)) [5;4;3;2;1;0]
+*)
+module StrangeOperatorTest =
+ let (&&&) x y = x^y
+ let (<<<) (x:string) (y:string) = x ^y^x
+
+ let e1 = ("0" &&& ("1" <<< "2"))
+ let e2= (("0" &&& "1") <<< "2")
+ let e3= ("0" &&& "1" <<< "2")
+
+ let _ = if (e1 <> e2) then stderr.WriteLine "Control Passed" else stderr.WriteLine "Control Failed"
+ let _ = if (e1 = e3) then (stderr.WriteLine "Parsed to Right! Wrong!" ; reportFailure "parsing")
+ let _ = if (e2 = e3) then stderr.WriteLine "Parsed to Left - correct!"
+
+
+
+//let _ = if (3 then do ignore(4)) = 3 then stderr.WriteLine "OK!" else (stderr.WriteLine "Wrong!" ; reportFailure "unlabelled test")
+//let _ = let x = ref 1 in if (!x then do x := !x + 1) = 1 then stderr.WriteLine "OK!" else (stderr.WriteLine "Wrong!" ; reportFailure "unlabelled test")
+
+
+(* Check codegen for using functions of type (unit -> _) as first class values. *)
+let _ = List.map printNewLine [(); (); ()]
+
+(* Check codegen for tail recursive functions with argument and return types involving "unit" *)
+let rec unitElimTailRecursion1() = stdout.WriteLine "loop"; (unitElimTailRecursion1() : string)
+let rec unitElimTailRecursion2((),()) = stdout.WriteLine "loop"; (unitElimTailRecursion2((),()) : string)
+let rec unitElimTailRecursion3() = stdout.WriteLine "loop"; (unitElimTailRecursion3() : unit)
+let rec unitElimTailRecursion4((),()) = stdout.WriteLine "loop"; (unitElimTailRecursion4((),()) : unit)
+let rec unitElimTailRecursion5() = stdout.WriteLine "loop"; (unitElimTailRecursion5() : 'a)
+let rec unitElimTailRecursion6((),()) = stdout.WriteLine "loop"; (unitElimTailRecursion6((),()) : 'a)
+
+(* Check codegen for inner tail recursive functions with argument and return types involving "unit". *)
+let innerUnitElimTailRecursion1 () =
+ let rec unitElimTailRecursion1() = stdout.WriteLine "loop"; (unitElimTailRecursion1() : string) in
+ let rec unitElimTailRecursion2((),()) = stdout.WriteLine "loop"; (unitElimTailRecursion2((),()) : string) in
+ let rec unitElimTailRecursion3() = stdout.WriteLine "loop"; (unitElimTailRecursion3() : unit) in
+ let rec unitElimTailRecursion4((),()) = stdout.WriteLine "loop"; (unitElimTailRecursion4((),()) : unit) in
+ let rec unitElimTailRecursion5() = stdout.WriteLine "loop"; (unitElimTailRecursion5() : 'a) in
+ let rec unitElimTailRecursion6((),()) = stdout.WriteLine "loop"; (unitElimTailRecursion6((),()) : 'a) in
+ (unitElimTailRecursion1, unitElimTailRecursion2, unitElimTailRecursion3, unitElimTailRecursion4, unitElimTailRecursion5, unitElimTailRecursion6)
+
+(* Check codegen for tail recursive functions with argument types involving " int * int" *)
+let rec tupleElimTailRecursion1((x:int), (y:int)) = stdout.WriteLine "loop"; (tupleElimTailRecursion1(x,y) : string)
+let rec tupleElimTailRecursion2((x1:int), (y1:int)) ((x2:int), (y2:int)) = stdout.WriteLine "loop"; (tupleElimTailRecursion2(x2,y2) (x1,y1) : string)
+
+let innerTupleElimTailRecursion1 () =
+ let rec tupleElimTailRecursion1((x:int), (y:int)) = stdout.WriteLine "loop"; (tupleElimTailRecursion1(x,y) : string) in
+ let rec tupleElimTailRecursion2((x1:int), (y1:int)) ((x2:int), (y2:int)) = stdout.WriteLine "loop"; (tupleElimTailRecursion2(x2,y2) (x1,y1) : string) in
+ tupleElimTailRecursion1, tupleElimTailRecursion2
+
+let test3d9cw90 () =
+ let set = (Set.add 1 (Set.add 0 (Set.add 1 (Set.add 5 (Set.add 4 (Set.add 3 Set.empty)))))) in
+ let i = (set :> seq<_>).GetEnumerator() in
+ check "set iterator" true (i.MoveNext());
+ check "set iterator" 0 i.Current;
+ check "set iterator" true (i.MoveNext());
+ check "set iterator" 1 i.Current;
+ check "set iterator" true (i.MoveNext());
+ check "set iterator" 3 i.Current;
+ check "set iterator" true (i.MoveNext());
+ check "set iterator" 4 i.Current;
+ check "set iterator" true (i.MoveNext());
+ check "set iterator" 5 i.Current;
+ check "set iterator" false (i.MoveNext())
+
+do test3d9cw90 ()
+
+do check "set comparison" 0 ((Seq.compareWith Operators.compare) Set.empty Set.empty)
+do check "set comparison" 0 ((Seq.compareWith Operators.compare) (Set.add 1 Set.empty) (Set.add 1 Set.empty))
+do check "set comparison" 0 ((Seq.compareWith Operators.compare) (Set.add 1 (Set.add 2 Set.empty)) (Set.add 2 (Set.add 1 Set.empty)))
+do check "set comparison" 0 ((Seq.compareWith Operators.compare) (Set.add 1 (Set.add 2 (Set.add 3 Set.empty))) (Set.add 3 (Set.add 2 (Set.add 1 Set.empty))))
+
+
+do check "set comparison" (-1) ((Seq.compareWith Operators.compare) Set.empty (Set.add 1 Set.empty))
+do check "set comparison" (-1) ((Seq.compareWith Operators.compare) (Set.add 1 Set.empty) (Set.add 2 Set.empty))
+do check "set comparison" (-1) ((Seq.compareWith Operators.compare) (Set.add 1 (Set.add 2 Set.empty)) (Set.add 3 (Set.add 1 Set.empty)))
+do check "set comparison" (-1) ((Seq.compareWith Operators.compare) (Set.add 1 (Set.add 2 (Set.add 3 Set.empty))) (Set.add 4 (Set.add 2 (Set.add 1 Set.empty))))
+
+let checkReflexive f x y = (f x y = - f y x)
+
+do check "set comparison" true (checkReflexive (Seq.compareWith Operators.compare) Set.empty (Set.add 1 Set.empty))
+do check "set comparison" true (checkReflexive (Seq.compareWith Operators.compare) (Set.add 1 Set.empty) (Set.add 2 Set.empty))
+do check "set comparison" true (checkReflexive (Seq.compareWith Operators.compare) (Set.add 1 (Set.add 2 Set.empty)) (Set.add 3 (Set.add 1 Set.empty)))
+do check "set comparison" true (checkReflexive (Seq.compareWith Operators.compare) (Set.add 1 (Set.add 2 (Set.add 3 Set.empty))) (Set.add 4 (Set.add 2 (Set.add 1 Set.empty))))
+
+
+
+
+(*================================================================================*)
+
+(* Set ordering - tests *)
+
+let rec nlist i n =
+ if n=0 then [] else
+ if n % 2 = 1 then i :: nlist (i+1) (n / 2)
+ else nlist (i+1) (n / 2)
+
+let orderTest n m =
+ //printf "Check sorted-list order against ordered-set order: n=%-10d m=%-10d\n" n m;
+ let nL = nlist 0 n in
+ let nS = Set.ofList nL in
+ let mL = nlist 0 m in
+ let mS = Set.ofList mL in
+ test "vwnwer" (compare nL mL = Seq.compareWith Operators.compare nS mS)
+
+let nMax = 4096 * 4096
+let ran = new System.Random()
+let testOrder() = orderTest (ran.Next(nMax)) (ran.Next(nMax))
+do for i = 1 to 1000 do testOrder() done
+
+(*================================================================================*)
+
+
+
+
+(*
+let test2398985() =
+ let l = ReadonlyArray.ofList [1;2;3] in
+ let res = ref 2 in
+ for i in ReadonlyArray.toSeq l do res.Value <- res.Value + i done;
+ check "test2398985: ReadonlyArray.toSeq" 8 !res
+
+do test2398985()
+*)
+
+let test2398986() =
+ let l = Array.ofList [1;2;3] in
+ let mutable res = 2 in
+ for i in Array.toSeq l do res <- res + i done;
+ check "test2398986: Array.toSeq" 8 res
+
+do test2398986()
+
+let test2398987() =
+ let l = Set.ofList [1;2;3] in
+ let res = ref 2 in
+ for i in Set.toSeq l do res.Value <- res.Value + i done;
+ check "test2398987: Idioms.foreach, Set.toSeq" 8 !res
+
+do test2398987()
+
+let test2398987b() =
+ let l = Set.ofList [1;2;3] in
+ let res = ref 2 in
+ for i in l do res.Value <- res.Value + i done;
+ check "test2398987: Idioms.foreach, Set.toSeq" 8 !res
+
+do test2398987b()
+
+
+(*---------------------------------------------------------------------------
+!* foreachG/to_seq
+ *--------------------------------------------------------------------------- *)
+
+
+
+let foreach e f = Seq.iter f e
+let test2398993() =
+ let l = [1;2;3] in
+ let res = ref 2 in
+ foreach (List.toSeq l) (fun i -> res.Value <- res.Value + i);
+ check "test2398993: foreach, List.toSeq" 8 !res
+
+do test2398993()
+
+(*
+let test2398995() =
+ let l = ReadonlyArray.ofList [1;2;3] in
+ let res = ref 2 in
+ foreach (ReadonlyArray.toSeq l) (fun i -> res.Value <- res.Value + i);
+ check "test2398995: foreach, ReadonlyArray.toSeq" 8 !res
+
+do test2398995()
+*)
+
+let test2398996() =
+ let l = Array.ofList [1;2;3] in
+ let res = ref 2 in
+ foreach (Array.toSeq l) (fun i -> res.Value <- res.Value + i);
+ check "test2398996: foreach, Array.toSeq" 8 !res
+
+do test2398996()
+
+let test2398997() =
+ let l = Set.ofList [1;2;3] in
+ let res = ref 2 in
+ foreach (Set.toSeq l) (fun i -> res.Value <- res.Value + i);
+ check "test2398997: foreach, Set.toSeq" 8 !res
+
+do test2398997()
+
+
+(*---------------------------------------------------------------------------
+!* Generic formatting
+ *--------------------------------------------------------------------------- *)
+
+
+do check "generic format 1" "[1; 2]" (sprintf "%A" [1;2])
+do check "generic format 2" "Some [1; 2]" (sprintf "%A" (Some [1;2]))
+do check "generic format a" "1y" (sprintf "%A" 1y)
+do check "generic format b" "1uy" (sprintf "%A" 1uy)
+do check "generic format c" "1s" (sprintf "%A" 1s)
+do check "generic format d" "1us" (sprintf "%A" 1us)
+do check "generic format e" "1" (sprintf "%A" 1)
+do check "generic format f" "1u" (sprintf "%A" 1ul)
+do check "generic format g" "1L" (sprintf "%A" 1L)
+do check "generic format j" "1.0" (sprintf "%A" 1.0)
+do check "generic format k" "1.01" (sprintf "%A" 1.01)
+do check "generic format l" "1000.0" (sprintf "%A" 1000.0)
+
+do check "generic format m" "-1y" (sprintf "%A" (-1y))
+do check "generic format n" "-1s" (sprintf "%A" (-1s))
+do check "generic format o" "-1" (sprintf "%A" (-1))
+do check "generic format p" "-1L" (sprintf "%A" (-1L))
+#if !NETCOREAPP
+// See FSHARP1.0:4797
+// On NetFx4.0 and above we do not emit the 'I' suffix
+let bigintsuffix = if (System.Environment.Version.Major, System.Environment.Version.Minor) > (2,0) then "" else "I"
+do check "generic format i" ("1" + bigintsuffix) ( printf "%A" 1I
+ sprintf "%A" 1I)
+do check "generic format r" ("-1" + bigintsuffix) (sprintf "%A" (-1I))
+#endif
+
+
+(*---------------------------------------------------------------------------
+!* For loop variables can escape
+ *--------------------------------------------------------------------------- *)
+
+do for i = 1 to 10 do List.iter (fun x -> Printf.printf "x = %d\n" x) (List.map (fun x -> x + i) [1;2;3]) done
+
+
+(*---------------------------------------------------------------------------
+!* Type tests
+ *--------------------------------------------------------------------------- *)
+
+do check "type test string" "right" (match box("right") with | :? System.String as s -> s | _ -> "wrong")
+do check "type test string (2)" "right" (match box("right") with| :? System.Int32 -> "wrong" | :? System.String as s -> s | _ -> "wrong")
+do check "type test int32" "right" (match box(1) with | :? System.String -> "wrong" | :? System.Int32 -> "right" | _ -> "wrong")
+do check "type test int32 (2)" "right" (match box(1) with | :? System.Int32 -> "right" | :? System.String -> "wrong" | _ -> "wrong")
+do check "type test int32 (3)" 4 (match box(4) with | :? System.Int32 as d -> d | :? System.String -> 3 | _ -> 2)
+do check "type test double" 1.0 (match box(1.0) with | :? System.Int32 -> 3.14 | :? System.Double as d -> d | _ -> 2.71)
+
+
+
+(*---------------------------------------------------------------------------
+!* type syntax
+ *--------------------------------------------------------------------------- *)
+
+module TypeSyntax =
+ let x1 = [Map.add 1 (Map.add 1 1 Map.empty) Map.empty]
+ let x2 : Map<'a,'b> list = [Map.empty]
+ let x3 : Map<'a,'b> list = []
+
+
+module IEnumerableTests = begin
+
+ // This one gave a stack overflow when we weren't tail-calling on 64-bit
+ do check "Seq.filter-length" ({ 1 .. 1000000 } |> Seq.filter (fun n -> n <> 1) |> Seq.length) 999999
+ do check "Seq.filter-length" ({ 1 .. 1000000 } |> Seq.filter (fun n -> n = 1) |> Seq.length) 1
+ do check "Seq.filter-length" ({ 1 .. 1000000 } |> Seq.filter (fun n -> n % 2 = 0) |> Seq.length) 500000
+
+ do check "IEnumerableTest.empty-length" (Seq.length Seq.empty) 0
+ do check "IEnumerableTest.length-of-array" (Seq.length [| 1;2;3 |]) 3
+ do check "IEnumerableTest.head-of-array" (Seq.head [| 1;2;3 |]) 1
+ do check "IEnumerableTest.take-0-of-array" (Seq.take 0 [| 1;2;3 |] |> Seq.toList) []
+ do check "IEnumerableTest.take-1-of-array" (Seq.take 1 [| 1;2;3 |] |> Seq.toList) [1]
+ do check "IEnumerableTest.take-3-of-array" (Seq.take 3 [| 1;2;3 |] |> Seq.toList) [1;2;3]
+ do check "IEnumerableTest.nonempty-true" (Seq.isEmpty [| 1;2;3 |]) false
+ do check "IEnumerableTest.nonempty-false" (Seq.isEmpty [| |]) true
+ do check "IEnumerableTest.fold" (Seq.fold (+) 0 [| 1;2;3 |] ) 6
+ do check "IEnumerableTest.unfold" (Seq.unfold (fun _ -> None) 1 |> Seq.toArray) [| |]
+ do check "IEnumerableTest.unfold" (Seq.unfold (fun x -> if x = 1 then Some("a",2) else None) 1 |> Seq.toArray) [| "a" |]
+ do check "IEnumerableTest.exists" (Seq.exists ((=) "a") [| |]) false
+ do check "IEnumerableTest.exists" (Seq.exists ((=) "a") [| "a" |]) true
+ do check "IEnumerableTest.exists" (Seq.exists ((=) "a") [| "1"; "a" |]) true
+ do check "IEnumerableTest.exists" (Seq.forall ((=) "a") [| |]) true
+ do check "IEnumerableTest.exists" (Seq.forall ((=) "a") [| "a" |]) true
+ do check "IEnumerableTest.exists" (Seq.forall ((=) "a") [| "1"; "a" |]) false
+ do check "IEnumerableTest.map on finite" ([| "a" |] |> Seq.map (fun x -> x.Length) |> Seq.toArray) [| 1 |]
+ do check "IEnumerableTest.filter on finite" ([| "a";"ab";"a" |] |> Seq.filter (fun x -> x.Length = 1) |> Seq.toArray) [| "a";"a" |]
+ do check "IEnumerableTest.choose on finite" ([| "a";"ab";"a" |] |> Seq.choose (fun x -> if x.Length = 1 then Some(x^"a") else None) |> Seq.toArray) [| "aa";"aa" |]
+ do check "Seq.tryPick on finite (succeeding)" ([| "a";"ab";"a" |] |> Seq.tryPick (fun x -> if x.Length = 1 then Some(x^"a") else None)) (Some "aa")
+ do check "Seq.tryPick on finite (failing)" ([| "a";"ab";"a" |] |> Seq.tryPick (fun x -> if x.Length = 6 then Some(x^"a") else None)) None
+ do check "IEnumerableTest.find on finite (succeeding)" ([| "a";"ab";"a" |] |> Seq.find (fun x -> x.Length = 1)) "a"
+ do check "IEnumerableTest.find on finite (failing)" (try Some ([| "a";"ab";"a" |] |> Seq.find (fun x -> x.Length = 6)) with :? System.Collections.Generic.KeyNotFoundException -> None) None
+ do check "IEnumerableTest.map_with_type (string up to obj,finite)" ([| "a" |] |> Seq.cast |> Seq.toArray) [| ("a" :> obj) |]
+ do check "IEnumerableTest.map_with_type (obj down to string, finite)" ([| ("a" :> obj) |] |> Seq.cast |> Seq.toArray) [| "a" |]
+ do check "IEnumerableTest.append, finite, finite" (Seq.append [| "a" |] [| "b" |] |> Seq.toArray) [| "a"; "b" |]
+ do check "IEnumerableTest.concat, finite" (Seq.concat [| [| "a" |]; [| |]; [| "b";"c" |] |] |> Seq.toList) [ "a";"b";"c" ]
+ do check "IEnumerableTest.init_infinite, then take" (Seq.take 2 (Seq.initInfinite (fun i -> i+1)) |> Seq.toList) [ 1;2 ]
+ do check "IEnumerableTest.to_array, empty" (Seq.init 0 (fun i -> i+1) |> Seq.toArray) [| |]
+ do check "IEnumerableTest.to_array, small" (Seq.init 1 (fun i -> i+1) |> Seq.toArray) [| 1 |]
+ do check "IEnumerableTest.to_array, large" (Seq.init 100000 (fun i -> i+1) |> Seq.toArray |> Array.length) 100000
+ do check "IEnumerableTest.to_array, very large" (Seq.init 1000000 (fun i -> i+1) |> Seq.toArray |> Array.length) 1000000
+ do check "IEnumerableTest.to_list, empty" (Seq.init 0 (fun i -> i+1) |> Seq.toList) [ ]
+ do check "IEnumerableTest.to_list, small" (Seq.init 1 (fun i -> i+1) |> Seq.toList) [ 1 ]
+ do check "IEnumerableTest.to_list, large" (Seq.init 100000 (fun i -> i+1) |> Seq.toList |> List.length) 100000
+ do check "IEnumerableTest.to_list, large" (Seq.init 1000000 (fun i -> i+1) |> Seq.toList |> List.length) 1000000
+ do check "IEnumerableTest.to_list, large" (Seq.init 1000000 (fun i -> i+1) |> List.ofSeq |> List.length) 1000000
+ do check "List.unzip, large" (Seq.init 1000000 (fun i -> (i,i+1)) |> List.ofSeq |> List.unzip |> fst |> List.length) 1000000
+ let dup x = x,x
+ let uncurry f (x,y) = f x y
+ do check "List.zip, large" (Seq.init 1000000 (fun i -> (i,i+1)) |> List.ofSeq |> dup |> uncurry List.zip |> List.length) 1000000
+
+(*
+ // Currently disabled, since IStructuralEquatable.Equals will cause this to stack overflow around 140000 elements
+ do check "List.sort, large" ((Seq.init 140000 (fun i -> 139999 - i) |> List.ofSeq |> List.sort) =
+ (Seq.init 140000 (fun i -> i) |> List.ofSeq |> List.sort)) true
+*)
+
+
+ do check "Seq.singleton" (Seq.singleton 42 |> Seq.length) 1
+ do check "Seq.singleton" (Seq.singleton 42 |> Seq.toList) [42]
+
+ do check "Seq.truncate" (Seq.truncate 20 [1..100] |> Seq.toList) [1..20]
+ do check "Seq.truncate" (Seq.truncate 1 [1..100] |> Seq.toList) [1]
+ do check "Seq.truncate" (Seq.truncate 0 [1..100] |> Seq.toList) []
+
+ do check "Seq.scan" (Seq.scan (+) 0 [|1..5|] |> Seq.toArray) [|0; 1; 3; 6; 10; 15|]
+ //do check "Seq.scan1" (Seq.scan1 (+) [|1..5|] |> Seq.toArray) [|3; 6; 10; 15|]
+
+ do check "Seq.exists2" (Seq.exists2 (=) [|1; 2; 3; 4; 5; 6|] [|2; 3; 4; 5; 6; 6|]) true
+ do check "Seq.exists2" (Seq.exists2 (=) [|1; 2; 3; 4; 5; 6|] [|2; 3; 4; 5; 6; 7|]) false
+
+ do check "Seq.forall2" (Seq.forall2 (=) [|1..10|] [|1..10|]) true
+ do check "Seq.forall2" (Seq.forall2 (=) [|1;2;3;4;5|] [|1;2;3;0;5|]) false
+
+
+// do check "Seq.find_index" (Seq.find_index (fun i -> i >= 4) [|0..10|]) 4
+// do check "Seq.find_index" (try Seq.find_index (fun i -> i >= 20) [|0..10|] |> ignore; false
+// with _ -> true) true
+
+// do check "Seq.find_indexi" (Seq.find_indexi (=) [|1; 2; 3; 3; 2; 1|]) 3
+// do check "Seq.find_indexi" (try Seq.find_indexi (=) [|1..10|] |> ignore; false
+// with _ -> true) true
+
+ do check "Seq.tryFind" ([|1..100|] |> Seq.tryFind (fun x -> x > 50)) (Some 51)
+ do check "Seq.tryFind" ([|1..100|] |> Seq.tryFind (fun x -> x > 180)) None
+
+// do check "Seq.tryfind_index" (Seq.tryfind_index (fun x -> x = 4) [|0..10|]) (Some 4)
+// do check "Seq.tryfind_index" (Seq.tryfind_index (fun x -> x = 42) [|0..10|]) None
+
+// do check "Seq.tryfind_indexi" (Seq.tryfind_indexi (=) [|1;2;3;4;4;3;2;1|]) (Some 4)
+// do check "Seq.tryfind_indexi" (Seq.tryfind_indexi (=) [|1..10|]) None
+
+ do check "Seq.compareWith" (Seq.compareWith compare [1;2] [2;1]) -1
+ do check "Seq.compareWith" (Seq.compareWith compare [2;1] [1;2]) 1
+ do check "Seq.compareWith" (Seq.compareWith compare [1;2] [1;2]) 0
+ do check "Seq.compareWith" (Seq.compareWith compare [] [1;2]) -1
+
+ do check "Seq.ofList" (Seq.toList (Seq.ofList [1..20])) [1..20]
+
+ do check "Seq.cast" (Seq.cast [1..10] |> Seq.toList) [1..10]
+ do check "Seq.collect" (Seq.collect (fun i -> [i*10 .. i*10+9]) [0..9] |> Seq.toList) [0..99]
+
+ let c = ref -1
+ do Seq.iter2 (fun x y -> incr c; test "Seq.iter2" (c.Value = x && c.Value = y)) [0..10] [0..10]
+ do check "Seq.iter2" c.Value 10
+
+ do check "Seq.zip"
+ (Seq.zip [1..10] [2..11] |> Seq.toList) [for i in 1..10 -> i, i+1]
+
+
+ do check "Seq.zip3"
+ (Seq.zip3 [1..10] [2..11] [3..12] |> Seq.toList) [for i in 1..10 -> i, i+1, i+2]
+
+ do c.Value <- -1
+ do Seq.iteri (fun n x -> incr c; test "Seq.iter2" (c.Value = n && c.Value+1 = x)) [1..11]
+ do check "Seq.iter2" c.Value 10
+
+ do check "Seq.pairwise" (Seq.pairwise [1..20] |> Seq.toList) [for i in 1 .. 19 -> i, i+1]
+
+ do check "Seq.windowed 1" (Seq.windowed 1 [1..20] |> Seq.toList) [for i in 1 .. 20 -> [|i|]]
+ do check "Seq.windowed 2" (Seq.windowed 2 [1..20] |> Seq.toList) [for i in 1 .. 19 -> [|i; i+1|]]
+ do check "Seq.windowed 3" (Seq.windowed 3 [1..20] |> Seq.toList) [for i in 1 .. 18 -> [|i; i+1; i+2|]]
+ do check "Seq.windowed 4" (Seq.windowed 4 [1..20] |> Seq.toList) [for i in 1 .. 17 -> [|i; i+1; i+2; i+3|]]
+
+ let group = Seq.groupBy (fun x -> x % 5) [1..100]
+ do for n, s in group do
+ check "Seq.groupBy" (Seq.forall (fun x -> x % 5 = n) s) true
+ done
+ do check "Seq.groupBy" ([for n,_ in group -> n] |> List.sort) [0..4]
+
+ let sorted = Seq.sortBy abs [2; 4; 3; -5; 2; -4; -8; 0; 5; 2]
+ do check "Seq.sortBy" (Seq.pairwise sorted |> Seq.forall (fun (x, y) -> abs x <= abs y)) true
+
+ let counts = Seq.countBy id [for i in 1..10 do yield! [10..-1..i] done]
+ do check "Seq.countBy" (counts |> Seq.toList) [for i in 10..-1..1 -> i, i]
+
+ do check "Seq.sum" (Seq.sum [1..100]) (100*101/2)
+ do check "Seq.sumBy" (Seq.sumBy float [1..100]) (100.*101./2.)
+
+ do check "Seq.average" (Seq.average [1.; 2.; 3.]) 2.
+ do check "Seq.averageBy" (Seq.averageBy float [0..100]) 50.
+ do check "Seq.min" (Seq.min [1; 4; 2; 5; 8; 4; 0; 3]) 0
+ do check "Seq.max" (Seq.max [1; 4; 2; 5; 8; 4; 0; 3]) 8
+ do check "Seq.minBy" (Seq.minBy int "this is a test") ' '
+ do check "Seq.maxBy" (Seq.maxBy int "this is a test") 't'
+
+ // Test where the key includes null values
+ do check "dict - option key" (dict [ (None,10); (Some 3, 220) ]).[None] 10
+ do check "dict - option key" (dict [ (None,10); (Some 3, 220) ]).[Some 3] 220
+ do check "dict - option key" (([ (None,10); (Some 3, 220) ] |> Seq.groupBy fst) |> Seq.length) 2
+ do check "dict - option key" (([ (None,10); (Some 3, 220); (None,10); (Some 3, 220) ] |> Seq.distinct ) |> Seq.length) 2
+ do check "dict - option key" (([ (None,10); (Some 3, 220); (None,10); (Some 4, 220) ] |> Seq.distinctBy fst) |> Seq.length) 3
+ do check "dict - option key" (([ (None,10); (Some 3, 220); (None,10); (Some 4, 220) ] |> Seq.countBy fst) |> Seq.length) 3
+
+ // Test where the key includes null values
+ do check "dict - option key" (dict [ ([| |],10); ([| 3 |], 220) ]).[[| |]] 10
+ do check "dict - option key" (dict [ ([| |],10); ([| 3 |], 220) ]).[[| 3 |]] 220
+ do check "dict - option key" (([ ([| |],10); ([| 3 |], 220) ] |> Seq.groupBy fst) |> Seq.length) 2
+ do check "dict - option key" (([ ([| |],10); ([| 3 |], 220); ([| |],10); ([| 3 |], 220) ] |> Seq.distinct ) |> Seq.length) 2
+ do check "dict - option key" (([ ([| |],10); ([| 3 |], 220); ([| |],10); ([| 4 |], 220) ] |> Seq.distinctBy fst) |> Seq.length) 3
+ do check "dict - option key" (([ ([| |],10); ([| 3 |], 220); ([| |],10); ([| 4 |], 220) ] |> Seq.countBy fst) |> Seq.length) 3
+
+end
+
+module SeqTestsOnEnumerableEnforcingDisposalAtEnd = begin
+
+ let mutable numActiveEnumerators = 0
+
+ let countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd (seq: seq<'a>) =
+ let enumerator() =
+ numActiveEnumerators <- numActiveEnumerators + 1;
+ let disposed = ref false in
+ let endReached = ref false in
+ let ie = seq.GetEnumerator() in
+ { new System.Collections.Generic.IEnumerator<'a> with
+ member x.Current =
+ test "rvlrve0" (not !endReached);
+ test "rvlrve1" (not !disposed);
+ ie.Current
+ member x.Dispose() =
+ test "rvlrve2" !endReached;
+ test "rvlrve4" (not !disposed);
+ numActiveEnumerators <- numActiveEnumerators - 1;
+ disposed.Value <- true;
+ ie.Dispose()
+ interface System.Collections.IEnumerator with
+ member x.MoveNext() =
+ test "rvlrve0" (not !endReached);
+ test "rvlrve3" (not !disposed);
+ endReached.Value <- not (ie.MoveNext());
+ not !endReached
+ member x.Current =
+ test "qrvlrve0" (not !endReached);
+ test "qrvlrve1" (not !disposed);
+ box ie.Current
+ member x.Reset() =
+ ie.Reset()
+ } in
+
+ { new seq<'a> with
+ member x.GetEnumerator() = enumerator()
+ interface System.Collections.IEnumerable with
+ member x.GetEnumerator() = (enumerator() :> _) }
+
+ let countEnumeratorsAndCheckedDisposedAtMostOnce (seq: seq<'a>) =
+ let enumerator() =
+ let disposed = ref false in
+ let endReached = ref false in
+ let ie = seq.GetEnumerator() in
+ numActiveEnumerators <- numActiveEnumerators + 1;
+ { new System.Collections.Generic.IEnumerator<'a> with
+ member x.Current =
+ test "qrvlrve0" (not !endReached);
+ test "qrvlrve1" (not !disposed);
+ ie.Current
+ member x.Dispose() =
+ test "qrvlrve4" (not !disposed);
+ numActiveEnumerators <- numActiveEnumerators - 1;
+ disposed.Value <- true;
+ ie.Dispose()
+ interface System.Collections.IEnumerator with
+ member x.MoveNext() =
+ test "qrvlrve0" (not !endReached);
+ test "qrvlrve3" (not !disposed);
+ endReached.Value <- not (ie.MoveNext());
+ not !endReached
+ member x.Current =
+ test "qrvlrve0" (not !endReached);
+ test "qrvlrve1" (not !disposed);
+ box ie.Current
+ member x.Reset() =
+ ie.Reset()
+ } in
+
+ { new seq<'a> with
+ member x.GetEnumerator() = enumerator()
+ interface System.Collections.IEnumerable with
+ member x.GetEnumerator() = (enumerator() :> _) }
+
+ // This one gave a stack overflow when we weren't tail-calling on 64-bit
+ do check "Seq.filter-length" ({ 1 .. 1000000 } |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> Seq.filter (fun n -> n <> 1) |> Seq.length) 999999
+ do check "" numActiveEnumerators 0
+ do check "Seq.filter-length" ({ 1 .. 1000000 } |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> Seq.filter (fun n -> n = 1) |> Seq.length) 1
+ do check "" numActiveEnumerators 0
+ do check "Seq.filter-length" ({ 1 .. 1000000 } |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> Seq.filter (fun n -> n % 2 = 0) |> Seq.length) 500000
+ do check "" numActiveEnumerators 0
+
+ do check "IEnumerableTest.empty-length" (Seq.length (countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd Seq.empty)) 0
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.length-of-array" (Seq.length (countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd [| 1;2;3 |])) 3
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.head-of-array" (Seq.head (countEnumeratorsAndCheckedDisposedAtMostOnce [| 1;2;3 |])) 1
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.take-0-of-array" (Seq.take 0 (countEnumeratorsAndCheckedDisposedAtMostOnce [| 1;2;3 |]) |> Seq.toList) []
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.take-1-of-array" (Seq.take 1 (countEnumeratorsAndCheckedDisposedAtMostOnce [| 1;2;3 |]) |> Seq.toList) [1]
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.take-3-of-array" (Seq.take 3 (countEnumeratorsAndCheckedDisposedAtMostOnce [| 1;2;3 |]) |> Seq.toList) [1;2;3]
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.nonempty-true" (Seq.isEmpty (countEnumeratorsAndCheckedDisposedAtMostOnce [| 1;2;3 |])) false
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.nonempty-false" (Seq.isEmpty (countEnumeratorsAndCheckedDisposedAtMostOnce [| |])) true
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.fold" (Seq.fold (+) 0 (countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd [| 1;2;3 |]) ) 6
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.unfold" (Seq.unfold (fun _ -> None) 1 |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> Seq.toArray) [| |]
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.unfold" (Seq.unfold (fun x -> if x = 1 then Some("a",2) else None) 1 |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> Seq.toArray) [| "a" |]
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.exists" (Seq.exists ((=) "a") (countEnumeratorsAndCheckedDisposedAtMostOnce [| |])) false
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.exists" (Seq.exists ((=) "a") (countEnumeratorsAndCheckedDisposedAtMostOnce [| "a" |])) true
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.exists" (Seq.exists ((=) "a") (countEnumeratorsAndCheckedDisposedAtMostOnce [| "1"; "a" |])) true
+ do check "" numActiveEnumerators 0
+
+
+ do check "IEnumerableTest.exists" (Seq.forall ((=) "a") (countEnumeratorsAndCheckedDisposedAtMostOnce [| |])) true
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.exists" (Seq.forall ((=) "a") (countEnumeratorsAndCheckedDisposedAtMostOnce [| "a" |])) true
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.exists" (Seq.forall ((=) "a") (countEnumeratorsAndCheckedDisposedAtMostOnce [| "1"; "a" |])) false
+ do check "" numActiveEnumerators 0
+
+ do check "IEnumerableTest.map on finite" ([| "a" |] |> Seq.map (fun x -> x.Length) |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> Seq.toArray) [| 1 |]
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.filter on finite" ([| "a";"ab";"a" |] |> Seq.filter (fun x -> x.Length = 1) |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> Seq.toArray) [| "a";"a" |]
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.choose on finite" ([| "a";"ab";"a" |] |> Seq.choose (fun x -> if x.Length = 1 then Some(x^"a") else None) |> Seq.toArray) [| "aa";"aa" |]
+ do check "" numActiveEnumerators 0
+ do check "Seq.pick on finite (succeeding)" ([| "a";"ab";"a" |] |> countEnumeratorsAndCheckedDisposedAtMostOnce |> Seq.pick (fun x -> if x.Length = 1 then Some(x^"a") else None)) "aa"
+ do check "" numActiveEnumerators 0
+ do check "Seq.tryPick on finite (succeeding)" ([| "a";"ab";"a" |] |> countEnumeratorsAndCheckedDisposedAtMostOnce |> Seq.tryPick (fun x -> if x.Length = 1 then Some(x^"a") else None)) (Some "aa")
+ do check "" numActiveEnumerators 0
+ do check "Seq.tryPick on finite (failing)" ([| "a";"ab";"a" |] |> countEnumeratorsAndCheckedDisposedAtMostOnce |> Seq.tryPick (fun x -> if x.Length = 6 then Some(x^"a") else None)) None
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.find on finite (succeeding)" ([| "a";"ab";"a" |] |> countEnumeratorsAndCheckedDisposedAtMostOnce |> Seq.find (fun x -> x.Length = 1)) "a"
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.find on finite (failing)" (try Some ([| "a";"ab";"a" |] |> countEnumeratorsAndCheckedDisposedAtMostOnce |> Seq.find (fun x -> x.Length = 6)) with :? System.Collections.Generic.KeyNotFoundException -> None) None
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.map_with_type (string up to obj,finite)" ([| "a" |] |> Seq.cast |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> Seq.toArray) [| ("a" :> obj) |]
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.map_with_type (obj down to string, finite)" ([| ("a" :> obj) |] |> Seq.cast |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> Seq.toArray) [| "a" |]
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.append, finite, finite" (Seq.append [| "a" |] [| "b" |] |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> Seq.toArray) [| "a"; "b" |]
+ do check "" numActiveEnumerators 0
+
+
+
+ do check "IEnumerableTest.concat, finite" (Seq.concat [| [| "a" |]; [| |]; [| "b";"c" |] |] |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> Seq.toList) [ "a";"b";"c" ]
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.init_infinite, then take" (Seq.take 2 (countEnumeratorsAndCheckedDisposedAtMostOnce (Seq.initInfinite (fun i -> i+1))) |> Seq.toList) [ 1;2 ]
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.to_array, empty" (Seq.init 0 (fun i -> i+1) |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> Seq.toArray) [| |]
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.to_array, small" (Seq.init 1 (fun i -> i+1) |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> Seq.toArray) [| 1 |]
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.to_array, large" (Seq.init 100000 (fun i -> i+1) |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> Seq.toArray |> Array.length) 100000
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.to_array, very large" (Seq.init 1000000 (fun i -> i+1) |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> Seq.toArray |> Array.length) 1000000
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.to_list, empty" (Seq.init 0 (fun i -> i+1) |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> Seq.toList) [ ]
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.to_list, small" (Seq.init 1 (fun i -> i+1) |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> Seq.toList) [ 1 ]
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.to_list, large" (Seq.init 100000 (fun i -> i+1) |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> Seq.toList |> List.length) 100000
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.to_list, large" (Seq.init 1000000 (fun i -> i+1) |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> Seq.toList |> List.length) 1000000
+ do check "" numActiveEnumerators 0
+ do check "IEnumerableTest.to_list, large" (Seq.init 1000000 (fun i -> i+1) |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> List.ofSeq |> List.length) 1000000
+ do check "" numActiveEnumerators 0
+ do check "List.unzip, large" (Seq.init 1000000 (fun i -> (i,i+1)) |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> List.ofSeq |> List.unzip |> fst |> List.length) 1000000
+ do check "" numActiveEnumerators 0
+ let dup x = x,x
+ let uncurry f (x,y) = f x y
+
+ do check "List.zip, large" (Seq.init 1000000 (fun i -> (i,i+1)) |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> List.ofSeq |> dup |> uncurry List.zip |> List.length) 1000000
+ do check "" numActiveEnumerators 0
+
+(*
+ // Currently disabled, since IStructuralEquatable.Equals will cause this to stack overflow around 140000 elements
+ do check "List.sort, large" ((Seq.init 140000 (fun i -> 139999 - i) |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> List.ofSeq |> List.sort) =
+ (Seq.init 140000 (fun i -> i) |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> List.ofSeq |> List.sort)) true
+ do check "" numActiveEnumerators 0
+*)
+
+ do check "Seq.singleton" (Seq.singleton 42 |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> Seq.length) 1
+ do check "" numActiveEnumerators 0
+ do check "Seq.singleton" (Seq.singleton 42 |> countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd |> Seq.toList) [42]
+ do check "" numActiveEnumerators 0
+
+ do check "Seq.truncate" (Seq.truncate 20 (countEnumeratorsAndCheckedDisposedAtMostOnce [1..100]) |> Seq.toList) [1..20]
+ do check "" numActiveEnumerators 0
+ do check "Seq.truncate" (Seq.truncate 1 (countEnumeratorsAndCheckedDisposedAtMostOnce [1..100]) |> Seq.toList) [1]
+ do check "" numActiveEnumerators 0
+ do check "Seq.truncate" (Seq.truncate 0 (countEnumeratorsAndCheckedDisposedAtMostOnce [1..100]) |> Seq.toList) []
+ do check "" numActiveEnumerators 0
+
+ do check "Seq.scan" (Seq.scan (+) 0 (countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd [|1..5|]) |> Seq.toArray) [|0; 1; 3; 6; 10; 15|]
+ do check "" numActiveEnumerators 0
+ //do check "Seq.scan1" (Seq.scan1 (+) (countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd [|1..5|]) |> Seq.toArray) [|3; 6; 10; 15|]
+ //do check "" numActiveEnumerators 0
+
+ do check "Seq.exists2" (Seq.exists2 (=) (countEnumeratorsAndCheckedDisposedAtMostOnce [|1; 2; 3; 4; 5; 6|]) (countEnumeratorsAndCheckedDisposedAtMostOnce [|2; 3; 4; 5; 6; 6|])) true
+ do check "" numActiveEnumerators 0
+ do check "Seq.exists2" (Seq.exists2 (=) (countEnumeratorsAndCheckedDisposedAtMostOnce [|1; 2; 3; 4; 5; 6|]) (countEnumeratorsAndCheckedDisposedAtMostOnce [|2; 3; 4; 5; 6; 7|])) false
+ do check "" numActiveEnumerators 0
+
+ do check "Seq.forall2" (Seq.forall2 (=) (countEnumeratorsAndCheckedDisposedAtMostOnce [|1..10|]) (countEnumeratorsAndCheckedDisposedAtMostOnce [|1..10|])) true
+ do check "" numActiveEnumerators 0
+ do check "Seq.forall2" (Seq.forall2 (=) (countEnumeratorsAndCheckedDisposedAtMostOnce [|1;2;3;4;5|]) (countEnumeratorsAndCheckedDisposedAtMostOnce [|1;2;3;0;5|])) false
+ do check "" numActiveEnumerators 0
+
+
+
+ do check "Seq.tryFind" ([|1..100|] |> countEnumeratorsAndCheckedDisposedAtMostOnce |> Seq.tryFind (fun x -> x > 50)) (Some 51)
+ do check "" numActiveEnumerators 0
+ do check "Seq.tryFind" ([|1..100|] |> countEnumeratorsAndCheckedDisposedAtMostOnce |> Seq.tryFind (fun x -> x > 180)) None
+ do check "" numActiveEnumerators 0
+
+
+ do check "Seq.compareWith" (Seq.compareWith compare (countEnumeratorsAndCheckedDisposedAtMostOnce [1;2]) (countEnumeratorsAndCheckedDisposedAtMostOnce [2;1])) -1
+ do check "" numActiveEnumerators 0
+ do check "Seq.compareWith" (Seq.compareWith compare (countEnumeratorsAndCheckedDisposedAtMostOnce [2;1]) (countEnumeratorsAndCheckedDisposedAtMostOnce [1;2])) 1
+ do check "" numActiveEnumerators 0
+ do check "Seq.compareWith" (Seq.compareWith compare (countEnumeratorsAndCheckedDisposedAtMostOnce [1;2]) (countEnumeratorsAndCheckedDisposedAtMostOnce [1;2])) 0
+ do check "" numActiveEnumerators 0
+ do check "Seq.compareWith" (Seq.compareWith compare (countEnumeratorsAndCheckedDisposedAtMostOnce []) (countEnumeratorsAndCheckedDisposedAtMostOnce [1;2])) -1
+ do check "" numActiveEnumerators 0
+
+ do check "Seq.collect" (Seq.collect (fun i -> [i*10 .. i*10+9]) (countEnumeratorsAndCheckedDisposedAtMostOnce [0..9]) |> Seq.toList) [0..99]
+ do check "" numActiveEnumerators 0
+
+ let c = ref -1
+ do Seq.iter2 (fun x y -> incr c; test "Seq.iter2" (c.Value = x && c.Value = y)) (countEnumeratorsAndCheckedDisposedAtMostOnce [0..10]) (countEnumeratorsAndCheckedDisposedAtMostOnce [0..10])
+ do check "Seq.iter2" c.Value 10
+ do check "" numActiveEnumerators 0
+
+ do check "Seq.zip"
+ (Seq.zip [1..10] (countEnumeratorsAndCheckedDisposedAtMostOnce [2..11]) |> Seq.toList) [for i in 1..10 -> i, i+1]
+ do check "" numActiveEnumerators 0
+
+
+ do check "Seq.zip3"
+ (Seq.zip3 (countEnumeratorsAndCheckedDisposedAtMostOnce [1..10]) (countEnumeratorsAndCheckedDisposedAtMostOnce [2..11]) (countEnumeratorsAndCheckedDisposedAtMostOnce [3..12]) |> Seq.toList) [for i in 1..10 -> i, i+1, i+2]
+ do check "" numActiveEnumerators 0
+
+ do c.Value <- -1
+ do Seq.iteri (fun n x -> incr c; test "Seq.iter2" (c.Value = n && c.Value+1 = x)) (countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd [1..11])
+ do check "" numActiveEnumerators 0
+ do check "Seq.iter2" c.Value 10
+
+ do check "Seq.pairwise" (Seq.pairwise (countEnumeratorsAndCheckedDisposedAtMostOnce [1..20]) |> Seq.toList) [for i in 1 .. 19 -> i, i+1]
+ do check "" numActiveEnumerators 0
+
+ do check "Seq.windowed 1" (Seq.windowed 1 (countEnumeratorsAndCheckedDisposedAtMostOnce [1..20]) |> Seq.toList) [for i in 1 .. 20 -> [|i|]]
+ do check "" numActiveEnumerators 0
+ do check "Seq.windowed 2" (Seq.windowed 2 (countEnumeratorsAndCheckedDisposedAtMostOnce [1..20]) |> Seq.toList) [for i in 1 .. 19 -> [|i; i+1|]]
+ do check "" numActiveEnumerators 0
+ do check "Seq.windowed 3" (Seq.windowed 3 (countEnumeratorsAndCheckedDisposedAtMostOnce [1..20]) |> Seq.toList) [for i in 1 .. 18 -> [|i; i+1; i+2|]]
+ do check "" numActiveEnumerators 0
+ do check "Seq.windowed 4" (Seq.windowed 4 (countEnumeratorsAndCheckedDisposedAtMostOnce [1..20]) |> Seq.toList) [for i in 1 .. 17 -> [|i; i+1; i+2; i+3|]]
+ do check "" numActiveEnumerators 0
+
+ let group = Seq.groupBy (fun x -> x % 5) (countEnumeratorsAndCheckedDisposedAtMostOnce [1..100])
+ do for n, s in group do
+ check "Seq.groupBy" (Seq.forall (fun x -> x % 5 = n) s) true;
+ check "" numActiveEnumerators 0
+ done
+
+ let sorted = Seq.sortBy abs (countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd [2; 4; 3; -5; 2; -4; -8; 0; 5; 2])
+ do check "Seq.sortBy" (Seq.pairwise sorted |> Seq.forall (fun (x, y) -> abs x <= abs y)) true
+ do check "" numActiveEnumerators 0
+ let counts = Seq.countBy id (countEnumeratorsAndCheckedDisposedAtMostOnce [for i in 1..10 do yield! [10..-1..i] done ])
+ do check "Seq.countBy" (counts |> Seq.toList) [for i in 10..-1..1 -> i, i]
+ do check "" numActiveEnumerators 0
+
+ do check "Seq.sum" (Seq.sum (countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd [1..100])) (100*101/2)
+ do check "" numActiveEnumerators 0
+ do check "Seq.sumBy" (Seq.sumBy float [1..100]) (100.*101./2.)
+ do check "" numActiveEnumerators 0
+
+ do check "Seq.average" (Seq.average (countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd [1.; 2.; 3.])) 2.
+ do check "" numActiveEnumerators 0
+ do check "Seq.averageBy" (Seq.averageBy float (countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd [0..100])) 50.
+ do check "" numActiveEnumerators 0
+ do check "Seq.min" (Seq.min (countEnumeratorsAndCheckedDisposedAtMostOnceAtEnd [1; 4; 2; 5; 8; 4; 0; 3])) 0
+ do check "" numActiveEnumerators 0
+ do check "Seq.max" (Seq.max (countEnumeratorsAndCheckedDisposedAtMostOnce [1; 4; 2; 5; 8; 4; 0; 3])) 8
+ do check "" numActiveEnumerators 0
+#if !NETCOREAPP
+// strings don't have enumerators in portable
+ do check "Seq.minBy" (Seq.minBy int (countEnumeratorsAndCheckedDisposedAtMostOnce "this is a test")) ' '
+ do check "" numActiveEnumerators 0
+ do check "Seq.maxBy" (Seq.maxBy int (countEnumeratorsAndCheckedDisposedAtMostOnce "this is a test")) 't'
+ do check "" numActiveEnumerators 0
+#endif
+
+end
+
+let (lsr) (a:int) (b:int) = int32 (uint32 a >>> b)
+let (lsl) (a:int) (b:int) = a <<< b
+let (lor) (a:int) (b:int) = a ||| b
+let (lxor) (a:int) (b:int) = a ^^^ b
+let (land) (a:int) (b:int) = a &&& b
+// check precedence of lsl, lsr etc.
+let _ = fun (x:int) -> x > x lsr 1
+let _ = fun (x:int) -> x > (x lsr 1)
+let _ = fun (x:int) -> x > x lsl 1
+let _ = fun (x:int) -> x > (x lsl 1)
+let _ = fun (x:int) -> x > x lor 1
+let _ = fun (x:int) -> x > (x lor 1)
+let _ = fun (x:int) -> x > x lxor 1
+let _ = fun (x:int) -> x > (x lxor 1)
+let _ = fun (x:int) -> x > x land 1
+let _ = fun (x:int) -> x > (x land 1)
+
+
+// check ordering of NaN
+(*
+The predefined floating-point comparison operators are:
+bool operator ==(float x, float y);
+bool operator ==(double x, double y);
+bool operator !=(float x, float y);
+bool operator !=(double x, double y);
+bool operator <(float x, float y);
+bool operator <(double x, double y);
+bool operator >(float x, float y);
+bool operator >(double x, double y);
+bool operator <=(float x, float y);
+bool operator <=(double x, double y);
+bool operator >=(float x, float y);
+bool operator >=(double x, double y);
+The operators compare the operands according to the rules of the IEC 60559 standard:
+If either operand is NaN, the result is false for all operators except !=, for which the result is true. For
+any two operands, x != y always produces the same result as !(x == y). However, when one or both
+operands are NaN, the <, >, <=, and >= operators do not produce the same results as the logical negation of
+the opposite operator. [Example: If either of x and y is NaN, then x < y is false, but !(x >= y) is true.
+end example]
+? When neither operand is NaN, the operators compare the values of the two floating-point operands with
+respect to the ordering
+-inf < ?max < ? < ?min < ?0.0 == +0.0 < +min < ? < +max < +inf
+where min and max are the smallest and largest positive finite values that can be represented in the given
+floating-point format. Notable effects of this ordering are:
+o Negative and positive zeros are considered equal.
+o A negative infinity is considered less than all other values, but equal to another negative infinity.
+o A positive infinity is considered greater than all other values, but equal to another positive infinity.
+*)
+open System
+
+(* ----- NaN tests for DOUBLE ----- *)
+
+module DoubleNaN =
+ let nan1 = (let r = ref Double.NaN in (if sprintf "Hello" = "Hello" then !r else 0.0))
+ let nan2 = (let r = ref Double.NaN in (if sprintf "Hello" = "Hello" then !r else 0.0))
+
+ do printf "checking floating point relational operators\n"
+ let _ = check "d3wiojd30a" ((Double.NaN > Double.NaN)) false
+ check "d3wiojd30a" (if (Double.NaN > Double.NaN) then "a" else "b") "b"
+ check "d3wiojd30b" ((Double.NaN >= Double.NaN)) false
+ check "d3wiojd30b" (if (Double.NaN >= Double.NaN) then "a" else "b") "b"
+ check "d3wiojd30c" ((Double.NaN < Double.NaN)) false
+ check "d3wiojd30c" (if (Double.NaN < Double.NaN) then "a" else "b") "b"
+ check "d3wiojd30d" ((Double.NaN <= Double.NaN)) false
+ check "d3wiojd30d" (if (Double.NaN <= Double.NaN) then "a" else "b") "b"
+ check "d3wiojd30e" ((Double.NaN = Double.NaN)) false
+ check "d3wiojd30e" (if (Double.NaN = Double.NaN) then "a" else "b") "b"
+ check "d3wiojd30q" ((Double.NaN <> Double.NaN)) true
+ check "d3wiojd30w" ((Double.NaN > 1.0)) false
+ check "d3wiojd30e" ((Double.NaN >= 1.0)) false
+ check "d3wiojd30r" ((Double.NaN < 1.0)) false
+ check "d3wiojd30t" ((Double.NaN <= 1.0)) false
+ check "d3wiojd30y" ((Double.NaN = 1.0)) false
+ check "d3wiojd30u" ((Double.NaN <> 1.0)) true
+ check "d3wiojd30i" ((1.0 > Double.NaN)) false
+ check "d3wiojd30o" ((1.0 >= Double.NaN)) false
+ check "d3wiojd30p" ((1.0 < Double.NaN)) false
+ check "d3wiojd30a" ((1.0 <= Double.NaN)) false
+ check "d3wiojd30s" ((1.0 = Double.NaN)) false
+ check "d3wiojd30d" ((1.0 <> Double.NaN)) true
+ check "d3wiojd30a" ((nan1 > Double.NaN)) false
+ check "d3wiojd30b" ((nan1 >= nan2)) false
+ check "d3wiojd30c" ((nan1 < nan2)) false
+ check "d3wiojd30d" ((nan1 <= nan2)) false
+ check "d3wiojd30e" ((nan1 = nan2)) false
+ check "d3wiojd30q" ((nan1 <> nan2)) true
+ check "d3wiojd30w" ((nan1 > 1.0)) false
+ check "d3wiojd30e" ((nan1 >= 1.0)) false
+ check "d3wiojd30r" ((nan1 < 1.0)) false
+ check "d3wiojd30t" ((nan1 <= 1.0)) false
+ check "d3wiojd30y" ((nan1 = 1.0)) false
+ check "d3wiojd30u" ((nan1 <> 1.0)) true
+ check "d3wiojd30i" ((1.0 > nan2)) false
+ check "d3wiojd30o" ((1.0 >= nan2)) false
+ check "d3wiojd30p" ((1.0 < nan2)) false
+ check "d3wiojd30a" ((1.0 <= nan2)) false
+ check "d3wiojd30s" ((1.0 = nan2)) false
+ check "d3wiojd30d" ((1.0 <> nan2)) true
+ check "d3wiojd30f" ((Double.NegativeInfinity = Double.NegativeInfinity)) true
+ check "d3wiojd30g" ((Double.NegativeInfinity < Double.PositiveInfinity)) true
+ check "d3wiojd30h" ((Double.NegativeInfinity > Double.PositiveInfinity)) false
+ check "d3wiojd30j" ((Double.NegativeInfinity <= Double.NegativeInfinity)) true
+
+ check "D1nancompare01" (0 = (compare Double.NaN Double.NaN)) true
+ check "D1nancompare02" (0 = (compare Double.NaN nan1)) true
+ check "D1nancompare03" (0 = (compare nan1 Double.NaN)) true
+ check "D1nancompare04" (0 = (compare nan1 nan1)) true
+ check "D1nancompare05" (1 = (compare 1. Double.NaN)) true
+ check "D1nancompare06" (1 = (compare 0. Double.NaN)) true
+ check "D1nancompare07" (1 = (compare -1. Double.NaN)) true
+ check "D1nancompare08" (1 = (compare Double.NegativeInfinity Double.NaN)) true
+ check "D1nancompare09" (1 = (compare Double.PositiveInfinity Double.NaN)) true
+ check "D1nancompare10" (1 = (compare Double.MaxValue Double.NaN)) true
+ check "D1nancompare11" (1 = (compare Double.MinValue Double.NaN)) true
+ check "D1nancompare12" (-1 = (compare Double.NaN 1.)) true
+ check "D1nancompare13" (-1 = (compare Double.NaN 0.)) true
+ check "D1nancompare14" (-1 = (compare Double.NaN -1.)) true
+ check "D1nancompare15" (-1 = (compare Double.NaN Double.NegativeInfinity)) true
+ check "D1nancompare16" (-1 = (compare Double.NaN Double.PositiveInfinity)) true
+ check "D1nancompare17" (-1 = (compare Double.NaN Double.MaxValue)) true
+ check "D1nancompare18" (-1 = (compare Double.NaN Double.MinValue)) true
+
+module DoubleNaNNonStructuralComparison1 =
+ open NonStructuralComparison
+ let nan1 = (let r = ref Double.NaN in (if sprintf "Hello" = "Hello" then !r else 0.0))
+ let nan2 = (let r = ref Double.NaN in (if sprintf "Hello" = "Hello" then !r else 0.0))
+
+ check "d3wiojd30a" (if (Double.NaN > Double.NaN) then "a" else "b") "b"
+ check "d3wiojd30b" ((Double.NaN >= Double.NaN)) false
+ check "d3wiojd30b" (if (Double.NaN >= Double.NaN) then "a" else "b") "b"
+ check "d3wiojd30c" ((Double.NaN < Double.NaN)) false
+ check "d3wiojd30c" (if (Double.NaN < Double.NaN) then "a" else "b") "b"
+ check "d3wiojd30d" ((Double.NaN <= Double.NaN)) false
+ check "d3wiojd30d" (if (Double.NaN <= Double.NaN) then "a" else "b") "b"
+ check "d3wiojd30e" ((Double.NaN = Double.NaN)) false
+ check "d3wiojd30e" (if (Double.NaN = Double.NaN) then "a" else "b") "b"
+ check "d3wiojd30q" ((Double.NaN <> Double.NaN)) true
+ check "d3wiojd30w" ((Double.NaN > 1.0)) false
+ check "d3wiojd30e" ((Double.NaN >= 1.0)) false
+ check "d3wiojd30r" ((Double.NaN < 1.0)) false
+ check "d3wiojd30t" ((Double.NaN <= 1.0)) false
+ check "d3wiojd30y" ((Double.NaN = 1.0)) false
+ check "d3wiojd30u" ((Double.NaN <> 1.0)) true
+ check "d3wiojd30i" ((1.0 > Double.NaN)) false
+ check "d3wiojd30o" ((1.0 >= Double.NaN)) false
+ check "d3wiojd30p" ((1.0 < Double.NaN)) false
+ check "d3wiojd30a" ((1.0 <= Double.NaN)) false
+ check "d3wiojd30s" ((1.0 = Double.NaN)) false
+ check "d3wiojd30d" ((1.0 <> Double.NaN)) true
+ check "d3wiojd30a" ((nan1 > Double.NaN)) false
+ check "d3wiojd30b" ((nan1 >= nan2)) false
+ check "d3wiojd30c" ((nan1 < nan2)) false
+ check "d3wiojd30d" ((nan1 <= nan2)) false
+ check "d3wiojd30e" ((nan1 = nan2)) false
+ check "d3wiojd30q" ((nan1 <> nan2)) true
+ check "d3wiojd30w" ((nan1 > 1.0)) false
+ check "d3wiojd30e" ((nan1 >= 1.0)) false
+ check "d3wiojd30r" ((nan1 < 1.0)) false
+ check "d3wiojd30t" ((nan1 <= 1.0)) false
+ check "d3wiojd30y" ((nan1 = 1.0)) false
+ check "d3wiojd30u" ((nan1 <> 1.0)) true
+ check "d3wiojd30i" ((1.0 > nan2)) false
+ check "d3wiojd30o" ((1.0 >= nan2)) false
+ check "d3wiojd30p" ((1.0 < nan2)) false
+ check "d3wiojd30a" ((1.0 <= nan2)) false
+ check "d3wiojd30s" ((1.0 = nan2)) false
+ check "d3wiojd30d" ((1.0 <> nan2)) true
+ check "d3wiojd30f" ((Double.NegativeInfinity = Double.NegativeInfinity)) true
+ check "d3wiojd30g" ((Double.NegativeInfinity < Double.PositiveInfinity)) true
+ check "d3wiojd30h" ((Double.NegativeInfinity > Double.PositiveInfinity)) false
+ check "d3wiojd30j" ((Double.NegativeInfinity <= Double.NegativeInfinity)) true
+
+ check "D2nancompare01" (0 = (compare Double.NaN Double.NaN)) true
+ check "D2nancompare02" (0 = (compare Double.NaN nan1)) true
+ check "D2nancompare03" (0 = (compare nan1 Double.NaN)) true
+ check "D2nancompare04" (0 = (compare nan1 nan1)) true
+ check "D2nancompare05" (1 = (compare 1. Double.NaN)) true
+ check "D2nancompare06" (1 = (compare 0. Double.NaN)) true
+ check "D2nancompare07" (1 = (compare -1. Double.NaN)) true
+ check "D2nancompare08" (1 = (compare Double.NegativeInfinity Double.NaN)) true
+ check "D2nancompare09" (1 = (compare Double.PositiveInfinity Double.NaN)) true
+ check "D2nancompare10" (1 = (compare Double.MaxValue Double.NaN)) true
+ check "D2nancompare11" (1 = (compare Double.MinValue Double.NaN)) true
+ check "D2nancompare12" (-1 = (compare Double.NaN 1.)) true
+ check "D2nancompare13" (-1 = (compare Double.NaN 0.)) true
+ check "D2nancompare14" (-1 = (compare Double.NaN -1.)) true
+ check "D2nancompare15" (-1 = (compare Double.NaN Double.NegativeInfinity)) true
+ check "D2nancompare16" (-1 = (compare Double.NaN Double.PositiveInfinity)) true
+ check "D2nancompare17" (-1 = (compare Double.NaN Double.MaxValue)) true
+ check "D2nancompare18" (-1 = (compare Double.NaN Double.MinValue)) true
+
+module DoubleNaNStructured =
+ type www = W of float
+ let nan1 = (let r = ref Double.NaN in (if sprintf "Hello" = "Hello" then !r else 0.0))
+ let nan2 = (let r = ref Double.NaN in (if sprintf "Hello" = "Hello" then !r else 0.0))
+
+ do printf "checking floating point relational operators on structured data\n"
+ // NOTE: SPECIFICATION: The relational operators work differently when applied to
+ // floats embedded in structured data than when applied to raw floats.
+
+ let _ = check "d3wiojd31q" ((W Double.NaN > W Double.NaN)) false
+ let _ = check "d3wiojd31w" ((W Double.NaN >= W Double.NaN)) false
+ let _ = check "d3wiojd31e" ((W Double.NaN < W Double.NaN)) false
+ let _ = check "d3wiojd31r" ((W Double.NaN <= W Double.NaN)) false
+ let _ = check "d3wiojd31ty" ((W Double.NaN = W Double.NaN)) false
+ let _ = check "d3wiojd31y" ((W Double.NaN <> W Double.NaN)) true
+ let _ = check "d3wiojd31dy" (0 = compare (W Double.NaN) (W Double.NaN)) true
+ let _ = check "d3wiojd31u" ((W Double.NaN > W 1.0)) false
+ let _ = check "d3wiojd31i" ((W Double.NaN >= W 1.0)) false
+ let _ = check "d3wiojd31o" ((W Double.NaN < W 1.0)) false
+ let _ = check "d3wiojd31p" ((W Double.NaN <= W 1.0)) false
+ let _ = check "d3wiojd31a" ((W Double.NaN = W 1.0)) false
+ let _ = check "d3wiojd31s" ((W Double.NaN <> W 1.0)) true
+ let _ = check "d3wiojd31d" ((W 1.0 > W Double.NaN)) false
+ let _ = check "d3wiojd31f" ((W 1.0 >= W Double.NaN)) false
+ let _ = check "d3wiojd31g" ((W 1.0 < W Double.NaN)) false
+ let _ = check "d3wiojd31h" ((W 1.0 <= W Double.NaN)) false
+ let _ = check "d3wiojd31j" ((W 1.0 = W Double.NaN)) false
+ let _ = check "d3wiojd31k" ((W 1.0 <> W Double.NaN)) true
+ let _ = check "d3wiojd31l" ((W Double.NegativeInfinity = W Double.NegativeInfinity)) true
+ let _ = check "d3wiojd31c" ((W Double.NegativeInfinity < W Double.PositiveInfinity)) true
+ let _ = check "d3wiojd3xx" ((W Double.NegativeInfinity > W Double.PositiveInfinity)) false
+ let _ = check "d3wiojd31z" ((W Double.NegativeInfinity <= W Double.NegativeInfinity)) true
+
+ let _ = check "D3nancompare01" (0 = (compare (W Double.NaN) (W Double.NaN))) true
+ let _ = check "D3nancompare02" (0 = (compare (W Double.NaN) (W nan1))) true
+ let _ = check "D3nancompare03" (0 = (compare (W nan1) (W Double.NaN))) true
+ let _ = check "D3nancompare04" (0 = (compare (W nan1) (W nan1))) true
+ let _ = check "D3nancompare05" (1 = (compare (W 1.) (W Double.NaN))) true
+ let _ = check "D3nancompare06" (1 = (compare (W 0.) (W Double.NaN))) true
+ let _ = check "D3nancompare07" (1 = (compare (W -1.) (W Double.NaN))) true
+ let _ = check "D3nancompare08" (1 = (compare (W Double.NegativeInfinity) (W Double.NaN))) true
+ let _ = check "D3nancompare09" (1 = (compare (W Double.PositiveInfinity) (W Double.NaN))) true
+ let _ = check "D3nancompare10" (1 = (compare (W Double.MaxValue) (W Double.NaN))) true
+ let _ = check "D3nancompare11" (1 = (compare (W Double.MinValue) (W Double.NaN))) true
+ let _ = check "D3nancompare12" (-1 = (compare (W Double.NaN) (W 1.))) true
+ let _ = check "D3nancompare13" (-1 = (compare (W Double.NaN) (W 0.))) true
+ let _ = check "D3nancompare14" (-1 = (compare (W Double.NaN) (W -1.))) true
+ let _ = check "D3nancompare15" (-1 = (compare (W Double.NaN) (W Double.NegativeInfinity))) true
+ let _ = check "D3nancompare16" (-1 = (compare (W Double.NaN) (W Double.PositiveInfinity))) true
+ let _ = check "D3nancompare17" (-1 = (compare (W Double.NaN) (W Double.MaxValue))) true
+ let _ = check "D3nancompare18" (-1 = (compare (W Double.NaN) (W Double.MinValue))) true
+
+module DoubleNaNStructuredPoly =
+ type 'a www = W of 'a
+ let nan1 = (let r = ref Double.NaN in (if sprintf "Hello" = "Hello" then !r else 0.0))
+ let nan2 = (let r = ref Double.NaN in (if sprintf "Hello" = "Hello" then !r else 0.0))
+ do printf "checking floating point relational operators on polymorphic structured data\n"
+
+ let _ = check "d3wiojd32q" ((W Double.NaN > W Double.NaN)) false
+ let _ = check "d3wiojd32w" ((W Double.NaN >= W Double.NaN)) false
+ let _ = check "d3wiojd32e" ((W Double.NaN < W Double.NaN)) false
+ let _ = check "d3wiojd32r" ((W Double.NaN <= W Double.NaN)) false
+ let _ = check "d3wiojd32t" ((W Double.NaN = W Double.NaN)) false
+ let _ = check "d3wiojd32dt" ((W Double.NaN).Equals(W Double.NaN)) true
+ let _ = check "d3wiojd32y" ((W Double.NaN <> W Double.NaN)) true
+ let _ = check "d3wiojd32u" ((W Double.NaN > W 1.0)) false
+ let _ = check "d3wiojd32i" ((W Double.NaN >= W 1.0)) false
+ let _ = check "d3wiojd32o" ((W Double.NaN < W 1.0)) false
+ let _ = check "d3wiojd32p" ((W Double.NaN <= W 1.0)) false
+ let _ = check "d3wiojd32a" ((W Double.NaN = W 1.0)) false
+ let _ = check "d3wiojd32s" ((W Double.NaN <> W 1.0)) true
+ let _ = check "d3wiojd32d" ((W 1.0 > W Double.NaN)) false
+ let _ = check "d3wiojd32f" ((W 1.0 >= W Double.NaN)) false
+ let _ = check "d3wiojd32g" ((W 1.0 < W Double.NaN)) false
+ let _ = check "d3wiojd32h" ((W 1.0 <= W Double.NaN)) false
+ let _ = check "d3wiojd32j" ((W 1.0 = W Double.NaN)) false
+ let _ = check "d3wiojd32k" ((W 1.0 <> W Double.NaN)) true
+ let _ = check "d3wiojd32l" ((W Double.NegativeInfinity = W Double.NegativeInfinity)) true
+ let _ = check "d3wiojd32z" ((W Double.NegativeInfinity < W Double.PositiveInfinity)) true
+ let _ = check "d3wiojd32x" ((W Double.NegativeInfinity > W Double.PositiveInfinity)) false
+ let _ = check "d3wiojd32c" ((W Double.NegativeInfinity <= W Double.NegativeInfinity)) true
+
+ let _ = check "D4nancompare01" (0 = (compare (W Double.NaN) (W Double.NaN))) true
+ let _ = check "D4nancompare02" (0 = (compare (W Double.NaN) (W nan1))) true
+ let _ = check "D4nancompare03" (0 = (compare (W nan1) (W Double.NaN))) true
+ let _ = check "D4nancompare04" (0 = (compare (W nan1) (W nan1))) true
+ let _ = check "D4nancompare05" (1 = (compare (W 1.) (W Double.NaN))) true
+ let _ = check "D4nancompare06" (1 = (compare (W 0.) (W Double.NaN))) true
+ let _ = check "D4nancompare07" (1 = (compare (W -1.) (W Double.NaN))) true
+ let _ = check "D4nancompare08" (1 = (compare (W Double.NegativeInfinity) (W Double.NaN))) true
+ let _ = check "D4nancompare09" (1 = (compare (W Double.PositiveInfinity) (W Double.NaN))) true
+ let _ = check "D4nancompare10" (1 = (compare (W Double.MaxValue) (W Double.NaN))) true
+ let _ = check "D4nancompare11" (1 = (compare (W Double.MinValue) (W Double.NaN))) true
+ let _ = check "D4nancompare12" (-1 = (compare (W Double.NaN) (W 1.))) true
+ let _ = check "D4nancompare13" (-1 = (compare (W Double.NaN) (W 0.))) true
+ let _ = check "D4nancompare14" (-1 = (compare (W Double.NaN) (W -1.))) true
+ let _ = check "D4nancompare15" (-1 = (compare (W Double.NaN) (W Double.NegativeInfinity))) true
+ let _ = check "D4nancompare16" (-1 = (compare (W Double.NaN) (W Double.PositiveInfinity))) true
+ let _ = check "D4nancompare17" (-1 = (compare (W Double.NaN) (W Double.MaxValue))) true
+ let _ = check "D4nancompare18" (-1 = (compare (W Double.NaN) (W Double.MinValue))) true
+
+(* ----- NaN tests for SINGLE ----- *)
+
+module SingleNaN =
+ let nan1 = (let r = ref Single.NaN in (if sprintf "Hello" = "Hello" then !r else 0.0f))
+ let nan2 = (let r = ref Single.NaN in (if sprintf "Hello" = "Hello" then !r else 0.0f))
+
+ do printf "checking floating point relational operators\n"
+ let _ = check "d3wiojd30a" ((Single.NaN > Single.NaN)) false
+ check "d3wiojd30a" (if (Single.NaN > Single.NaN) then "a" else "b") "b"
+ check "d3wiojd30b" ((Single.NaN >= Single.NaN)) false
+ check "d3wiojd30b" (if (Single.NaN >= Single.NaN) then "a" else "b") "b"
+ check "d3wiojd30c" ((Single.NaN < Single.NaN)) false
+ check "d3wiojd30c" (if (Single.NaN < Single.NaN) then "a" else "b") "b"
+ check "d3wiojd30d" ((Single.NaN <= Single.NaN)) false
+ check "d3wiojd30d" (if (Single.NaN <= Single.NaN) then "a" else "b") "b"
+ check "d3wiojd30e" ((Single.NaN = Single.NaN)) false
+ check "d3wiojd30e" (if (Single.NaN = Single.NaN) then "a" else "b") "b"
+ check "d3wiojd30q" ((Single.NaN <> Single.NaN)) true
+ check "d3wiojd30w" ((Single.NaN > 1.0f)) false
+ check "d3wiojd30e" ((Single.NaN >= 1.0f)) false
+ check "d3wiojd30r" ((Single.NaN < 1.0f)) false
+ check "d3wiojd30t" ((Single.NaN <= 1.0f)) false
+ check "d3wiojd30y" ((Single.NaN = 1.0f)) false
+ check "d3wiojd30u" ((Single.NaN <> 1.0f)) true
+ check "d3wiojd30i" ((1.0f > Single.NaN)) false
+ check "d3wiojd30o" ((1.0f >= Single.NaN)) false
+ check "d3wiojd30p" ((1.0f < Single.NaN)) false
+ check "d3wiojd30a" ((1.0f <= Single.NaN)) false
+ check "d3wiojd30s" ((1.0f = Single.NaN)) false
+ check "d3wiojd30d" ((1.0f <> Single.NaN)) true
+ check "d3wiojd30a" ((nan1 > Single.NaN)) false
+ check "d3wiojd30b" ((nan1 >= nan2)) false
+ check "d3wiojd30c" ((nan1 < nan2)) false
+ check "d3wiojd30d" ((nan1 <= nan2)) false
+ check "d3wiojd30e" ((nan1 = nan2)) false
+ check "d3wiojd30q" ((nan1 <> nan2)) true
+ check "d3wiojd30w" ((nan1 > 1.0f)) false
+ check "d3wiojd30e" ((nan1 >= 1.0f)) false
+ check "d3wiojd30r" ((nan1 < 1.0f)) false
+ check "d3wiojd30t" ((nan1 <= 1.0f)) false
+ check "d3wiojd30y" ((nan1 = 1.0f)) false
+ check "d3wiojd30u" ((nan1 <> 1.0f)) true
+ check "d3wiojd30i" ((1.0f > nan2)) false
+ check "d3wiojd30o" ((1.0f >= nan2)) false
+ check "d3wiojd30p" ((1.0f < nan2)) false
+ check "d3wiojd30a" ((1.0f <= nan2)) false
+ check "d3wiojd30s" ((1.0f = nan2)) false
+ check "d3wiojd30d" ((1.0f <> nan2)) true
+ check "d3wiojd30f" ((Single.NegativeInfinity = Single.NegativeInfinity)) true
+ check "d3wiojd30g" ((Single.NegativeInfinity < Single.PositiveInfinity)) true
+ check "d3wiojd30h" ((Single.NegativeInfinity > Single.PositiveInfinity)) false
+ check "d3wiojd30j" ((Single.NegativeInfinity <= Single.NegativeInfinity)) true
+
+ check "S1nancompare01" (0 = (compare Single.NaN Single.NaN)) true
+ check "S1nancompare02" (0 = (compare Single.NaN nan1)) true
+ check "S1nancompare03" (0 = (compare nan1 Single.NaN)) true
+ check "S1nancompare04" (0 = (compare nan1 nan1)) true
+ check "S1nancompare05" (1 = (compare 1.f Single.NaN)) true
+ check "S1nancompare06" (1 = (compare 0.f Single.NaN)) true
+ check "S1nancompare07" (1 = (compare -1.f Single.NaN)) true
+ check "S1nancompare08" (1 = (compare Single.NegativeInfinity Single.NaN)) true
+ check "S1nancompare09" (1 = (compare Single.PositiveInfinity Single.NaN)) true
+ check "S1nancompare10" (1 = (compare Single.MaxValue Single.NaN)) true
+ check "S1nancompare11" (1 = (compare Single.MinValue Single.NaN)) true
+ check "S1nancompare12" (-1 = (compare Single.NaN 1.f)) true
+ check "S1nancompare13" (-1 = (compare Single.NaN 0.f)) true
+ check "S1nancompare14" (-1 = (compare Single.NaN -1.f)) true
+ check "S1nancompare15" (-1 = (compare Single.NaN Single.NegativeInfinity)) true
+ check "S1nancompare16" (-1 = (compare Single.NaN Single.PositiveInfinity)) true
+ check "S1nancompare17" (-1 = (compare Single.NaN Single.MaxValue)) true
+ check "S1nancompare18" (-1 = (compare Single.NaN Single.MinValue)) true
+
+module SingleNaNNonStructuralComparison1 =
+ open NonStructuralComparison
+
+ let nan1 = (let r = ref Single.NaN in (if sprintf "Hello" = "Hello" then !r else 0.0f))
+ let nan2 = (let r = ref Single.NaN in (if sprintf "Hello" = "Hello" then !r else 0.0f))
+
+ check "d3wiojd30a" (if (Single.NaN > Single.NaN) then "a" else "b") "b"
+ check "d3wiojd30b" ((Single.NaN >= Single.NaN)) false
+ check "d3wiojd30b" (if (Single.NaN >= Single.NaN) then "a" else "b") "b"
+ check "d3wiojd30c" ((Single.NaN < Single.NaN)) false
+ check "d3wiojd30c" (if (Single.NaN < Single.NaN) then "a" else "b") "b"
+ check "d3wiojd30d" ((Single.NaN <= Single.NaN)) false
+ check "d3wiojd30d" (if (Single.NaN <= Single.NaN) then "a" else "b") "b"
+ check "d3wiojd30e" ((Single.NaN = Single.NaN)) false
+ check "d3wiojd30e" (if (Single.NaN = Single.NaN) then "a" else "b") "b"
+ check "d3wiojd30q" ((Single.NaN <> Single.NaN)) true
+ check "d3wiojd30w" ((Single.NaN > 1.0f)) false
+ check "d3wiojd30e" ((Single.NaN >= 1.0f)) false
+ check "d3wiojd30r" ((Single.NaN < 1.0f)) false
+ check "d3wiojd30t" ((Single.NaN <= 1.0f)) false
+ check "d3wiojd30y" ((Single.NaN = 1.0f)) false
+ check "d3wiojd30u" ((Single.NaN <> 1.0f)) true
+ check "d3wiojd30i" ((1.0f > Single.NaN)) false
+ check "d3wiojd30o" ((1.0f >= Single.NaN)) false
+ check "d3wiojd30p" ((1.0f < Single.NaN)) false
+ check "d3wiojd30a" ((1.0f <= Single.NaN)) false
+ check "d3wiojd30s" ((1.0f = Single.NaN)) false
+ check "d3wiojd30d" ((1.0f <> Single.NaN)) true
+ check "d3wiojd30a" ((nan1 > Single.NaN)) false
+ check "d3wiojd30b" ((nan1 >= nan2)) false
+ check "d3wiojd30c" ((nan1 < nan2)) false
+ check "d3wiojd30d" ((nan1 <= nan2)) false
+ check "d3wiojd30e" ((nan1 = nan2)) false
+ check "d3wiojd30q" ((nan1 <> nan2)) true
+ check "d3wiojd30w" ((nan1 > 1.0f)) false
+ check "d3wiojd30e" ((nan1 >= 1.0f)) false
+ check "d3wiojd30r" ((nan1 < 1.0f)) false
+ check "d3wiojd30t" ((nan1 <= 1.0f)) false
+ check "d3wiojd30y" ((nan1 = 1.0f)) false
+ check "d3wiojd30u" ((nan1 <> 1.0f)) true
+ check "d3wiojd30i" ((1.0f > nan2)) false
+ check "d3wiojd30o" ((1.0f >= nan2)) false
+ check "d3wiojd30p" ((1.0f < nan2)) false
+ check "d3wiojd30a" ((1.0f <= nan2)) false
+ check "d3wiojd30s" ((1.0f = nan2)) false
+ check "d3wiojd30d" ((1.0f <> nan2)) true
+ check "d3wiojd30f" ((Single.NegativeInfinity = Single.NegativeInfinity)) true
+ check "d3wiojd30g" ((Single.NegativeInfinity < Single.PositiveInfinity)) true
+ check "d3wiojd30h" ((Single.NegativeInfinity > Single.PositiveInfinity)) false
+ check "d3wiojd30j" ((Single.NegativeInfinity <= Single.NegativeInfinity)) true
+
+ check "S2nancompare01" (0 = (compare Single.NaN Single.NaN)) true
+ check "S2nancompare02" (0 = (compare Single.NaN nan1)) true
+ check "S2nancompare03" (0 = (compare nan1 Single.NaN)) true
+ check "S2nancompare04" (0 = (compare nan1 nan1)) true
+ check "S2nancompare05" (1 = (compare 1.f Single.NaN)) true
+ check "S2nancompare06" (1 = (compare 0.f Single.NaN)) true
+ check "S2nancompare07" (1 = (compare -1.f Single.NaN)) true
+ check "S2nancompare08" (1 = (compare Single.NegativeInfinity Single.NaN)) true
+ check "S2nancompare09" (1 = (compare Single.PositiveInfinity Single.NaN)) true
+ check "S2nancompare10" (1 = (compare Single.MaxValue Single.NaN)) true
+ check "S2nancompare11" (1 = (compare Single.MinValue Single.NaN)) true
+ check "S2nancompare12" (-1 = (compare Single.NaN 1.f)) true
+ check "S2nancompare13" (-1 = (compare Single.NaN 0.f)) true
+ check "S2nancompare14" (-1 = (compare Single.NaN -1.f)) true
+ check "S2nancompare15" (-1 = (compare Single.NaN Single.NegativeInfinity)) true
+ check "S2nancompare16" (-1 = (compare Single.NaN Single.PositiveInfinity)) true
+ check "S2nancompare17" (-1 = (compare Single.NaN Single.MaxValue)) true
+ check "S2nancompare18" (-1 = (compare Single.NaN Single.MinValue)) true
+
+module SingleNaNStructured =
+ type www = W of single
+
+ let nan1 = (let r = ref Single.NaN in (if sprintf "Hello" = "Hello" then !r else 0.0f))
+ let nan2 = (let r = ref Single.NaN in (if sprintf "Hello" = "Hello" then !r else 0.0f))
+
+ do printf "checking floating point relational operators on structured data\n"
+ // NOTE: SPECIFICATION: The relational operators work differently when applied to
+ // floats embedded in structured data than when applied to raw floats.
+
+ let _ = check "d3wiojd31q" ((W Single.NaN > W Single.NaN)) false
+ let _ = check "d3wiojd31w" ((W Single.NaN >= W Single.NaN)) false
+ let _ = check "d3wiojd31e" ((W Single.NaN < W Single.NaN)) false
+ let _ = check "d3wiojd31r" ((W Single.NaN <= W Single.NaN)) false
+ let _ = check "d3wiojd31ty" ((W Single.NaN = W Single.NaN)) false
+ let _ = check "d3wiojd31y" ((W Single.NaN <> W Single.NaN)) true
+ let _ = check "d3wiojd31dy" (0 = compare (W Single.NaN) (W Single.NaN)) true
+ let _ = check "d3wiojd31u" ((W Single.NaN > W 1.0f)) false
+ let _ = check "d3wiojd31i" ((W Single.NaN >= W 1.0f)) false
+ let _ = check "d3wiojd31o" ((W Single.NaN < W 1.0f)) false
+ let _ = check "d3wiojd31p" ((W Single.NaN <= W 1.0f)) false
+ let _ = check "d3wiojd31a" ((W Single.NaN = W 1.0f)) false
+ let _ = check "d3wiojd31s" ((W Single.NaN <> W 1.0f)) true
+ let _ = check "d3wiojd31d" ((W 1.0f > W Single.NaN)) false
+ let _ = check "d3wiojd31f" ((W 1.0f >= W Single.NaN)) false
+ let _ = check "d3wiojd31g" ((W 1.0f < W Single.NaN)) false
+ let _ = check "d3wiojd31h" ((W 1.0f <= W Single.NaN)) false
+ let _ = check "d3wiojd31j" ((W 1.0f = W Single.NaN)) false
+ let _ = check "d3wiojd31k" ((W 1.0f <> W Single.NaN)) true
+ let _ = check "d3wiojd31l" ((W Single.NegativeInfinity = W Single.NegativeInfinity)) true
+ let _ = check "d3wiojd31c" ((W Single.NegativeInfinity < W Single.PositiveInfinity)) true
+ let _ = check "d3wiojd3xx" ((W Single.NegativeInfinity > W Single.PositiveInfinity)) false
+ let _ = check "d3wiojd31z" ((W Single.NegativeInfinity <= W Single.NegativeInfinity)) true
+
+ let _ = check "S3nancompare01" (0 = (compare (W Single.NaN) (W Single.NaN))) true
+ let _ = check "S3nancompare02" (0 = (compare (W Single.NaN) (W nan1))) true
+ let _ = check "S3nancompare03" (0 = (compare (W nan1) (W Single.NaN))) true
+ let _ = check "S3nancompare04" (0 = (compare (W nan1) (W nan1))) true
+ let _ = check "S3nancompare05" (1 = (compare (W 1.f) (W Single.NaN))) true
+ let _ = check "S3nancompare06" (1 = (compare (W 0.f) (W Single.NaN))) true
+ let _ = check "S3nancompare07" (1 = (compare (W -1.f) (W Single.NaN))) true
+ let _ = check "S3nancompare08" (1 = (compare (W Single.NegativeInfinity) (W Single.NaN))) true
+ let _ = check "S3nancompare09" (1 = (compare (W Single.PositiveInfinity) (W Single.NaN))) true
+ let _ = check "S3nancompare10" (1 = (compare (W Single.MaxValue) (W Single.NaN))) true
+ let _ = check "S3nancompare11" (1 = (compare (W Single.MinValue) (W Single.NaN))) true
+ let _ = check "S3nancompare12" (-1 = (compare (W Single.NaN) (W 1.f))) true
+ let _ = check "S3nancompare13" (-1 = (compare (W Single.NaN) (W 0.f))) true
+ let _ = check "S3nancompare14" (-1 = (compare (W Single.NaN) (W -1.f))) true
+ let _ = check "S3nancompare15" (-1 = (compare (W Single.NaN) (W Single.NegativeInfinity))) true
+ let _ = check "S3nancompare16" (-1 = (compare (W Single.NaN) (W Single.PositiveInfinity))) true
+ let _ = check "S3nancompare17" (-1 = (compare (W Single.NaN) (W Single.MaxValue))) true
+ let _ = check "S3nancompare18" (-1 = (compare (W Single.NaN) (W Single.MinValue))) true
+
+module SingleNaNStructuredPoly =
+ type 'a www = W of 'a
+
+ let nan1 = (let r = ref Single.NaN in (if sprintf "Hello" = "Hello" then !r else 0.0f))
+ let nan2 = (let r = ref Single.NaN in (if sprintf "Hello" = "Hello" then !r else 0.0f))
+
+ do printf "checking floating point relational operators on polymorphic structured data\n"
+
+ let _ = check "d3wiojd32q" ((W Single.NaN > W Single.NaN)) false
+ let _ = check "d3wiojd32w" ((W Single.NaN >= W Single.NaN)) false
+ let _ = check "d3wiojd32e" ((W Single.NaN < W Single.NaN)) false
+ let _ = check "d3wiojd32r" ((W Single.NaN <= W Single.NaN)) false
+ let _ = check "d3wiojd32t" ((W Single.NaN = W Single.NaN)) false
+ let _ = check "d3wiojd32dt" ((W Single.NaN).Equals(W Single.NaN)) true
+ let _ = check "d3wiojd32y" ((W Single.NaN <> W Single.NaN)) true
+ let _ = check "d3wiojd32u" ((W Single.NaN > W 1.0f)) false
+ let _ = check "d3wiojd32i" ((W Single.NaN >= W 1.0f)) false
+ let _ = check "d3wiojd32o" ((W Single.NaN < W 1.0f)) false
+ let _ = check "d3wiojd32p" ((W Single.NaN <= W 1.0f)) false
+ let _ = check "d3wiojd32a" ((W Single.NaN = W 1.0f)) false
+ let _ = check "d3wiojd32s" ((W Single.NaN <> W 1.0f)) true
+ let _ = check "d3wiojd32d" ((W 1.0f > W Single.NaN)) false
+ let _ = check "d3wiojd32f" ((W 1.0f >= W Single.NaN)) false
+ let _ = check "d3wiojd32g" ((W 1.0f < W Single.NaN)) false
+ let _ = check "d3wiojd32h" ((W 1.0f <= W Single.NaN)) false
+ let _ = check "d3wiojd32j" ((W 1.0f = W Single.NaN)) false
+ let _ = check "d3wiojd32k" ((W 1.0f <> W Single.NaN)) true
+ let _ = check "d3wiojd32l" ((W Single.NegativeInfinity = W Single.NegativeInfinity)) true
+ let _ = check "d3wiojd32z" ((W Single.NegativeInfinity < W Single.PositiveInfinity)) true
+ let _ = check "d3wiojd32x" ((W Single.NegativeInfinity > W Single.PositiveInfinity)) false
+ let _ = check "d3wiojd32c" ((W Single.NegativeInfinity <= W Single.NegativeInfinity)) true
+
+ let _ = check "S4nancompare01" (0 = (compare (W Single.NaN) (W Single.NaN))) true
+ let _ = check "S4nancompare02" (0 = (compare (W Single.NaN) (W nan1))) true
+ let _ = check "S4nancompare03" (0 = (compare (W nan1) (W Single.NaN))) true
+ let _ = check "S4nancompare04" (0 = (compare (W nan1) (W nan1))) true
+ let _ = check "S4nancompare05" (1 = (compare (W 1.f) (W Single.NaN))) true
+ let _ = check "S4nancompare06" (1 = (compare (W 0.f) (W Single.NaN))) true
+ let _ = check "S4nancompare07" (1 = (compare (W -1.f) (W Single.NaN))) true
+ let _ = check "S4nancompare08" (1 = (compare (W Single.NegativeInfinity) (W Single.NaN))) true
+ let _ = check "S4nancompare09" (1 = (compare (W Single.PositiveInfinity) (W Single.NaN))) true
+ let _ = check "S4nancompare10" (1 = (compare (W Single.MaxValue) (W Single.NaN))) true
+ let _ = check "S4nancompare11" (1 = (compare (W Single.MinValue) (W Single.NaN))) true
+ let _ = check "S4nancompare12" (-1 = (compare (W Single.NaN) (W 1.f))) true
+ let _ = check "S4nancompare13" (-1 = (compare (W Single.NaN) (W 0.f))) true
+ let _ = check "S4nancompare14" (-1 = (compare (W Single.NaN) (W -1.f))) true
+ let _ = check "S4nancompare15" (-1 = (compare (W Single.NaN) (W Single.NegativeInfinity))) true
+ let _ = check "S4nancompare16" (-1 = (compare (W Single.NaN) (W Single.PositiveInfinity))) true
+ let _ = check "S4nancompare17" (-1 = (compare (W Single.NaN) (W Single.MaxValue))) true
+ let _ = check "S4nancompare18" (-1 = (compare (W Single.NaN) (W Single.MinValue))) true
+
+module MoreStructuralEqHashCompareNaNChecks =
+ let test398275413() =
+ let floats = [1.0; 0.0; System.Double.NaN; System.Double.NegativeInfinity; System.Double.PositiveInfinity; nan] in
+ for x in floats do
+ for y in floats do
+ let xnan = System.Double.IsNaN(x) in
+ let ynan = System.Double.IsNaN(y) in
+ let test1 x y op b = if not b then (printfn "\n****failure on %A %s %A\n" x op y; reportFailure "unlabelled test") in
+ if (xnan && not(ynan)) || (ynan && not(xnan)) then (
+
+ let testEq x y =
+ test1 x y "=" ((x = y) = false);
+ test1 x y "<>" ((x <> y) = true) in
+ let testRel x y =
+ test1 x y "<" ((x < y) = false );
+ test1 x y ">" ((x > y) = false );
+ test1 x y ">=" ((x >= y) = false);
+ test1 x y "<=" ((x <= y) = false) in
+ testEq x y;
+ testEq [x] [y];
+ testEq [| x |] [| y |];
+ testEq (x,x) (y,y);
+ testEq (x,1) (y,1);
+ testEq (1,x) (1,y);
+
+ testRel x y;
+
+ testRel [x] [y];
+ testRel [| x |] [| y |];
+ testRel (x,x) (y,y);
+ testRel (x,1) (y,1);
+ testRel (1,x) (1,y);
+ );
+ if xnan && ynan then
+ test1 x y "compare" ((compare x y) = 0)
+ done
+ done
+
+ let _ = test398275413()
+
+ let test398275414() =
+ let floats = [1.0f; 0.0f; System.Single.NaN; System.Single.NegativeInfinity; System.Single.PositiveInfinity; nanf] in
+ for x in floats do
+ for y in floats do
+ let xnan = System.Single.IsNaN(x) in
+ let ynan = System.Single.IsNaN(y) in
+ let test1 x y op b = if not b then (printfn "\n****failure on %A %s %A\n" x op y; reportFailure "unlabelled test") in
+ if (xnan && not(ynan)) || (ynan && not(xnan)) then (
+
+ let testEq x y =
+ test1 x y "=" ((x = y) = false);
+ test1 x y "<>" ((x <> y) = true) in
+ let testRel x y =
+ test1 x y "<" ((x < y) = false );
+ test1 x y ">" ((x > y) = false );
+ test1 x y ">=" ((x >= y) = false);
+ test1 x y "<=" ((x <= y) = false) in
+ testEq x y;
+ testEq [x] [y];
+ testEq [| x |] [| y |];
+ testEq (x,x) (y,y);
+ testEq (x,1) (y,1);
+ testEq (1,x) (1,y);
+
+ testRel x y;
+
+ testRel [x] [y];
+ testRel [| x |] [| y |];
+ testRel (x,x) (y,y);
+ testRel (x,1) (y,1);
+ testRel (1,x) (1,y);
+ );
+ if xnan && ynan then
+ test1 x y "compare" ((compare x y) = 0)
+ done
+ done
+
+ let _ = test398275414()
+
+ type A<'a,'b> = {h : 'a ; w : 'b}
+ type C<'T> = {n : string ; s : 'T}
+ type D = {x : float ; y : float}
+ type D2 = {x2 : float32 ; y2 : float32}
+ exception E of float
+ exception E2 of float32
+ type F = | F of float
+ type F2 = | F2 of float32
+
+ // Test ER semantics for obj.Equals and PER semantics for (=)
+ let test398275415() =
+
+ let l1 = [nan; 1.0] in
+ let l2 = [nan; 1.0] in
+
+ let a1 = [|nan; 1.0|] in
+ let a2 = [|nan; 1.0|] in
+
+ let t1 = (nan, 1.0) in
+ let t2 = (nan, 1.0) in
+
+ let d1 = {x=1.0;y=nan} in
+ let d2 = {x=1.0;y=nan} in
+
+ let e1 = E nan in
+ let e2 = E nan in
+
+ let f1 = F nan in
+ let f2 = F nan in
+
+
+ let j1 : C> = {n="Foo" ; s={h=5.9 ; w=nan}} in
+ let j2 : C > = {n="Foo" ; s={h=5.9 ; w=nan}} in
+
+ let jT1 = ("Foo", {h=5.9 ; w=nan}) in
+ let jT2 = ("Foo", {h=5.9 ; w=nan}) in
+ let id x = x in
+
+ let testER x y f = if f(not(x.Equals(y))) then (printfn "\n****failure on %A %A\n" x y ; reportFailure "unlabelled test") in
+ let testPER x y f = if f((x = y)) then (printfn "\n****failure on %A %A\n" x y ; reportFailure "unlabelled test") in
+
+ testER l1 l2 id ;
+ testER l2 l1 id ;
+ testPER l1 l2 id ;
+ testPER l2 l1 id ;
+
+ testER a1 a2 not ;
+ testER a2 a1 not ;
+ testPER a1 a2 id ;
+ testPER a2 a1 id ;
+
+ testER t1 t2 id ;
+ testER t2 t1 id ;
+ testPER t1 t2 id ;
+ testPER t2 t1 id ;
+
+ testER j1 j2 id ;
+ testER j2 j1 id ;
+ testPER j1 j2 id ;
+ testPER j2 j1 id ;
+
+ testER jT1 jT2 id ;
+ testER jT2 jT1 id ;
+ testPER jT1 jT2 id ;
+ testPER jT2 jT1 id ;
+
+ testER d1 d2 id ;
+ testER d2 d1 id ;
+ testPER d1 d2 id ;
+ testPER d2 d1 id ;
+
+ testER e1 e2 id ;
+ testER e2 e1 id ;
+ testPER e1 e2 id ;
+ testPER e2 e1 id ;
+
+ testER f1 f2 id ;
+ testER f2 f1 id ;
+ testPER f1 f2 id ;
+ testPER f2 f1 id
+
+
+ let _ = test398275415()
+
+ // Test ER semantics for obj.Equals and PER semantics for (=)
+ let test398275416() =
+
+ let l1 = [nanf; 1.0f] in
+ let l2 = [nanf; 1.0f] in
+
+ let a1 = [|nanf; 1.0f|] in
+ let a2 = [|nanf; 1.0f|] in
+
+ let t1 = (nanf, 1.0f) in
+ let t2 = (nanf, 1.0f) in
+
+ let d1 = {x2=1.0f;y2=nanf} in
+ let d2 = {x2=1.0f;y2=nanf} in
+
+ let e1 = E2 nanf in
+ let e2 = E2 nanf in
+
+ let f1 = F2 nanf in
+ let f2 = F2 nanf in
+
+ let j1 : C > = {n="Foo" ; s={h=5.9f ; w=nanf}} in
+ let j2 : C > = {n="Foo" ; s={h=5.9f ; w=nanf}} in
+
+ let jT1 = ("Foo", {h=5.9f ; w=nanf}) in
+ let jT2 = ("Foo", {h=5.9f ; w=nanf}) in
+ let id x = x in
+
+ let testER x y f = if f(not(x.Equals(y))) then (printfn "\n****failure on %A %A\n" x y ; reportFailure "unlabelled test") in
+ let testPER x y f = if f((x = y)) then (printfn "\n****failure on %A %A\n" x y ; reportFailure "unlabelled test") in
+
+ testER l1 l2 id ;
+ testER l2 l1 id ;
+ testPER l1 l2 id ;
+ testPER l2 l1 id ;
+
+ testER a1 a2 not ;
+ testER a2 a1 not ;
+ testPER a1 a2 id ;
+ testPER a2 a1 id ;
+
+ testER t1 t2 id ;
+ testER t2 t1 id ;
+ testPER t1 t2 id ;
+ testPER t2 t1 id ;
+
+ testER j1 j2 id ;
+ testER j2 j1 id ;
+ testPER j1 j2 id ;
+ testPER j2 j1 id ;
+
+ testER jT1 jT2 id ;
+ testER jT2 jT1 id ;
+ testPER jT1 jT2 id ;
+ testPER jT2 jT1 id ;
+
+ testER d1 d2 id ;
+ testER d2 d1 id ;
+ testPER d1 d2 id ;
+ testPER d2 d1 id ;
+
+ testER e1 e2 id ;
+ testER e2 e1 id ;
+ testPER e1 e2 id ;
+ testPER e2 e1 id ;
+
+ testER f1 f2 id ;
+ testER f2 f1 id ;
+ testPER f1 f2 id ;
+ testPER f2 f1 id
+
+
+ let _ = test398275416()
+
+
+
+// This test tests basic behavior of IEquatable and IComparable augmentations
+module GenericComparisonAndEquality = begin
+ open System.Collections.Generic
+ open System
+
+ // over records and unions
+ []
+ type UnionTypeA =
+ | Foo of float
+ | Int of int
+ | Recursive of UnionTypeA
+
+ []
+ type RecordTypeA<'T> = {f1 : string ; f2 : 'T}
+
+ // IComparable
+ let _ =
+
+ let sl = SortedList,string>() in
+ sl.Add({f1="joj";f2=69.0},"prg") ;
+ sl.Add({f1="bri";f2=68.0},"prg") ;
+ sl.Add({f1="jom";f2=70.0},"prg") ;
+ sl.Add({f1="tmi";f2=75.0},"lde") ;
+
+ // add items to sl2 in a different order than sl1
+ let sl2 = SortedList,string>() in
+ sl2.Add({f1="jom";f2=70.0},"prg") ;
+ sl2.Add({f1="bri";f2=68.0},"prg") ;
+ sl2.Add({f1="joj";f2=69.0},"prg") ;
+ sl2.Add({f1="tmi";f2=75.0},"lde") ;
+
+ let sl3 = SortedList() in
+ sl3.Add(Foo(2.0), 0.0) ;
+ sl3.Add(Int(1), 1.0) ;
+ sl3.Add(Recursive(Foo(3.0)),2.0) ;
+
+ let sl4 = SortedList() in
+ sl4.Add(Foo(2.0), 0.0) ;
+ sl4.Add(Int(1), 1.0) ;
+ sl4.Add(Recursive(Foo(3.0)),2.0) ;
+
+
+ let l1 = List.ofSeq sl.Keys in
+ let l2 = List.ofSeq sl2.Keys in
+
+ let l3 = List.ofSeq sl3.Keys in
+ let l4 = List.ofSeq sl4.Keys in
+
+ check "d3wiojd32icr" (l1 = l2) true ;
+ check "d3wiojd32icu" (l3 = l4) true
+
+ // IEquatable