Skip to content

Commit 0697803

Browse files
author
Oscar Smith
authored
Merge pull request #2 from AayushSabharwal/as/tests
test: add tests
2 parents 22911ad + e6caf2b commit 0697803

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

.github/workflows/tests.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Tests
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
push:
7+
branches:
8+
- main
9+
10+
# needed to allow julia-actions/cache to delete old caches that it has created
11+
permissions:
12+
actions: write
13+
contents: read
14+
15+
jobs:
16+
test:
17+
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
version:
21+
- 'min'
22+
- '1'
23+
- 'pre'
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: julia-actions/setup-julia@v2
27+
with:
28+
version: ${{ matrix.version }}
29+
- uses: julia-actions/cache@v2
30+
- uses: julia-actions/julia-buildpkg@v1
31+
- uses: julia-actions/julia-runtest@v1
32+
- uses: julia-actions/julia-processcoverage@v1
33+
- uses: codecov/codecov-action@v1
34+
with:
35+
file: lcov.info

test/runtests.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using WeakCacheSets
2+
using Test
3+
4+
# This doesn't work if put inside a testset
5+
wcs = WeakCacheSet{Vector{Int}}()
6+
# The only function we have is `getkey!`, so we check
7+
# contents using `repr`.
8+
@test repr(wcs) == "WeakCacheSet()"
9+
a = [1,2,3]
10+
b = @inferred getkey!(wcs, a)
11+
@test repr(wcs) == "WeakCacheSet([1, 2, 3])"
12+
@test b === a
13+
c = @inferred getkey!(wcs, b)
14+
@test a === b === c
15+
a = b = c = nothing
16+
17+
# hopefully this is enough
18+
GC.gc(); GC.gc(); GC.gc()
19+
20+
@test repr(wcs) == "WeakCacheSet()"

0 commit comments

Comments
 (0)