question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expect.equal throws an NRE on failure

See original GitHub issue

On 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
hafcommented, Jul 2, 2019

Putting a check for Windows won’t help that at all I would imagine.

No, that’s separate; the change that fixed your problem was to default the colours setting to something other than null (None).

1reaction
AnthonyLloydcommented, Jul 2, 2019

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found