Skip to content

Commit

Permalink
tests: mocklib: forward compatibility change
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jow- committed Feb 11, 2022
1 parent 5f769a0 commit 9789c75
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/lib/mocklib/uci.uc
Original file line number Diff line number Diff line change
@@ -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;
};
Expand Down

0 comments on commit 9789c75

Please sign in to comment.