GithubHelp home page GithubHelp logo

Comments (4)

icy-arctic-fox avatar icy-arctic-fox commented on June 15, 2024

I've found two issues:

  1. Hexdump::Type::Int#initialize has a size parameter. That uses Int32 instead of ::Int32, so it accidentally references the Int32 class below it.
  2. The use of .to be(nil) doesn't behave correctly against value-types. In this instance, Endian is nillable. The be matcher uses the #same method for comparison. But this is only found on Nil and reference types. Spectator has custom logic for values, but didn't handle nil and value types quite right. This has been fixed and pushed to master.

After addressing both of these issues, the spec passes.

Alternatively, for 2, be_nil can be used in place of be(nil).

from spectator.

postmodern avatar postmodern commented on June 15, 2024

Could a special case be added for be(nil) and Value types?

from spectator.

icy-arctic-fox avatar icy-arctic-fox commented on June 15, 2024

Could a special case be added for be(nil) and Value types?

Yup, one has been added and is on master.

from spectator.

postmodern avatar postmodern commented on June 15, 2024

I've made the suggested changes and updated spectator, but now I'm hitting this issue when using .to be(...) to compare entries in a Hash.

  TYPES = Hash(Symbol,Type).new
  TYPES[:uint8] = Type::UInt8.new
  TYPES[:byte] = TYPES[:uint8]
require "./spec_helper"
require "../src/hexdump/types"

Spectator.describe "Hexdump::TYPES" do
  subject { Hexdump::TYPES }

  describe "byte" do
    it "must be an alias to uint8" do
      expect(subject[:byte]).to be(subject[:uint8])
    end
  end
In spec/types_spec.cr:9:31

 9 | expect(subject[:byte]).to be(subject[:uint8])
                             ^-
Error: instantiating 'Spectator::Expectation::Target(Hexdump::Type)#to(Spectator::Matchers::ReferenceMatcher(Hexdump::Type))'


In lib/spectator/src/spectator/expectation.cr:104:7

 104 | def to(matcher, message = nil) : Nil
       ^-
Error: instantiating 'to(Spectator::Matchers::ReferenceMatcher(Hexdump::Type), Nil)'


In lib/spectator/src/spectator/expectation.cr:105:30

 105 | match_data = matcher.match(@expression)
                            ^----
Error: instantiating 'Spectator::Matchers::ReferenceMatcher(Hexdump::Type)#match(Spectator::Expression(Hexdump::Type)+)'


In lib/spectator/src/spectator/matchers/standard_matcher.cr:27:10

 27 | if match?(actual)
         ^-----
Error: instantiating 'match?(Spectator::Expression(Hexdump::Type)+)'


In lib/spectator/src/spectator/matchers/reference_matcher.cr:20:15

 20 | value.same?(actual.value)
            ^----
Error: instantiating 'Hexdump::Type+#same?(Hexdump::Type+)'


In /var/lib/snapd/snap/crystal/793/share/crystal/src/reference.cr:29:5

 29 | object_id == other.object_id
      ^--------
Error: instantiating 'object_id()'


In /var/lib/snapd/snap/crystal/793/share/crystal/src/primitives.cr:50:19

 50 | def object_id : UInt64
                      ^-----
Error: method Hexdump::Type+#object_id must return UInt64 but it is returning Hexdump::Type::UInt64

Hexdump::Type::UInt64 trace:

  /var/lib/snapd/snap/crystal/793/share/crystal/src/primitives.cr:50

      def object_id : UInt64

from spectator.

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.