Giter VIP home page Giter VIP logo

Comments (5)

glantucan avatar glantucan commented on May 30, 2024 1

Thanks for taking care of this :)

from ospec.

pygy avatar pygy commented on May 30, 2024

@glantucan Not sure how we'll fix this, but in the mean time, you can write your own validator using the .satisfies() assertion.

Schematically:

const  compareImmutable = (reference) => (candidate) => {
  const discrepancies = []
  // actually compare `reference` and `candidate`, populate `discrepancies` if needed
  return {pass: discrepancies.length === 0, message: discrepancies.join("\n")}
}
o("test", () => {
  o(candidate).satisfies(compareImmutable(reference))
})

You'll probably want a recursive helper of the form

_compareImmutable(reference, candidate, discrepancies) {}

from ospec.

pygy avatar pygy commented on May 30, 2024

So, this is not something we can fix in core, as these objects are not deepEquals according to our definition, and out API leaves no room for adding an exception list.

Here's a rudimentary port of deepEquals to support seamless-immutable arrays (a slightly modified version of ospec's deepEquals). Feel free to embellish it to your fit needs.

Edit: better demo

from ospec.

pygy avatar pygy commented on May 30, 2024

Rethinking about this, I may have gotten this wrong... Non-enumerable properties are not compared on objects, we should skip them on arrays too for consistency.

from ospec.

pygy avatar pygy commented on May 30, 2024

This is fixed in v4.1.6

from ospec.

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.