diff --git a/tests/fsharp/Compiler/Libraries/Core/ExtraTopLevelOperators/DictionaryTests.fs b/tests/fsharp/Compiler/Libraries/Core/ExtraTopLevelOperators/DictionaryTests.fs new file mode 100644 index 00000000000..d36945b4cd1 --- /dev/null +++ b/tests/fsharp/Compiler/Libraries/Core/ExtraTopLevelOperators/DictionaryTests.fs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.UnitTests + +open NUnit.Framework +open FSharp.TestHelpers + +module ``Dictionary Tests`` = + + [] + let ``Assigning to dictionary should compile``() = + // Regression test for FSHARP1.0:5365 + + CompilerAssert.Pass + """ +module N.M + + open System + open System.Collections.Generic + + type ICloneable<'a> = + abstract Clone : unit -> 'a + + type DictionaryFeature<'key> (dict: IDictionary<'key, int>) = + member this.Add key value = + dict.[key] <- value + """ + + [] + let ``Assigning to dictionary with type constraint should compile``() = + // Regression test for FSHARP1.0:5365 + // Used to give error: value must be local and mutable in order to mutate the contents of a value type, e.g. 'let mutable x = ...' + + CompilerAssert.Pass + """ +module N.M + + open System + open System.Collections.Generic + + type ICloneable<'a> = + abstract Clone : unit -> 'a + + type DictionaryFeature<'key, 'dict when 'dict :> IDictionary<'key, int> and 'dict :> ICloneable<'dict>> (dict: 'dict) = + member this.Add key value = + dict.[key] <- value + """ diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index 09a02d492ca..0c84007859f 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -79,6 +79,7 @@ + diff --git a/tests/fsharpqa/Source/Libraries/Core/ExtraTopLevelOperators/dict_typecheck01.fs b/tests/fsharpqa/Source/Libraries/Core/ExtraTopLevelOperators/dict_typecheck01.fs deleted file mode 100644 index b381e4993ae..00000000000 --- a/tests/fsharpqa/Source/Libraries/Core/ExtraTopLevelOperators/dict_typecheck01.fs +++ /dev/null @@ -1,16 +0,0 @@ -// #Regression #Llibraries -// Regression test for FSHARP1.0:5365 -// - -module N.M - - open System - open System.Collections.Generic - - type ICloneable<'a> = - abstract Clone : unit -> 'a - - type DictionaryFeature<'key, 'dict when 'dict :> IDictionary<'key, int> and 'dict :> ICloneable<'dict>> (dict: 'dict) = - member this.Add key value = - dict.[key] <- value // use to give error: value must be local and mutable in order to mutate the contents of a value type, e.g. 'let mutable x = ...' - diff --git a/tests/fsharpqa/Source/Libraries/Core/ExtraTopLevelOperators/dict_typecheck02.fs b/tests/fsharpqa/Source/Libraries/Core/ExtraTopLevelOperators/dict_typecheck02.fs deleted file mode 100644 index 2068f55ece7..00000000000 --- a/tests/fsharpqa/Source/Libraries/Core/ExtraTopLevelOperators/dict_typecheck02.fs +++ /dev/null @@ -1,15 +0,0 @@ -// #Regression #Llibraries -// Regression test for FSHARP1.0:5365 -// - -module N.M - - open System - open System.Collections.Generic - - type ICloneable<'a> = - abstract Clone : unit -> 'a - - type DictionaryFeature<'key> (dict: IDictionary<'key, int>) = - member this.Add key value = - dict.[key] <- value diff --git a/tests/fsharpqa/Source/Libraries/Core/ExtraTopLevelOperators/env.lst b/tests/fsharpqa/Source/Libraries/Core/ExtraTopLevelOperators/env.lst deleted file mode 100644 index 777dd651096..00000000000 --- a/tests/fsharpqa/Source/Libraries/Core/ExtraTopLevelOperators/env.lst +++ /dev/null @@ -1,2 +0,0 @@ - SOURCE=dict_typecheck01.fs SCFLAGS="-a --warnaserror+" # dict_typecheck01.fs - SOURCE=dict_typecheck02.fs SCFLAGS="-a --warnaserror+" # dict_typecheck02.fs