From 71856adc5ff5d64c7be1b37854fc8a205d55e482 Mon Sep 17 00:00:00 2001 From: Marcos Magueta Date: Sat, 31 Oct 2026 02:28:17 -0300 Subject: update tests and add beam tests --- test/integration/beam/shelf.erl | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 test/integration/beam/shelf.erl (limited to 'test/integration/beam/shelf.erl') diff --git a/test/integration/beam/shelf.erl b/test/integration/beam/shelf.erl new file mode 100644 index 0000000..a9b6823 --- /dev/null +++ b/test/integration/beam/shelf.erl @@ -0,0 +1,22 @@ +-module(shelf). +-export([rnt_init/0, titles/0, authors/0]). + +-define(TITLES, [<<"karuta">>, <<"program">>, <<"titles">>]). +-define(BOOKS, {$b, [<<"karuta">>, <<"program">>, <<"books">>]}). + +%% A FOL program over a beam program RNT holds, defined from the node. +rnt_init() -> + rnt:define(?TITLES, <<"fol">>, project(?BOOKS, [<<"title">>])). + +titles() -> rnt:invoke(?TITLES). + +authors() -> rnt:evaluate(<<"fol">>, project(?BOOKS, [<<"author">>])). + +project(Term, Attributes) -> + bencode({$p, #{<<"term">> => Term, <<"attributes">> => Attributes}}). + +bencode(Bytes) when is_binary(Bytes) -> [integer_to_binary(byte_size(Bytes)), $:, Bytes]; +bencode(List) when is_list(List) -> [$l, [bencode(X) || X <- List], $e]; +bencode(Map) when is_map(Map) -> + [$d, [[bencode(K), bencode(V)] || {K, V} <- lists:sort(maps:to_list(Map))], $e]; +bencode({Tag, Value}) -> [$t, Tag, bencode(Value)]. -- cgit v1.2.3