Skip to content

Commit d002be6

Browse files
committed
Use ArgumentError instead of TypeError in Memory#initialize (closes #60).
1 parent 27bb9d6 commit d002be6

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

lib/ronin/asm/memory.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,24 @@ class Memory < Operand
7575
# @param [Integer, nil] width
7676
# The optional width of the memory operand.
7777
#
78-
# @raise [TypeError]
78+
# @raise [ArgumentError]
7979
# `base` or `index` was not a {Register} or `nil`.
8080
#
8181
def initialize(base=nil,displacement=0,index=nil,scale=1,width=nil)
8282
unless (base.nil? || base.kind_of?(Register))
83-
raise(TypeError,"base must be a Register or nil")
83+
raise(ArgumentError,"base must be a Register or nil")
8484
end
8585

8686
unless displacement.kind_of?(Integer)
87-
raise(TypeError,"displacement must be an Integer")
87+
raise(ArgumentError,"displacement must be an Integer")
8888
end
8989

9090
unless (index.nil? || index.kind_of?(Register))
91-
raise(TypeError,"index must be a Register or nil")
91+
raise(ArgumentError,"index must be a Register or nil")
9292
end
9393

9494
unless scale.kind_of?(Integer)
95-
raise(TypeError,"scale must be an Integer")
95+
raise(ArgumentError,"scale must be an Integer")
9696
end
9797

9898
@base = base

spec/memory_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@
1515
it "must only accept nil and a Register for base" do
1616
expect {
1717
described_class.new(Object.new)
18-
}.to raise_error(TypeError)
18+
}.to raise_error(ArgumentError)
1919
end
2020

2121
it "must only accept Integers for displacement" do
2222
expect {
2323
described_class.new(register,2.0)
24-
}.to raise_error(TypeError)
24+
}.to raise_error(ArgumentError)
2525
end
2626

2727
it "must only accept nil and a Register for index" do
2828
expect {
2929
described_class.new(register,0,Object.new)
30-
}.to raise_error(TypeError)
30+
}.to raise_error(ArgumentError)
3131
end
3232

3333
it "must only accept Integers for displacement" do
3434
expect {
3535
described_class.new(register,0,nil,2.0)
36-
}.to raise_error(TypeError)
36+
}.to raise_error(ArgumentError)
3737
end
3838

3939
end

0 commit comments

Comments
 (0)