Skip to content

Commit

Permalink
Upgrade moc/base.
Browse files Browse the repository at this point in the history
  • Loading branch information
q-uint committed Dec 16, 2022
1 parent be7f60e commit 1b175d4
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 61 deletions.
14 changes: 0 additions & 14 deletions .github/workflows/src.yml

This file was deleted.

15 changes: 7 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
on:
push:
paths:
- 'test/**'
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: aviate-labs/setup-dfx@v0.2.3
with:
dfx-version: 0.8.4
vessel-version: 0.6.2
- run: for i in test/*.mo ; do $(vessel bin)/moc $(vessel sources) -r $i ; done
dfx-version: 0.12.1
vessel-version: 0.6.3
- run: |
make check
make test
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.PHONY: check test
check:
find src -type f -name '*.mo' -print0 | xargs -0 $(shell vessel bin)/moc $(shell vessel sources 2>/dev/null) --check
test:
find test -type f -name '*.mo' -print0 | xargs -0 $(shell vessel bin)/moc $(shell vessel sources 2>/dev/null) -r
18 changes: 14 additions & 4 deletions package-set.dhall
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
let upstream = https://github.com/aviate-labs/package-set/releases/download/v0.1.3/package-set.dhall sha256:ca68dad1e4a68319d44c587f505176963615d533b8ac98bdb534f37d1d6a5b47
let base = https://github.com/internet-computer/base-package-set/releases/download/moc-0.7.4/package-set.dhall sha256:3a20693fc597b96a8c7cf8645fda7a3534d13e5fbda28c00d01f0b7641efe494
let Package = { name : Text, version : Text, repo : Text, dependencies : List Text }

let additions = [
{ name = "array"
, version = "v0.2.1"
, repo = "https://github.com/aviate-labs/array.mo"
, dependencies = [ "base-0.7.3" ] : List Text
},
{ name = "encoding"
, version = "v0.4.1"
, repo = "https://github.com/aviate-labs/encoding.mo"
, dependencies = [ "base-0.7.3", "array" ]
},
{ name = "io"
, version = "v0.3.2"
, repo = "https://github.com/aviate-labs/io.mo"
, version = "v0.3.1"
, dependencies = [ "base" ]
, dependencies = [ "base-0.7.3" ]
}
] : List Package

in upstream # additions
in base # additions
20 changes: 10 additions & 10 deletions src/LFSR.mo
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Buffer "mo:base/Buffer";
import Int "mo:base/Int";
import Buffer "mo:base-0.7.3/Buffer";
import Int "mo:base-0.7.3/Int";
import IO "mo:io/IO";
import Iter "mo:base/Iter";
import Nat8 "mo:base/Nat8";
import Nat16 "mo:base/Nat16";
import Nat32 "mo:base/Nat32";
import Nat64 "mo:base/Nat64";
import Time "mo:base/Time";
import Iter "mo:base-0.7.3/Iter";
import Nat8 "mo:base-0.7.3/Nat8";
import Nat16 "mo:base-0.7.3/Nat16";
import Nat32 "mo:base-0.7.3/Nat32";
import Nat64 "mo:base-0.7.3/Nat64";
import Time "mo:base-0.7.3/Time";

module {
public type LFSR<T> = {
Expand Down Expand Up @@ -96,12 +96,12 @@ module {
public func read(n : Nat) : IO.Result<[T]> {
let ts = Buffer.Buffer<T>(n);
for (i in Iter.range(0, n-1)) {
if (restarted) return #eof(ts.toArray());
if (restarted) return #eof(Buffer.toArray(ts));
let (v, r) = lfsr.next();
restarted := r;
ts.add(v);
};
#ok(ts.toArray());
#ok(Buffer.toArray(ts));
};
};

Expand Down
14 changes: 7 additions & 7 deletions src/XorShift.mo
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Binary "mo:encoding/Binary";
import Buffer "mo:base/Buffer";
import Int "mo:base/Int";
import Buffer "mo:base-0.7.3/Buffer";
import Int "mo:base-0.7.3/Int";
import IO "mo:io/IO";
import Iter "mo:base/Iter";
import Nat64 "mo:base/Nat64";
import Time "mo:base/Time";
import Iter "mo:base-0.7.3/Iter";
import Nat64 "mo:base-0.7.3/Nat64";
import Time "mo:base-0.7.3/Time";

module {
public type XorShift = {
Expand Down Expand Up @@ -50,10 +50,10 @@ module {
case (? v) {
ts.add(v);
};
case (null) return #eof(ts.toArray());
case (null) return #eof(Buffer.toArray(ts));
};
};
#ok(ts.toArray());
#ok(Buffer.toArray(ts));
};
};
};
21 changes: 11 additions & 10 deletions test/LFSR.mo
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import Hash "mo:base/Hash";
import Iter "mo:base/Iter";
import Nat "mo:base/Nat";
import Nat8 "mo:base/Nat8";
import Nat16 "mo:base/Nat16";
import TrieSet "mo:base/TrieSet";
import Hash "mo:base-0.7.3/Hash";
import Iter "mo:base-0.7.3/Iter";
import Nat "mo:base-0.7.3/Nat";
import Nat8 "mo:base-0.7.3/Nat8";
import Nat16 "mo:base-0.7.3/Nat16";
import Nat32 "mo:base-0.7.3/Nat32";
import TrieSet "mo:base-0.7.3/TrieSet";

import IO "mo:io/IO";

import LFSR "../src/LFSR";

do {
let feed = LFSR.LFSR8(null);
var s = TrieSet.empty<Nat>();
var s = TrieSet.empty<Nat32>();
var i = 0;
var restarted = false;
while (not restarted) {
i += 1;
let (v, r) = feed.next();
let n = Nat8.toNat(v);
if (TrieSet.mem<Nat>(s, n, Hash.hash(n), Nat.equal)) {
let n = Nat32.fromNat(Nat8.toNat(v));
if (TrieSet.mem<Nat32>(s, n, n, Nat32.equal)) {
assert(false);
};
s := TrieSet.put(s, n, Hash.hash(n), Nat.equal);
s := TrieSet.put(s, n, n, Nat32.equal);
restarted := r;
};
if (i != 0xFF) assert(false);
Expand Down
12 changes: 6 additions & 6 deletions test/XorShift.mo
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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 Hash "mo:base-0.7.3/Hash";
import Nat "mo:base-0.7.3/Nat";
import Nat64 "mo:base-0.7.3/Nat64";
import Text "mo:base-0.7.3/Text";
import TrieSet "mo:base-0.7.3/TrieSet";

import XorShift "../src/XorShift";

import Debug "mo:base/Debug";
import Debug "mo:base-0.7.3/Debug";

var r = XorShift.XorShift64(null);
var s = TrieSet.empty<Text>();
Expand Down
4 changes: 2 additions & 2 deletions vessel.dhall
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
dependencies = [ "base", "encoding", "io" ],
compiler = Some "0.6.11"
dependencies = [ "base-0.7.3", "encoding", "io" ],
compiler = Some "0.7.3"
}

0 comments on commit 1b175d4

Please sign in to comment.