aboutsummaryrefslogtreecommitdiffstats
path: root/test/integration/beam/shelf.erl
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-10-31 02:28:17 -0300
committerMarcos Magueta <maguetamarcos@gmail.com>2026-10-31 02:28:17 -0300
commit71856adc5ff5d64c7be1b37854fc8a205d55e482 (patch)
tree25770cf98154c0da696878228783ac8faecde08b /test/integration/beam/shelf.erl
parente76cc6f862656a3ada9fa3d4418bd060df937885 (diff)
downloadRNT-71856adc5ff5d64c7be1b37854fc8a205d55e482.tar.gz
RNT-71856adc5ff5d64c7be1b37854fc8a205d55e482.zip
update tests and add beam tests
Diffstat (limited to 'test/integration/beam/shelf.erl')
-rw-r--r--test/integration/beam/shelf.erl22
1 files changed, 22 insertions, 0 deletions
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)].