fix: recognize yen in currency conversions

This commit is contained in:
2026-10-22 14:04:29 +02:00
parent 751f22f6b1
commit 0a85d21801
3 changed files with 19 additions and 0 deletions
+15
View File
@@ -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: [