Details

    • Type: Sub-task
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.5.4
    • Fix Version/s: None
    • Component/s: groovy-runtime
    • Labels:
      None

      Description

      If toString is overridden via the metaClass then "${obj}" != obj.toString().

      Test case below

      class DateTest extends GroovyTestCase {
      
          void testToString(){
      
              Date.metaClass.toString = { ->
                  'boogie'
              }
             
              def date = new Date()
              assertEquals('boogie', date.toString())
              assertEquals( date.toString(), "${date}") //fails
          }
      }
      

      Paul King gave this pointer as to where the problem is:

      "Yes, the final line of InvokerHelper.format() should be something like:

      return (String) invokeMethod(arguments, "toString", EMPTY_ARGS);
      //return arguments.toString();

      to make your example work."

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                leebutts Lee Butts
              • Votes:
                7 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated: