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

Asserts.assert* should print values

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b43

      Backports

        Description

        assert methods which get message as a parameter should print "compared" values anyway

        suggested fix:
        diff -r 3d018f7c144e test/testlibrary/com/oracle/java/testlibrary/Asserts.java
        --- a/test/testlibrary/com/oracle/java/testlibrary/Asserts.java Fri Nov 14 16:55:27 2014 +0300
        +++ b/test/testlibrary/com/oracle/java/testlibrary/Asserts.java Sat Nov 15 00:35:05 2014 +0300
        @@ -234,8 +234,7 @@
              * @see #assertGreaterThan(T, T, String)
              */
             public static <T extends Comparable<T>> void assertGreaterThan(T lhs, T rhs) {
        - String msg = "Expected that " + format(lhs) + " > " + format(rhs);
        - assertGreaterThan(lhs, rhs, msg);
        + assertGreaterThan(lhs, rhs, null);
             }
         
             /**
        @@ -247,7 +246,7 @@
              * @throws RuntimeException if the assertion isn't valid.
              */
             public static <T extends Comparable<T>> void assertGreaterThan(T lhs, T rhs, String msg) {
        - assertTrue(compare(lhs, rhs, msg) > 0, msg);
        + assertTrue(compare(lhs, rhs, msg) > 0, (msg == null ? "Expected that " : msg) + " " + format(lhs) + " > " + format(rhs));
             }

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  tpivovarova Tatiana Pivovarova (Inactive)
                  Reporter:
                  iignatyev Igor Ignatyev
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Due:
                    Created:
                    Updated:
                    Resolved: