Skip to content

Commit

Permalink
Add xor test.
Browse files Browse the repository at this point in the history
  • Loading branch information
q-uint committed Nov 19, 2021
1 parent 5ade917 commit c6b8a59
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/src.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: aviate-labs/setup-dfx@v0.2.2
- uses: aviate-labs/setup-dfx@v0.2.3
with:
dfx-version: 0.8.0
install-moc: true
dfx-version: 0.8.4
vessel-version: 0.6.2
- run: for i in src/*.mo ; do moc $(vessel sources) --check $i ; done
- run: for i in src/*.mo ; do $(vessel bin)/moc $(vessel sources) --check $i ; done
7 changes: 3 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: aviate-labs/setup-dfx@v0.2.2
- uses: aviate-labs/setup-dfx@v0.2.3
with:
dfx-version: 0.8.0
install-moc: true
dfx-version: 0.8.4
vessel-version: 0.6.2
- run: for i in test/*.mo ; do moc $(vessel sources) -r $i ; done
- run: for i in test/*.mo ; do $(vessel bin)/moc $(vessel sources) -r $i ; done
2 changes: 1 addition & 1 deletion src/XorShift.mo
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module {
state ^= (state >> 12);
state ^= (state << 25);
state ^= (state >> 27);
state * 2685821657736338717;
state *% 2685821657736338717;
};
};

Expand Down
19 changes: 19 additions & 0 deletions test/XorShift.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Hash "mo:base/Hash";
import Nat "mo:base/Nat";
import Nat64 "mo:base/Nat64";
import Text "mo:base/Text";
import TrieSet "mo:base/TrieSet";

import XorShift "../src/XorShift";

import Debug "mo:base/Debug";

var r = XorShift.XorShift64(null);
var s = TrieSet.empty<Text>();
var i = 0;
while (i < 99) {
let n = Nat64.toText(r.next());
s := TrieSet.put<Text>(s, n, Text.hash(n), Text.equal);
i += 1;
};
assert(TrieSet.size(s) == 99);

0 comments on commit c6b8a59

Please sign in to comment.