am aff22a6d: Merge "Fix DecimalFormatSymbols.setCurrency."
* commit 'aff22a6ddb474b00719dea04d8a4258b8773d0d0':
Fix DecimalFormatSymbols.setCurrency.
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/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());
+ }
}