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

ReturnFunc not working for int64 properties #4

Closed
marklam opened this issue Nov 2, 2015 · 6 comments
Closed

ReturnFunc not working for int64 properties #4

marklam opened this issue Nov 2, 2015 · 6 comments

Comments

@marklam
Copy link

marklam commented Nov 2, 2015

Visual F# 4.4, .net 4.5.2, Foq 1.7.1, debug build

open Foq

type IFoo =
    abstract N : int64

[<EntryPoint>]
let main _ = 
    let mock1 = Mock<IFoo>().Setup(fun foo -> <@ foo.N @>).Returns(7L).Create()
    printfn "%d" mock1.N

    let mock2 = Mock<IFoo>().Setup(fun foo -> <@ foo.N @>).ReturnsFunc(fun () -> 7L).Create()
    printfn "%d" mock2.N

    0

Should write

7
7

Actually writes

7
200113899394039815
@marklam
Copy link
Author

marklam commented Nov 2, 2015

Also, using SetupByName produces a similar result (on this run, 209092047489990663):

    let mock2 = Mock<IFoo>().SetupByName("get_N").ReturnsFunc(fun () -> 7L).Create()
    printfn "%d" mock2.N

but not doing any setup produces the default value, 0

    let mock2 = Mock<IFoo>().Create()
    printfn "%d" mock2.N

@ptrelford
Copy link
Contributor

Hi Mark and sorry for the excessively delayed response. Thanks for the bug report, unfortunately to this day I have been unable to repro your issue, it's returning 7 for me in all cases. If this is still an issue please provide more details, i.e. which version of Foq are you using, which version of the F# Compiler, FSharp.Core. Have you tried pulling the Foq source code directly from the site?

@marklam
Copy link
Author

marklam commented Nov 23, 2016

Hi Phil,
I've created a GitHub repo with the repro case here
And my debug build here

It was built Debug AnyCPU using the NuGet release 1.7.1, FSharp.Core 4.40.23413.0, and .net 4.5.2

@marklam
Copy link
Author

marklam commented Nov 23, 2016

I also tried dropping in the current version of Foq.fs from GitHub, but it made no difference.

@ptrelford
Copy link
Contributor

Sorry, still unable to reproduce your issue. I've added your reported issue as a test case all-the-same.

@marklam
Copy link
Author

marklam commented Apr 24, 2017

For the record, the 1.7.2 version does fix the problem. Sorry it took me a while to check, but I'd added a (now-stale) copy of Foq.fs to my repro case. Removing that and updating to 1.7.2 fixed the problem.
Thanks!

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

2 participants