-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
66 additions
and
72 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
on: | ||
push: | ||
paths: | ||
- 'src/**' | ||
- 'test/**' | ||
on: push | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: aviate-labs/setup-dfx@v0.2.2 | ||
- uses: actions/checkout@v3 | ||
- uses: aviate-labs/setup-dfx@v0.2.3 | ||
with: | ||
dfx-version: 0.8.1 | ||
dfx-version: 0.12.1 | ||
install-moc: true | ||
- run: for i in test/*.mo ; do moc --package base $(dfx cache show)/base -r $i ; done | ||
vessel-version: 0.6.3 | ||
- run: | | ||
make check | ||
make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.vessel/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
let base = https://github.com/internet-computer/base-package-set/releases/download/moc-0.7.4/package-set.dhall sha256:3a20693fc597b96a8c7cf8645fda7a3534d13e5fbda28c00d01f0b7641efe494 | ||
in base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
import Nat "mo:base/Nat"; | ||
import { equal } = "mo:base-0.7.3/Nat"; | ||
|
||
import Array "../src/Array"; | ||
import { contains; drop; slice; split; take } = "../src/Array"; | ||
|
||
let xs : [Nat] = [1, 2, 3]; | ||
for (x in xs.vals()) { | ||
assert(Array.contains<Nat>(xs, x, Nat.equal)); | ||
assert(not Array.contains<Nat>(xs, x + 3, Nat.equal)); | ||
assert(contains<Nat>(xs, x, equal)); | ||
assert(not contains<Nat>(xs, x + 3, equal)); | ||
}; | ||
|
||
assert(Array.drop<Nat>(xs, 0) == xs); | ||
assert(Array.drop<Nat>(xs, 1) == [2, 3]); | ||
assert(Array.drop<Nat>(xs, 2) == [3]); | ||
assert(Array.drop<Nat>(xs, 3) == []); | ||
assert(Array.drop<Nat>(xs, 9) == []); | ||
assert(drop<Nat>(xs, 0) == xs); | ||
assert(drop<Nat>(xs, 1) == [2, 3]); | ||
assert(drop<Nat>(xs, 2) == [3]); | ||
assert(drop<Nat>(xs, 3) == []); | ||
assert(drop<Nat>(xs, 9) == []); | ||
|
||
assert(Array.take<Nat>(xs, 0) == []); | ||
assert(Array.take<Nat>(xs, 1) == [1]); | ||
assert(Array.take<Nat>(xs, 2) == [1, 2]); | ||
assert(Array.take<Nat>(xs, 3) == xs); | ||
assert(Array.take<Nat>(xs, 9) == xs); | ||
assert(take<Nat>(xs, 0) == []); | ||
assert(take<Nat>(xs, 1) == [1]); | ||
assert(take<Nat>(xs, 2) == [1, 2]); | ||
assert(take<Nat>(xs, 3) == xs); | ||
assert(take<Nat>(xs, 9) == xs); | ||
|
||
assert(Array.split<Nat>(xs, 0) == (xs, [])); | ||
assert(Array.split<Nat>(xs, 1) == ([1], [2, 3])); | ||
assert(Array.split<Nat>(xs, 2) == ([1, 2], [3])); | ||
assert(Array.split<Nat>(xs, 3) == ([], xs)); | ||
assert(Array.split<Nat>(xs, 9) == ([], xs)); | ||
assert(split<Nat>(xs, 0) == (xs, [])); | ||
assert(split<Nat>(xs, 1) == ([1], [2, 3])); | ||
assert(split<Nat>(xs, 2) == ([1, 2], [3])); | ||
assert(split<Nat>(xs, 3) == ([], xs)); | ||
assert(split<Nat>(xs, 9) == ([], xs)); | ||
|
||
assert(Array.slice<Nat>(xs, 0, 0) == [1]); | ||
assert(Array.slice<Nat>(xs, 1, 0) == []); | ||
assert(Array.slice<Nat>(xs, 0, 3) == xs); | ||
assert(slice<Nat>(xs, 0, 0) == [1]); | ||
assert(slice<Nat>(xs, 1, 0) == []); | ||
assert(slice<Nat>(xs, 0, 3) == xs); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
import Array "mo:base/Array"; | ||
import Iter "mo:base/Iter"; | ||
import { freeze; init } = "mo:base-0.7.3/Array"; | ||
import { range; toArray } = "mo:base-0.7.3/Iter"; | ||
|
||
import Debug "mo:base/Debug"; | ||
import { copy; copyOffset; copyOffsetVar } = "../src/Copy"; | ||
|
||
import Array_ "mo:base/Array"; | ||
import Copy "../src/Copy"; | ||
let n = init<Nat>(10, 0); | ||
let m = toArray(range(0, 9)); | ||
|
||
let n = Array.init<Nat>(10, 0); | ||
let m = Iter.toArray(Iter.range(0, 9)); | ||
|
||
Copy.copy(n, m); | ||
assert(Array.freeze(n) == m); | ||
copy(n, m); | ||
assert(freeze(n) == m); | ||
|
||
// copy(n[5:], m) | ||
Copy.copyOffset(n, 5, m, 0); | ||
assert(Array.freeze(n) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4]); | ||
copyOffset(n, 5, m, 0); | ||
assert(freeze(n) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4]); | ||
|
||
// copy(n[6:], n) | ||
Copy.copyOffsetVar(n, 6, n, 0); | ||
assert(Array.freeze(n) == [0, 1, 2, 3, 4, 0, 0, 1, 2, 3]); | ||
copyOffsetVar(n, 6, n, 0); | ||
assert(freeze(n) == [0, 1, 2, 3, 4, 0, 0, 1, 2, 3]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
dependencies = [ "base-0.7.3" ], | ||
compiler = Some "0.7.3" | ||
} |