Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8281183

RandomGenerator:NextDouble() default behavior partially fixed by JDK-8280950

XMLWordPrintable

    • b09
    • Verified

         It looks the fix(JDK-8280950) addressed the issue partially, I see the test (test_nextDoubleWithBoundDef1) using nextDouble(bound) still fails with the latest JDK nightly.

        =======
          @TestCase
            @TestedStatement(source = "nextDouble(double)", value = {"The default implementation checks that bound is a " +
                    "positive finite double. Then invokes nextDouble(), scaling the result so that the final result lies " +
                    "between 0.0 (inclusive) and bound (exclusive)."})
            public void test_nextDoubleWithBoundDef1(@Doubles({Double.MIN_VALUE, 10.0, 1234455555.45, 10000000d}) double bound) {
                AtomicBoolean nextDoubleInvoked = new AtomicBoolean(false);
                RandomGenerator rg = new RandomGenerator() {
                    @Override
                    public double nextDouble() {
                        nextDoubleInvoked.set(true);
                        return 123456789.34d;
                    }

                    @Override
                    public long nextLong() {
                        return 0;
                    }
                };
                double value = rg.nextDouble(bound);
                Assert.assertTrue(nextDoubleInvoked.get());
                Assert.assertTrue(value >= 0);
                Assert.assertTrue(value < bound);
            }

        ===========
         Possibly one more place to address it may be - public static double boundedNextDouble(RandomGenerator rng, double bound)

              darcy Joe Darcy
              kganapureddy Krushnareddy Ganapureddy
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: