[eclipse/golo-lang] aeb7b9: [471709] Exception when comparing numbers

0 views
Skip to first unread message

GitHub

unread,
Jul 3, 2015, 8:27:37 AM7/3/15
to golo...@googlegroups.com
Branch: refs/heads/master
Home: https://github.com/eclipse/golo-lang
Commit: aeb7b972d1dc26a6da4ba78bdae25372a49f788c
https://github.com/eclipse/golo-lang/commit/aeb7b972d1dc26a6da4ba78bdae25372a49f788c
Author: Yannick Loiseau <m...@yloiseau.net>
Date: 2015-07-02 (Thu, 02 Jul 2015)

Changed paths:
M src/main/java/fr/insalyon/citi/golo/runtime/OperatorSupport.java
M src/test/java/fr/insalyon/citi/golo/compiler/CompileAndRunTest.java
M src/test/resources/for-execution/operators.golo

Log Message:
-----------
[471709] Exception when comparing numbers

The implementation of comparison operators was done using `compareTo`,
which fails when comparing two numbers of different classes.

The bug is fixed by using `Double.compare` on the two numbers
`doubleValue` when both values are instances of `Number`, falling back
to `compareTo` otherwise.

The same is done for equality, since until now, golo considered
`1 != 1.0`. When the two values are numbers, the double value is
compared by value, `equals` is called otherwise.

Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=471709


Commit: bb41732e008b1ac645a414d16f24fcf20e8acd9f
https://github.com/eclipse/golo-lang/commit/bb41732e008b1ac645a414d16f24fcf20e8acd9f
Author: Yannick Loiseau <m...@yloiseau.net>
Date: 2015-07-03 (Fri, 03 Jul 2015)

Changed paths:
M src/main/java/fr/insalyon/citi/golo/runtime/OperatorSupport.java
M src/main/ruby/generate_math.rb
M src/test/java/fr/insalyon/citi/golo/compiler/CompileAndRunTest.java
M src/test/resources/for-execution/unions.golo

Log Message:
-----------
Alternative implementation

Use the `generate_math.rb` script to generate type specific operators
with explicit cast and guard.
The operators semantic will then be the same as Java on primitive types,
falling back to `equals` and `compareTo`.
This allows to use the binary operator inline cache.

Also use `java.util.Objects.equals` for `==` and `!=` implementation.


Commit: 1ec34025d81ec6fb2cc6430ffd0c611a53b6d1bd
https://github.com/eclipse/golo-lang/commit/1ec34025d81ec6fb2cc6430ffd0c611a53b6d1bd
Author: Yannick Loiseau <m...@yloiseau.net>
Date: 2015-07-03 (Fri, 03 Jul 2015)

Changed paths:
M src/test/resources/for-execution/operators.golo

Log Message:
-----------
Changes comparison unit test

Raises an exception when the comparison failed instead of aggregating
booleans.


Commit: 61a542e3dc5e17494b73de778f7c174c9d0090e7
https://github.com/eclipse/golo-lang/commit/61a542e3dc5e17494b73de778f7c174c9d0090e7
Author: Julien Ponge <jpo...@users.noreply.github.com>
Date: 2015-07-03 (Fri, 03 Jul 2015)

Changed paths:
M src/main/java/fr/insalyon/citi/golo/runtime/OperatorSupport.java
M src/main/ruby/generate_math.rb
M src/test/java/fr/insalyon/citi/golo/compiler/CompileAndRunTest.java
M src/test/resources/for-execution/operators.golo
M src/test/resources/for-execution/unions.golo

Log Message:
-----------
Merge pull request #288 from yloiseau/fix/471709-polymorphic-numbers-comparison

[471709] Exception when comparing numbers


Compare: https://github.com/eclipse/golo-lang/compare/c87d21f71e1d...61a542e3dc5e
Reply all
Reply to author
Forward
0 new messages