From 83d1961a0520c2aa898a9b7203793c7de8113163 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Wed, 22 May 2024 14:37:02 +0200 Subject: [PATCH 01/25] .NET 9preview4 --- .devcontainer/devcontainer.json | 2 +- global.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 8de3807c90d..c43b4df8ebd 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,7 @@ // For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at: { "name": "F#", - "image": "mcr.microsoft.com/dotnet/sdk:9.0.100-preview.3", + "image": "mcr.microsoft.com/dotnet/sdk:9.0.100-preview.4", "features": { "ghcr.io/devcontainers/features/common-utils:2.4.2": {}, "ghcr.io/devcontainers/features/git:1.2.0": {}, diff --git a/global.json b/global.json index 20baab986d0..61fc12c0e61 100644 --- a/global.json +++ b/global.json @@ -1,10 +1,10 @@ { "sdk": { - "version": "9.0.100-preview.3.24204.13", + "version": "9.0.100-preview.4.24267.66", "allowPrerelease": true }, "tools": { - "dotnet": "9.0.100-preview.3.24204.13", + "dotnet": "9.0.100-preview.4.24267.66", "vs": { "version": "17.8", "components": [ From bdeb6e25a7fb723fae91b45570a8693d516fdc37 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Wed, 22 May 2024 14:57:12 +0200 Subject: [PATCH 02/25] New macos + udpated prebuilts --- azure-pipelines-PR.yml | 4 ++-- eng/SourceBuildPrebuiltBaseline.xml | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/azure-pipelines-PR.yml b/azure-pipelines-PR.yml index be8dc94eca5..d791b78bdc0 100644 --- a/azure-pipelines-PR.yml +++ b/azure-pipelines-PR.yml @@ -507,7 +507,7 @@ stages: # MacOS - job: MacOS pool: - vmImage: macos-11 + vmImage: macos-13 variables: - name: _SignType value: Test @@ -642,7 +642,7 @@ stages: # Plain FCS build Mac - job: Plain_Build_MacOS pool: - vmImage: macos-11 + vmImage: macos-13 variables: - name: _BuildConfig value: Debug diff --git a/eng/SourceBuildPrebuiltBaseline.xml b/eng/SourceBuildPrebuiltBaseline.xml index bd4b7f794d0..fc4044d9b05 100644 --- a/eng/SourceBuildPrebuiltBaseline.xml +++ b/eng/SourceBuildPrebuiltBaseline.xml @@ -9,16 +9,16 @@ These will go away when repo updates targeting to net8.0 Tracked with https://github.com/dotnet/fsharp/issues/14765 --> - - - + + + - - - + + + From 8796001ed32ba71af73cdacabc8ffddc6b80e6d0 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Tue, 18 Jun 2024 15:29:03 +0200 Subject: [PATCH 03/25] p5 + some tests fixes --- .devcontainer/devcontainer.json | 6 +- global.json | 4 +- .../FSharp.Core/OperatorsModuleDynamic.fs | 59 +++++++++++++++---- 3 files changed, 52 insertions(+), 17 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index c43b4df8ebd..03b4cb55daf 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,12 +1,12 @@ // For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at: { "name": "F#", - "image": "mcr.microsoft.com/dotnet/sdk:9.0.100-preview.4", + "image": "mcr.microsoft.com/dotnet/sdk:9.0.100-preview.5", "features": { - "ghcr.io/devcontainers/features/common-utils:2.4.2": {}, + "ghcr.io/devcontainers/features/common-utils:2.4.3": {}, "ghcr.io/devcontainers/features/git:1.2.0": {}, "ghcr.io/devcontainers/features/github-cli:1.0.11": {}, - "ghcr.io/devcontainers/features/dotnet:2.0.5": {} + "ghcr.io/devcontainers/features/dotnet:2.1.0": {} }, "hostRequirements": { "cpus": 2, diff --git a/global.json b/global.json index 61fc12c0e61..06a22c02553 100644 --- a/global.json +++ b/global.json @@ -1,10 +1,10 @@ { "sdk": { - "version": "9.0.100-preview.4.24267.66", + "version": "9.0.100-preview.5.24307.3", "allowPrerelease": true }, "tools": { - "dotnet": "9.0.100-preview.4.24267.66", + "dotnet": "9.0.100-preview.5.24307.3", "vs": { "version": "17.8", "components": [ diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs index 9af581dca52..7aa1ff09193 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs @@ -94,7 +94,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.byte Single.MaxValue - Assert.AreEqual(0uy, result) + if not Info.isNetFramework then + Assert.AreEqual(255uy, result) + else + Assert.AreEqual(0uy, result) // Overflow let result = Operators.byte Double.MinValue @@ -135,7 +138,12 @@ module OperatorsModuleDynamic = // Overflow Assert.AreEqual('\000', Operators.char Single.MinValue) Assert.AreEqual('\000', Operators.char Double.MinValue) - Assert.AreEqual('\000', Operators.char Single.MaxValue) + + if not Info.isNetFramework then + Assert.AreEqual('\uffff', Operators.char Single.MaxValue) + else + Assert.AreEqual('\000', Operators.char Single.MaxValue) + Assert.AreEqual('\000', Operators.char Double.MaxValue) CheckThrowsOverflowException(fun () -> Operators.char Decimal.MinValue |> ignore) @@ -286,7 +294,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int16 Single.MaxValue - Assert.AreEqual(0s, result) + if not Info.isNetFramework then + Assert.AreEqual(-1s, result) + else + Assert.AreEqual(0s, result) // Overflow let result = Operators.int16 Single.MinValue @@ -338,7 +349,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int32 Single.MaxValue - Assert.AreEqual(Int32.MinValue, result) + if not Info.isNetFramework then + Assert.AreEqual(Int32.MaxValue, result) + else + Assert.AreEqual(Int32.MinValue, result) // Overflow let result = Operators.int32 Single.MinValue @@ -391,7 +405,10 @@ module OperatorsModuleDynamic = // Overflow. let result = Operators.int64 Single.MaxValue - Assert.AreEqual(Int64.MinValue, result) + if not Info.isNetFramework then + Assert.AreEqual(Int64.MaxValue, result) + else + Assert.AreEqual(Int64.MinValue, result) // Overflow let result = Operators.int64 Single.MinValue @@ -444,8 +461,11 @@ module OperatorsModuleDynamic = if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 - Assert.AreEqual(-9223372036854775807n - 1n, result) + if not Info.isNetFramework then + Assert.AreEqual(9223372036854775807n, result) + else + // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual(-9223372036854775807n - 1n, result) // Overflow (depends on pointer size) let result = Operators.nativeint Single.MinValue @@ -544,7 +564,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.sbyte Single.MaxValue - Assert.AreEqual(0y, result) + if not Info.isNetFramework then + Assert.AreEqual(-1y, result) + else + Assert.AreEqual(0y, result) // Overflow let result = Operators.sbyte Double.MinValue @@ -596,7 +619,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint16 Single.MaxValue - Assert.AreEqual(0us, result) + if not Info.isNetFramework then + Assert.AreEqual(65535us, result) + else + Assert.AreEqual(0us, result) // Overflow let result = Operators.uint16 Single.MinValue @@ -629,7 +655,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint32 Single.MaxValue - Assert.AreEqual(0u, result) + if not Info.isNetFramework then + Assert.AreEqual(4294967295u, result) + else + Assert.AreEqual(0u, result) // Overflow let result = Operators.uint32 Single.MinValue @@ -679,7 +708,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint64 Single.MaxValue - Assert.AreEqual(0UL, result) + if not Info.isNetFramework then + Assert.AreEqual(18446744073709551615UL, result) + else + Assert.AreEqual(0UL, result) // Overflow let result = Operators.uint64 Single.MinValue @@ -721,7 +753,10 @@ module OperatorsModuleDynamic = // Overflow Single.MaxValue is equal on 32 bits and 64 bits runtimes let result = Operators.unativeint Single.MaxValue - Assert.AreEqual(0un, result) + if not Info.isNetFramework then + Assert.AreEqual(18446744073709551615un, result) + else + Assert.AreEqual(0un, result) // Overflow (depends on pointer size) let result = Operators.unativeint Single.MinValue From 6be852bb1152e52ac049f3a1548432c02dbc2320 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Tue, 18 Jun 2024 15:31:33 +0200 Subject: [PATCH 04/25] Update SourceBuildPrebuiltBaseline.xml --- eng/SourceBuildPrebuiltBaseline.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/eng/SourceBuildPrebuiltBaseline.xml b/eng/SourceBuildPrebuiltBaseline.xml index fc4044d9b05..c14c248d78a 100644 --- a/eng/SourceBuildPrebuiltBaseline.xml +++ b/eng/SourceBuildPrebuiltBaseline.xml @@ -9,16 +9,16 @@ These will go away when repo updates targeting to net8.0 Tracked with https://github.com/dotnet/fsharp/issues/14765 --> - - - + + + - - - + + + From f51e157211c052bb21beb4b01c2a4d2d4440ace0 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Wed, 19 Jun 2024 13:29:33 +0200 Subject: [PATCH 05/25] fix --- eng/Build.ps1 | 1 + eng/build.sh | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/eng/Build.ps1 b/eng/Build.ps1 index 104353203df..1bee9140d79 100644 --- a/eng/Build.ps1 +++ b/eng/Build.ps1 @@ -391,6 +391,7 @@ function TestUsingMSBuild([string] $testProject, [string] $targetFramework, [str } } +# TODO: These two has 0 differences, shold be merged, as it just causes confusion, we don't care much about the underlying runner function TestUsingXUnit([string] $testProject, [string] $targetFramework, [string]$testadapterpath, [boolean] $asBackgroundJob = $false) { TestUsingMsBuild -testProject $testProject -targetFramework $targetFramework -testadapterpath $testadapterpath -noTestFilter $true -asBackgroundJob $asBackgroundJob } diff --git a/eng/build.sh b/eng/build.sh index e0a3348bfdb..c00feeb3bae 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -325,9 +325,9 @@ BuildSolution if [[ "$test_core_clr" == true ]]; then coreclrtestframework=$tfm TestUsingNUnit --testproject "$repo_root/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj" --targetframework $coreclrtestframework --notestfilter - TestUsingXUnit --testproject "$repo_root/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj" --targetframework $coreclrtestframework --notestfilter + TestUsingNUnit --testproject "$repo_root/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj" --targetframework $coreclrtestframework --notestfilter TestUsingNUnit --testproject "$repo_root/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharp.Compiler.Private.Scripting.UnitTests.fsproj" --targetframework $coreclrtestframework - TestUsingXUnit --testproject "$repo_root/tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj" --targetframework $coreclrtestframework + TestUsingNUnit --testproject "$repo_root/tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj" --targetframework $coreclrtestframework TestUsingNUnit --testproject "$repo_root/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj" --targetframework $coreclrtestframework fi From 8827f19236d0d7281aff09636b6c803e0ad11bfc Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Wed, 19 Jun 2024 13:36:39 +0200 Subject: [PATCH 06/25] Don't use msbuild output --- eng/Build.ps1 | 2 +- eng/build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/Build.ps1 b/eng/Build.ps1 index 1bee9140d79..7bfe11313cc 100644 --- a/eng/Build.ps1 +++ b/eng/Build.ps1 @@ -361,7 +361,7 @@ function TestUsingMSBuild([string] $testProject, [string] $targetFramework, [str $testLogPath = "$ArtifactsDir\TestResults\$configuration\${projectName}_$targetFramework.xml" $testBinLogPath = "$LogDir\${projectName}_$targetFramework.binlog" $args = "test $testProject -c $configuration -f $targetFramework -v n --test-adapter-path $testadapterpath --logger ""nunit;LogFilePath=$testLogPath"" /bl:$testBinLogPath" - $args += " --blame --results-directory $ArtifactsDir\TestResults\$configuration" + $args += " --blame --results-directory $ArtifactsDir\TestResults\$configuration -p:vstestusemsbuildoutput=false" if (-not $noVisualStudio -or $norestore) { $args += " --no-restore" diff --git a/eng/build.sh b/eng/build.sh index c00feeb3bae..24b499d538f 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -219,7 +219,7 @@ function TestUsingNUnit() { projectname=$(basename -- "$testproject") projectname="${projectname%.*}" testlogpath="$artifacts_dir/TestResults/$configuration/${projectname}_$targetframework.xml" - args="test \"$testproject\" --no-restore --no-build -c $configuration -f $targetframework --test-adapter-path . --logger \"nunit;LogFilePath=$testlogpath\"$filterArgs --blame --results-directory $artifacts_dir/TestResults/$configuration" + args="test \"$testproject\" --no-restore --no-build -c $configuration -f $targetframework --test-adapter-path . --logger \"nunit;LogFilePath=$testlogpath\"$filterArgs --blame --results-directory $artifacts_dir/TestResults/$configuration -p:vstestusemsbuildoutput=false" "$DOTNET_INSTALL_DIR/dotnet" $args || exit $? } From 93afd241060c25f26314361eaf4566bc9273f716 Mon Sep 17 00:00:00 2001 From: psfinaki Date: Fri, 21 Jun 2024 19:25:54 +0200 Subject: [PATCH 07/25] Update OperatorsModuleDynamic.fs --- .../FSharp.Core/OperatorsModuleDynamic.fs | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs index 7aa1ff09193..fa6389b907f 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs @@ -7,6 +7,10 @@ namespace FSharp.Core.UnitTests.Operators open System open Xunit +// For information on the runtime-dependent behavior differences in this file, see: +// - https://github.com/dotnet/runtime/issues/61885 +// - https://github.com/dotnet/runtime/pull/97529 + #nowarn "1204" // CompilerMessage: This function is for use by dynamic invocations of F# code and should not be used directly module OperatorsModuleDynamic = @@ -94,7 +98,7 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.byte Single.MaxValue - if not Info.isNetFramework then + if Info.isNetFramework then Assert.AreEqual(255uy, result) else Assert.AreEqual(0uy, result) @@ -139,7 +143,7 @@ module OperatorsModuleDynamic = Assert.AreEqual('\000', Operators.char Single.MinValue) Assert.AreEqual('\000', Operators.char Double.MinValue) - if not Info.isNetFramework then + if Info.isNetFramework then Assert.AreEqual('\uffff', Operators.char Single.MaxValue) else Assert.AreEqual('\000', Operators.char Single.MaxValue) @@ -294,7 +298,7 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int16 Single.MaxValue - if not Info.isNetFramework then + if Info.isNetFramework then Assert.AreEqual(-1s, result) else Assert.AreEqual(0s, result) @@ -349,7 +353,7 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int32 Single.MaxValue - if not Info.isNetFramework then + if Info.isNetFramework then Assert.AreEqual(Int32.MaxValue, result) else Assert.AreEqual(Int32.MinValue, result) @@ -405,7 +409,7 @@ module OperatorsModuleDynamic = // Overflow. let result = Operators.int64 Single.MaxValue - if not Info.isNetFramework then + if Info.isNetFramework then Assert.AreEqual(Int64.MaxValue, result) else Assert.AreEqual(Int64.MinValue, result) @@ -461,7 +465,7 @@ module OperatorsModuleDynamic = if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - if not Info.isNetFramework then + if Info.isNetFramework then Assert.AreEqual(9223372036854775807n, result) else // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 @@ -564,7 +568,7 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.sbyte Single.MaxValue - if not Info.isNetFramework then + if Info.isNetFramework then Assert.AreEqual(-1y, result) else Assert.AreEqual(0y, result) @@ -619,7 +623,7 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint16 Single.MaxValue - if not Info.isNetFramework then + if Info.isNetFramework then Assert.AreEqual(65535us, result) else Assert.AreEqual(0us, result) @@ -655,7 +659,7 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint32 Single.MaxValue - if not Info.isNetFramework then + if Info.isNetFramework then Assert.AreEqual(4294967295u, result) else Assert.AreEqual(0u, result) @@ -708,7 +712,7 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint64 Single.MaxValue - if not Info.isNetFramework then + if Info.isNetFramework then Assert.AreEqual(18446744073709551615UL, result) else Assert.AreEqual(0UL, result) @@ -753,7 +757,7 @@ module OperatorsModuleDynamic = // Overflow Single.MaxValue is equal on 32 bits and 64 bits runtimes let result = Operators.unativeint Single.MaxValue - if not Info.isNetFramework then + if Info.isNetFramework then Assert.AreEqual(18446744073709551615un, result) else Assert.AreEqual(0un, result) From 54117e13709880c62b32641437eb727c7fd28125 Mon Sep 17 00:00:00 2001 From: psfinaki Date: Fri, 21 Jun 2024 19:28:54 +0200 Subject: [PATCH 08/25] reverting this, will be fixed separately --- eng/Build.ps1 | 1 - eng/build.sh | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/eng/Build.ps1 b/eng/Build.ps1 index 7bfe11313cc..4fdae65bafc 100644 --- a/eng/Build.ps1 +++ b/eng/Build.ps1 @@ -391,7 +391,6 @@ function TestUsingMSBuild([string] $testProject, [string] $targetFramework, [str } } -# TODO: These two has 0 differences, shold be merged, as it just causes confusion, we don't care much about the underlying runner function TestUsingXUnit([string] $testProject, [string] $targetFramework, [string]$testadapterpath, [boolean] $asBackgroundJob = $false) { TestUsingMsBuild -testProject $testProject -targetFramework $targetFramework -testadapterpath $testadapterpath -noTestFilter $true -asBackgroundJob $asBackgroundJob } diff --git a/eng/build.sh b/eng/build.sh index 24b499d538f..29eb3ab1f62 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -325,9 +325,9 @@ BuildSolution if [[ "$test_core_clr" == true ]]; then coreclrtestframework=$tfm TestUsingNUnit --testproject "$repo_root/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj" --targetframework $coreclrtestframework --notestfilter - TestUsingNUnit --testproject "$repo_root/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj" --targetframework $coreclrtestframework --notestfilter + TestUsingXUnit --testproject "$repo_root/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj" --targetframework $coreclrtestframework --notestfilter TestUsingNUnit --testproject "$repo_root/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharp.Compiler.Private.Scripting.UnitTests.fsproj" --targetframework $coreclrtestframework - TestUsingNUnit --testproject "$repo_root/tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj" --targetframework $coreclrtestframework + TestUsingXUnit --testproject "$repo_root/tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj" --targetframework $coreclrtestframework TestUsingNUnit --testproject "$repo_root/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj" --targetframework $coreclrtestframework fi From c8056fbba4422f7f539c5d03922f38a20e2ca571 Mon Sep 17 00:00:00 2001 From: psfinaki Date: Fri, 21 Jun 2024 20:43:03 +0200 Subject: [PATCH 09/25] up --- .../FSharp.Core/OperatorsModuleDynamic.fs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs index fa6389b907f..05291895c6e 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs @@ -98,7 +98,7 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.byte Single.MaxValue - if Info.isNetFramework then + if not Info.isNetFramework then Assert.AreEqual(255uy, result) else Assert.AreEqual(0uy, result) @@ -143,7 +143,7 @@ module OperatorsModuleDynamic = Assert.AreEqual('\000', Operators.char Single.MinValue) Assert.AreEqual('\000', Operators.char Double.MinValue) - if Info.isNetFramework then + if not Info.isNetFramework then Assert.AreEqual('\uffff', Operators.char Single.MaxValue) else Assert.AreEqual('\000', Operators.char Single.MaxValue) @@ -298,7 +298,7 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int16 Single.MaxValue - if Info.isNetFramework then + if not Info.isNetFramework then Assert.AreEqual(-1s, result) else Assert.AreEqual(0s, result) @@ -353,7 +353,7 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int32 Single.MaxValue - if Info.isNetFramework then + if not Info.isNetFramework then Assert.AreEqual(Int32.MaxValue, result) else Assert.AreEqual(Int32.MinValue, result) @@ -409,7 +409,7 @@ module OperatorsModuleDynamic = // Overflow. let result = Operators.int64 Single.MaxValue - if Info.isNetFramework then + if not Info.isNetFramework then Assert.AreEqual(Int64.MaxValue, result) else Assert.AreEqual(Int64.MinValue, result) @@ -465,7 +465,7 @@ module OperatorsModuleDynamic = if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - if Info.isNetFramework then + if not Info.isNetFramework then Assert.AreEqual(9223372036854775807n, result) else // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 @@ -568,7 +568,7 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.sbyte Single.MaxValue - if Info.isNetFramework then + if not Info.isNetFramework then Assert.AreEqual(-1y, result) else Assert.AreEqual(0y, result) @@ -623,7 +623,7 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint16 Single.MaxValue - if Info.isNetFramework then + if not Info.isNetFramework then Assert.AreEqual(65535us, result) else Assert.AreEqual(0us, result) @@ -659,7 +659,7 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint32 Single.MaxValue - if Info.isNetFramework then + if not Info.isNetFramework then Assert.AreEqual(4294967295u, result) else Assert.AreEqual(0u, result) @@ -712,7 +712,7 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint64 Single.MaxValue - if Info.isNetFramework then + if not Info.isNetFramework then Assert.AreEqual(18446744073709551615UL, result) else Assert.AreEqual(0UL, result) @@ -757,7 +757,7 @@ module OperatorsModuleDynamic = // Overflow Single.MaxValue is equal on 32 bits and 64 bits runtimes let result = Operators.unativeint Single.MaxValue - if Info.isNetFramework then + if not Info.isNetFramework then Assert.AreEqual(18446744073709551615un, result) else Assert.AreEqual(0un, result) From fc20f9e4565b82485b10fd6812fa327788d80bc4 Mon Sep 17 00:00:00 2001 From: psfinaki Date: Mon, 24 Jun 2024 13:47:33 +0200 Subject: [PATCH 10/25] Update OperatorsModuleDynamic.fs --- .../FSharp.Core/OperatorsModuleDynamic.fs | 57 ++++--------------- 1 file changed, 12 insertions(+), 45 deletions(-) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs index 05291895c6e..5696f41193f 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs @@ -98,10 +98,7 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.byte Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(255uy, result) - else - Assert.AreEqual(0uy, result) + Assert.AreEqual(0uy, result) // Overflow let result = Operators.byte Double.MinValue @@ -143,10 +140,7 @@ module OperatorsModuleDynamic = Assert.AreEqual('\000', Operators.char Single.MinValue) Assert.AreEqual('\000', Operators.char Double.MinValue) - if not Info.isNetFramework then - Assert.AreEqual('\uffff', Operators.char Single.MaxValue) - else - Assert.AreEqual('\000', Operators.char Single.MaxValue) + Assert.AreEqual('\000', Operators.char Single.MaxValue) Assert.AreEqual('\000', Operators.char Double.MaxValue) CheckThrowsOverflowException(fun () -> Operators.char Decimal.MinValue |> ignore) @@ -298,10 +292,7 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int16 Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(-1s, result) - else - Assert.AreEqual(0s, result) + Assert.AreEqual(0s, result) // Overflow let result = Operators.int16 Single.MinValue @@ -353,10 +344,7 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int32 Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(Int32.MaxValue, result) - else - Assert.AreEqual(Int32.MinValue, result) + Assert.AreEqual(Int32.MinValue, result) // Overflow let result = Operators.int32 Single.MinValue @@ -409,10 +397,7 @@ module OperatorsModuleDynamic = // Overflow. let result = Operators.int64 Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(Int64.MaxValue, result) - else - Assert.AreEqual(Int64.MinValue, result) + Assert.AreEqual(Int64.MinValue, result) // Overflow let result = Operators.int64 Single.MinValue @@ -465,11 +450,8 @@ module OperatorsModuleDynamic = if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - if not Info.isNetFramework then - Assert.AreEqual(9223372036854775807n, result) - else - // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 - Assert.AreEqual(-9223372036854775807n - 1n, result) + // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual(-9223372036854775807n - 1n, result) // Overflow (depends on pointer size) let result = Operators.nativeint Single.MinValue @@ -568,10 +550,7 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.sbyte Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(-1y, result) - else - Assert.AreEqual(0y, result) + Assert.AreEqual(0y, result) // Overflow let result = Operators.sbyte Double.MinValue @@ -623,10 +602,7 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint16 Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(65535us, result) - else - Assert.AreEqual(0us, result) + Assert.AreEqual(0us, result) // Overflow let result = Operators.uint16 Single.MinValue @@ -659,10 +635,7 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint32 Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(4294967295u, result) - else - Assert.AreEqual(0u, result) + Assert.AreEqual(0u, result) // Overflow let result = Operators.uint32 Single.MinValue @@ -712,10 +685,7 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint64 Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(18446744073709551615UL, result) - else - Assert.AreEqual(0UL, result) + Assert.AreEqual(0UL, result) // Overflow let result = Operators.uint64 Single.MinValue @@ -757,10 +727,7 @@ module OperatorsModuleDynamic = // Overflow Single.MaxValue is equal on 32 bits and 64 bits runtimes let result = Operators.unativeint Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(18446744073709551615un, result) - else - Assert.AreEqual(0un, result) + Assert.AreEqual(0un, result) // Overflow (depends on pointer size) let result = Operators.unativeint Single.MinValue From c1455b22a4cdb77e47cd92a809df4ffb5e128880 Mon Sep 17 00:00:00 2001 From: psfinaki Date: Mon, 24 Jun 2024 14:24:50 +0200 Subject: [PATCH 11/25] Revert "Update OperatorsModuleDynamic.fs" This reverts commit fc20f9e4565b82485b10fd6812fa327788d80bc4. --- .../FSharp.Core/OperatorsModuleDynamic.fs | 57 +++++++++++++++---- 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs index 5696f41193f..05291895c6e 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs @@ -98,7 +98,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.byte Single.MaxValue - Assert.AreEqual(0uy, result) + if not Info.isNetFramework then + Assert.AreEqual(255uy, result) + else + Assert.AreEqual(0uy, result) // Overflow let result = Operators.byte Double.MinValue @@ -140,7 +143,10 @@ module OperatorsModuleDynamic = Assert.AreEqual('\000', Operators.char Single.MinValue) Assert.AreEqual('\000', Operators.char Double.MinValue) - Assert.AreEqual('\000', Operators.char Single.MaxValue) + if not Info.isNetFramework then + Assert.AreEqual('\uffff', Operators.char Single.MaxValue) + else + Assert.AreEqual('\000', Operators.char Single.MaxValue) Assert.AreEqual('\000', Operators.char Double.MaxValue) CheckThrowsOverflowException(fun () -> Operators.char Decimal.MinValue |> ignore) @@ -292,7 +298,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int16 Single.MaxValue - Assert.AreEqual(0s, result) + if not Info.isNetFramework then + Assert.AreEqual(-1s, result) + else + Assert.AreEqual(0s, result) // Overflow let result = Operators.int16 Single.MinValue @@ -344,7 +353,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int32 Single.MaxValue - Assert.AreEqual(Int32.MinValue, result) + if not Info.isNetFramework then + Assert.AreEqual(Int32.MaxValue, result) + else + Assert.AreEqual(Int32.MinValue, result) // Overflow let result = Operators.int32 Single.MinValue @@ -397,7 +409,10 @@ module OperatorsModuleDynamic = // Overflow. let result = Operators.int64 Single.MaxValue - Assert.AreEqual(Int64.MinValue, result) + if not Info.isNetFramework then + Assert.AreEqual(Int64.MaxValue, result) + else + Assert.AreEqual(Int64.MinValue, result) // Overflow let result = Operators.int64 Single.MinValue @@ -450,8 +465,11 @@ module OperatorsModuleDynamic = if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 - Assert.AreEqual(-9223372036854775807n - 1n, result) + if not Info.isNetFramework then + Assert.AreEqual(9223372036854775807n, result) + else + // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual(-9223372036854775807n - 1n, result) // Overflow (depends on pointer size) let result = Operators.nativeint Single.MinValue @@ -550,7 +568,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.sbyte Single.MaxValue - Assert.AreEqual(0y, result) + if not Info.isNetFramework then + Assert.AreEqual(-1y, result) + else + Assert.AreEqual(0y, result) // Overflow let result = Operators.sbyte Double.MinValue @@ -602,7 +623,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint16 Single.MaxValue - Assert.AreEqual(0us, result) + if not Info.isNetFramework then + Assert.AreEqual(65535us, result) + else + Assert.AreEqual(0us, result) // Overflow let result = Operators.uint16 Single.MinValue @@ -635,7 +659,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint32 Single.MaxValue - Assert.AreEqual(0u, result) + if not Info.isNetFramework then + Assert.AreEqual(4294967295u, result) + else + Assert.AreEqual(0u, result) // Overflow let result = Operators.uint32 Single.MinValue @@ -685,7 +712,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint64 Single.MaxValue - Assert.AreEqual(0UL, result) + if not Info.isNetFramework then + Assert.AreEqual(18446744073709551615UL, result) + else + Assert.AreEqual(0UL, result) // Overflow let result = Operators.uint64 Single.MinValue @@ -727,7 +757,10 @@ module OperatorsModuleDynamic = // Overflow Single.MaxValue is equal on 32 bits and 64 bits runtimes let result = Operators.unativeint Single.MaxValue - Assert.AreEqual(0un, result) + if not Info.isNetFramework then + Assert.AreEqual(18446744073709551615un, result) + else + Assert.AreEqual(0un, result) // Overflow (depends on pointer size) let result = Operators.unativeint Single.MinValue From 5014bbf8311cca196c3783fec2ed9bff0305e23e Mon Sep 17 00:00:00 2001 From: psfinaki Date: Mon, 24 Jun 2024 14:42:04 +0200 Subject: [PATCH 12/25] Update OperatorsModuleDynamic.fs --- .../FSharp.Core/OperatorsModuleDynamic.fs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs index 05291895c6e..c602546da61 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs @@ -484,8 +484,11 @@ module OperatorsModuleDynamic = if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 - Assert.AreEqual(-9223372036854775807n - 1n, result) + if not Info.isNetFramework then + Assert.AreEqual(9223372036854775807n, result) + else + // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual(-9223372036854775807n - 1n, result) // Overflow (depends on pointer size) let result = Operators.nativeint Double.MinValue @@ -767,7 +770,10 @@ module OperatorsModuleDynamic = if Info.isX86Runtime then Assert.AreEqual(0un, result) else - Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 + if not Info.isNetFramework then + Assert.AreEqual(0un, result) + else + Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 // Overflow Double.MaxValue is equal on 32 bits and 64 bits runtimes let result = Operators.unativeint Double.MaxValue From 7b3cf55d2e168c1c61a7721e7c14f578d6efdc2b Mon Sep 17 00:00:00 2001 From: psfinaki Date: Mon, 24 Jun 2024 15:38:14 +0200 Subject: [PATCH 13/25] Update OperatorsModuleDynamic.fs --- .../FSharp.Core/OperatorsModuleDynamic.fs | 57 +++++++++++++++---- 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs index c602546da61..1a601364fb7 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs @@ -109,7 +109,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.byte Double.MaxValue - Assert.AreEqual(0uy, result) + if not Info.isNetFramework then + Assert.AreEqual(255uy, result) + else + Assert.AreEqual(0uy, result) // Overflow let result = Operators.byte (Int64.MaxValue * 8L) @@ -148,7 +151,10 @@ module OperatorsModuleDynamic = else Assert.AreEqual('\000', Operators.char Single.MaxValue) - Assert.AreEqual('\000', Operators.char Double.MaxValue) + if not Info.isNetFramework then + Assert.AreEqual('\uffff', Operators.char Double.MaxValue) + else + Assert.AreEqual('\000', Operators.char Double.MaxValue) CheckThrowsOverflowException(fun () -> Operators.char Decimal.MinValue |> ignore) // string type @@ -245,7 +251,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int Single.MaxValue - Assert.AreEqual(Int32.MinValue, result) + if not Info.isNetFramework then + Assert.AreEqual(Int32.MaxValue, result) + else + Assert.AreEqual(Int32.MinValue, result) // Overflow let result = Operators.int Single.MinValue @@ -309,7 +318,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int16 Double.MaxValue - Assert.AreEqual(0s, result) + if not Info.isNetFramework then + Assert.AreEqual(-1s, result) + else + Assert.AreEqual(0s, result) // Overflow let result = Operators.int16 Double.MinValue @@ -364,7 +376,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int32 Double.MaxValue - Assert.AreEqual(Int32.MinValue, result) + if not Info.isNetFramework then + Assert.AreEqual(Int32.MaxValue, result) + else + Assert.AreEqual(Int32.MinValue, result) // Overflow let result = Operators.int32 Double.MinValue @@ -420,7 +435,10 @@ module OperatorsModuleDynamic = // Overflow. let result = Operators.int64 Double.MaxValue - Assert.AreEqual(Int64.MinValue, result) + if not Info.isNetFramework then + Assert.AreEqual(Int64.MaxValue, result) + else + Assert.AreEqual(Int64.MinValue, result) // Overflow let result = Operators.int64 Double.MinValue @@ -519,8 +537,11 @@ module OperatorsModuleDynamic = if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 - Assert.AreEqual("-9223372036854775808", string result) + if not Info.isNetFramework then + Assert.AreEqual("9223372036854775807", result) + else + // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual("-9223372036854775808", string result) let result = Operators.nativeint System.Double.MinValue if Info.isX86Runtime then @@ -582,7 +603,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.sbyte Double.MaxValue - Assert.AreEqual(0y, result) + if not Info.isNetFramework then + Assert.AreEqual(-1y, result) + else + Assert.AreEqual(0y, result) // Overflow let result = Operators.sbyte (Int64.MaxValue * 8L) @@ -637,7 +661,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint16 Double.MaxValue - Assert.AreEqual(0us, result) + if not Info.isNetFramework then + Assert.AreEqual(65535us, result) + else + Assert.AreEqual(0us, result) // Overflow let result = Operators.uint16 Double.MinValue @@ -673,7 +700,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint32 Double.MaxValue - Assert.AreEqual(0u, result) + if not Info.isNetFramework then + Assert.AreEqual(4294967295u, result) + else + Assert.AreEqual(0u, result) // Overflow let result = Operators.uint32 Double.MinValue @@ -722,7 +752,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint64 Single.MinValue - Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 + if not Info.isNetFramework then + Assert.AreEqual(0UL, result) + else + Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 // Overflow let result = Operators.uint64 Double.MaxValue From cfa359bf054ea9f7c62c858228f9cd3e3bc55114 Mon Sep 17 00:00:00 2001 From: psfinaki Date: Mon, 24 Jun 2024 16:25:17 +0200 Subject: [PATCH 14/25] up --- .../FSharp.Core/OperatorsModuleDynamic.fs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs index 1a601364fb7..0020f389d1a 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs @@ -262,7 +262,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int Double.MaxValue - Assert.AreEqual(Int32.MinValue, result) + if not Info.isNetFramework then + Assert.AreEqual(Int32.MaxValue, result) + else + Assert.AreEqual(Int32.MinValue, result) // Overflow let result = Operators.int Double.MinValue @@ -538,7 +541,7 @@ module OperatorsModuleDynamic = Assert.AreEqual(-2147483648n, result) else if not Info.isNetFramework then - Assert.AreEqual("9223372036854775807", result) + Assert.AreEqual(9223372036854775807n, result) else // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 Assert.AreEqual("-9223372036854775808", string result) @@ -759,7 +762,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint64 Double.MaxValue - Assert.AreEqual(0UL, result) + if not Info.isNetFramework then + Assert.AreEqual(18446744073709551615UL, result) + else + Assert.AreEqual(0UL, result) // Overflow let result = Operators.uint64 Double.MinValue @@ -810,7 +816,10 @@ module OperatorsModuleDynamic = // Overflow Double.MaxValue is equal on 32 bits and 64 bits runtimes let result = Operators.unativeint Double.MaxValue - Assert.AreEqual(0un, result) + if not Info.isNetFramework then + Assert.AreEqual(18446744073709551615un, result) + else + Assert.AreEqual(0un, result) // Overflow (depends on pointer size) let result = Operators.unativeint Double.MinValue From 8df899f736ebd25aab124d46ed3e562c3113edfb Mon Sep 17 00:00:00 2001 From: psfinaki Date: Mon, 24 Jun 2024 16:31:04 +0200 Subject: [PATCH 15/25] Update OperatorsModule1.fs --- .../FSharp.Core/OperatorsModule1.fs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs index a7672d9925f..661515436c9 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs @@ -281,7 +281,10 @@ type OperatorsModule1() = // Overflow let result = Operators.byte Single.MaxValue - Assert.AreEqual(0uy, result) + if not Info.isNetFramework then + Assert.AreEqual(255uy, result) + else + Assert.AreEqual(0uy, result) // Overflow let result = Operators.byte Double.MinValue @@ -344,7 +347,10 @@ type OperatorsModule1() = // Overflow Assert.AreEqual('\000', Operators.char Single.MinValue) Assert.AreEqual('\000', Operators.char Double.MinValue) - Assert.AreEqual('\000', Operators.char Single.MaxValue) + if not Info.isNetFramework then + Assert.AreEqual('\uffff', Operators.char Single.MaxValue) + else + Assert.AreEqual('\000', Operators.char Single.MaxValue) Assert.AreEqual('\000', Operators.char Double.MaxValue) CheckThrowsOverflowException(fun () -> Operators.char Decimal.MinValue |> ignore) From 2d75326a18cceb80b3e646d8a98bb6ec658d2918 Mon Sep 17 00:00:00 2001 From: psfinaki Date: Mon, 24 Jun 2024 16:57:17 +0200 Subject: [PATCH 16/25] Update OperatorsModule2.fs --- .../FSharp.Core/OperatorsModule2.fs | 52 +++++++++++++++---- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs index d4197529ea6..b71997fa0a6 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs @@ -53,7 +53,10 @@ type OperatorsModule2() = // Overflow. let result = Operators.int Single.MaxValue - Assert.AreEqual(Int32.MinValue, result) + if not Info.isNetFramework then + Assert.AreEqual(2147483647, result) + else + Assert.AreEqual(Int32.MinValue, result) // Overflow let result = Operators.int Single.MinValue @@ -106,7 +109,10 @@ type OperatorsModule2() = // Overflow. let result = Operators.int16 Single.MaxValue - Assert.AreEqual(0s, result) + if not Info.isNetFramework then + Assert.AreEqual(-1s, result) + else + Assert.AreEqual(0s, result) // Overflow let result = Operators.int16 Single.MinValue @@ -158,7 +164,10 @@ type OperatorsModule2() = // Overflow. let result = Operators.int32 Single.MaxValue - Assert.AreEqual(Int32.MinValue, result) + if not Info.isNetFramework then + Assert.AreEqual(2147483647, result) + else + Assert.AreEqual(Int32.MinValue, result) // Overflow let result = Operators.int32 Single.MinValue @@ -211,7 +220,10 @@ type OperatorsModule2() = // Overflow. let result = Operators.int64 Single.MaxValue - Assert.AreEqual(Int64.MinValue, result) + if not Info.isNetFramework then + Assert.AreEqual(9223372036854775807L, result) + else + Assert.AreEqual(Int64.MinValue, result) // Overflow let result = Operators.int64 Single.MinValue @@ -365,8 +377,11 @@ type OperatorsModule2() = if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 - Assert.AreEqual(-9223372036854775807n - 1n, result) + if not Info.isNetFramework then + Assert.AreEqual(9223372036854775807n, result) + else + // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual(-9223372036854775807n - 1n, result) // Overflow (depends on pointer size) let result = Operators.nativeint Single.MinValue @@ -596,7 +611,10 @@ type OperatorsModule2() = // Overflow let result = Operators.sbyte Double.MaxValue - Assert.AreEqual(0y, result) + if not Info.isNetFramework then + Assert.AreEqual(-1y, result) + else + Assert.AreEqual(0y, result) // Overflow let result = Operators.sbyte (Int64.MaxValue * 8L) @@ -954,7 +972,10 @@ type OperatorsModule2() = // Overflow let result = Operators.uint16 Single.MaxValue - Assert.AreEqual(0us, result) + if not Info.isNetFramework then + Assert.AreEqual(65535us, result) + else + Assert.AreEqual(0us, result) // Overflow let result = Operators.uint16 Single.MinValue @@ -987,7 +1008,10 @@ type OperatorsModule2() = // Overflow let result = Operators.uint32 Single.MaxValue - Assert.AreEqual(0u, result) + if not Info.isNetFramework then + Assert.AreEqual(4294967295u, result) + else + Assert.AreEqual(0u, result) // Overflow let result = Operators.uint32 Single.MinValue @@ -1037,7 +1061,10 @@ type OperatorsModule2() = // Overflow let result = Operators.uint64 Single.MaxValue - Assert.AreEqual(0UL, result) + if not Info.isNetFramework then + Assert.AreEqual(18446744073709551615UL, result) + else + Assert.AreEqual(0UL, result) // Overflow let result = Operators.uint64 Single.MinValue @@ -1079,7 +1106,10 @@ type OperatorsModule2() = // Overflow Single.MaxValue is equal on 32 bits and 64 bits runtimes let result = Operators.unativeint Single.MaxValue - Assert.AreEqual(0un, result) + if not Info.isNetFramework then + Assert.AreEqual(18446744073709551615un, result) + else + Assert.AreEqual(0un, result) // Overflow (depends on pointer size) let result = Operators.unativeint Single.MinValue From 229ecfb75184126a5c3a7461b0180f84cc545d87 Mon Sep 17 00:00:00 2001 From: psfinaki Date: Mon, 24 Jun 2024 17:20:09 +0200 Subject: [PATCH 17/25] Update OperatorsModuleDynamic.fs --- .../FSharp.Core/OperatorsModuleDynamic.fs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs index 0020f389d1a..30542dc9420 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs @@ -769,7 +769,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint64 Double.MinValue - Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 + if not Info.isNetFramework then + Assert.AreEqual(0UL, result) + else + Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 // Overflow let result = Operators.uint64 Int64.MinValue @@ -826,7 +829,10 @@ module OperatorsModuleDynamic = if Info.isX86Runtime then Assert.AreEqual(0un, result) else - Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 + if not Info.isNetFramework then + Assert.AreEqual(0un, result) + else + Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 // Overflow (depends on pointer size) let result = Operators.unativeint Int64.MinValue From bdc26e991415bd75e6509035ef6f6dfbf493811f Mon Sep 17 00:00:00 2001 From: psfinaki Date: Mon, 24 Jun 2024 17:22:14 +0200 Subject: [PATCH 18/25] Update OperatorsModule1.fs --- .../FSharp.Core/OperatorsModule1.fs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs index 661515436c9..458757589b3 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs @@ -292,7 +292,10 @@ type OperatorsModule1() = // Overflow let result = Operators.byte Double.MaxValue - Assert.AreEqual(0uy, result) + if not Info.isNetFramework then + Assert.AreEqual(255uy, result) + else + Assert.AreEqual(0uy, result) // Overflow let result = Operators.byte (Int64.MaxValue * 8L) @@ -351,7 +354,11 @@ type OperatorsModule1() = Assert.AreEqual('\uffff', Operators.char Single.MaxValue) else Assert.AreEqual('\000', Operators.char Single.MaxValue) - Assert.AreEqual('\000', Operators.char Double.MaxValue) + + if not Info.isNetFramework then + Assert.AreEqual('\uffff', Operators.char Double.MaxValue) + else + Assert.AreEqual('\000', Operators.char Double.MaxValue) CheckThrowsOverflowException(fun () -> Operators.char Decimal.MinValue |> ignore) // string type From ec15c9d6c4bb1e17b428e6670151fa3381e828b9 Mon Sep 17 00:00:00 2001 From: psfinaki Date: Tue, 25 Jun 2024 12:20:34 +0200 Subject: [PATCH 19/25] Update OperatorsModule2.fs --- .../FSharp.Core/OperatorsModule2.fs | 50 ++++++++++++++----- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs index b71997fa0a6..a8954ff9de0 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs @@ -64,7 +64,10 @@ type OperatorsModule2() = // Overflow let result = Operators.int Double.MaxValue - Assert.AreEqual(Int32.MinValue, result) + if not Info.isNetFramework then + Assert.AreEqual(2147483647, result) + else + Assert.AreEqual(Int32.MinValue, result) // Overflow let result = Operators.int Double.MinValue @@ -120,7 +123,10 @@ type OperatorsModule2() = // Overflow let result = Operators.int16 Double.MaxValue - Assert.AreEqual(0s, result) + if not Info.isNetFramework then + Assert.AreEqual(-1s, result) + else + Assert.AreEqual(0s, result) // Overflow let result = Operators.int16 Double.MinValue @@ -175,7 +181,10 @@ type OperatorsModule2() = // Overflow let result = Operators.int32 Double.MaxValue - Assert.AreEqual(Int32.MinValue, result) + if not Info.isNetFramework then + Assert.AreEqual(2147483647, result) + else + Assert.AreEqual(Int32.MinValue, result) // Overflow let result = Operators.int32 Double.MinValue @@ -231,7 +240,10 @@ type OperatorsModule2() = // Overflow. let result = Operators.int64 Double.MaxValue - Assert.AreEqual(Int64.MinValue, result) + if not Info.isNetFramework then + Assert.AreEqual(9223372036854775807L, result) + else + Assert.AreEqual(Int64.MinValue, result) // Overflow let result = Operators.int64 Double.MinValue @@ -396,8 +408,11 @@ type OperatorsModule2() = if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 - Assert.AreEqual(-9223372036854775807n - 1n, result) + if not Info.isNetFramework then + Assert.AreEqual(9223372036854775807n, result) + else + // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual(-9223372036854775807n - 1n, result) // Overflow (depends on pointer size) let result = Operators.nativeint Double.MinValue @@ -448,7 +463,6 @@ type OperatorsModule2() = Assert.AreEqual("-9223372036854775808", string -9223372036854775808n) Assert.AreEqual("9223372036854775807", string 9223372036854775807n) - [] member _.not() = let result = Operators.not true @@ -460,7 +474,6 @@ type OperatorsModule2() = [] member _.nullArg() = CheckThrowsArgumentNullException(fun () -> Operators.nullArg "A" |> ignore) - [] member _.pown() = @@ -498,7 +511,6 @@ type OperatorsModule2() = member _.raise() = CheckThrowsArgumentException(fun () -> Operators.raise <| new ArgumentException("Invalid Argument ") |> ignore) - [] member _.ref() = // value type @@ -983,7 +995,10 @@ type OperatorsModule2() = // Overflow let result = Operators.uint16 Double.MaxValue - Assert.AreEqual(0us, result) + if not Info.isNetFramework then + Assert.AreEqual(65535us, result) + else + Assert.AreEqual(0us, result) // Overflow let result = Operators.uint16 Double.MinValue @@ -1019,7 +1034,10 @@ type OperatorsModule2() = // Overflow let result = Operators.uint32 Double.MaxValue - Assert.AreEqual(0u, result) + if not Info.isNetFramework then + Assert.AreEqual(4294967295u, result) + else + Assert.AreEqual(0u, result) // Overflow let result = Operators.uint32 Double.MinValue @@ -1068,7 +1086,10 @@ type OperatorsModule2() = // Overflow let result = Operators.uint64 Single.MinValue - Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 + if not Info.isNetFramework then + Assert.AreEqual(0UL, result) + else + Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 // Overflow let result = Operators.uint64 Double.MaxValue @@ -1116,7 +1137,10 @@ type OperatorsModule2() = if Info.isX86Runtime then Assert.AreEqual(0un, result) else - Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 + if not Info.isNetFramework then + Assert.AreEqual(0un, result) + else + Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 // Overflow Double.MaxValue is equal on 32 bits and 64 bits runtimes let result = Operators.unativeint Double.MaxValue From 656ad408704f4cc479d41e521ba31255e410eb7c Mon Sep 17 00:00:00 2001 From: psfinaki Date: Tue, 25 Jun 2024 12:59:13 +0200 Subject: [PATCH 20/25] Update OperatorsModule2.fs --- .../FSharp.Core/OperatorsModule2.fs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs index a8954ff9de0..0eaad82082c 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs @@ -444,8 +444,11 @@ type OperatorsModule2() = if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 - Assert.AreEqual("-9223372036854775808", string result) + if not Info.isNetFramework then + Assert.AreEqual(9223372036854775807n, result) + else + // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual("-9223372036854775808", string result) let result = Operators.nativeint System.Double.MinValue if Info.isX86Runtime then @@ -1093,7 +1096,10 @@ type OperatorsModule2() = // Overflow let result = Operators.uint64 Double.MaxValue - Assert.AreEqual(0UL, result) + if not Info.isNetFramework then + Assert.AreEqual(18446744073709551615UL, result) + else + Assert.AreEqual(0UL, result) // Overflow let result = Operators.uint64 Double.MinValue @@ -1144,7 +1150,10 @@ type OperatorsModule2() = // Overflow Double.MaxValue is equal on 32 bits and 64 bits runtimes let result = Operators.unativeint Double.MaxValue - Assert.AreEqual(0un, result) + if not Info.isNetFramework then + Assert.AreEqual(18446744073709551615un, result) + else + Assert.AreEqual(0un, result) // Overflow (depends on pointer size) let result = Operators.unativeint Double.MinValue From a27df0f826c01d4e353ee12d877f466a0f606339 Mon Sep 17 00:00:00 2001 From: psfinaki Date: Tue, 25 Jun 2024 13:00:27 +0200 Subject: [PATCH 21/25] remove old workarond --- tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs | 6 ++---- .../FSharp.Core/OperatorsModuleDynamic.fs | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs index 0eaad82082c..22fa9203303 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs @@ -447,15 +447,13 @@ type OperatorsModule2() = if not Info.isNetFramework then Assert.AreEqual(9223372036854775807n, result) else - // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 - Assert.AreEqual("-9223372036854775808", string result) + Assert.AreEqual(-9223372036854775808n, string result) let result = Operators.nativeint System.Double.MinValue if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 - Assert.AreEqual("-9223372036854775808", string result) + Assert.AreEqual(-9223372036854775808n, string result) // Max and min value as literals (this breaks compilation if the lexer fails). // The following tests ensure that the proper value is parsed, which is similar to `nativeint Int64.MaxValue` etc. diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs index 30542dc9420..ba09c8e9c12 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs @@ -543,15 +543,13 @@ module OperatorsModuleDynamic = if not Info.isNetFramework then Assert.AreEqual(9223372036854775807n, result) else - // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 - Assert.AreEqual("-9223372036854775808", string result) + Assert.AreEqual(-9223372036854775808n, string result) let result = Operators.nativeint System.Double.MinValue if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 - Assert.AreEqual("-9223372036854775808", string result) + Assert.AreEqual(-9223372036854775808n, string result) // Max and min value as literals (this breaks compilation if the lexer fails). // The following tests ensure that the proper value is parsed, which is similar to `nativeint Int64.MaxValue` etc. From 1ba5e299d2a55b34d08ffb334d4c7228287bb2ba Mon Sep 17 00:00:00 2001 From: psfinaki Date: Tue, 25 Jun 2024 13:39:01 +0200 Subject: [PATCH 22/25] Revert "remove old workarond" This reverts commit a27df0f826c01d4e353ee12d877f466a0f606339. --- tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs | 6 ++++-- .../FSharp.Core/OperatorsModuleDynamic.fs | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs index 22fa9203303..0eaad82082c 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs @@ -447,13 +447,15 @@ type OperatorsModule2() = if not Info.isNetFramework then Assert.AreEqual(9223372036854775807n, result) else - Assert.AreEqual(-9223372036854775808n, string result) + // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual("-9223372036854775808", string result) let result = Operators.nativeint System.Double.MinValue if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - Assert.AreEqual(-9223372036854775808n, string result) + // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual("-9223372036854775808", string result) // Max and min value as literals (this breaks compilation if the lexer fails). // The following tests ensure that the proper value is parsed, which is similar to `nativeint Int64.MaxValue` etc. diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs index ba09c8e9c12..30542dc9420 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs @@ -543,13 +543,15 @@ module OperatorsModuleDynamic = if not Info.isNetFramework then Assert.AreEqual(9223372036854775807n, result) else - Assert.AreEqual(-9223372036854775808n, string result) + // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual("-9223372036854775808", string result) let result = Operators.nativeint System.Double.MinValue if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - Assert.AreEqual(-9223372036854775808n, string result) + // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual("-9223372036854775808", string result) // Max and min value as literals (this breaks compilation if the lexer fails). // The following tests ensure that the proper value is parsed, which is similar to `nativeint Int64.MaxValue` etc. From ce5418331d4b47d72c4cded6cf77ea295132fd8d Mon Sep 17 00:00:00 2001 From: psfinaki Date: Tue, 25 Jun 2024 13:42:36 +0200 Subject: [PATCH 23/25] Update OperatorsModule2.fs --- .../FSharp.Core/OperatorsModule2.fs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs index 0eaad82082c..696b3388996 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs @@ -1103,7 +1103,10 @@ type OperatorsModule2() = // Overflow let result = Operators.uint64 Double.MinValue - Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 + if not Info.isNetFramework then + Assert.AreEqual(0UL, result) + else + Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 // Overflow let result = Operators.uint64 Int64.MinValue @@ -1160,7 +1163,10 @@ type OperatorsModule2() = if Info.isX86Runtime then Assert.AreEqual(0un, result) else - Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 + if not Info.isNetFramework then + Assert.AreEqual(0un, result) + else + Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 // Overflow (depends on pointer size) let result = Operators.unativeint Int64.MinValue From 569c521b45d963c1e9a14357036dc1710e1399e0 Mon Sep 17 00:00:00 2001 From: psfinaki Date: Tue, 25 Jun 2024 15:10:15 +0200 Subject: [PATCH 24/25] invert ifs, set up consts --- .../FSharp.Core/OperatorsModule1.fs | 31 ++- .../FSharp.Core/OperatorsModule2.fs | 148 +++++++------- .../FSharp.Core/OperatorsModuleDynamic.fs | 192 +++++++++--------- 3 files changed, 183 insertions(+), 188 deletions(-) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs index 458757589b3..3c35c1286fb 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs @@ -278,24 +278,24 @@ type OperatorsModule1() = // Overflow let result = Operators.byte Single.MinValue Assert.AreEqual(0uy, result) - + // Overflow let result = Operators.byte Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(255uy, result) - else + if Info.isNetFramework then Assert.AreEqual(0uy, result) - + else + Assert.AreEqual(255uy, result) + // Overflow let result = Operators.byte Double.MinValue Assert.AreEqual(0uy, result) - + // Overflow let result = Operators.byte Double.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(255uy, result) - else + if Info.isNetFramework then Assert.AreEqual(0uy, result) + else + Assert.AreEqual(255uy, result) // Overflow let result = Operators.byte (Int64.MaxValue * 8L) @@ -349,16 +349,15 @@ type OperatorsModule1() = // Overflow Assert.AreEqual('\000', Operators.char Single.MinValue) - Assert.AreEqual('\000', Operators.char Double.MinValue) - if not Info.isNetFramework then - Assert.AreEqual('\uffff', Operators.char Single.MaxValue) - else + if Info.isNetFramework then Assert.AreEqual('\000', Operators.char Single.MaxValue) - - if not Info.isNetFramework then - Assert.AreEqual('\uffff', Operators.char Double.MaxValue) else + Assert.AreEqual('\uffff', Operators.char Single.MaxValue) + + if Info.isNetFramework then Assert.AreEqual('\000', Operators.char Double.MaxValue) + else + Assert.AreEqual('\uffff', Operators.char Double.MaxValue) CheckThrowsOverflowException(fun () -> Operators.char Decimal.MinValue |> ignore) // string type diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs index 696b3388996..7c2f9148e01 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs @@ -53,10 +53,10 @@ type OperatorsModule2() = // Overflow. let result = Operators.int Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(2147483647, result) - else + if Info.isNetFramework then Assert.AreEqual(Int32.MinValue, result) + else + Assert.AreEqual(Int32.MaxValue, result) // Overflow let result = Operators.int Single.MinValue @@ -64,10 +64,10 @@ type OperatorsModule2() = // Overflow let result = Operators.int Double.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(2147483647, result) - else + if Info.isNetFramework then Assert.AreEqual(Int32.MinValue, result) + else + Assert.AreEqual(Int32.MaxValue, result) // Overflow let result = Operators.int Double.MinValue @@ -112,10 +112,10 @@ type OperatorsModule2() = // Overflow. let result = Operators.int16 Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(-1s, result) - else + if Info.isNetFramework then Assert.AreEqual(0s, result) + else + Assert.AreEqual(-1s, result) // Overflow let result = Operators.int16 Single.MinValue @@ -123,10 +123,10 @@ type OperatorsModule2() = // Overflow let result = Operators.int16 Double.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(-1s, result) - else + if Info.isNetFramework then Assert.AreEqual(0s, result) + else + Assert.AreEqual(-1s, result) // Overflow let result = Operators.int16 Double.MinValue @@ -170,10 +170,10 @@ type OperatorsModule2() = // Overflow. let result = Operators.int32 Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(2147483647, result) - else + if Info.isNetFramework then Assert.AreEqual(Int32.MinValue, result) + else + Assert.AreEqual(Int32.MaxValue, result) // Overflow let result = Operators.int32 Single.MinValue @@ -181,11 +181,11 @@ type OperatorsModule2() = // Overflow let result = Operators.int32 Double.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(2147483647, result) - else + if Info.isNetFramework then Assert.AreEqual(Int32.MinValue, result) - + else + Assert.AreEqual(Int32.MaxValue, result) + // Overflow let result = Operators.int32 Double.MinValue Assert.AreEqual(Int32.MinValue, result) @@ -229,10 +229,10 @@ type OperatorsModule2() = // Overflow. let result = Operators.int64 Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(9223372036854775807L, result) - else + if Info.isNetFramework then Assert.AreEqual(Int64.MinValue, result) + else + Assert.AreEqual(Int64.MaxValue, result) // Overflow let result = Operators.int64 Single.MinValue @@ -240,10 +240,10 @@ type OperatorsModule2() = // Overflow. let result = Operators.int64 Double.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(9223372036854775807L, result) - else + if Info.isNetFramework then Assert.AreEqual(Int64.MinValue, result) + else + Assert.AreEqual(Int64.MaxValue, result) // Overflow let result = Operators.int64 Double.MinValue @@ -389,11 +389,11 @@ type OperatorsModule2() = if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - if not Info.isNetFramework then - Assert.AreEqual(9223372036854775807n, result) - else + if Info.isNetFramework then // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 Assert.AreEqual(-9223372036854775807n - 1n, result) + else + Assert.AreEqual(9223372036854775807n, result) // Overflow (depends on pointer size) let result = Operators.nativeint Single.MinValue @@ -408,12 +408,12 @@ type OperatorsModule2() = if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - if not Info.isNetFramework then - Assert.AreEqual(9223372036854775807n, result) - else + if Info.isNetFramework then // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 Assert.AreEqual(-9223372036854775807n - 1n, result) - + else + Assert.AreEqual(9223372036854775807n, result) + // Overflow (depends on pointer size) let result = Operators.nativeint Double.MinValue if Info.isX86Runtime then @@ -444,11 +444,11 @@ type OperatorsModule2() = if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - if not Info.isNetFramework then - Assert.AreEqual(9223372036854775807n, result) - else + if Info.isNetFramework then // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 Assert.AreEqual("-9223372036854775808", string result) + else + Assert.AreEqual(9223372036854775807n, result) let result = Operators.nativeint System.Double.MinValue if Info.isX86Runtime then @@ -626,10 +626,10 @@ type OperatorsModule2() = // Overflow let result = Operators.sbyte Double.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(-1y, result) - else + if Info.isNetFramework then Assert.AreEqual(0y, result) + else + Assert.AreEqual(-1y, result) // Overflow let result = Operators.sbyte (Int64.MaxValue * 8L) @@ -987,10 +987,10 @@ type OperatorsModule2() = // Overflow let result = Operators.uint16 Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(65535us, result) - else + if Info.isNetFramework then Assert.AreEqual(0us, result) + else + Assert.AreEqual(65535us, result) // Overflow let result = Operators.uint16 Single.MinValue @@ -998,10 +998,10 @@ type OperatorsModule2() = // Overflow let result = Operators.uint16 Double.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(65535us, result) - else + if Info.isNetFramework then Assert.AreEqual(0us, result) + else + Assert.AreEqual(65535us, result) // Overflow let result = Operators.uint16 Double.MinValue @@ -1026,10 +1026,10 @@ type OperatorsModule2() = // Overflow let result = Operators.uint32 Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(4294967295u, result) - else + if Info.isNetFramework then Assert.AreEqual(0u, result) + else + Assert.AreEqual(4294967295u, result) // Overflow let result = Operators.uint32 Single.MinValue @@ -1037,10 +1037,10 @@ type OperatorsModule2() = // Overflow let result = Operators.uint32 Double.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(4294967295u, result) - else + if Info.isNetFramework then Assert.AreEqual(0u, result) + else + Assert.AreEqual(4294967295u, result) // Overflow let result = Operators.uint32 Double.MinValue @@ -1082,31 +1082,31 @@ type OperatorsModule2() = // Overflow let result = Operators.uint64 Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(18446744073709551615UL, result) - else + if Info.isNetFramework then Assert.AreEqual(0UL, result) + else + Assert.AreEqual(18446744073709551615UL, result) // Overflow let result = Operators.uint64 Single.MinValue - if not Info.isNetFramework then - Assert.AreEqual(0UL, result) - else + if Info.isNetFramework then Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 + else + Assert.AreEqual(0UL, result) // Overflow let result = Operators.uint64 Double.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(18446744073709551615UL, result) - else + if Info.isNetFramework then Assert.AreEqual(0UL, result) + else + Assert.AreEqual(18446744073709551615UL, result) // Overflow let result = Operators.uint64 Double.MinValue - if not Info.isNetFramework then - Assert.AreEqual(0UL, result) - else + if Info.isNetFramework then Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 + else + Assert.AreEqual(0UL, result) // Overflow let result = Operators.uint64 Int64.MinValue @@ -1136,37 +1136,37 @@ type OperatorsModule2() = // Overflow Single.MaxValue is equal on 32 bits and 64 bits runtimes let result = Operators.unativeint Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(18446744073709551615un, result) - else + if Info.isNetFramework then Assert.AreEqual(0un, result) + else + Assert.AreEqual(18446744073709551615un, result) // Overflow (depends on pointer size) let result = Operators.unativeint Single.MinValue if Info.isX86Runtime then Assert.AreEqual(0un, result) else - if not Info.isNetFramework then - Assert.AreEqual(0un, result) - else + if Info.isNetFramework then Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 + else + Assert.AreEqual(0un, result) // Overflow Double.MaxValue is equal on 32 bits and 64 bits runtimes let result = Operators.unativeint Double.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(18446744073709551615un, result) - else + if Info.isNetFramework then Assert.AreEqual(0un, result) + else + Assert.AreEqual(18446744073709551615un, result) // Overflow (depends on pointer size) let result = Operators.unativeint Double.MinValue if Info.isX86Runtime then Assert.AreEqual(0un, result) else - if not Info.isNetFramework then - Assert.AreEqual(0un, result) - else + if Info.isNetFramework then Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 + else + Assert.AreEqual(0un, result) // Overflow (depends on pointer size) let result = Operators.unativeint Int64.MinValue diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs index 30542dc9420..7d8b3678821 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs @@ -98,10 +98,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.byte Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(255uy, result) - else + if Info.isNetFramework then Assert.AreEqual(0uy, result) + else + Assert.AreEqual(255uy, result) // Overflow let result = Operators.byte Double.MinValue @@ -109,10 +109,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.byte Double.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(255uy, result) - else + if Info.isNetFramework then Assert.AreEqual(0uy, result) + else + Assert.AreEqual(255uy, result) // Overflow let result = Operators.byte (Int64.MaxValue * 8L) @@ -146,15 +146,15 @@ module OperatorsModuleDynamic = Assert.AreEqual('\000', Operators.char Single.MinValue) Assert.AreEqual('\000', Operators.char Double.MinValue) - if not Info.isNetFramework then - Assert.AreEqual('\uffff', Operators.char Single.MaxValue) - else + if Info.isNetFramework then Assert.AreEqual('\000', Operators.char Single.MaxValue) - - if not Info.isNetFramework then - Assert.AreEqual('\uffff', Operators.char Double.MaxValue) else + Assert.AreEqual('\uffff', Operators.char Single.MaxValue) + + if Info.isNetFramework then Assert.AreEqual('\000', Operators.char Double.MaxValue) + else + Assert.AreEqual('\uffff', Operators.char Double.MaxValue) CheckThrowsOverflowException(fun () -> Operators.char Decimal.MinValue |> ignore) // string type @@ -251,10 +251,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(Int32.MaxValue, result) - else + if Info.isNetFramework then Assert.AreEqual(Int32.MinValue, result) + else + Assert.AreEqual(Int32.MaxValue, result) // Overflow let result = Operators.int Single.MinValue @@ -262,10 +262,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int Double.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(Int32.MaxValue, result) - else + if Info.isNetFramework then Assert.AreEqual(Int32.MinValue, result) + else + Assert.AreEqual(Int32.MaxValue, result) // Overflow let result = Operators.int Double.MinValue @@ -310,10 +310,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int16 Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(-1s, result) - else + if Info.isNetFramework then Assert.AreEqual(0s, result) + else + Assert.AreEqual(-1s, result) // Overflow let result = Operators.int16 Single.MinValue @@ -321,10 +321,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int16 Double.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(-1s, result) - else + if Info.isNetFramework then Assert.AreEqual(0s, result) + else + Assert.AreEqual(-1s, result) // Overflow let result = Operators.int16 Double.MinValue @@ -368,10 +368,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int32 Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(Int32.MaxValue, result) - else + if Info.isNetFramework then Assert.AreEqual(Int32.MinValue, result) + else + Assert.AreEqual(Int32.MaxValue, result) // Overflow let result = Operators.int32 Single.MinValue @@ -379,10 +379,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int32 Double.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(Int32.MaxValue, result) - else + if Info.isNetFramework then Assert.AreEqual(Int32.MinValue, result) + else + Assert.AreEqual(Int32.MaxValue, result) // Overflow let result = Operators.int32 Double.MinValue @@ -427,10 +427,10 @@ module OperatorsModuleDynamic = // Overflow. let result = Operators.int64 Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(Int64.MaxValue, result) - else + if Info.isNetFramework then Assert.AreEqual(Int64.MinValue, result) + else + Assert.AreEqual(Int64.MaxValue, result) // Overflow let result = Operators.int64 Single.MinValue @@ -438,10 +438,10 @@ module OperatorsModuleDynamic = // Overflow. let result = Operators.int64 Double.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(Int64.MaxValue, result) - else + if Info.isNetFramework then Assert.AreEqual(Int64.MinValue, result) + else + Assert.AreEqual(Int64.MaxValue, result) // Overflow let result = Operators.int64 Double.MinValue @@ -486,12 +486,12 @@ module OperatorsModuleDynamic = if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - if not Info.isNetFramework then - Assert.AreEqual(9223372036854775807n, result) - else + if Info.isNetFramework then // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 Assert.AreEqual(-9223372036854775807n - 1n, result) - + else + Assert.AreEqual(9223372036854775807n, result) + // Overflow (depends on pointer size) let result = Operators.nativeint Single.MinValue if Info.isX86Runtime then @@ -499,18 +499,18 @@ module OperatorsModuleDynamic = else // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 Assert.AreEqual(-9223372036854775807n - 1n, result) - + // Overflow Double.MaxValue is equal on 32 bits and 64 bits runtimes let result = Operators.nativeint Double.MaxValue if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - if not Info.isNetFramework then - Assert.AreEqual(9223372036854775807n, result) - else + if Info.isNetFramework then // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 Assert.AreEqual(-9223372036854775807n - 1n, result) - + else + Assert.AreEqual(9223372036854775807n, result) + // Overflow (depends on pointer size) let result = Operators.nativeint Double.MinValue if Info.isX86Runtime then @@ -518,7 +518,7 @@ module OperatorsModuleDynamic = else // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 Assert.AreEqual(-9223372036854775807n - 1n, result) - + // Overflow (depends on pointer size) let result = Operators.nativeint Int64.MinValue if Info.isX86Runtime then @@ -540,11 +540,11 @@ module OperatorsModuleDynamic = if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - if not Info.isNetFramework then - Assert.AreEqual(9223372036854775807n, result) - else + if Info.isNetFramework then // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 Assert.AreEqual("-9223372036854775808", string result) + else + Assert.AreEqual(9223372036854775807n, result) let result = Operators.nativeint System.Double.MinValue if Info.isX86Runtime then @@ -552,7 +552,6 @@ module OperatorsModuleDynamic = else // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 Assert.AreEqual("-9223372036854775808", string result) - // Max and min value as literals (this breaks compilation if the lexer fails). // The following tests ensure that the proper value is parsed, which is similar to `nativeint Int64.MaxValue` etc. if Info.isX86Runtime then @@ -595,10 +594,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.sbyte Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(-1y, result) - else + if Info.isNetFramework then Assert.AreEqual(0y, result) + else + Assert.AreEqual(-1y, result) // Overflow let result = Operators.sbyte Double.MinValue @@ -606,10 +605,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.sbyte Double.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(-1y, result) - else + if Info.isNetFramework then Assert.AreEqual(0y, result) + else + Assert.AreEqual(-1y, result) // Overflow let result = Operators.sbyte (Int64.MaxValue * 8L) @@ -653,10 +652,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint16 Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(65535us, result) - else + if Info.isNetFramework then Assert.AreEqual(0us, result) + else + Assert.AreEqual(65535us, result) // Overflow let result = Operators.uint16 Single.MinValue @@ -664,10 +663,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint16 Double.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(65535us, result) - else + if Info.isNetFramework then Assert.AreEqual(0us, result) + else + Assert.AreEqual(65535us, result) // Overflow let result = Operators.uint16 Double.MinValue @@ -692,10 +691,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint32 Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(4294967295u, result) - else + if Info.isNetFramework then Assert.AreEqual(0u, result) + else + Assert.AreEqual(4294967295u, result) // Overflow let result = Operators.uint32 Single.MinValue @@ -703,11 +702,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint32 Double.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(4294967295u, result) - else + if Info.isNetFramework then Assert.AreEqual(0u, result) - + else + Assert.AreEqual(4294967295u, result) // Overflow let result = Operators.uint32 Double.MinValue Assert.AreEqual(0u, result) @@ -748,32 +746,31 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint64 Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(18446744073709551615UL, result) - else + if Info.isNetFramework then Assert.AreEqual(0UL, result) - + else + Assert.AreEqual(18446744073709551615UL, result) + // Overflow let result = Operators.uint64 Single.MinValue - if not Info.isNetFramework then - Assert.AreEqual(0UL, result) - else + if Info.isNetFramework then Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 - - // Overflow - let result = Operators.uint64 Double.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(18446744073709551615UL, result) else Assert.AreEqual(0UL, result) - + // Overflow - let result = Operators.uint64 Double.MinValue - if not Info.isNetFramework then + let result = Operators.uint64 Double.MaxValue + if Info.isNetFramework then Assert.AreEqual(0UL, result) else + Assert.AreEqual(18446744073709551615UL, result) + + // Overflow + let result = Operators.uint64 Double.MinValue + if Info.isNetFramework then Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 - + else + Assert.AreEqual(0UL, result) // Overflow let result = Operators.uint64 Int64.MinValue Assert.AreEqual(9223372036854775808UL, result) @@ -802,38 +799,37 @@ module OperatorsModuleDynamic = // Overflow Single.MaxValue is equal on 32 bits and 64 bits runtimes let result = Operators.unativeint Single.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(18446744073709551615un, result) - else + if Info.isNetFramework then Assert.AreEqual(0un, result) + else + Assert.AreEqual(18446744073709551615un, result) // Overflow (depends on pointer size) let result = Operators.unativeint Single.MinValue if Info.isX86Runtime then Assert.AreEqual(0un, result) else - if not Info.isNetFramework then - Assert.AreEqual(0un, result) - else + if Info.isNetFramework then Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 + else + Assert.AreEqual(0un, result) // Overflow Double.MaxValue is equal on 32 bits and 64 bits runtimes let result = Operators.unativeint Double.MaxValue - if not Info.isNetFramework then - Assert.AreEqual(18446744073709551615un, result) - else + if Info.isNetFramework then Assert.AreEqual(0un, result) + else + Assert.AreEqual(18446744073709551615un, result) // Overflow (depends on pointer size) let result = Operators.unativeint Double.MinValue if Info.isX86Runtime then Assert.AreEqual(0un, result) else - if not Info.isNetFramework then - Assert.AreEqual(0un, result) - else + if Info.isNetFramework then Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 - + else + Assert.AreEqual(0un, result) // Overflow (depends on pointer size) let result = Operators.unativeint Int64.MinValue if Info.isX86Runtime then From d929e261f0a77f14bd7fa0d12804c323d37c739d Mon Sep 17 00:00:00 2001 From: psfinaki Date: Tue, 25 Jun 2024 15:43:09 +0200 Subject: [PATCH 25/25] comments --- tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs | 4 ++++ tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs index 3c35c1286fb..727ed166b86 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs @@ -3,6 +3,10 @@ // Various tests for the: // Microsoft.FSharp.Core.Operators module +// For information on the runtime-dependent behavior differences in this file, see: +// - https://github.com/dotnet/runtime/issues/61885 +// - https://github.com/dotnet/runtime/pull/97529 + namespace FSharp.Core.UnitTests.Operators open System diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs index 7c2f9148e01..57647ead9ed 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs @@ -3,6 +3,10 @@ // Various tests for the: // Microsoft.FSharp.Core.Operators module +// For information on the runtime-dependent behavior differences in this file, see: +// - https://github.com/dotnet/runtime/issues/61885 +// - https://github.com/dotnet/runtime/pull/97529 + namespace FSharp.Core.UnitTests.Operators open System