Skip to content

Commit

Permalink
allow method definitions test
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrberry committed Oct 20, 2020
1 parent 06eaab7 commit 2cac0ae
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spec/bitfield_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ class TestTooMany < BitField(UInt16)
num too_many, 17
end

class TestMethods < BitField(UInt8)
num bits, 8

def double_bits : Nil
self.bits <<= 1
end
end

describe BitField do
it "gets whole value" do
bf = Test8.new 0xAF
Expand Down Expand Up @@ -94,4 +102,10 @@ describe BitField do
bf = TestTooMany.new 0x0000
end
end

it "allows new method definitions" do
bf = TestMethods.new 0b00000001
bf.double_bits
bf.bits.should eq 0b00000010
end
end

0 comments on commit 2cac0ae

Please sign in to comment.