Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix README

  • Loading branch information...
commit d67ee3e501698d13e010e7ca4a33e8ff41b2b2a5 1 parent 7d56bc8
@etrepum etrepum authored
Showing with 25 additions and 7 deletions.
  1. +7 −7 README.md
  2. +18 −0 src/statebox.erl
View
14 README.md
@@ -56,7 +56,7 @@ Optimizations:
--------------
There are two functions that modify a statebox that can be used to
-reduce its size. One of both of these should be done every time before
+reduce its size. One or both of these should be done every time before
serializing the statebox.
* `truncate(N, Statebox)` return Statebox with no more than `N` events in its
@@ -71,15 +71,15 @@ Usage:
Simple `ordsets()` example:
New = statebox:new(fun () -> [] end),
- ChildA = statebox:modify({fun ordsets:add_element, [a]}, New),
- ChildB = statebox:modify({fun ordsets:add_element, [b]}, New),
+ ChildA = statebox:modify({fun ordsets:add_element/2, [a]}, New),
+ ChildB = statebox:modify({fun ordsets:add_element/2, [b]}, New),
Resolved = statebox:merge([ChildA, ChildB]),
- value(Resolved) =:= [a, b].
+ statebox:value(Resolved) =:= [a, b].
With manual control over timestamps:
New = statebox:new(0, fun () -> [] end),
- ChildA = statebox:modify(1, {fun ordsets:add_element, [a]}, New),
- ChildB = statebox:modify(2, {fun ordsets:add_element, [b]}, New),
+ ChildA = statebox:modify(1, {fun ordsets:add_element/2, [a]}, New),
+ ChildB = statebox:modify(2, {fun ordsets:add_element/2, [b]}, New),
Resolved = statebox:merge([ChildA, ChildB]),
- value(Resolved) =:= [a, b].
+ statebox:value(Resolved) =:= [a, b].
View
18 src/statebox.erl
@@ -378,4 +378,22 @@ convenience_test_() ->
value(S1))
end}]}.
+readme_ordsets_test() ->
+ New = statebox:new(fun () -> [] end),
+ ChildA = statebox:modify({fun ordsets:add_element/2, [a]}, New),
+ ChildB = statebox:modify({fun ordsets:add_element/2, [b]}, New),
+ Resolved = statebox:merge([ChildA, ChildB]),
+ ?assertEqual(
+ [a, b],
+ statebox:value(Resolved)).
+
+readme_ordsets_manual_test() ->
+ New = statebox:new(0, fun () -> [] end),
+ ChildA = statebox:modify(1, {fun ordsets:add_element/2, [a]}, New),
+ ChildB = statebox:modify(2, {fun ordsets:add_element/2, [b]}, New),
+ Resolved = statebox:merge([ChildA, ChildB]),
+ ?assertEqual(
+ [a, b],
+ statebox:value(Resolved)).
+
-endif.
Please sign in to comment.
Something went wrong with that request. Please try again.