Skip to content

Commit 5bebaf8

Browse files
committed
style: format tests
1 parent 52177d1 commit 5bebaf8

7 files changed

Lines changed: 147 additions & 126 deletions

File tree

test/combinations.jl

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@testset "combinations" begin
22
@test [combinations([])...] == [[]]
3-
@test [combinations(['a', 'b', 'c'])...] == [[],['a'],['b'],['c'],['a','b'],['a','c'],['b','c'],['a','b','c']]
3+
@test [combinations(['a', 'b', 'c'])...] ==
4+
[[], ['a'], ['b'], ['c'], ['a', 'b'], ['a', 'c'], ['b', 'c'], ['a', 'b', 'c']]
45
@test length(collect(combinations(1:5))) == 32
56

67
@test [combinations("abc", 3)...] == [['a', 'b', 'c']]
@@ -13,7 +14,8 @@
1314

1415
# multiset_combinations
1516
@test [multiset_combinations("aabc", 5)...] == Any[]
16-
@test [multiset_combinations("aabc", 2)...] == Any[['a', 'a'], ['a', 'b'], ['a', 'c'], ['b', 'c']]
17+
@test [multiset_combinations("aabc", 2)...] ==
18+
Any[['a', 'a'], ['a', 'b'], ['a', 'c'], ['b', 'c']]
1719
@test [multiset_combinations("aabc", 1)...] == Any[['a'], ['b'], ['c']]
1820
@test [multiset_combinations("aabc", 0)...] == Any[Char[]]
1921
@test [multiset_combinations("aabc", -1)...] == Any[]
@@ -22,26 +24,30 @@
2224
@test [multiset_combinations("", -1)...] == Any[]
2325

2426
# with_replacement_combinations
25-
@test [with_replacement_combinations("abc", 2)...] == Any[['a', 'a'], ['a', 'b'], ['a', 'c'],
26-
['b', 'b'], ['b', 'c'], ['c', 'c']]
27+
@test [with_replacement_combinations("abc", 2)...] ==
28+
Any[['a', 'a'], ['a', 'b'], ['a', 'c'], ['b', 'b'], ['b', 'c'], ['c', 'c']]
2729
@test [with_replacement_combinations("abc", 1)...] == Any[['a'], ['b'], ['c']]
2830
@test [with_replacement_combinations("abc", 0)...] == Any[Char[]]
2931
@test [with_replacement_combinations("abc", -1)...] == Any[]
3032
@test [with_replacement_combinations("", 1)...] == Any[]
3133
@test [with_replacement_combinations("", 0)...] == Any[Char[]]
3234
@test [with_replacement_combinations("", -1)...] == Any[]
3335

34-
3536
#cool-lex iterator
3637
@test_throws DomainError [CoolLexCombinations(-1, 1)...]
3738
@test_throws DomainError [CoolLexCombinations(5, 0)...]
38-
@test [CoolLexCombinations(4, 2)...] == Vector[[1, 2], [2, 3], [1, 3], [2, 4], [3, 4], [1, 4]]
39-
@test isa(iterate(CoolLexCombinations(1000, 20))[2], Combinatorics.CoolLexIterState{BigInt})
39+
@test [CoolLexCombinations(4, 2)...] ==
40+
Vector[[1, 2], [2, 3], [1, 3], [2, 4], [3, 4], [1, 4]]
41+
@test isa(
42+
iterate(CoolLexCombinations(1000, 20))[2], Combinatorics.CoolLexIterState{BigInt}
43+
)
4044

4145
# Power set
4246
@test collect(powerset([])) == Any[[]]
43-
@test collect(powerset(['a', 'b', 'c'])) == Any[[], ['a'], ['b'], ['c'], ['a', 'b'], ['a', 'c'], ['b', 'c'], ['a', 'b', 'c']]
44-
@test collect(powerset(['a', 'b', 'c'], 1)) == Any[['a'], ['b'], ['c'], ['a', 'b'], ['a', 'c'], ['b', 'c'], ['a', 'b', 'c']]
45-
@test collect(powerset(['a', 'b', 'c'], 1, 2)) == Any[['a'], ['b'], ['c'], ['a', 'b'], ['a', 'c'], ['b', 'c']]
46-
47+
@test collect(powerset(['a', 'b', 'c'])) ==
48+
Any[[], ['a'], ['b'], ['c'], ['a', 'b'], ['a', 'c'], ['b', 'c'], ['a', 'b', 'c']]
49+
@test collect(powerset(['a', 'b', 'c'], 1)) ==
50+
Any[['a'], ['b'], ['c'], ['a', 'b'], ['a', 'c'], ['b', 'c'], ['a', 'b', 'c']]
51+
@test collect(powerset(['a', 'b', 'c'], 1, 2)) ==
52+
Any[['a'], ['b'], ['c'], ['a', 'b'], ['a', 'c'], ['b', 'c']]
4753
end

test/factorials.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
@test_throws DomainError partialderangement(-8, 0)
2525

2626
# doublefactorial
27-
@test doublefactorial(70) == parse(BigInt, "355044260642859198243475901411974413130137600000000")
27+
@test doublefactorial(70) ==
28+
parse(BigInt, "355044260642859198243475901411974413130137600000000")
2829
@test_throws DomainError doublefactorial(-1)
2930

3031
# hyperfactorial
@@ -51,11 +52,10 @@
5152
@test_throws OverflowError multinomial(10, 10, 10, 6)
5253
@test_throws OverflowError multinomial(10, 10, 10, 10)
5354
# binomial(200, 100) overflows
54-
@test_throws OverflowError multinomial(100, 100)
55+
@test_throws OverflowError multinomial(100, 100)
5556
end
5657

5758
# primorial
5859
@test primorial(17) == 510510
5960
@test_throws DomainError primorial(-1)
60-
6161
end

test/multinomials.jl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,22 @@ using LinearAlgebra
2020
@test [multiexponents(1, 10)...] == [[10]]
2121

2222
# general cases
23-
@test [multiexponents(3, 2)...] == [[2, 0, 0], [1, 1, 0], [1, 0, 1], [0, 2, 0], [0, 1, 1], [0, 0, 2]]
23+
@test [multiexponents(3, 2)...] ==
24+
[[2, 0, 0], [1, 1, 0], [1, 0, 1], [0, 2, 0], [0, 1, 1], [0, 0, 2]]
2425
@test [multiexponents(2, 3)...] == [[3, 0], [2, 1], [1, 2], [0, 3]]
2526
@test [multiexponents(2, 2)...] == [[2, 0], [1, 1], [0, 2]]
26-
@test [multiexponents(3, 3)...] == [[3, 0, 0], [2, 1, 0], [2, 0, 1], [1, 2, 0], [1, 1, 1], [1, 0, 2], [0, 3, 0], [0, 2, 1], [0, 1, 2], [0, 0, 3]]
27+
@test [multiexponents(3, 3)...] == [
28+
[3, 0, 0],
29+
[2, 1, 0],
30+
[2, 0, 1],
31+
[1, 2, 0],
32+
[1, 1, 1],
33+
[1, 0, 2],
34+
[0, 3, 0],
35+
[0, 2, 1],
36+
[0, 1, 2],
37+
[0, 0, 3],
38+
]
2739

2840
@test length(multiexponents(1, 1)) == 1
2941
@test length(multiexponents(2, 2)) == 3

test/numbers.jl

Lines changed: 77 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,90 @@
11
@testset "numbers" begin
2-
# catalan
3-
@test catalannum(5) == 42
4-
@test catalannum(30) == parse(BigInt, "3814986502092304")
5-
@test_throws DomainError catalannum(-1)
2+
# catalan
3+
@test catalannum(5) == 42
4+
@test catalannum(30) == parse(BigInt, "3814986502092304")
5+
@test_throws DomainError catalannum(-1)
66

7-
# fibonacci
8-
@test fibonaccinum(5) == 5
9-
@test fibonaccinum(101) == parse(BigInt, "573147844013817084101")
10-
@test_throws DomainError fibonaccinum(-1)
7+
# fibonacci
8+
@test fibonaccinum(5) == 5
9+
@test fibonaccinum(101) == parse(BigInt, "573147844013817084101")
10+
@test_throws DomainError fibonaccinum(-1)
1111

12-
# lobb
13-
@test lobbnum(2, 3) == 5
14-
@test lobbnum(50, 100) == parse(BigInt, "303574146822833458064977353764024400258025594128")
15-
@test_throws DomainError lobbnum(-1, 2)
12+
# lobb
13+
@test lobbnum(2, 3) == 5
14+
@test lobbnum(50, 100) ==
15+
parse(BigInt, "303574146822833458064977353764024400258025594128")
16+
@test_throws DomainError lobbnum(-1, 2)
1617

17-
# narayana
18-
@test narayana(8, 5) == 490
19-
@test narayana(100, 50) == parse(BigInt, "99794739256977899071474889425225225330079579752931446368")
20-
@test_throws DomainError narayana(-1, -1)
18+
# narayana
19+
@test narayana(8, 5) == 490
20+
@test narayana(100, 50) ==
21+
parse(BigInt, "99794739256977899071474889425225225330079579752931446368")
22+
@test_throws DomainError narayana(-1, -1)
2123

22-
# lassalle
23-
@test lassallenum(14) == parse(BigInt, "270316008395632253340")
24+
# lassalle
25+
@test lassallenum(14) == parse(BigInt, "270316008395632253340")
2426

25-
# legendresymbol
26-
@test legendresymbol(1001, 9907) == jacobisymbol(1001, 9907) == -1
27+
# legendresymbol
28+
@test legendresymbol(1001, 9907) == jacobisymbol(1001, 9907) == -1
2729

28-
# lucas
29-
@test lucasnum(10) == 123
30-
@test lucasnum(100) == parse(BigInt, "792070839848372253127")
31-
@test_throws DomainError lucasnum(-1)
30+
# lucas
31+
@test lucasnum(10) == 123
32+
@test lucasnum(100) == parse(BigInt, "792070839848372253127")
33+
@test_throws DomainError lucasnum(-1)
3234

33-
# stirlings1
34-
@test_throws DomainError stirlings1(-1, 1)
35-
@test typeof(stirlings1(6, 2)) == Int
36-
@test stirlings1(0, 0) == 1
37-
@test stirlings1(1, 1) == 1
38-
@test stirlings1(2, 6) == 0
39-
@test stirlings1(6, 0) == 0
40-
@test stirlings1(6, 0, true) == 0
41-
@test stirlings1(6, 1) == 120
42-
@test stirlings1(6, 1, true) == -120
43-
@test stirlings1(6, 2) == 274
44-
@test stirlings1(6, 2, true) == 274
45-
@test stirlings1(6, 3) == 225
46-
@test stirlings1(6, 3, true) == -225
47-
@test stirlings1(6, 4) == 85
48-
@test stirlings1(6, 4, true) == 85
49-
@test stirlings1(6, 5) == 15
50-
@test stirlings1(6, 5, true) == -15
51-
@test stirlings1(6, 6) == 1
52-
@test stirlings1(6, 6, true) == 1
53-
@test sum([abs(stirlings1(8, i, true)) for i = 0:8]) == factorial(8)
54-
@test stirlings1(big"26", 10) == 196928100451110820242880
35+
# stirlings1
36+
@test_throws DomainError stirlings1(-1, 1)
37+
@test typeof(stirlings1(6, 2)) == Int
38+
@test stirlings1(0, 0) == 1
39+
@test stirlings1(1, 1) == 1
40+
@test stirlings1(2, 6) == 0
41+
@test stirlings1(6, 0) == 0
42+
@test stirlings1(6, 0, true) == 0
43+
@test stirlings1(6, 1) == 120
44+
@test stirlings1(6, 1, true) == -120
45+
@test stirlings1(6, 2) == 274
46+
@test stirlings1(6, 2, true) == 274
47+
@test stirlings1(6, 3) == 225
48+
@test stirlings1(6, 3, true) == -225
49+
@test stirlings1(6, 4) == 85
50+
@test stirlings1(6, 4, true) == 85
51+
@test stirlings1(6, 5) == 15
52+
@test stirlings1(6, 5, true) == -15
53+
@test stirlings1(6, 6) == 1
54+
@test stirlings1(6, 6, true) == 1
55+
@test sum([abs(stirlings1(8, i, true)) for i in 0:8]) == factorial(8)
56+
@test stirlings1(big"26", 10) == 196928100451110820242880
5557

56-
# stirlings2
57-
@test_throws DomainError stirlings2(-1, 1)
58-
@test typeof(stirlings2(6, 2)) == Int
59-
@test stirlings2(0, 0) == 1
60-
@test stirlings2(1, 1) == 1
61-
@test stirlings2(2, 6) == 0
62-
@test stirlings2(6, 0) == 0
63-
@test stirlings2(6, 1) == 1
64-
@test stirlings2(6, 2) == 31
65-
@test stirlings2(6, 3) == 90
66-
@test stirlings2(6, 4) == 65
67-
@test stirlings2(6, 5) == 15
68-
@test stirlings2(6, 6) == 1
69-
@test stirlings2(big"26", 10) == 13199555372846848005
58+
# stirlings2
59+
@test_throws DomainError stirlings2(-1, 1)
60+
@test typeof(stirlings2(6, 2)) == Int
61+
@test stirlings2(0, 0) == 1
62+
@test stirlings2(1, 1) == 1
63+
@test stirlings2(2, 6) == 0
64+
@test stirlings2(6, 0) == 0
65+
@test stirlings2(6, 1) == 1
66+
@test stirlings2(6, 2) == 31
67+
@test stirlings2(6, 3) == 90
68+
@test stirlings2(6, 4) == 65
69+
@test stirlings2(6, 5) == 15
70+
@test stirlings2(6, 6) == 1
71+
@test stirlings2(big"26", 10) == 13199555372846848005
7072

71-
# bell
72-
@test bellnum.(0:10) == [
73-
1
74-
1
75-
2
76-
5
77-
15
78-
52
79-
203
80-
877
73+
# bell
74+
@test bellnum.(0:10) == [
75+
1
76+
1
77+
2
78+
5
79+
15
80+
52
81+
203
82+
877
8183
4140
82-
21147
83-
115975
84-
]
85-
86-
@test bellnum(42) == parse(BigInt, "35742549198872617291353508656626642567")
87-
@test_throws DomainError(-1) bellnum(-1)
84+
21147
85+
115975
86+
]
8887

88+
@test bellnum(42) == parse(BigInt, "35742549198872617291353508656626642567")
89+
@test_throws DomainError(-1) bellnum(-1)
8990
end

test/partitions.jl

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
@testset "partitions" begin
2-
32
@testset "partitions(n::Integer)" begin
43
@test_broken collect(partitions(0)) == [[]]
54
@test collect(partitions(1)) == [[1]]
@@ -22,7 +21,8 @@
2221

2322
@testset "partitions(n::Integer, m::Integer)" begin
2423
@test collect(partitions(8, 1)) == [[8]]
25-
@test collect(partitions(8, 3)) == [[6, 1, 1], [5, 2, 1], [4, 3, 1], [4, 2, 2], [3, 3, 2]]
24+
@test collect(partitions(8, 3)) ==
25+
[[6, 1, 1], [5, 2, 1], [4, 3, 1], [4, 2, 2], [3, 3, 2]]
2626
@test collect(partitions(8, 8)) == [ones(Int, 8)]
2727
@test collect(partitions(8, 9)) == []
2828
@test collect(partitions(90, 90)) == [ones(Int, 90)]
@@ -52,7 +52,8 @@
5252
@testset "partitions(s::AbstractVector)" begin
5353
@test collect(partitions([1])) == [[[1]]]
5454
@test collect(partitions([1, 2])) == [[[1, 2]], [[1], [2]]]
55-
@test collect(partitions([1, 2, 3])) == [[[1, 2, 3]], [[1, 2], [3]], [[1, 3], [2]], [[1], [2, 3]], [[1], [2], [3]]]
55+
@test collect(partitions([1, 2, 3])) ==
56+
[[[1, 2, 3]], [[1, 2], [3]], [[1, 3], [2]], [[1], [2, 3]], [[1], [2], [3]]]
5657
@test collect(partitions(1:3)) == collect(partitions([1, 2, 3]))
5758
@test collect(partitions('a':'b')) == [[['a', 'b']], [['a'], ['b']]]
5859

@@ -67,15 +68,15 @@
6768
end
6869

6970
@testset "partitions(s::AbstractVector, m::Int)" begin
70-
@test collect(partitions(1:3, 2)) == [
71-
[[1, 2], [3]],
72-
[[1, 3], [2]],
73-
[[1], [2, 3]],
74-
]
71+
@test collect(partitions(1:3, 2)) == [[[1, 2], [3]], [[1, 3], [2]], [[1], [2, 3]]]
7572
@test collect(partitions([1, 2, 3, 4], 1)) == [[[1, 2, 3, 4]]]
7673
@test collect(partitions([1, 2, 3, 4], 3)) == [
77-
[[1, 2], [3], [4]], [[1, 3], [2], [4]], [[1], [2, 3], [4]],
78-
[[1, 4], [2], [3]], [[1], [2, 4], [3]], [[1], [2], [3, 4]]
74+
[[1, 2], [3], [4]],
75+
[[1, 3], [2], [4]],
76+
[[1], [2, 3], [4]],
77+
[[1, 4], [2], [3]],
78+
[[1], [2, 4], [3]],
79+
[[1], [2], [3, 4]],
7980
]
8081
@test collect(partitions([1, 2, 3, 4], 4)) == [[[1], [2], [3], [4]]]
8182
@test collect(partitions([1, 2, 3, 4], 5)) == []
@@ -101,15 +102,8 @@
101102
@test integer_partitions(2) == [[1, 1], [2]]
102103
@test integer_partitions(3) == [[1, 1, 1], [2, 1], [3]]
103104
# gap> Partitions( 5 );
104-
@test integer_partitions(5) == [
105-
[1, 1, 1, 1, 1],
106-
[2, 1, 1, 1],
107-
[2, 2, 1],
108-
[3, 1, 1],
109-
[3, 2],
110-
[4, 1],
111-
[5]
112-
]
105+
@test integer_partitions(5) ==
106+
[[1, 1, 1, 1, 1], [2, 1, 1, 1], [2, 2, 1], [3, 1, 1], [3, 2], [4, 1], [5]]
113107
# integer_partitions <--> partitions(::Integer)
114108
@test Set(integer_partitions(5)) == Set(partitions(5))
115109

@@ -170,5 +164,4 @@
170164
@test length(ncpartitions(n)) == catalannum(n)
171165
end
172166
end
173-
174167
end

0 commit comments

Comments
 (0)