{"action":"created","issue":{"url":"https://api.github.com/repos/fscheck/FsCheck/issues/215","repository_url":"https://api.github.com/repos/fscheck/FsCheck","labels_url":"https://api.github.com/repos/fscheck/FsCheck/issues/215/labels{/name}","comments_url":"https://api.github.com/repos/fscheck/FsCheck/issues/215/comments","events_url":"https://api.github.com/repos/fscheck/FsCheck/issues/215/events","html_url":"https://github.com/fscheck/FsCheck/issues/215","id":147520356,"number":215,"title":"`'a option` generates `null`","user":{"login":"simendsjo","id":351519,"avatar_url":"https://avatars.githubusercontent.com/u/351519?v=3","gravatar_id":"","url":"https://api.github.com/users/simendsjo","html_url":"https://github.com/simendsjo","followers_url":"https://api.github.com/users/simendsjo/followers","following_url":"https://api.github.com/users/simendsjo/following{/other_user}","gists_url":"https://api.github.com/users/simendsjo/gists{/gist_id}","starred_url":"https://api.github.com/users/simendsjo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simendsjo/subscriptions","organizations_url":"https://api.github.com/users/simendsjo/orgs","repos_url":"https://api.github.com/users/simendsjo/repos","events_url":"https://api.github.com/users/simendsjo/events{/privacy}","received_events_url":"https://api.github.com/users/simendsjo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-04-11T18:57:35Z","updated_at":"2016-04-11T19:39:54Z","closed_at":null,"body":"What is the best way to test `Option` values? I can use `obj.ReferenceEquals` to make sure the `Option` isn't null, but it just doesn't seem right.\r\n\r\n```\r\n// The type ''a option' does not have 'null' as a proper value\r\nlet f (x : 'a option) = isNull x\r\n\r\n// Ok, passed 100 tests (99% <null>).\r\n[<Property>]\r\nlet testOption (x : int option) =\r\n    obj.ReferenceEquals(x, null) ==> Prop.collect x true\r\n```"},"comment":{"url":"https://api.github.com/repos/fscheck/FsCheck/issues/comments/208521172","html_url":"https://github.com/fscheck/FsCheck/issues/215#issuecomment-208521172","issue_url":"https://api.github.com/repos/fscheck/FsCheck/issues/215","id":208521172,"user":{"login":"simendsjo","id":351519,"avatar_url":"https://avatars.githubusercontent.com/u/351519?v=3","gravatar_id":"","url":"https://api.github.com/users/simendsjo","html_url":"https://github.com/simendsjo","followers_url":"https://api.github.com/users/simendsjo/followers","following_url":"https://api.github.com/users/simendsjo/following{/other_user}","gists_url":"https://api.github.com/users/simendsjo/gists{/gist_id}","starred_url":"https://api.github.com/users/simendsjo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simendsjo/subscriptions","organizations_url":"https://api.github.com/users/simendsjo/orgs","repos_url":"https://api.github.com/users/simendsjo/repos","events_url":"https://api.github.com/users/simendsjo/events{/privacy}","received_events_url":"https://api.github.com/users/simendsjo/received_events","type":"User","site_admin":false},"created_at":"2016-04-11T19:39:54Z","updated_at":"2016-04-11T19:39:54Z","body":"Might be related to `==>` or me misunderstanding it.\r\n\r\n```\r\ntype T = {\r\n    X : string option\r\n}\r\n\r\n[<Property>]\r\nlet ``If set has length gteq 0`` (t : T) =\r\n    (t.X.IsSome && t.X.Value <> null) ==>\r\n        let i = (t.X.Value.Length) // fails here, but shouldn't t.X be Some and the value be <> null?\r\n        i >= 0\r\n    |> Prop.collect t\r\n```\r\n\r\n```\r\nSystem.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.\r\n  ----> NUnit.Framework.AssertionException : Falsifiable, after 3 tests (0 shrinks) (StdGen (101390474,296142000)):\r\nOriginal:\r\n{X = null;}\r\nwith exception:\r\nSystem.NullReferenceException: Object reference not set to an instance of an object.\r\n   at FsLibCheck.Tests.If set has length gteq 0(T t) in C:\\Users\\simendsjo\\code\\ProjectScaffold\\tests\\FsLibCheck.Tests\\Tests.fs:line 224\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at FsCheck.Runner.invokeAndThrowInner@310-1.Invoke(Object[] o) in C:\\Users\\Kurt\\Projects\\FsCheck\\FsCheck\\src\\FsCheck\\Runner.fs:line 314\r\n   at <StartupCode$FSharp-Core>.$Reflect.Invoke@961-4.Invoke(T1 inp)\r\n   at FsCheck.Testable.evaluate[a,b](FSharpFunc`2 body, a a) in C:\\Users\\Kurt\\Projects\\FsCheck\\FsCheck\\src\\FsCheck\\Testable.fs:line 161\r\n\r\n\r\n   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)\r\n   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)\r\n   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)\r\n   at FsCheck.Runner.checkMethod(Config config, MethodInfo m, FSharpOption`1 target) in C:\\Users\\Kurt\\Projects\\FsCheck\\FsCheck\\src\\FsCheck\\Runner.fs:line 318\r\n   at FsCheck.NUnit.Addin.FsCheckTestMethod.runTestMethod(TestResult testResult) in C:\\Users\\Kurt\\Projects\\FsCheck\\FsCheck\\src\\FsCheck.NUnit.Addin\\FsCheckTestMethod.fs:line 100\r\n   at FsCheck.NUnit.Addin.FsCheckTestMethod.runTestCase(TestResult testResult) in C:\\Users\\Kurt\\Projects\\FsCheck\\FsCheck\\src\\FsCheck.NUnit.Addin\\FsCheckTestMethod.fs:line 56\r\n--AssertionException\r\n   at NUnit.Framework.Assert.Fail(String message, Object[] args)\r\n   at <StartupCode$FsCheck-NUnit-Addin>.$FsCheckTestMethod.testRunner@66.FsCheck-IRunner-OnFinished(String , TestResult ) in C:\\Users\\Kurt\\Projects\\FsCheck\\FsCheck\\src\\FsCheck.NUnit.Addin\\FsCheckTestMethod.fs:line 86\r\n   at FsCheck.Runner.check[a](Config config, a p) in C:\\Users\\Kurt\\Projects\\FsCheck\\FsCheck\\src\\FsCheck\\Runner.fs:line 275\r\n\r\nFalsifiable, after 3 tests (0 shrinks) (StdGen (101390474,296142000)):\r\nOriginal:\r\n{X = null;}\r\nwith exception:\r\nSystem.NullReferenceException: Object reference not set to an instance of an object.\r\n   at FsLibCheck.Tests.If set has length gteq 0(T t) in C:\\Users\\simendsjo\\code\\ProjectScaffold\\tests\\FsLibCheck.Tests\\Tests.fs:line 224\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at FsCheck.Runner.invokeAndThrowInner@310-1.Invoke(Object[] o) in C:\\Users\\Kurt\\Projects\\FsCheck\\FsCheck\\src\\FsCheck\\Runner.fs:line 314\r\n   at <StartupCode$FSharp-Core>.$Reflect.Invoke@961-4.Invoke(T1 inp)\r\n   at FsCheck.Testable.evaluate[a,b](FSharpFunc`2 body, a a) in C:\\Users\\Kurt\\Projects\\FsCheck\\FsCheck\\src\\FsCheck\\Testable.fs:line 161\r\n```"}}