fix: recognize yen in currency conversions
This commit is contained in:
@@ -11,6 +11,21 @@ func calculatorCrossConvertsCurrencyExpressionsAndPreservesSnapshotDate() throws
|
||||
#expect(result.detail == "2*50 USD → DKK · Daily snapshot 2026-01-02")
|
||||
}
|
||||
|
||||
@Test
|
||||
func calculatorConvertsYenAsJPYInEitherDirection() {
|
||||
let snapshot = CurrencyRates(date: "2026-01-02", rates: ["eur": 1, "jpy": 160, "dkk": 8])
|
||||
for (query, expected) in [
|
||||
("1000 yen to dkk", "50 DKK"),
|
||||
("1000JPY to DKK", "50 DKK"),
|
||||
("1000YeN in dkk", "50 DKK"),
|
||||
("50 DKK as yen", "1000 JPY"),
|
||||
("2*500 yen to JPY", "1000 JPY"),
|
||||
] {
|
||||
#expect(Calculator.isCurrencyQuery(query), "\(query)")
|
||||
#expect(Calculator.evaluate(query, currencyRates: snapshot)?.copyValue == expected, "\(query)")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
func calculatorConvertsFiatAndCryptoWithCaseInsensitiveSeparators() {
|
||||
let snapshot = CurrencyRates(date: "2026-01-02", rates: [
|
||||
|
||||
Reference in New Issue
Block a user