GithubHelp home page GithubHelp logo

faqt's People

Contributors

cmeeren avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

faqt's Issues

Consider diff rendering for certain equality assertions

Not immediately planning this, just noting that a few assertions (like Be) might be improved by rendering some kind of diff in the assertion message.

The diff could be made via e.g. Diffract.

Drawbacks/caveats:

  • Adds a dependency (if using Diffract), or significant complexity (if implementing custom differ)
  • May not really be necessary
  • Diffract does not diff strings, only objects?

Use [<ReflectedDefinition(true)>] expressions for lambdas etc. and include printed expression in output

It is possible to annotate a parameter with [<ReflectedDefinition(true)>]. The usage syntax stays the same, but it will then be of type Expr<_> and match the pattern Microsoft.FSharp.Quotations.Patterns.WithValue, where we can get the value (without having to manually evaluate the expression) as well as the expression for the parameter.

This could be used in assertions like Be(expected, isEqual) to get the name/expression of the custom comparer and include it in the assertion failure output.

Unfortunately, this has two significant drawbacks:

  1. Quotations have several limitations, e.g., no calls to inner generic functions, some problems with mutable values, etc. This requires the user to adapt their code. (This is one of the reasons I no longer use Unquote.) This is made worse due to the fact that the user is seemingly not writing an expression (this fact is hidden from the user by ReflectedDefinition), likely causing confusion.

  2. Sensibly printing the expression tree can be difficult. This code could be adapted, but I am unsure how complete it and what it doesn't handle, and after experimenting a bit, I find it hard to get the results I want. It seems the the expression tree does not contain enough information to render something sufficiently close to the original code, even for simple values like a curried function as the isEqual parameter.

I find that either of the points above is a sufficient reason for dropping this feature.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.