Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1459

empty GStrings and Character 0 should evaluate to false in boolean tests

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-JSR-6
    • 1.0-RC-1
    • groovy-jdk
    • None

    Description

      public void testAsBoolean() {

      assertAsBoolean(false, "");
      GString emptyGString = new GString(new Object[]

      { "" }) {
      public String[] getStrings() {
      return new String[] { "" }

      ;
      }
      };
      assertAsBoolean(false, emptyGString);
      GString nonEmptyGString = new GString(new Object[]

      { "x" }) {
      public String[] getStrings() {
      return new String[] { "x" }

      ;
      }
      };
      assertAsBoolean(true, nonEmptyGString);

      assertAsBoolean(true, new Character((char) 1));
      assertAsBoolean(false, new Character((char) 0));

      }

      Attachments

        Activity

          People

            codevise Dierk König
            codevise Dierk König
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: