Giter VIP home page Giter VIP logo

Comments (5)

mnot avatar mnot commented on June 27, 2024

I can think of three ways:

  1. Have a file "negative-tests.json", in the same format, where they're all expected to fail.
  2. Add a property to the test suite (like "level") called something like "expected".
  3. use false to denote an expected failure; e.g., [ "{/keys", false ]

I kind of like 3... Note that whatever we do, we'd probably put these in a separate file, as spec-examples is just that, and I'd like to see us gather all kinds of tests here; no need to make it a single-file suite (that way, people can select the tests they want by choosing files).

from uritemplate-test.

damnhandy avatar damnhandy commented on June 27, 2024

I was already going down the path of number 3 myself, so let's do that! :) I completely agree that these tests belong in a separate file given that reporting errors is not a MUST. I'll send a pull request later today.

from uritemplate-test.

hannesg avatar hannesg commented on June 27, 2024

@damnhandy: +1

I'll rework my uritemplate library over the weekend and I could really use more tricky invalid examples.

from uritemplate-test.

damnhandy avatar damnhandy commented on June 27, 2024

I've issued a pull request for both issues #3 and #4. Regarding the negative test cases, I think it might get a bit more complicated. If you take a look at the last two tests, they likely should not fail, but they are also not valid URI templates. For example, the very last test uses the URI routing syntax found in frameworks like express.js:

   /vars/:var

A URI template processor like shouldn't bail on this test, citing invalid syntax, but one also shouldn't expect a properly expanded URI either. I guess my point is that we may need another category whereby the expected result isn't a just true or false, but that the expected result should not match. So I am thinking that we need something like option 2 to indicate that these tests will parse properly but will not yield the expected result. Thoughts?

from uritemplate-test.

mnot avatar mnot commented on June 27, 2024

Looks done (sure we'll have more).

from uritemplate-test.

Related Issues (20)

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.