From 8f4466067e403e4a063ff011f265bc25b256ebfc Mon Sep 17 00:00:00 2001 From: Maxime Mangel Date: Fri, 27 Oct 2023 15:32:12 +0200 Subject: [PATCH 1/6] Add applicative test for accessor function shorthand --- src/quicktest/Quicktest.fsproj | 4 ++-- tests/Js/Main/ApplicativeTests.fs | 30 ++++++++++++++++++++++++ tests/Python/TestApplicative.fs | 29 +++++++++++++++++++++++ tests/Rust/tests/src/ApplicativeTests.fs | 29 +++++++++++++++++++++++ 4 files changed, 90 insertions(+), 2 deletions(-) diff --git a/src/quicktest/Quicktest.fsproj b/src/quicktest/Quicktest.fsproj index 50f439d151..33fcee7ca2 100644 --- a/src/quicktest/Quicktest.fsproj +++ b/src/quicktest/Quicktest.fsproj @@ -3,7 +3,7 @@ Exe net6.0 Major - + Preview @@ -12,4 +12,4 @@ - \ No newline at end of file + diff --git a/tests/Js/Main/ApplicativeTests.fs b/tests/Js/Main/ApplicativeTests.fs index 3c176843cf..76b3cfc0e0 100644 --- a/tests/Js/Main/ApplicativeTests.fs +++ b/tests/Js/Main/ApplicativeTests.fs @@ -1732,6 +1732,35 @@ module MultipleInlines = NonEmptyList("a", ["b"; "c"]) |> mapMyList |> equal (NonEmptyList("a_", ["b_"; "c_"])) ] +module AccessorFunctionShorthand = + + type User = + { + Name : string + } + + let tests = + [ + testCase "Accessor function shorthand works for records" <| fun () -> + let people = + [ + { Name = "John" } + { Name = "Jane" } + ] + + let names = people |> List.map _.Name + equal names ["John"; "Jane"] + + testCase "Accessor function shorthand works for anonymous records" <| fun () -> + let people = + [ + {| Name = "John" |} + {| Name = "Jane" |} + ] + + let names = people |> List.map _.Name + equal names ["John"; "Jane"] + ] let tests = testList "Applicative" ( tests1 @@ -1745,4 +1774,5 @@ let tests = @ Curry.tests @ Uncurry.tests @ MultipleInlines.tests + @ AccessorFunctionShorthand.tests ) diff --git a/tests/Python/TestApplicative.fs b/tests/Python/TestApplicative.fs index 723df4c87a..1d4ecfedf6 100644 --- a/tests/Python/TestApplicative.fs +++ b/tests/Python/TestApplicative.fs @@ -1684,3 +1684,32 @@ let ``test Trait call works with multiple inlined functions II`` () = // See #28 [] let ``test Identifiers from witnesses don't get duplicated when resolving inline expressions`` () = // See #2855 NonEmptyList("a", ["b"; "c"]) |> mapMyList |> equal (NonEmptyList("a_", ["b_"; "c_"])) + +module AccessorFunctionShorthand = + + type User = + { + Name : string + } + +[] +let ``test Accessor function shorthand works for records`` () = + let people : AccessorFunctionShorthand.User list = + [ + { Name = "John" } + { Name = "Jane" } + ] + + let names = people |> List.map _.Name + equal names ["John"; "Jane"] + +[] +let ``test Accessor function shorthand works for anonymous records`` () = + let people = + [ + {| Name = "John" |} + {| Name = "Jane" |} + ] + + let names = people |> List.map _.Name + equal names ["John"; "Jane"] diff --git a/tests/Rust/tests/src/ApplicativeTests.fs b/tests/Rust/tests/src/ApplicativeTests.fs index 6b6dc538f7..5f184656f9 100644 --- a/tests/Rust/tests/src/ApplicativeTests.fs +++ b/tests/Rust/tests/src/ApplicativeTests.fs @@ -1761,3 +1761,32 @@ let ``Trait call works with multiple inlined functions II`` () = // See #2809 [] let ``Identifiers from witnesses don't get duplicated when resolving inline expressions`` () = // See #2855 NonEmptyList("a", ["b"; "c"]) |> mapMyList |> equal (NonEmptyList("a_", ["b_"; "c_"])) + +module AccessorFunctionShorthand = + + type User = + { + Name : string + } + +[] +let ``test Accessor function shorthand works for records`` () = + let people : AccessorFunctionShorthand.User list = + [ + { Name = "John" } + { Name = "Jane" } + ] + + let names = people |> List.map _.Name + equal names ["John"; "Jane"] + +[] +let ``test Accessor function shorthand works for anonymous records`` () = + let people = + [ + {| Name = "John" |} + {| Name = "Jane" |} + ] + + let names = people |> List.map _.Name + equal names ["John"; "Jane"] From 8f17982bb7e643faea4c14f961cac4de1eb34e92 Mon Sep 17 00:00:00 2001 From: Maxime Mangel Date: Wed, 15 Nov 2023 19:42:34 +0100 Subject: [PATCH 2/6] Update .NET version to .NET 8 --- .github/workflows/build.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c6f5fa01d4..a5d2347b5a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.x' + dotnet-version: '8.0.x' - name: Setup Node.js environment uses: actions/setup-node@v2.4.1 @@ -35,7 +35,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.x' + dotnet-version: '8.0.x' - name: Setup Node.js environment uses: actions/setup-node@v2.4.1 @@ -56,7 +56,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.x' + dotnet-version: '8.0.x' - name: Setup Node.js environment uses: actions/setup-node@v2.4.1 @@ -74,7 +74,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.x' + dotnet-version: '8.0.x' - name: Setup Node.js environment uses: actions/setup-node@v2.4.1 @@ -96,7 +96,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.x' + dotnet-version: '8.0.x' - name: Setup dotnet tools run: dotnet tool restore @@ -142,7 +142,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.x' + dotnet-version: '8.0.x' - name: Setup Node.js environment uses: actions/setup-node@v2.4.1 @@ -168,7 +168,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.x' + dotnet-version: '8.0.x' - name: Setup Dart SDK uses: dart-lang/setup-dart@v1.3 From f7ab82237ba7e476b5ae2d39d491ad6b92e87328 Mon Sep 17 00:00:00 2001 From: Maxime Mangel Date: Wed, 15 Nov 2023 20:28:30 +0100 Subject: [PATCH 3/6] Add more tests for new F# 8 features --- .devcontainer/Dockerfile | 4 ++-- global.json | 2 +- tests/Js/Main/ApplicativeTests.fs | 17 +++++++++++++++++ tests/Js/Main/RecordTypeTests.fs | 24 +++++++++++++++++++++++- 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 8f99df5399..0f8006030a 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -24,7 +24,7 @@ RUN apt-get update && apt-get install -y xz-utils # Options # Let it here to avoid conflicts with Microsoft options !!! -ARG DOTNET_VERSION=6.0.406 +ARG DOTNET_VERSION=8.0.100 ARG NODE_VERSION=18.8.0 ARG PYTHON_VERSION=3.11.5 ARG DART_VERSION=3.1.2 @@ -103,4 +103,4 @@ RUN rm /home/vscode/install_dart.sh # Force docker to load the zsh profile # This should be the last steps -CMD [ "/bin/zsh" ] \ No newline at end of file +CMD [ "/bin/zsh" ] diff --git a/global.json b/global.json index 126149e6bb..8eb62bed1e 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.100", + "version": "8.0.0", "rollForward": "latestMajor" } } diff --git a/tests/Js/Main/ApplicativeTests.fs b/tests/Js/Main/ApplicativeTests.fs index 76b3cfc0e0..882f1cca80 100644 --- a/tests/Js/Main/ApplicativeTests.fs +++ b/tests/Js/Main/ApplicativeTests.fs @@ -1739,6 +1739,14 @@ module AccessorFunctionShorthand = Name : string } + type Student = + { + Name : string + Age : int + } + + let inline namePropertyGetter<'a when 'a:(member Name: string)> (x: 'a) = x |> _.Name + let tests = [ testCase "Accessor function shorthand works for records" <| fun () -> @@ -1760,6 +1768,15 @@ module AccessorFunctionShorthand = let names = people |> List.map _.Name equal names ["John"; "Jane"] + + testCase "Accessor function shorthand works with STRP syntax" <| fun () -> + let user = + { Name = "John" } + let student = + { Name = "Jane"; Age = 20 } + + equal (namePropertyGetter user) "John" + equal (namePropertyGetter student) "Jane" ] let tests = testList "Applicative" ( diff --git a/tests/Js/Main/RecordTypeTests.fs b/tests/Js/Main/RecordTypeTests.fs index 6a10f84326..2b047987d1 100644 --- a/tests/Js/Main/RecordTypeTests.fs +++ b/tests/Js/Main/RecordTypeTests.fs @@ -42,6 +42,9 @@ type Time = static member inline duration(value: {| from: int; until: int |}) = value.until - value.from static member inline duration(value: {| from: int |}) = Time.duration {| value with until = 10 |} +type CarInterior = { Seats: int } +type Car = { Interior: CarInterior } + let tests = testList "RecordTypes" [ @@ -120,4 +123,23 @@ let tests = let x'' = { x' with uniqueA = -10 } equal -10 x''.uniqueA equal -20 x''.uniqueB - ] \ No newline at end of file + + testCase "Nested record fiel copy and update works for records" <| fun () -> + let car = + { Interior = { Seats = 5 } } + + let car2 = + { car with Interior.Seats = 5 } + + equal 5 car2.Interior.Seats + + testCase "Nested record fiel copy and update works for anonymous records" <| fun () -> + let car = + {| Interior = {| Seats = 5 |} |} + + let car2 = + {| car with Interior.Seats = 5 |} + + equal 5 car2.Interior.Seats + + ] From d70e41ebc0a287eefce7eb771e4647d0a4571227 Mon Sep 17 00:00:00 2001 From: Maxime Mangel Date: Wed, 15 Nov 2023 20:39:32 +0100 Subject: [PATCH 4/6] Add F# 8 tests to Rust and Python targets --- tests/Js/Main/RecordTypeTests.fs | 6 +++--- tests/Python/TestApplicative.fs | 18 ++++++++++++++++++ tests/Python/TestRecordType.fs | 23 +++++++++++++++++++++++ tests/Rust/tests/src/ApplicativeTests.fs | 19 +++++++++++++++++++ tests/Rust/tests/src/RecordTests.fs | 24 ++++++++++++++++++++++++ 5 files changed, 87 insertions(+), 3 deletions(-) diff --git a/tests/Js/Main/RecordTypeTests.fs b/tests/Js/Main/RecordTypeTests.fs index 2b047987d1..98f8c8adfb 100644 --- a/tests/Js/Main/RecordTypeTests.fs +++ b/tests/Js/Main/RecordTypeTests.fs @@ -124,9 +124,9 @@ let tests = equal -10 x''.uniqueA equal -20 x''.uniqueB - testCase "Nested record fiel copy and update works for records" <| fun () -> + testCase "Nested record fiel opy and update works for records" <| fun () -> let car = - { Interior = { Seats = 5 } } + { Interior = { Seats = 4 } } let car2 = { car with Interior.Seats = 5 } @@ -135,7 +135,7 @@ let tests = testCase "Nested record fiel copy and update works for anonymous records" <| fun () -> let car = - {| Interior = {| Seats = 5 |} |} + {| Interior = {| Seats = 4 |} |} let car2 = {| car with Interior.Seats = 5 |} diff --git a/tests/Python/TestApplicative.fs b/tests/Python/TestApplicative.fs index 1d4ecfedf6..565071fe5b 100644 --- a/tests/Python/TestApplicative.fs +++ b/tests/Python/TestApplicative.fs @@ -1692,6 +1692,14 @@ module AccessorFunctionShorthand = Name : string } + type Student = + { + Name : string + Age : int + } + + let inline namePropertyGetter<'a when 'a:(member Name: string)> (x: 'a) = x |> _.Name + [] let ``test Accessor function shorthand works for records`` () = let people : AccessorFunctionShorthand.User list = @@ -1713,3 +1721,13 @@ let ``test Accessor function shorthand works for anonymous records`` () = let names = people |> List.map _.Name equal names ["John"; "Jane"] + +[] +let ``Accessor function shorthand works with STRP syntax`` = + let user : AccessorFunctionShorthand.User = + { Name = "John" } + let student : AccessorFunctionShorthand.Student = + { Name = "Jane"; Age = 20 } + + equal (AccessorFunctionShorthand.namePropertyGetter user) "John" + equal (AccessorFunctionShorthand.namePropertyGetter student) "Jane" diff --git a/tests/Python/TestRecordType.fs b/tests/Python/TestRecordType.fs index 94c0e5fd28..c751ff2ac6 100644 --- a/tests/Python/TestRecordType.fs +++ b/tests/Python/TestRecordType.fs @@ -39,6 +39,9 @@ type Time = static member inline duration(value: {| from: int; until: int |}) = value.until - value.from static member inline duration(value: {| from: int |}) = Time.duration {| value with until = 10 |} +type CarInterior = { Seats: int } +type Car = { Interior: CarInterior } + [] let ``test Anonymous records work`` () = let r = makeAnonRec() @@ -125,3 +128,23 @@ let ``test Mutating records work`` () = let x'' = { x' with uniqueA = -10 } equal -10 x''.uniqueA equal -20 x''.uniqueB + +[] +let ``test Nested record fiel copy and update works for records`` = + let car = + { Interior = { Seats = 4 } } + + let car2 = + { car with Interior.Seats = 5 } + + equal 5 car2.Interior.Seats + +[] +let ``Nested record fiel copy and update works for anonymous records`` = + let car = + {| Interior = {| Seats = 4 |} |} + + let car2 = + {| car with Interior.Seats = 5 |} + + equal 5 car2.Interior.Seats diff --git a/tests/Rust/tests/src/ApplicativeTests.fs b/tests/Rust/tests/src/ApplicativeTests.fs index 5f184656f9..7b490b8708 100644 --- a/tests/Rust/tests/src/ApplicativeTests.fs +++ b/tests/Rust/tests/src/ApplicativeTests.fs @@ -1769,6 +1769,14 @@ module AccessorFunctionShorthand = Name : string } + type Student = + { + Name : string + Age : int + } + + let inline namePropertyGetter<'a when 'a:(member Name: string)> (x: 'a) = x |> _.Name + [] let ``test Accessor function shorthand works for records`` () = let people : AccessorFunctionShorthand.User list = @@ -1790,3 +1798,14 @@ let ``test Accessor function shorthand works for anonymous records`` () = let names = people |> List.map _.Name equal names ["John"; "Jane"] + + +[] +let ``Accessor function shorthand works with STRP syntax`` = + let user : AccessorFunctionShorthand.User = + { Name = "John" } + let student : AccessorFunctionShorthand.Student = + { Name = "Jane"; Age = 20 } + + equal (AccessorFunctionShorthand.namePropertyGetter user) "John" + equal (AccessorFunctionShorthand.namePropertyGetter student) "Jane" diff --git a/tests/Rust/tests/src/RecordTests.fs b/tests/Rust/tests/src/RecordTests.fs index 225c72ab14..39ae1313cd 100644 --- a/tests/Rust/tests/src/RecordTests.fs +++ b/tests/Rust/tests/src/RecordTests.fs @@ -251,6 +251,9 @@ type MutatingRecord = type Id = Id of string +type CarInterior = { Seats: int } +type Car = { Interior: CarInterior } + //TODO: // let inline replaceById< ^t when ^t : (member Id : Id)> (newItem : ^t) (ar: ^t[]) = // Array.map (fun (x: ^t) -> if (^t : (member Id : Id) newItem) = (^t : (member Id : Id) x) then newItem else x) ar @@ -352,6 +355,27 @@ let ``Mutating records work`` () = equal -10 x''.uniqueA equal -20 x''.uniqueB + +[] +let ``test Nested record fiel copy and update works for records`` = + let car = + { Interior = { Seats = 4 } } + + let car2 = + { car with Interior.Seats = 5 } + + equal 5 car2.Interior.Seats + +[] +let ``Nested record fiel copy and update works for anonymous records`` = + let car = + {| Interior = {| Seats = 4 |} |} + + let car2 = + {| car with Interior.Seats = 5 |} + + equal 5 car2.Interior.Seats + module ComplexEdgeCases = open Common.Imports.Vectors open Fable.Core.Rust From 741b61f8891fa7e851ef62aae93e2669ea054900 Mon Sep 17 00:00:00 2001 From: Maxime Mangel Date: Wed, 15 Nov 2023 20:56:00 +0100 Subject: [PATCH 5/6] Add test for F# 8 new features related to strings --- tests/Js/Main/StringTests.fs | 24 +++++++++++++++++++++++- tests/Python/TestApplicative.fs | 2 +- tests/Python/TestRecordType.fs | 2 +- tests/Python/TestString.fs | 24 ++++++++++++++++++++++++ tests/React/Counter.fs | 2 +- tests/Rust/tests/src/StringTests.fs | 24 ++++++++++++++++++++++++ 6 files changed, 74 insertions(+), 4 deletions(-) diff --git a/tests/Js/Main/StringTests.fs b/tests/Js/Main/StringTests.fs index 381ca25f4d..8efb2df4c4 100644 --- a/tests/Js/Main/StringTests.fs +++ b/tests/Js/Main/StringTests.fs @@ -19,6 +19,15 @@ let LINE_SEPARATOR = "\u2028" let [] aLiteral = "foo" let notALiteral = "foo" +[] +let formatCoordinateBody = "(%f,%f)" + +[] +let formatPrefix = "Person at coordinates" + +[] +let fullFormat = formatPrefix + formatCoordinateBody + type MyUnion = Bar of int * int | Foo1 of float | Foo3 | Foo4 of MyUnion type Test(i: int) = @@ -160,6 +169,13 @@ let tests = sprintf "%d" -1L |> equal "-1" sprintf "%.2f" -1. |> equal "-1.00" + testCase "format string can use and compose string literals" <| fun () -> + let renderedCoordinates = sprintf formatCoordinateBody 0.25 0.75 + let renderedText = sprintf fullFormat 0.25 0.75 + + equal "(0.250000,0.750000)" renderedCoordinates + equal "Person at coordinates(0.250000,0.750000)" renderedText + testCase "Print.sprintf works" <| fun () -> // See #1216 let res = Printf.sprintf "%s" "abc" equal "res: abc" ("res: " + res) @@ -288,6 +304,12 @@ let tests = $"b=(%O{b})" |> equal "b=(a=6)" $"%O{b}%O{b}" |> equal "a=7a=8" + testCase "Extended string interpolation syntax" <| fun () -> + let classAttr = "item-panel" + let cssNew = $$""".{{classAttr}}:hover {background-color: #eee;}""" + + cssNew |> equal ".item-panel:hover {background-color: #eee;}" + testCase "sprintf \"%A\" with lists works" <| fun () -> let xs = ["Hi"; "Hello"; "Hola"] (sprintf "%A" xs).Replace("\"", "") |> equal "[Hi; Hello; Hola]" @@ -1098,4 +1120,4 @@ let tests = let s3: FormattableString = $"""I have no holes""" s3.GetStrings() |> toArray |> equal [|"I have no holes"|] #endif -] \ No newline at end of file +] diff --git a/tests/Python/TestApplicative.fs b/tests/Python/TestApplicative.fs index 565071fe5b..b4bf0544b0 100644 --- a/tests/Python/TestApplicative.fs +++ b/tests/Python/TestApplicative.fs @@ -1723,7 +1723,7 @@ let ``test Accessor function shorthand works for anonymous records`` () = equal names ["John"; "Jane"] [] -let ``Accessor function shorthand works with STRP syntax`` = +let ``test Accessor function shorthand works with STRP syntax`` = let user : AccessorFunctionShorthand.User = { Name = "John" } let student : AccessorFunctionShorthand.Student = diff --git a/tests/Python/TestRecordType.fs b/tests/Python/TestRecordType.fs index c751ff2ac6..6d4cb145ad 100644 --- a/tests/Python/TestRecordType.fs +++ b/tests/Python/TestRecordType.fs @@ -140,7 +140,7 @@ let ``test Nested record fiel copy and update works for records`` = equal 5 car2.Interior.Seats [] -let ``Nested record fiel copy and update works for anonymous records`` = +let ``test Nested record fiel copy and update works for anonymous records`` = let car = {| Interior = {| Seats = 4 |} |} diff --git a/tests/Python/TestString.fs b/tests/Python/TestString.fs index d3e489b645..a2034f95d4 100644 --- a/tests/Python/TestString.fs +++ b/tests/Python/TestString.fs @@ -7,6 +7,15 @@ open Util.Testing #nowarn "44" // This construct is deprecated. Uri.EscapeUriString can corrupt the Uri string in some cases. (code 44) +[] +let formatCoordinateBody = "(%f,%f)" + +[] +let formatPrefix = "Person at coordinates" + +[] +let fullFormat = formatPrefix + formatCoordinateBody + let containsInOrder (substrings: string list) (str: string) = let mutable lastIndex = -1 substrings |> List.forall (fun s -> @@ -51,6 +60,14 @@ let ``test sprintf displays sign correctly`` () = sprintf "%d" -1L |> equal "-1" sprintf "%.2f" -1. |> equal "-1.00" +[] +let ``test format string can use and compose string literals`` = + let renderedCoordinates = sprintf formatCoordinateBody 0.25 0.75 + let renderedText = sprintf fullFormat 0.25 0.75 + + equal "(0.250000,0.750000)" renderedCoordinates + equal "Person at coordinates(0.250000,0.750000)" renderedText + [] let ``test Print.sprintf works`` () = let res = Printf.sprintf "%s" "abc" @@ -92,6 +109,13 @@ let ``test string interpolation works with anonymous records`` () = $"Hi! My name is %s{person.Name} %s{person.Surname.ToUpper()}. I'm %i{person.Age} years old and I'm from %s{person.Country}!" |> equal "Hi! My name is John DOE. I'm 32 years old and I'm from The United Kingdom!" +[] +let ``test Extended string interpolation syntax`` = + let classAttr = "item-panel" + let cssNew = $$""".{{classAttr}}:hover {background-color: #eee;}""" + + cssNew |> equal ".item-panel:hover {background-color: #eee;}" + [] let ``test sprintf \"%A\" with lists works`` () = let xs = ["Hi"; "Hello"; "Hola"] diff --git a/tests/React/Counter.fs b/tests/React/Counter.fs index dea89fcba2..d6a41d49ca 100644 --- a/tests/React/Counter.fs +++ b/tests/React/Counter.fs @@ -41,4 +41,4 @@ let CounterJSX(init: int) = Increment - """ \ No newline at end of file + """ diff --git a/tests/Rust/tests/src/StringTests.fs b/tests/Rust/tests/src/StringTests.fs index b52ddb3da5..53d646f300 100644 --- a/tests/Rust/tests/src/StringTests.fs +++ b/tests/Rust/tests/src/StringTests.fs @@ -13,6 +13,15 @@ let LINE_SEPARATOR = "\u2028" let [] aLiteral = "foo" let notALiteral = "foo" +[] +let formatCoordinateBody = "(%f,%f)" + +[] +let formatPrefix = "Person at coordinates" + +[] +let fullFormat = formatPrefix + formatCoordinateBody + // type MyUnion = Bar of int * int | Foo1 of float | Foo3 | Foo4 of MyUnion // type Test(i: int) = @@ -342,6 +351,13 @@ let ``Backslash is escaped in interpolated strings`` () = // See #2649 @$"\{4}" |> equal @"\4" @$"\{4}".Length |> equal 2 +[] +let ``Extended string interpolation syntax`` = + let classAttr = "item-panel" + let cssNew = $$""".{{classAttr}}:hover {background-color: #eee;}""" + + cssNew |> equal ".item-panel:hover {background-color: #eee;}" + [] let ``interpolated string with double % should be unescaped`` () = $"{100}%%" |> equal "100%" @@ -424,6 +440,14 @@ let ``sprintf integers with sign and padding works`` () = // See #1931 sprintf "%5d" -5L |> equal " -5" // sprintf "%- 4i" 5 |> equal " 5 " //TODO: +[] +let ``test format string can use and compose string literals`` = + let renderedCoordinates = sprintf formatCoordinateBody 0.25 0.75 + let renderedText = sprintf fullFormat 0.25 0.75 + + equal "(0.250000,0.750000)" renderedCoordinates + equal "Person at coordinates(0.250000,0.750000)" renderedText + // [] // let ``parameterized padding works`` () = // See #2336 // sprintf "[%*s][%*s]" 6 "Hello" 5 "Foo" From 40f4de18b7bbb0cad0278ddaecc61dfe81f615b0 Mon Sep 17 00:00:00 2001 From: Maxime Mangel Date: Wed, 15 Nov 2023 21:16:30 +0100 Subject: [PATCH 6/6] Remove old comments --- tests/Js/Main/ListTests.fs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/Js/Main/ListTests.fs b/tests/Js/Main/ListTests.fs index 75f79ab47d..13ec81d133 100644 --- a/tests/Js/Main/ListTests.fs +++ b/tests/Js/Main/ListTests.fs @@ -867,8 +867,6 @@ let tests = (3, 'c'); (3, 'd'); (3, 'e'); (3, 'f'); (4, 'a'); (4, 'b'); (4, 'c'); (4, 'd'); (4, 'e'); (4, 'f')] - // TODO: Remove conditional compilation after upgrading to dotnet SDK with F# 4.7 - // #if FABLE_COMPILER testCase "Implicit yields work" <| fun () -> let makeList condition = [ @@ -879,7 +877,6 @@ let tests = ] makeList true |> List.sum |> equal 6 makeList false |> List.sum |> equal 3 - // #endif testCase "List.splitInto works" <| fun () -> [1..10] |> List.splitInto 3 |> equal [ [1..4]; [5..7]; [8..10] ] @@ -993,4 +990,4 @@ let tests = throwsAnyError (fun () -> List.removeManyAt 0 2 [] |> ignore) throwsAnyError (fun () -> List.removeManyAt -1 2 [1] |> ignore) throwsAnyError (fun () -> List.removeManyAt 2 2 [1] |> ignore) - ] \ No newline at end of file + ]