From 9789c752ac0b37dbc3f639ded53cbe24b9e145d5 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 11 Feb 2022 17:41:00 +0100 Subject: [PATCH] tests: mocklib: forward compatibility change Upstream ucode will change ord()'s return value type from array to integer, add logic to handle both old and new cases. Signed-off-by: Jo-Philipp Wich --- tests/lib/mocklib/uci.uc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/lib/mocklib/uci.uc b/tests/lib/mocklib/uci.uc index 542eeb8..015c602 100644 --- a/tests/lib/mocklib/uci.uc +++ b/tests/lib/mocklib/uci.uc @@ -1,11 +1,16 @@ {% let mocklib = global.mocklib; + let byte = (str, off) => { + let v = ord(str, off); + return length(v) ? v[0] : v; + }; + let hash = (s) => { let h = 7; for (let i = 0; i < length(s); i++) - h = h * 31 + ord(s, i)[0]; + h = h * 31 + byte(s, i); return h; };