Skip to content

Commit b4d2f71

Browse files
committed
[GR-17457] Update Complex to match methods spec
PullRequest: truffleruby/2376
2 parents 48f575b + 48c063d commit b4d2f71

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

spec/tags/truffle/methods_tags.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
fails:Public methods on Array should include all?
22
fails:Public methods on Array should include none?
33
fails:Public methods on Array should include one?
4-
fails:Public methods on Complex should include to_c
5-
fails:Public methods on Complex should not include divide
6-
fails:Public methods on Complex should not include marshal_load
74
fails:Public methods on File should include birthtime
85
fails:Public methods on File should not include inspect
96
fails:Public methods on File should not include stat

src/main/ruby/truffleruby/core/complex.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def *(other)
159159
end
160160
end
161161

162-
def divide(other)
162+
def /(other)
163163
if other.kind_of?(Complex)
164164
self * other.conjugate / other.abs2
165165
elsif other.kind_of?(Numeric) && other.real?
@@ -168,8 +168,7 @@ def divide(other)
168168
redo_coerced(:quo, other)
169169
end
170170
end
171-
alias_method :/, :divide
172-
alias_method :quo, :divide
171+
alias_method :quo, :/
173172

174173
def ** (other)
175174
if !other.kind_of?(Float) && other == 0
@@ -290,6 +289,10 @@ def rect
290289
end
291290
alias_method :rectangular, :rect
292291

292+
def to_c
293+
self
294+
end
295+
293296
def to_f
294297
raise RangeError, "can't convert #{self} into Float" unless !imag.kind_of?(Float) && imag == 0
295298
real.to_f
@@ -372,6 +375,7 @@ def marshal_load(ary)
372375
end
373376
self
374377
end
378+
private :marshal_load
375379

376380
def <=>(other)
377381
if imag == 0 && other.kind_of?(Numeric)

0 commit comments

Comments
 (0)