Skip to content

Commit

Permalink
Use StableRNGs for easier testing and add CompatHelper (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
giordano committed May 11, 2020
1 parent 95c1b78 commit 8def899
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 31 deletions.
3 changes: 1 addition & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
environment:
matrix:
- julia_version: 1.0
- julia_version: 1.1
- julia_version: 1.2
- julia_version: 1
- julia_version: nightly
platform:
- x86
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: CompatHelper
on:
schedule:
- cron: 54 6 * * *
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
run: julia -e 'using CompatHelper; CompatHelper.main()'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: TagBot
on:
schedule:
- cron: 0 * * * *
- cron: 35 17 * * *
jobs:
TagBot:
runs-on: ubuntu-latest
Expand Down
6 changes: 4 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
name = "RandomBasedArrays"
uuid = "079b6ec6-a4f7-11e9-0358-1904ae85a441"
authors = ["Mosè Giordano"]
version = "0.1.0"
version = "0.2.0"

[deps]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[compat]
StableRNGs = "0.1"
julia = "1"

[extras]
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
test = ["StableRNGs", "Test"]
38 changes: 12 additions & 26 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,33 +1,19 @@
using RandomBasedArrays
using Random, Test
using StableRNGs, Test

@testset "RandomBasedArrays.jl" begin
Random.seed!(1)
rng = StableRNG(42)
p = reshape(collect(1:6), 2, 3)
A = RandomBasedArray(p)
A = RandomBasedArray(p, rng)
@test parent(A) === p
@test parent(A) == [1 3 5; 2 4 6]
if Sys.WORD_SIZE == 64
@test size(A) === size(p)
@test A[42] == 1
@test A[-35] == 1
@test A[4,0] == 6
A[-314] = 0
@test parent(A) == [1 3 5; 2 0 6]
A[0,0] = 42
@test parent(A) == [1 3 5; 42 0 6]
@test repr("text/plain", A) == "2×3 Array{Int64,2}:\n 3 42 6\n 3 1 5"
elseif Sys.WORD_SIZE == 32
@test size(A) === size(p)
@test A[42] == 3
@test A[-35] == 3
@test A[4,0] == 6
A[-314] = 0
@test parent(A) == [1 3 5; 2 4 0]
A[0,0] = 42
@test parent(A) == [1 3 5; 2 42 0]
@test repr("text/plain", A) == "2×3 Array{Int32,2}:\n 1 2 42\n 1 1 5"
else
@info "We are not on a 32- or 64-bit system"
end
@test size(A) === size(p)
@test A[42] == 2
@test A[-35] == 1
@test A[4,0] == 5
A[-314] = 0
@test parent(A) == [0 3 5; 2 4 6]
A[0,0] = 42
@test parent(A) == [42 3 5; 2 4 6]
@test occursin(r"2×3 Array{Int[2346]+,2}:\n 42 +6 +3\n +6 +3 +42", repr("text/plain", A))
end

2 comments on commit 8def899

@giordano
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/14525

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.0 -m "<description of version>" 8def89905e9f435110b53adc03aab2bb96461d39
git push origin v0.2.0

Please sign in to comment.