Revision: 6811
Author: [email protected]
Date: Tue Nov 10 12:00:29 2009
Log: Merge trunk r6809 into this branch
  Fixes custom PluralRule classes that are nested
      svn merge --ignore-ancestry -c6809 \
            https://google-web-toolkit.googlecode.com/svn/trunk/ .


http://code.google.com/p/google-web-toolkit/source/detail?r=6811

Added:
  /releases/2.0/user/test/com/google/gwt/i18n/client/CustomPluralsTest.java
Modified:
  /releases/2.0/branch-info.txt
   
/releases/2.0/user/src/com/google/gwt/i18n/rebind/MessagesMethodCreator.java
  /releases/2.0/user/test/com/google/gwt/i18n/I18NSuite.java

=======================================
--- /dev/null
+++  
/releases/2.0/user/test/com/google/gwt/i18n/client/CustomPluralsTest.java       
 
Tue Nov 10 12:00:29 2009
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may  
not
+ * use this file except in compliance with the License. You may obtain a  
copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations  
under
+ * the License.
+ */
+package com.google.gwt.i18n.client;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.junit.client.GWTTestCase;
+
+/**
+ * Tests custom plural rules, including as an inner class.
+ *
+ * <p>Captures issue 4175.
+ */
+public class CustomPluralsTest extends GWTTestCase {
+
+  /**
+   * Messages interface with a custom plural rule.
+   */
+  public interface MyMessages extends Messages {
+
+    /**
+     * A custom plural rule that returns "0", "1", or "other".
+     */
+    public static class CustomPluralRule implements PluralRule {
+       public PluralForm[] pluralForms() {
+          return new PluralForm[] {
+             new PluralForm("other", "other"),
+             new PluralForm("0", "first"),
+             new PluralForm("1", "second")
+          };
+       }
+
+       public int select(int n) {
+          if (0 <= n && n <= 1) {
+             return n + 1;
+          }
+          return 0;
+       }
+    }
+
+    @DefaultMessage("other: {0}")
+    @PluralText({"0", "zero", "1", "one"})
+    String customPlural(@PluralCount(CustomPluralRule.class) int cnt);
+  }
+
+  @Override
+  public String getModuleName() {
+    return "com.google.gwt.i18n.I18NTest";
+  }
+
+  public void testCustomPluralRule() {
+    MyMessages m = GWT.create(MyMessages.class);
+    assertEquals("zero", m.customPlural(0));
+    assertEquals("one", m.customPlural(1));
+    assertEquals("other: 2", m.customPlural(2));
+  }
+}
=======================================
--- /releases/2.0/branch-info.txt       Tue Nov 10 11:37:16 2009
+++ /releases/2.0/branch-info.txt       Tue Nov 10 12:00:29 2009
@@ -504,3 +504,8 @@
  same classloader that Generators run in.  There is also no need to resolve  
them
  since they may be binary-only.
    for i in 6782 6783 6784 6785 ; do svn merge --ignore-ancestry -c $i  
https://google-web-toolkit.googlecode.com/svn/trunk .; done
+
+tr...@6809 was merged into this branch
+ Fixes custom PluralRule classes that are nested
+    svn merge --ignore-ancestry -c6809 \
+      https://google-web-toolkit.googlecode.com/svn/trunk/ .
=======================================
---  
/releases/2.0/user/src/com/google/gwt/i18n/rebind/MessagesMethodCreator.java    
 
Mon Mar  2 23:51:53 2009
+++  
/releases/2.0/user/src/com/google/gwt/i18n/rebind/MessagesMethodCreator.java    
 
Tue Nov 10 12:00:29 2009
@@ -412,7 +412,7 @@
        if (localizedType != null) {
          try {
            Class<?> testClass = Class.forName(
-              localizedType.getQualifiedSourceName(), false,
+              localizedType.getQualifiedBinaryName(), false,
                PluralRule.class.getClassLoader());
            if (PluralRule.class.isAssignableFrom(testClass)) {
              return (PluralRule) testClass.newInstance();
=======================================
--- /releases/2.0/user/test/com/google/gwt/i18n/I18NSuite.java  Tue Jun 23  
20:13:51 2009
+++ /releases/2.0/user/test/com/google/gwt/i18n/I18NSuite.java  Tue Nov 10  
12:00:29 2009
@@ -17,6 +17,7 @@

  import com.google.gwt.i18n.client.AnnotationsTest;
  import com.google.gwt.i18n.client.ArabicPluralsTest;
+import com.google.gwt.i18n.client.CustomPluralsTest;
  import com.google.gwt.i18n.client.DateTimeFormat_de_Test;
  import com.google.gwt.i18n.client.DateTimeFormat_en_Test;
  import com.google.gwt.i18n.client.DateTimeParse_en_Test;
@@ -57,6 +58,7 @@
      suite.addTestSuite(AnnotationsTest.class);
      suite.addTestSuite(ConstantMapTest.class);
      suite.addTestSuite(CurrencyTest.class);
+    suite.addTestSuite(CustomPluralsTest.class);
      suite.addTestSuite(DateTimeFormat_de_Test.class);
      suite.addTestSuite(DateTimeFormat_en_Test.class);
      suite.addTestSuite(DateTimeParse_en_Test.class);

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to