New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #373: Implement BigInteger and BigDecimal. #1549

Merged
merged 2 commits into from May 8, 2015

Conversation

Projects
None yet
5 participants
@ghost

ghost commented Mar 16, 2015

Implements #373

Notes:

  • There are four tests marked as xit, all relating to float infinity being casted to doubl infinity
  • There are a couple of comments of "Todo:" where some functionality could go into main javalib.
@scala-jenkins

This comment has been minimized.

Show comment
Hide comment
@scala-jenkins

scala-jenkins Mar 16, 2015

Can one of the admins verify this patch?

scala-jenkins commented Mar 16, 2015

Can one of the admins verify this patch?

@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd Mar 16, 2015

Member

Well, that comes at a rather bad time for me. I probably won't be able to review this until March 25, date of an academic deadline.

(next comment is intended for the build bot)

Member

sjrd commented Mar 16, 2015

Well, that comes at a rather bad time for me. I probably won't be able to review this until March 25, date of an academic deadline.

(next comment is intended for the build bot)

@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd Mar 16, 2015

Member

test this please

Member

sjrd commented Mar 16, 2015

test this please

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 16, 2015

@sjrd np at all - I'm just glad to have got my bit done already!

ghost commented Mar 16, 2015

@sjrd np at all - I'm just glad to have got my bit done already!

@gzm0

This comment has been minimized.

Show comment
Hide comment
@gzm0

gzm0 Mar 16, 2015

Contributor

I might have some resources to review. @sjrd how about you hold off and I start reviewing and we'll see where I get.

Contributor

gzm0 commented Mar 16, 2015

I might have some resources to review. @sjrd how about you hold off and I start reviewing and we'll see where I get.

@gzm0

View changes

Show outdated Hide outdated javalanglib/src/main/scala/java/lang/Long.scala
@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd Mar 16, 2015

Member

@gzm0 That would be good, thanks :-D

Member

sjrd commented Mar 16, 2015

@gzm0 That would be good, thanks :-D

@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd Mar 16, 2015

Member

Some feedback from the CI:

[warn] /localhome/jenkins/b/workspace/scalajs-task-worker/test-suite/src/test/scala/org/scalajs/testsuite/javalib/math/BigDecimalCompareTest.scala:166: comparing values of types java.math.BigDecimal and String using `==' will always yield false
[warn]       assertFalse(aNumber == b)
[warn]                           ^

Also, BigDecimalArithmeticTest.testDivideZero fails:

[error]  x testDivideZero
[error]     Expected { toStringImage$2 : '0', $$undhashCode$2 : 0, intVal$2 : { digits$2 : { u : [ 0 ] }, numberLength$2 : 1, sign$2 : 0, firstNonzeroDigit$2 : -2, java$math$BigInteger$$$undhashCode$2 : 0 }, java$math$BigDecimal$$$undbitLength$2 : 0, java$math$BigDecimal$$$undsmallValue$2 : { l$2 : 0, m$2 : 0, h$2 : 0 }, java$math$BigDecimal$$$undscale$2 : 0, $$undprecision$2 : 0 } to equal { toStringImage$2 : null, $$undhashCode$2 : 0, intVal$2 : { digits$2 : { u : [ 0 ] }, numberLength$2 : 1, sign$2 : 0, firstNonzeroDigit$2 : -2, java$math$BigInteger$$$undhashCode$2 : 0 }, java$math$BigDecimal$$$undbitLength$2 : 0, java$math$BigDecimal$$$undsmallValue$2 : { l$2 : 0, m$2 : 0, h$2 : 0 }, java$math$BigDecimal$$$undscale$2 : 0, $$undprecision$2 : 0 }.
Member

sjrd commented Mar 16, 2015

Some feedback from the CI:

[warn] /localhome/jenkins/b/workspace/scalajs-task-worker/test-suite/src/test/scala/org/scalajs/testsuite/javalib/math/BigDecimalCompareTest.scala:166: comparing values of types java.math.BigDecimal and String using `==' will always yield false
[warn]       assertFalse(aNumber == b)
[warn]                           ^

Also, BigDecimalArithmeticTest.testDivideZero fails:

[error]  x testDivideZero
[error]     Expected { toStringImage$2 : '0', $$undhashCode$2 : 0, intVal$2 : { digits$2 : { u : [ 0 ] }, numberLength$2 : 1, sign$2 : 0, firstNonzeroDigit$2 : -2, java$math$BigInteger$$$undhashCode$2 : 0 }, java$math$BigDecimal$$$undbitLength$2 : 0, java$math$BigDecimal$$$undsmallValue$2 : { l$2 : 0, m$2 : 0, h$2 : 0 }, java$math$BigDecimal$$$undscale$2 : 0, $$undprecision$2 : 0 } to equal { toStringImage$2 : null, $$undhashCode$2 : 0, intVal$2 : { digits$2 : { u : [ 0 ] }, numberLength$2 : 1, sign$2 : 0, firstNonzeroDigit$2 : -2, java$math$BigInteger$$$undhashCode$2 : 0 }, java$math$BigDecimal$$$undbitLength$2 : 0, java$math$BigDecimal$$$undsmallValue$2 : { l$2 : 0, m$2 : 0, h$2 : 0 }, java$math$BigDecimal$$$undscale$2 : 0, $$undprecision$2 : 0 }.
@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd Mar 16, 2015

Member

The bootstrap test fails with a linking error (locally, use ´set scalaJSStage in Global := FastOptStageandtoolsJS/test` to reproduce):

[info] Fast optimizing /localhome/jenkins/a/workspace/scalajs-task-worker/test-suite/target/scala-2.11/scalajs-test-suite-test-fastopt.js
[info] Fast optimizing /localhome/jenkins/a/workspace/scalajs-task-worker/tools/js/target/scala-2.11/scalajs-tools-test-fastopt.js
[error] Referring to non-existent method jl_Long$.toString__J__I__T
[error]   called from Ljava_math_Conversion$.bigInteger2String__Ljava_math_BigInteger__I__T
[error]   called from Ljava_math_BigInteger.toString__I__T
[error]   called from Lorg_scalajs_testsuite_javalib_math_BigIntegerToStringTest$$anonfun$1.apply$mcV$sp__V
[error]   called from Lorg_scalajs_testsuite_javalib_math_BigIntegerToStringTest$$anonfun$1.apply__V
[error]   called from Lorg_scalajs_testsuite_javalib_math_BigIntegerToStringTest$$anonfun$1.apply__O
[error]   called from Lorg_scalajs_testinterface_internal_Slave.jsonArg$1__p2__F0__sjs_js_Dynamic
[error]   called from Lorg_scalajs_testinterface_internal_Slave.$$anonfun$1__p2__T__F0__V
[error]   called from Lorg_scalajs_testinterface_internal_Slave.handleMsgImpl__T__F0__V
[error]   called from Lorg_scalajs_testinterface_internal_BridgeBase.handleMsg__p1__T__V
[error]   called from Lorg_scalajs_testinterface_internal_BridgeBase.$$anonfun$1__p1__T__V
[error]   called from Lorg_scalajs_testinterface_internal_BridgeBase.init__V
[error]   called from Lorg_scalajs_testinterface_internal_BridgeBase.$$js$exported$meth$init__O
[error]   called from Lorg_scalajs_testinterface_internal_BridgeBase.init
[error]   exported to JavaScript with @JSExport
[error] involving instantiated classes:
[error]   Ljava_math_Conversion$
[error]   Ljava_math_BigInteger
[error]     (already seen, not repeating call stack)
[error]   Lorg_scalajs_testsuite_javalib_math_BigIntegerToStringTest$$anonfun$1
[error]   Lorg_scalajs_testinterface_internal_Slave
[error]   Lorg_scalajs_testinterface_internal_Master
[error] Referring to non-existent method jl_Long$.toString__J__I__T
[error]   called from Ljava_math_Conversion$.bigInteger2String__Ljava_math_BigInteger__I__T
[error]   called from Ljava_math_BigInteger.toString__I__T
[error]   called from Lorg_scalajs_testsuite_javalib_math_BigIntegerToStringTest$$anonfun$1.apply$mcV$sp__V
[error]   called from Lorg_scalajs_testsuite_javalib_math_BigIntegerToStringTest$$anonfun$1.apply__V
[error]   called from Lorg_scalajs_testsuite_javalib_math_BigIntegerToStringTest$$anonfun$1.apply__O
[error]   called from Lorg_scalajs_testinterface_internal_Slave.jsonArg$1__p2__F0__sjs_js_Dynamic
[error]   called from Lorg_scalajs_testinterface_internal_Slave.$$anonfun$1__p2__T__F0__V
[error]   called from Lorg_scalajs_testinterface_internal_Slave.handleMsgImpl__T__F0__V
[error]   called from Lorg_scalajs_testinterface_internal_BridgeBase.handleMsg__p1__T__V
[error]   called from Lorg_scalajs_testinterface_internal_BridgeBase.$$anonfun$1__p1__T__V
[error]   called from Lorg_scalajs_testinterface_internal_BridgeBase.init__V
[error]   called from Lorg_scalajs_testinterface_internal_BridgeBase.$$js$exported$meth$init__O
[error]   called from Lorg_scalajs_testinterface_internal_BridgeBase.init
[error]   exported to JavaScript with @JSExport
[error] involving instantiated classes:
[error]   Ljava_math_Conversion$
[error]   Ljava_math_BigInteger
[error]     (already seen, not repeating call stack)
[error]   Lorg_scalajs_testsuite_javalib_math_BigIntegerToStringTest$$anonfun$1
[error]   Lorg_scalajs_testinterface_internal_Slave
[error]   Lorg_scalajs_testinterface_internal_Master
java.lang.RuntimeException: There were linking errors
Member

sjrd commented Mar 16, 2015

The bootstrap test fails with a linking error (locally, use ´set scalaJSStage in Global := FastOptStageandtoolsJS/test` to reproduce):

[info] Fast optimizing /localhome/jenkins/a/workspace/scalajs-task-worker/test-suite/target/scala-2.11/scalajs-test-suite-test-fastopt.js
[info] Fast optimizing /localhome/jenkins/a/workspace/scalajs-task-worker/tools/js/target/scala-2.11/scalajs-tools-test-fastopt.js
[error] Referring to non-existent method jl_Long$.toString__J__I__T
[error]   called from Ljava_math_Conversion$.bigInteger2String__Ljava_math_BigInteger__I__T
[error]   called from Ljava_math_BigInteger.toString__I__T
[error]   called from Lorg_scalajs_testsuite_javalib_math_BigIntegerToStringTest$$anonfun$1.apply$mcV$sp__V
[error]   called from Lorg_scalajs_testsuite_javalib_math_BigIntegerToStringTest$$anonfun$1.apply__V
[error]   called from Lorg_scalajs_testsuite_javalib_math_BigIntegerToStringTest$$anonfun$1.apply__O
[error]   called from Lorg_scalajs_testinterface_internal_Slave.jsonArg$1__p2__F0__sjs_js_Dynamic
[error]   called from Lorg_scalajs_testinterface_internal_Slave.$$anonfun$1__p2__T__F0__V
[error]   called from Lorg_scalajs_testinterface_internal_Slave.handleMsgImpl__T__F0__V
[error]   called from Lorg_scalajs_testinterface_internal_BridgeBase.handleMsg__p1__T__V
[error]   called from Lorg_scalajs_testinterface_internal_BridgeBase.$$anonfun$1__p1__T__V
[error]   called from Lorg_scalajs_testinterface_internal_BridgeBase.init__V
[error]   called from Lorg_scalajs_testinterface_internal_BridgeBase.$$js$exported$meth$init__O
[error]   called from Lorg_scalajs_testinterface_internal_BridgeBase.init
[error]   exported to JavaScript with @JSExport
[error] involving instantiated classes:
[error]   Ljava_math_Conversion$
[error]   Ljava_math_BigInteger
[error]     (already seen, not repeating call stack)
[error]   Lorg_scalajs_testsuite_javalib_math_BigIntegerToStringTest$$anonfun$1
[error]   Lorg_scalajs_testinterface_internal_Slave
[error]   Lorg_scalajs_testinterface_internal_Master
[error] Referring to non-existent method jl_Long$.toString__J__I__T
[error]   called from Ljava_math_Conversion$.bigInteger2String__Ljava_math_BigInteger__I__T
[error]   called from Ljava_math_BigInteger.toString__I__T
[error]   called from Lorg_scalajs_testsuite_javalib_math_BigIntegerToStringTest$$anonfun$1.apply$mcV$sp__V
[error]   called from Lorg_scalajs_testsuite_javalib_math_BigIntegerToStringTest$$anonfun$1.apply__V
[error]   called from Lorg_scalajs_testsuite_javalib_math_BigIntegerToStringTest$$anonfun$1.apply__O
[error]   called from Lorg_scalajs_testinterface_internal_Slave.jsonArg$1__p2__F0__sjs_js_Dynamic
[error]   called from Lorg_scalajs_testinterface_internal_Slave.$$anonfun$1__p2__T__F0__V
[error]   called from Lorg_scalajs_testinterface_internal_Slave.handleMsgImpl__T__F0__V
[error]   called from Lorg_scalajs_testinterface_internal_BridgeBase.handleMsg__p1__T__V
[error]   called from Lorg_scalajs_testinterface_internal_BridgeBase.$$anonfun$1__p1__T__V
[error]   called from Lorg_scalajs_testinterface_internal_BridgeBase.init__V
[error]   called from Lorg_scalajs_testinterface_internal_BridgeBase.$$js$exported$meth$init__O
[error]   called from Lorg_scalajs_testinterface_internal_BridgeBase.init
[error]   exported to JavaScript with @JSExport
[error] involving instantiated classes:
[error]   Ljava_math_Conversion$
[error]   Ljava_math_BigInteger
[error]     (already seen, not repeating call stack)
[error]   Lorg_scalajs_testsuite_javalib_math_BigIntegerToStringTest$$anonfun$1
[error]   Lorg_scalajs_testinterface_internal_Slave
[error]   Lorg_scalajs_testinterface_internal_Master
java.lang.RuntimeException: There were linking errors
@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 16, 2015

[warn] assertFalse(aNumber == b)

Yes, it's supposed to always fail - this is one of the original tests. Shall I leave as is or remove it?

BigDecimalArithmeticTest.testDivideZero

This passes locally - any ideas on the environment that could cause this difference?

ghost commented Mar 16, 2015

[warn] assertFalse(aNumber == b)

Yes, it's supposed to always fail - this is one of the original tests. Shall I leave as is or remove it?

BigDecimalArithmeticTest.testDivideZero

This passes locally - any ideas on the environment that could cause this difference?

@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd Mar 16, 2015

Member

Yes, it's supposed to always fail - this is one of the original tests. Shall I leave as is or remove it?

Maybe call .equals directly to silence the warning, and add a comment saying why you do that.

This passes locally - any ideas on the environment that could cause this difference?

Scala version, maybe. It fails with 2.10.2, for example:
https://scala-webapps.epfl.ch/jenkins/job/scalajs-task-worker/32364/consoleFull

Member

sjrd commented Mar 16, 2015

Yes, it's supposed to always fail - this is one of the original tests. Shall I leave as is or remove it?

Maybe call .equals directly to silence the warning, and add a comment saying why you do that.

This passes locally - any ideas on the environment that could cause this difference?

Scala version, maybe. It fails with 2.10.2, for example:
https://scala-webapps.epfl.ch/jenkins/job/scalajs-task-worker/32364/consoleFull

@scala-jenkins

This comment has been minimized.

Show comment
Hide comment
@scala-jenkins

scala-jenkins Mar 16, 2015

Test FAILed.
Refer to this link for build results (access rights to CI server needed):

https://scala-webapps.epfl.ch/jenkins/job/scalajs-pr/1506/
https://scala-webapps.epfl.ch/jenkins/job/scalajs-matrix-build/1940/
Test FAILed.

scala-jenkins commented Mar 16, 2015

Test FAILed.
Refer to this link for build results (access rights to CI server needed):

https://scala-webapps.epfl.ch/jenkins/job/scalajs-pr/1506/
https://scala-webapps.epfl.ch/jenkins/job/scalajs-matrix-build/1940/
Test FAILed.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 16, 2015

The issue with the bootstap is a missing method in java.lang.Long.toString(long i, int radix)

ghost commented Mar 16, 2015

The issue with the bootstap is a missing method in java.lang.Long.toString(long i, int radix)

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 17, 2015

@sjrd @gzm0

I've fixed all the above but I have implemented the following as they are missing from javalib - perhaps I should pull these out first and PR them as for Long.signum?:

  • Integer toString(i: scala.Int, radix: scala.Int): String . this just calls private[this] def toStringBase(i: scala.Int, base: scala.Int): String . Perhaps it is best just to rename this and make public?
  • Ingteger highestOneBit(i: Int): Int
  • Char forDigit(digit: Int): Char and def forDigit(digit: Int, radix: Int): Char
  • Long toString(value: Long, intRadix: Int): String

Move awkward is

 String  regionMatches(s: String, ignoreCase: Boolean,
                            toffset: Int,
                            other: String,
                            ooffset: Int,
                            len: Int): Boolean 
def regionMatches(s: String, toffset: Int,
                            other: String,
                            ooffset: Int,
                            len: Int): Boolean 

as i believe you treat Strings differently. Any thoughts?

In the meantime, I'll finish #1551

ghost commented Mar 17, 2015

@sjrd @gzm0

I've fixed all the above but I have implemented the following as they are missing from javalib - perhaps I should pull these out first and PR them as for Long.signum?:

  • Integer toString(i: scala.Int, radix: scala.Int): String . this just calls private[this] def toStringBase(i: scala.Int, base: scala.Int): String . Perhaps it is best just to rename this and make public?
  • Ingteger highestOneBit(i: Int): Int
  • Char forDigit(digit: Int): Char and def forDigit(digit: Int, radix: Int): Char
  • Long toString(value: Long, intRadix: Int): String

Move awkward is

 String  regionMatches(s: String, ignoreCase: Boolean,
                            toffset: Int,
                            other: String,
                            ooffset: Int,
                            len: Int): Boolean 
def regionMatches(s: String, toffset: Int,
                            other: String,
                            ooffset: Int,
                            len: Int): Boolean 

as i believe you treat Strings differently. Any thoughts?

In the meantime, I'll finish #1551

@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd Mar 17, 2015

Member

It would be good indeed to factor out the other small methods in a dedicated PR.

toString with radix cannot use toStringBase, because they handle negative numbers differently.

Methods of java.lang.String are implemented in RuntimeString. The compiler magically rewires calls like s.someMethod(args...) to RuntimeString.someMethod(s, args...).

Member

sjrd commented Mar 17, 2015

It would be good indeed to factor out the other small methods in a dedicated PR.

toString with radix cannot use toStringBase, because they handle negative numbers differently.

Methods of java.lang.String are implemented in RuntimeString. The compiler magically rewires calls like s.someMethod(args...) to RuntimeString.someMethod(s, args...).

@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd Mar 18, 2015

Member

@inthenow You should not merge master into the branch used for this PR. You should rebase instead.

Member

sjrd commented Mar 18, 2015

@inthenow You should not merge master into the branch used for this PR. You should rebase instead.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 18, 2015

You should not merge master into the branch used for this PR. You should rebase instead.

Ahhhh... school boy error. And I had just finished everything!!!

ghost commented Mar 18, 2015

You should not merge master into the branch used for this PR. You should rebase instead.

Ahhhh... school boy error. And I had just finished everything!!!

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 18, 2015

Not sure if I have got git correct, but otherwise everything is in :)

ghost commented Mar 18, 2015

Not sure if I have got git correct, but otherwise everything is in :)

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 18, 2015

Ok- git looks good and build passes all tests on all scala versions (sbt +testSuite/test)

@sjrd @gzm0 With you now - no rush as I know you have a 25.03 deadline

ghost commented Mar 18, 2015

Ok- git looks good and build passes all tests on all scala versions (sbt +testSuite/test)

@sjrd @gzm0 With you now - no rush as I know you have a 25.03 deadline

@gzm0

This comment has been minimized.

Show comment
Hide comment
@gzm0

gzm0 Mar 19, 2015

Contributor

I'm sorry I have to say that, as I know the pain that this will inflict upon you to correct, but the commits are in the wrong order. The commits that add the auxiliary methods to the Javalib should come first in the history. Also, please reference the ticket numbers from the commits:

"Fix #xxx: msg" if the commit fixes a full issue, a comment in the body that mentions partial fixes. Further, please start commit messages upper-case and formulate in present tense. (Have a look at the history for examples).

I will start reviewing anyway, as most of it is orthogonal to how the commits are ordered.

Contributor

gzm0 commented Mar 19, 2015

I'm sorry I have to say that, as I know the pain that this will inflict upon you to correct, but the commits are in the wrong order. The commits that add the auxiliary methods to the Javalib should come first in the history. Also, please reference the ticket numbers from the commits:

"Fix #xxx: msg" if the commit fixes a full issue, a comment in the body that mentions partial fixes. Further, please start commit messages upper-case and formulate in present tense. (Have a look at the history for examples).

I will start reviewing anyway, as most of it is orthogonal to how the commits are ordered.

@gzm0

View changes

Show outdated Hide outdated javalanglib/src/main/scala/java/lang/Character.scala
@gzm0

View changes

Show outdated Hide outdated javalanglib/src/main/scala/java/lang/Character.scala
@gzm0

View changes

Show outdated Hide outdated javalanglib/src/main/scala/java/lang/Character.scala
@gzm0

View changes

Show outdated Hide outdated javalanglib/src/main/scala/java/lang/Integer.scala
@gzm0

View changes

Show outdated Hide outdated javalanglib/src/main/scala/java/lang/Integer.scala
@gzm0

View changes

Show outdated Hide outdated javalanglib/src/main/scala/java/lang/Integer.scala
@gzm0

View changes

Show outdated Hide outdated javalanglib/src/main/scala/java/lang/Long.scala
@gzm0

View changes

Show outdated Hide outdated javalanglib/src/main/scala/java/lang/Long.scala
@gzm0

View changes

Show outdated Hide outdated library/src/main/scala/scala/scalajs/runtime/RuntimeString.scala
@gzm0

View changes

Show outdated Hide outdated library/src/main/scala/scala/scalajs/runtime/RuntimeString.scala
@gzm0

View changes

Show outdated Hide outdated library/src/main/scala/scala/scalajs/runtime/RuntimeString.scala
@gzm0

View changes

Show outdated Hide outdated library/src/main/scala/scala/scalajs/runtime/RuntimeString.scala
@gzm0

View changes

Show outdated Hide outdated library/src/main/scala/scala/scalajs/runtime/RuntimeString.scala
@gzm0

View changes

Show outdated Hide outdated library/src/main/scala/scala/scalajs/runtime/RuntimeString.scala
@gzm0

View changes

Show outdated Hide outdated test-suite/src/test/scala/org/scalajs/testsuite/javalib/CharacterTest.scala
@gzm0

View changes

Show outdated Hide outdated test-suite/src/test/scala/org/scalajs/testsuite/javalib/IntegerTest.scala
@gzm0

View changes

Show outdated Hide outdated test-suite/src/test/scala/org/scalajs/testsuite/javalib/IntegerTest.scala
@gzm0

View changes

Show outdated Hide outdated test-suite/src/test/scala/org/scalajs/testsuite/javalib/LongTest.scala
@gzm0

View changes

Show outdated Hide outdated test-suite/src/test/scala/org/scalajs/testsuite/javalib/StringTest.scala
@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd May 5, 2015

Member

To test that it works with strict floats, do

> set scalaJSSemantics in testSuite ~= { _.withStrictFloats(true) }
> testSuite/test
Member

sjrd commented May 5, 2015

To test that it works with strict floats, do

> set scalaJSSemantics in testSuite ~= { _.withStrictFloats(true) }
> testSuite/test
@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd May 5, 2015

Member

Otherwise I think the PR's good (modulo rebase/squashing).

Member

sjrd commented May 5, 2015

Otherwise I think the PR's good (modulo rebase/squashing).

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost May 5, 2015

This seems to do the trick - OK?

when("strict-floats").
    it("testFloatValueBug2482") {
      val a = "2147483649"
      val result = 2.14748365E9f
      val aNumber = new BigInteger(a).floatValue()
      val delta = 0
      expect(Math.abs(aNumber - result)).toEqual(delta)
    }

    unless("strict-floats").
      it("testFloatValueBug2482") {
      val a = "2147483649"
      val result = 2.14748365E9f
      val aNumber = new BigInteger(a).floatValue()
      val delta = 1
      expect(Math.abs(aNumber - result)).toEqual(delta)
    }

ghost commented May 5, 2015

This seems to do the trick - OK?

when("strict-floats").
    it("testFloatValueBug2482") {
      val a = "2147483649"
      val result = 2.14748365E9f
      val aNumber = new BigInteger(a).floatValue()
      val delta = 0
      expect(Math.abs(aNumber - result)).toEqual(delta)
    }

    unless("strict-floats").
      it("testFloatValueBug2482") {
      val a = "2147483649"
      val result = 2.14748365E9f
      val aNumber = new BigInteger(a).floatValue()
      val delta = 1
      expect(Math.abs(aNumber - result)).toEqual(delta)
    }
@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd May 5, 2015

Member

Remove the unless("strict-floats") variant. Keep only the first block.

Strict floats is a requirement, but not strict-floats might still behave as in strict floats. So unless("strict-floats") doesn't make sense: on some platforms the test would fail because it would behave as if it had strict floats anyway.

Member

sjrd commented May 5, 2015

Remove the unless("strict-floats") variant. Keep only the first block.

Strict floats is a requirement, but not strict-floats might still behave as in strict floats. So unless("strict-floats") doesn't make sense: on some platforms the test would fail because it would behave as if it had strict floats anyway.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost May 5, 2015

@sjrd How is this looking?

ghost commented May 5, 2015

@sjrd How is this looking?

@gzm0

This comment has been minimized.

Show comment
Hide comment
@gzm0

gzm0 May 5, 2015

Contributor

Dude, I just saw you fixed a 3 digit issue :) That's sweet.

Contributor

gzm0 commented May 5, 2015

Dude, I just saw you fixed a 3 digit issue :) That's sweet.

@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd May 5, 2015

Member

@inthenow I think you missed the point of the "to track changes" commit ;-) The idea is to have that commit copy verbatim the file from the scala/scala repo, without any change (even keeping spaces at EOLs and other mistakes). The second commit, with the implementation of big numbers, then modifies that file as necessary. This way, we can see clearly, in our history, what is different wrt. normal Scala. Here, your second commit does not modify ScalaNumericConversions.scala, so I guess you already incorporated your changes to that file in the first commit. The changes should be in the second commit.

Member

sjrd commented May 5, 2015

@inthenow I think you missed the point of the "to track changes" commit ;-) The idea is to have that commit copy verbatim the file from the scala/scala repo, without any change (even keeping spaces at EOLs and other mistakes). The second commit, with the implementation of big numbers, then modifies that file as necessary. This way, we can see clearly, in our history, what is different wrt. normal Scala. Here, your second commit does not modify ScalaNumericConversions.scala, so I guess you already incorporated your changes to that file in the first commit. The changes should be in the second commit.

@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd May 5, 2015

Member

retest this please

Member

sjrd commented May 5, 2015

retest this please

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost May 5, 2015

Re ScalaNumericConversions.scala. I have not made any changes to it so the first commit is (or at least should be) the original. But without including it the tests fail

ghost commented May 5, 2015

Re ScalaNumericConversions.scala. I have not made any changes to it so the first commit is (or at least should be) the original. But without including it the tests fail

@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd May 5, 2015

Member

Ah. Hum that doesn't make any sense :-s Let me play a bit with that.

Member

sjrd commented May 5, 2015

Ah. Hum that doesn't make any sense :-s Let me play a bit with that.

@gzm0

This comment has been minimized.

Show comment
Hide comment
@gzm0

gzm0 May 5, 2015

Contributor

Just a comment on the commit messages: If you end up including ScalaNumericConversions.scala, please make sure to include the commit SHA1 of the scala/scala repo you took the file from. This will make it much easier to detect and backport changes if necessary.

Contributor

gzm0 commented May 5, 2015

Just a comment on the commit messages: If you end up including ScalaNumericConversions.scala, please make sure to include the commit SHA1 of the scala/scala repo you took the file from. This will make it much easier to detect and backport changes if necessary.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost May 5, 2015

fyi - I added it as I saw ScalaNumber.scala was also just a copy. Anyway, I'll leave this in your very capable hands - will be back online Wed p.m.

ghost commented May 5, 2015

fyi - I added it as I saw ScalaNumber.scala was also just a copy. Anyway, I'll leave this in your very capable hands - will be back online Wed p.m.

@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd May 5, 2015

Member

I added it as I saw ScalaNumber.scala was also just a copy.

It's not a copy, it's a rewrite in Scala of a file that is originally in Java ;-) See https://github.com/scala/scala/blob/2.11.x/src/library/scala/math/ScalaNumber.java

Member

sjrd commented May 5, 2015

I added it as I saw ScalaNumber.scala was also just a copy.

It's not a copy, it's a rewrite in Scala of a file that is originally in Java ;-) See https://github.com/scala/scala/blob/2.11.x/src/library/scala/math/ScalaNumber.java

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost May 5, 2015

Just looking through some code, I wonder if the issue is related to scala BigDecimal:

final class BigDecimal(val bigDecimal: BigDec, val mc: MathContext)
extends ScalaNumber with ScalaNumericConversions with Serializable {

ghost commented May 5, 2015

Just looking through some code, I wonder if the issue is related to scala BigDecimal:

final class BigDecimal(val bigDecimal: BigDec, val mc: MathContext)
extends ScalaNumber with ScalaNumericConversions with Serializable {
@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd May 5, 2015

Member

Locally, all the tests pass here when I remove the overrides file. Both on 2.11.6 and 2.10.5. Maybe you did this as an attempt of fixing something that was actually fixed by doing something else?

I suggest that you remove that commit (git rebase -i master and simply remove the line that picks that commit) and re-push.

Member

sjrd commented May 5, 2015

Locally, all the tests pass here when I remove the overrides file. Both on 2.11.6 and 2.10.5. Maybe you did this as an attempt of fixing something that was actually fixed by doing something else?

I suggest that you remove that commit (git rebase -i master and simply remove the line that picks that commit) and re-push.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost May 5, 2015

OK - i did actually test yesterday that it was required by removing it and it was still needed - but all the better if it can go !

ghost commented May 5, 2015

OK - i did actually test yesterday that it was required by removing it and it was still needed - but all the better if it can go !

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost commented May 5, 2015

done.

@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd May 5, 2015

Member

The bootstrapping tests do not pass on this PR. Example at https://scala-webapps.epfl.ch/jenkins/job/scalajs-task-worker/37782/console
To replicate locally:

> set scalaJSStage in Global := FastOptStage
> toolsJS/test

I verified locally: it does succeed on master, but fails on this PR's branch.

Member

sjrd commented May 5, 2015

The bootstrapping tests do not pass on this PR. Example at https://scala-webapps.epfl.ch/jenkins/job/scalajs-task-worker/37782/console
To replicate locally:

> set scalaJSStage in Global := FastOptStage
> toolsJS/test

I verified locally: it does succeed on master, but fails on this PR's branch.

@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd May 5, 2015

Member

@inthenow I will try and debug that one. It is probably caused by code under my responsibility, and only revealed by your additions.

Member

sjrd commented May 5, 2015

@inthenow I will try and debug that one. It is probably caused by code under my responsibility, and only revealed by your additions.

@scala-jenkins

This comment has been minimized.

Show comment
Hide comment
@scala-jenkins

scala-jenkins May 5, 2015

Test FAILed.
Refer to this link for build results (access rights to CI server needed):

https://scala-webapps.epfl.ch/jenkins/job/scalajs-pr/1638/
https://scala-webapps.epfl.ch/jenkins/job/scalajs-matrix-build/2128/
Test FAILed.

scala-jenkins commented May 5, 2015

Test FAILed.
Refer to this link for build results (access rights to CI server needed):

https://scala-webapps.epfl.ch/jenkins/job/scalajs-pr/1638/
https://scala-webapps.epfl.ch/jenkins/job/scalajs-matrix-build/2128/
Test FAILed.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost May 6, 2015

@sjrd Any development on this? Or anything I can look at?

ghost commented May 6, 2015

@sjrd Any development on this? Or anything I can look at?

@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd May 6, 2015

Member

I didn't have time today, unfortunately. I will investigate this tomorrow.

Member

sjrd commented May 6, 2015

I didn't have time today, unfortunately. I will investigate this tomorrow.

@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd May 7, 2015

Member

OK you can grab my branch at https://github.com/sjrd/scala-js/commits/BigNumerics, and push it here for the PR. It contains an additional commit that fixes how test detection for toolsJS/test works, so that it works with your commit. I haven't touched your commit, just rebased it on top of mine.

Member

sjrd commented May 7, 2015

OK you can grab my branch at https://github.com/sjrd/scala-js/commits/BigNumerics, and push it here for the PR. It contains an additional commit that fixes how test detection for toolsJS/test works, so that it works with your commit. I haven't touched your commit, just rebased it on top of mine.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost commented May 7, 2015

done

@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd May 7, 2015

Member

The history's all weird: there are duplicates of three commits already in master. To fix it, do:

$ git fetch scalajs
$ git rebase -i scalajs/master

and remove all lines except the two commits to keep: the one with TestDetector and the one with big numbers.

Member

sjrd commented May 7, 2015

The history's all weird: there are duplicates of three commits already in master. To fix it, do:

$ git fetch scalajs
$ git rebase -i scalajs/master

and remove all lines except the two commits to keep: the one with TestDetector and the one with big numbers.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost May 7, 2015

done - before had just pushed what was on you branch

ghost commented May 7, 2015

done - before had just pushed what was on you branch

@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd May 7, 2015

Member

retest this please

Member

sjrd commented May 7, 2015

retest this please

@scala-jenkins

This comment has been minimized.

Show comment
Hide comment
@scala-jenkins

scala-jenkins May 7, 2015

Test PASSed.
Refer to this link for build results (access rights to CI server needed):

https://scala-webapps.epfl.ch/jenkins/job/scalajs-pr/1656/
https://scala-webapps.epfl.ch/jenkins/job/scalajs-matrix-build/2147/
Test PASSed.

scala-jenkins commented May 7, 2015

Test PASSed.
Refer to this link for build results (access rights to CI server needed):

https://scala-webapps.epfl.ch/jenkins/job/scalajs-pr/1656/
https://scala-webapps.epfl.ch/jenkins/job/scalajs-matrix-build/2147/
Test PASSed.

@sjrd

This comment has been minimized.

Show comment
Hide comment
@ghost

View changes

Show outdated Hide outdated test-suite/src/test/scala/org/scalajs/testsuite/javalib/IntegerTest.scala

Alistair Johnson and others added some commits Mar 13, 2015

Generalize the ad hoc TestDetector to look in nested packages.
Previously, it was only able to detect tests precisely in the
org.scalajs.testsuite package. This commit makes it able to look
for nested packages, and for example detect tests in
org.scalajs.testsuite.math.
@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost commented May 8, 2015

done

@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd May 8, 2015

Member

LGTM

Member

sjrd commented May 8, 2015

LGTM

@sjrd

This comment has been minimized.

Show comment
Hide comment
@sjrd

sjrd May 8, 2015

Member

retest this please

Member

sjrd commented May 8, 2015

retest this please

@scala-jenkins

This comment has been minimized.

Show comment
Hide comment
@scala-jenkins

scala-jenkins May 8, 2015

Test PASSed.
Refer to this link for build results (access rights to CI server needed):

https://scala-webapps.epfl.ch/jenkins/job/scalajs-pr/1662/
https://scala-webapps.epfl.ch/jenkins/job/scalajs-matrix-build/2153/
Test PASSed.

scala-jenkins commented May 8, 2015

Test PASSed.
Refer to this link for build results (access rights to CI server needed):

https://scala-webapps.epfl.ch/jenkins/job/scalajs-pr/1662/
https://scala-webapps.epfl.ch/jenkins/job/scalajs-matrix-build/2153/
Test PASSed.

@sjrd sjrd changed the title from BigDecimal and BigInteger to Fix #373: scala's BigInt and BigDecimal are not implemented in Scala.js May 8, 2015

@sjrd sjrd changed the title from Fix #373: scala's BigInt and BigDecimal are not implemented in Scala.js to Fix #373: Implement BigInteger and BigDecimal. May 8, 2015

sjrd added a commit that referenced this pull request May 8, 2015

Merge pull request #1549 from InTheNow/BigNumerics
Fix #373: Implement BigInteger and BigDecimal.

@sjrd sjrd merged commit 3c9493e into scala-js:master May 8, 2015

1 check passed

default Merged build finished.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment