Giter Site home page Giter Site logo

Advanced examples about yard-doctest HOT 3 CLOSED

noraj avatar noraj commented on May 31, 2024
Advanced examples

from yard-doctest.

Comments (3)

p0deje avatar p0deje commented on May 31, 2024

Sorry for the late response, I somehow missed this message in my inbox.

I think we could be smarter about comparing two values in a similar to #=== way so that it supports comparing instances to classes, strings to regular expressions, etc.

For example, we could write any of these and they should pass.

true #=> true
true #=> TrueClass

"string" #=> "string"
"string" #=> /str/

[1, 2, 3] #=> Array

That would be implemented in a similar way as Ruby's case keyword or pattern matching where all these examples also are equal. Do you think that would cover your cases? Meanwhile, you can still write docs in a similar way:

obj === Array #=> true

In general, however, I don't think we should aim to cover all the possible assertions/matchers. The doctests should be lightweight so that anyone could read the example and comprehend them without knowing that those are also tests.

from yard-doctest.

p0deje avatar p0deje commented on May 31, 2024

I've just pushed ca7bf2e - you can see an example how to use it to assert instance of the object.

I just hope that switching to case equality won't break anything to existing users. @noraj Do you mind giving a new version a try if you use yard-doctest?

from yard-doctest.

noraj avatar noraj commented on May 31, 2024

I should give it a try for my next project.

from yard-doctest.

Related Issues (8)

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.