From: Jo-Philipp Wich Date: Fri, 11 Feb 2022 16:41:00 +0000 (+0100) Subject: tests: mocklib: forward compatibility change X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=93b710d49f57876f6885d8842178dbf1181b9330;p=project%2Ffirewall4.git 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 --- diff --git a/tests/lib/mocklib/uci.uc b/tests/lib/mocklib/uci.uc index 69d2561..ed6b610 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; };