Merge "Add exceptions for test_connectLjava_net_SocketAddressI"
diff --git a/luni/src/main/java/java/text/DecimalFormatSymbols.java b/luni/src/main/java/java/text/DecimalFormatSymbols.java
index 9750e6d..2f1d4f4 100644
--- a/luni/src/main/java/java/text/DecimalFormatSymbols.java
+++ b/luni/src/main/java/java/text/DecimalFormatSymbols.java
@@ -414,9 +414,6 @@
         if (currency == null) {
             throw new NullPointerException("currency == null");
         }
-        if (currency == this.currency) {
-            return;
-        }
         this.currency = currency;
         intlCurrencySymbol = currency.getCurrencyCode();
         currencySymbol = currency.getSymbol(locale);
diff --git a/luni/src/main/java/libcore/icu/NativePluralRules.java b/luni/src/main/java/libcore/icu/NativePluralRules.java
index dbcf089..f9fe74b 100644
--- a/luni/src/main/java/libcore/icu/NativePluralRules.java
+++ b/luni/src/main/java/libcore/icu/NativePluralRules.java
@@ -55,6 +55,10 @@
      * to the first rule that matches the given value.
      */
     public int quantityForInt(int value) {
+        // Pre-L compatibility. http://b/18429565.
+        if (value < 0) {
+            return OTHER;
+        }
         return quantityForIntImpl(address, value);
     }
 
diff --git a/luni/src/test/java/libcore/icu/NativePluralRulesTest.java b/luni/src/test/java/libcore/icu/NativePluralRulesTest.java
index 703a94a..76179b4 100644
--- a/luni/src/test/java/libcore/icu/NativePluralRulesTest.java
+++ b/luni/src/test/java/libcore/icu/NativePluralRulesTest.java
@@ -19,6 +19,24 @@
 import java.util.Locale;
 
 public class NativePluralRulesTest extends junit.framework.TestCase {
+    public void testNegatives() throws Exception {
+        // icu4c's behavior changed, but we prefer to preserve compatibility.
+        NativePluralRules en_US = NativePluralRules.forLocale(new Locale("en", "US"));
+        assertEquals(NativePluralRules.OTHER, en_US.quantityForInt(2));
+        assertEquals(NativePluralRules.ONE, en_US.quantityForInt(1));
+        assertEquals(NativePluralRules.OTHER, en_US.quantityForInt(0));
+        assertEquals(NativePluralRules.OTHER, en_US.quantityForInt(-1));
+        assertEquals(NativePluralRules.OTHER, en_US.quantityForInt(-2));
+
+        NativePluralRules ar = NativePluralRules.forLocale(new Locale("ar"));
+        assertEquals(NativePluralRules.ZERO, ar.quantityForInt(0));
+        assertEquals(NativePluralRules.OTHER, ar.quantityForInt(-1)); // Not ONE.
+        assertEquals(NativePluralRules.OTHER, ar.quantityForInt(-2)); // Not TWO.
+        assertEquals(NativePluralRules.OTHER, ar.quantityForInt(-3)); // Not FEW.
+        assertEquals(NativePluralRules.OTHER, ar.quantityForInt(-11)); // Not MANY.
+        assertEquals(NativePluralRules.OTHER, ar.quantityForInt(-100));
+    }
+
     public void testEnglish() throws Exception {
         NativePluralRules npr = NativePluralRules.forLocale(new Locale("en", "US"));
         assertEquals(NativePluralRules.OTHER, npr.quantityForInt(0));
diff --git a/luni/src/test/java/libcore/java/text/DecimalFormatSymbolsTest.java b/luni/src/test/java/libcore/java/text/DecimalFormatSymbolsTest.java
index 619c38e..3e0aeba 100644
--- a/luni/src/test/java/libcore/java/text/DecimalFormatSymbolsTest.java
+++ b/luni/src/test/java/libcore/java/text/DecimalFormatSymbolsTest.java
@@ -21,6 +21,7 @@
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.text.DecimalFormatSymbols;
+import java.util.Currency;
 import java.util.Locale;
 
 public class DecimalFormatSymbolsTest extends junit.framework.TestCase {
@@ -57,4 +58,32 @@
         // The two objects should claim to be equal.
         assertEquals(originalDfs, deserializedDfs);
     }
+
+    // https://code.google.com/p/android/issues/detail?id=79925
+    public void testSetSameCurrency() throws Exception {
+        DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US);
+        dfs.setCurrency(Currency.getInstance("USD"));
+        assertEquals("$", dfs.getCurrencySymbol());
+        dfs.setCurrencySymbol("poop");
+        assertEquals("poop", dfs.getCurrencySymbol());
+        dfs.setCurrency(Currency.getInstance("USD"));
+        assertEquals("$", dfs.getCurrencySymbol());
+    }
+
+    public void testSetNulInternationalCurrencySymbol() throws Exception {
+        Currency usd = Currency.getInstance("USD");
+
+        DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US);
+        dfs.setCurrency(usd);
+        assertEquals(usd, dfs.getCurrency());
+        assertEquals("$", dfs.getCurrencySymbol());
+        assertEquals("USD", dfs.getInternationalCurrencySymbol());
+
+        // Setting the international currency symbol to null sets the currency to null too,
+        // but not the currency symbol.
+        dfs.setInternationalCurrencySymbol(null);
+        assertEquals(null, dfs.getCurrency());
+        assertEquals("$", dfs.getCurrencySymbol());
+        assertEquals(null, dfs.getInternationalCurrencySymbol());
+    }
 }