summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJo-Philipp Wich2022-02-11 16:41:00 +0000
committerJo-Philipp Wich2022-02-11 16:41:00 +0000
commit93b710d49f57876f6885d8842178dbf1181b9330 (patch)
tree1368c44e4204f38586c4aa319d4edcf60eecb70d
parent1a94915b5d38c9f17b27481add5a0a62341da627 (diff)
downloadfirewall4-93b710d49f57876f6885d8842178dbf1181b9330.tar.gz
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 <jo@mein.io>
-rw-r--r--tests/lib/mocklib/uci.uc7
1 files changed, 6 insertions, 1 deletions
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;
};