Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skipWhile and takeWhile are reversed #15

Open
marklam opened this issue Jul 18, 2023 · 0 comments
Open

skipWhile and takeWhile are reversed #15

marklam opened this issue Jul 18, 2023 · 0 comments

Comments

@marklam
Copy link

marklam commented Jul 18, 2023

This test compares the behaviour between the methods for ImmutableList and Array

#r "nuget:FSharp.Collections.Immutable"
#r "nuget:Unquote"

open FSharp.Collections.Immutable
open Swensen.Unquote.Assertions

let xs = [ "one"; "two"; "three"; "four" ]
let xsIL = ImmutableList.ofList xs
let xsA = Array.ofList xs

let notThree = (<>) "three"

test <@ (xsIL |> ImmutableList.skipWhile notThree |> ImmutableList.toArray) = (xsA |> Array.skipWhile notThree) @>
test <@ (xsIL |> ImmutableList.takeWhile notThree |> ImmutableList.toArray) = (xsA |> Array.takeWhile notThree) @>
Test failed:

xsIL |> (fun list -> ImmutableList.skipWhile notThree list) |> ImmutableList.toArray = (xsA |> (fun array -> Array.skipWhile notThree array))
seq ["one"; "two"; "three"; "four"] |> (fun list -> ImmutableList.skipWhile notThree list) |> ImmutableList.toArray = ([|"one"; "two"; "three"; "four"|] |> (fun array -> Array.skipWhile notThree array))
seq ["one"; "two"] |> ImmutableList.toArray = [|"three"; "four"|]
[|"one"; "two"|] = [|"three"; "four"|]
false


Test failed:

xsIL |> (fun list -> ImmutableList.takeWhile notThree list) |> ImmutableList.toArray = (xsA |> (fun array -> Array.takeWhile notThree array))
seq ["one"; "two"; "three"; "four"] |> (fun list -> ImmutableList.takeWhile notThree list) |> ImmutableList.toArray = ([|"one"; "two"; "three"; "four"|] |> (fun array -> Array.takeWhile notThree array))
seq ["three"; "four"] |> ImmutableList.toArray = [|"one"; "two"|]
[|"three"; "four"|] = [|"one"; "two"|]
false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant