Discovered while enabling real (not just compile-only) test execution on Scala.js and Scala Native. These are runtime/javalib limitations of the respective platforms, not bugs in mcodec's own code — documented here and scoped out via `//> using target.platform` on the affected tests so the rest of the suite still runs cross-platform.
Scala.js: Float loses precision and sign-bit fidelity
Scala.js represents Float as a JS Double under the hood (no native 32-bit float type). Two consequences observed in IoContractExtTest (now split into IoContractExtJvmOnlyTest.scala, JVM-only):
1.1f round-tripped through JSON can drift to 1.100000023841858 (the classic float→double widening artifact) instead of staying 1.1.
-0.0f loses its sign bit through the write/read round-trip (Float.floatToIntBits differs from the JVM).
Scala Native: java.util.HashSet[Int] round-trip crashes
ExtendedStdCodecsTest's java.util.HashSet round-trips test (now JavaHashSetIntTest.scala, jvm+scala-js only) crashes with scala.scalanative.runtime.UndefinedBehaviorError: null on Scala Native 0.5.12. Passes fine on JVM and Scala.js. Looks like a scala-native javalib limitation around boxed Integer handling in HashSet, not something in mcodec's own code — not yet root-caused further.
Follow-up ideas
- Revisit if/when scala-native or Scala.js address these upstream.
- If real users hit the Float drift in practice on Scala.js, consider a from-scratch Float→string formatter instead of relying on the platform's
Float#toString.
Discovered while enabling real (not just compile-only) test execution on Scala.js and Scala Native. These are runtime/javalib limitations of the respective platforms, not bugs in mcodec's own code — documented here and scoped out via `//> using target.platform` on the affected tests so the rest of the suite still runs cross-platform.
Scala.js: Float loses precision and sign-bit fidelity
Scala.js represents
Floatas a JSDoubleunder the hood (no native 32-bit float type). Two consequences observed inIoContractExtTest(now split intoIoContractExtJvmOnlyTest.scala, JVM-only):1.1fround-tripped through JSON can drift to1.100000023841858(the classic float→double widening artifact) instead of staying1.1.-0.0floses its sign bit through the write/read round-trip (Float.floatToIntBitsdiffers from the JVM).Scala Native:
java.util.HashSet[Int]round-trip crashesExtendedStdCodecsTest'sjava.util.HashSet round-tripstest (nowJavaHashSetIntTest.scala, jvm+scala-js only) crashes withscala.scalanative.runtime.UndefinedBehaviorError: nullon Scala Native 0.5.12. Passes fine on JVM and Scala.js. Looks like a scala-native javalib limitation around boxedIntegerhandling inHashSet, not something in mcodec's own code — not yet root-caused further.Follow-up ideas
Float#toString.