Expect.equal throws an NRE on failure
See original GitHub issueOn Expecto 8.10.1, the following code in an F# script fails with an NRE rather than a “pretty” error.
open Expecto
Expect.equal 1 2 "Doh!"
with the error:
System.NullReferenceException: Object reference not set to an instance of an object.
at Expecto.Expect.highlightAllGreen(FSharpList`1 diffs, String s) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 45
at Expecto.Expect.printVerses[a,b](String firstName, a first, String secondName, b second) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 66
at Expecto.Expect.equal$cont@317[a](a actual, a expected, String message, Object e, Object a, Unit unitVar) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 335
at <StartupCode$FSI_0014>.$FSI_0014.main@()
Stopped due to error
Is this something I’m doing “wrong” - can you not call Expect.
functions directly in a script or something?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:12 (12 by maintainers)
Top Results From Across the Web
Any way how to force Equals to return false instead of Null ...
Whether you were trying to access a property, method, or field is irrelevant, the NRE will be thrown regardless.
Read more >Expect
Fails because the expected value didn't split the space in "Betty Botter" Text.split " " "Betty Botter bought some butter" |> Expect.equal [...
Read more >Issues
In general, NREs are bad (according to the Microsoft api design guidelines) as the error message is unclear and people expect ANEs, and...
Read more >c# - Limits of Defensive Programming acknowledging that ...
The only "disadvantage" would be that if selectedUser is null it's considered equal too, instead of throwing as in your line.
Read more >Deprecation of '==' operator overload and fake null for ...
The MissingReferenceException essentially becomes a synonym for an NRE and doesn't really give any additional information besides "it's null but ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
No, that’s separate; the change that fixed your problem was to default the colours setting to something other than null (None).
@isaacabraham Need to set --colours 0. They are ANSI control codes. No sensible way of detecting if they are not supported and we default to 8 colours.