From d48de85140ca007e870eac641e863f240547404e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rgen=20Lindqvist?= Date: Thu, 29 Aug 2024 11:22:49 +0200 Subject: [PATCH] eq, string = integer (#1459) --- packages/runtime/src/compare/eq.ts | 2 ++ test/operators/eq.ts | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/packages/runtime/src/compare/eq.ts b/packages/runtime/src/compare/eq.ts index 8a8594821..4af778dbe 100644 --- a/packages/runtime/src/compare/eq.ts +++ b/packages/runtime/src/compare/eq.ts @@ -80,6 +80,8 @@ export function eq( return right.get() === left.get(); } else if (left instanceof Character) { return (parseInt(left.get(), 10) || 0) === right.get(); + } else if (left instanceof String) { + return (parseInt(left.get(), 10) || 0) === right.get(); } else if (left instanceof Float) { return right.get() === left.getRaw(); } else if (left instanceof Numc) { diff --git a/test/operators/eq.ts b/test/operators/eq.ts index c04885333..bcf7947b0 100644 --- a/test/operators/eq.ts +++ b/test/operators/eq.ts @@ -98,4 +98,17 @@ ASSERT 1 = lv_val.`; } }); + it("integer = string = integer", async () => { + const code = ` +DATA num TYPE i. +DATA txt TYPE string. +num = 123. +txt = num. +ASSERT num = txt. +ASSERT txt = num.`; + const js = await run(code); + const f = new AsyncFunction("abap", js); + await f(abap); + }); + }); \ No newline at end of file