Skip to content

Commit 0eb39de

Browse files
committed
update to verbose unit testing
1 parent c0b2aa5 commit 0eb39de

File tree

79 files changed

+3187
-3077
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+3187
-3077
lines changed

exercises/concept.wip/annalyns-infiltration/runtests.jl

+50-48
Original file line numberDiff line numberDiff line change
@@ -9,61 +9,63 @@ if VERSION < v"1.1"
99
@eval eachrow(A) = (view(A, i, :) for i in axes(A, 1))
1010
end
1111

12-
@testset "fast attack" begin
13-
@test !can_do_fast_attack(true)
14-
@test can_do_fast_attack(false)
15-
end
12+
@testset verbose = true "" begin
13+
@testset "fast attack" begin
14+
@test !can_do_fast_attack(true)
15+
@test can_do_fast_attack(false)
16+
end
1617

17-
@testset "spying" begin
18-
character_state_combinations = Bool[
19-
0 0 0 0;
20-
0 0 1 1;
21-
0 1 0 1;
22-
0 1 1 1;
23-
1 0 0 1;
24-
1 0 1 1;
25-
1 1 1 1;
26-
]
18+
@testset "spying" begin
19+
character_state_combinations = Bool[
20+
0 0 0 0;
21+
0 0 1 1;
22+
0 1 0 1;
23+
0 1 1 1;
24+
1 0 0 1;
25+
1 0 1 1;
26+
1 1 1 1;
27+
]
2728

28-
for state in eachrow(character_state_combinations)
29-
@test can_spy(state[1:3]...) == state[4]
29+
for state in eachrow(character_state_combinations)
30+
@test can_spy(state[1:3]...) == state[4]
31+
end
3032
end
31-
end
3233

33-
@testset "signaling prisoner" begin
34-
character_state_combinations = Bool[
35-
0 0 0;
36-
0 1 1;
37-
1 0 0;
38-
1 1 0;
39-
]
34+
@testset "signaling prisoner" begin
35+
character_state_combinations = Bool[
36+
0 0 0;
37+
0 1 1;
38+
1 0 0;
39+
1 1 0;
40+
]
4041

41-
for state in eachrow(character_state_combinations)
42-
@test can_signal_prisoner(state[1:2]...) == state[3]
42+
for state in eachrow(character_state_combinations)
43+
@test can_signal_prisoner(state[1:2]...) == state[3]
44+
end
4345
end
44-
end
4546

46-
@testset "freeing prisoner" begin
47-
character_state_combinations = Bool[
48-
0 0 0 0 0;
49-
0 0 0 1 1;
50-
0 0 1 0 1;
51-
0 0 1 1 1;
52-
0 1 0 0 0;
53-
0 1 0 1 0;
54-
0 1 1 0 0;
55-
0 1 1 1 0;
56-
1 0 0 0 0;
57-
1 0 0 1 1;
58-
1 0 1 0 0;
59-
1 0 1 1 1;
60-
1 1 0 0 0;
61-
1 1 0 1 0;
62-
1 1 1 0 0;
63-
1 1 1 1 0;
64-
]
47+
@testset "freeing prisoner" begin
48+
character_state_combinations = Bool[
49+
0 0 0 0 0;
50+
0 0 0 1 1;
51+
0 0 1 0 1;
52+
0 0 1 1 1;
53+
0 1 0 0 0;
54+
0 1 0 1 0;
55+
0 1 1 0 0;
56+
0 1 1 1 0;
57+
1 0 0 0 0;
58+
1 0 0 1 1;
59+
1 0 1 0 0;
60+
1 0 1 1 1;
61+
1 1 0 0 0;
62+
1 1 0 1 0;
63+
1 1 1 0 0;
64+
1 1 1 1 0;
65+
]
6566

66-
for state in eachrow(character_state_combinations)
67-
@test can_free_prisoner(state[1:4]...) == state[5]
67+
for state in eachrow(character_state_combinations)
68+
@test can_free_prisoner(state[1:4]...) == state[5]
69+
end
6870
end
6971
end

exercises/concept.wip/annalyns-infiltration2/runtests.jl

+14-12
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@ include("game.jl")
55
# This exercise isn't about mathematical methods to determine the distribution of a random sample,
66
# therefore we only test that all possible values are returned at least once.
77

8-
@testset "fog" begin
9-
@test Set(is_foggy() for _ in 1:1000) == Set([true, false])
10-
end
8+
@testset verbose = true "" begin
9+
@testset "fog" begin
10+
@test Set(is_foggy() for _ in 1:1000) == Set([true, false])
11+
end
1112

12-
@testset "distracted dog" begin
13-
@test Set(is_dog_distracted() for _ in 1:1000) == Set([true, false])
14-
end
13+
@testset "distracted dog" begin
14+
@test Set(is_dog_distracted() for _ in 1:1000) == Set([true, false])
15+
end
1516

16-
@testset "loot purse" begin
17-
@test Set(loot() for _ in 1:1000) == Set(3:13)
18-
end
17+
@testset "loot purse" begin
18+
@test Set(loot() for _ in 1:1000) == Set(3:13)
19+
end
1920

20-
@testset "loot crate" begin
21-
crate = Set(["Cabbage", "Daring Dagger", "Sneaky Shoes"])
22-
@test Set(loot(crate) for _ in 1:1000) == crate
21+
@testset "loot crate" begin
22+
crate = Set(["Cabbage", "Daring Dagger", "Sneaky Shoes"])
23+
@test Set(loot(crate) for _ in 1:1000) == crate
24+
end
2325
end

exercises/concept.wip/dnd-char/runtests.jl

+41-39
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,51 @@ using Test
22

33
include("dnd-character.jl")
44

5-
@testset "Randomly generated ability is within range" begin
6-
for i in 1:1000
7-
@test 3 <= ability() <= 18
5+
@testset verbose = true "" begin
6+
@testset "Randomly generated ability is within range" begin
7+
for i in 1:1000
8+
@test 3 <= ability() <= 18
9+
end
810
end
9-
end
10-
11-
@testset "Ability modifiers are integers" begin
12-
@test typeof(modifier(7)) <: Integer
13-
end
1411

15-
@testset "Ability modifiers" begin
16-
@test modifier(3) == -4
17-
@test modifier(4) == -3
18-
@test modifier(5) == -3
19-
@test modifier(6) == -2
20-
@test modifier(7) == -2
21-
@test modifier(8) == -1
22-
@test modifier(9) == -1
23-
@test modifier(10) == 0
24-
@test modifier(11) == 0
25-
@test modifier(12) == 1
26-
@test modifier(13) == 1
27-
@test modifier(14) == 2
28-
@test modifier(15) == 2
29-
@test modifier(16) == 3
30-
@test modifier(17) == 3
31-
@test modifier(18) == 4
32-
end
12+
@testset "Ability modifiers are integers" begin
13+
@test typeof(modifier(7)) <: Integer
14+
end
3315

34-
@testset "Randomly generated character is valid" begin
35-
# Helper method to check if all abilities of a character are within the expected ranges.
36-
function ischaracter(c)
37-
3 <= c.strength <= 18 &&
38-
3 <= c.dexterity <= 18 &&
39-
3 <= c.constitution <= 18 &&
40-
3 <= c.intelligence <= 18 &&
41-
3 <= c.wisdom <= 18 &&
42-
3 <= c.charisma <= 18 &&
43-
c.hitpoints == 10 + modifier(c.constitution)
16+
@testset "Ability modifiers" begin
17+
@test modifier(3) == -4
18+
@test modifier(4) == -3
19+
@test modifier(5) == -3
20+
@test modifier(6) == -2
21+
@test modifier(7) == -2
22+
@test modifier(8) == -1
23+
@test modifier(9) == -1
24+
@test modifier(10) == 0
25+
@test modifier(11) == 0
26+
@test modifier(12) == 1
27+
@test modifier(13) == 1
28+
@test modifier(14) == 2
29+
@test modifier(15) == 2
30+
@test modifier(16) == 3
31+
@test modifier(17) == 3
32+
@test modifier(18) == 4
4433
end
4534

46-
for i in 1:1000
47-
c = DNDCharacter()
48-
@test ischaracter(c)
35+
@testset "Randomly generated character is valid" begin
36+
# Helper method to check if all abilities of a character are within the expected ranges.
37+
function ischaracter(c)
38+
3 <= c.strength <= 18 &&
39+
3 <= c.dexterity <= 18 &&
40+
3 <= c.constitution <= 18 &&
41+
3 <= c.intelligence <= 18 &&
42+
3 <= c.wisdom <= 18 &&
43+
3 <= c.charisma <= 18 &&
44+
c.hitpoints == 10 + modifier(c.constitution)
45+
end
46+
47+
for i in 1:1000
48+
c = DNDCharacter()
49+
@test ischaracter(c)
50+
end
4951
end
5052
end

exercises/concept.wip/documented-lasagna/runtests.jl

+22-20
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,26 @@ function hasdocstring(s::Symbol)
2222
haskey(meta, Docs.Binding(@__MODULE__, s))
2323
end
2424

25-
@testset "solution still works" begin
26-
@test preptime(2) == 4
27-
@test preptime(3) == 6
28-
@test preptime(8) == 16
29-
@test remaining_time(30) == 30
30-
@test remaining_time(50) == 10
31-
@test remaining_time(60) == 0
32-
@test total_working_time(3, 20) == 26
33-
end
34-
35-
@testset "preptime has a docstring" begin
36-
@test hasdocstring(:preptime)
37-
end
38-
39-
@testset "remaining_time has a docstring" begin
40-
@test hasdocstring(:remaining_time)
41-
end
42-
43-
@testset "total_working_time has a docstring" begin
44-
@test hasdocstring(:total_working_time)
25+
@testset verbose = true "" begin
26+
@testset "solution still works" begin
27+
@test preptime(2) == 4
28+
@test preptime(3) == 6
29+
@test preptime(8) == 16
30+
@test remaining_time(30) == 30
31+
@test remaining_time(50) == 10
32+
@test remaining_time(60) == 0
33+
@test total_working_time(3, 20) == 26
34+
end
35+
36+
@testset "preptime has a docstring" begin
37+
@test hasdocstring(:preptime)
38+
end
39+
40+
@testset "remaining_time has a docstring" begin
41+
@test hasdocstring(:remaining_time)
42+
end
43+
44+
@testset "total_working_time has a docstring" begin
45+
@test hasdocstring(:total_working_time)
46+
end
4547
end

exercises/concept.wip/elyses-analytic-enchantments/runtests.jl

+30-28
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,39 @@ using Test
22

33
include("enchantments.jl")
44

5-
@testset "Determine if a card is present" begin
6-
@test has_card([2, 3, 4, 5], 3)
7-
end
5+
@testset verbose = true "" begin
6+
@testset "Determine if a card is present" begin
7+
@test has_card([2, 3, 4, 5], 3)
8+
end
89

9-
@testset "Find the position of a card" begin
10-
@test find_card([3], 3) == 1
11-
@test find_card([9, 7, 3, 2], 2) == 4
12-
@test find_card([8, 3, 9, 5], 8) == 1
13-
@test isnothing(find_card([5, 3, 1, 9], 2))
14-
end
10+
@testset "Find the position of a card" begin
11+
@test find_card([3], 3) == 1
12+
@test find_card([9, 7, 3, 2], 2) == 4
13+
@test find_card([8, 3, 9, 5], 8) == 1
14+
@test isnothing(find_card([5, 3, 1, 9], 2))
15+
end
1516

16-
@testset "Determine if each card is even" begin
17-
@test !all_cards_even([1])
18-
@test !all_cards_even([2, 5])
19-
@test all_cards_even([2, 4, 8, 6])
20-
end
17+
@testset "Determine if each card is even" begin
18+
@test !all_cards_even([1])
19+
@test !all_cards_even([2, 5])
20+
@test all_cards_even([2, 4, 8, 6])
21+
end
2122

22-
@testset "Check if the deck contains an odd-value card" begin
23-
@test !any_odd_cards([2, 4, 6])
24-
@test any_odd_cards([2, 5])
25-
@test any_odd_cards([1, 3, 5, 7])
26-
end
23+
@testset "Check if the deck contains an odd-value card" begin
24+
@test !any_odd_cards([2, 4, 6])
25+
@test any_odd_cards([2, 5])
26+
@test any_odd_cards([1, 3, 5, 7])
27+
end
2728

28-
@testset "Determine the position of the first card that is even" begin
29-
@test first_even_card_idx([2, 4, 1, 3]) == 1
30-
@test first_even_card_idx([1, 2]) == 2
31-
@test isnothing(first_even_card_idx([1, 3, 5]))
32-
end
29+
@testset "Determine the position of the first card that is even" begin
30+
@test first_even_card_idx([2, 4, 1, 3]) == 1
31+
@test first_even_card_idx([1, 2]) == 2
32+
@test isnothing(first_even_card_idx([1, 3, 5]))
33+
end
3334

34-
@testset "Get the first odd card from the deck" begin
35-
@test first_odd_card([2, 4, 1, 3]) == 1
36-
@test first_odd_card([1, 2]) == 1
37-
@test isnothing(first_odd_card([4, 2, 6]))
35+
@testset "Get the first odd card from the deck" begin
36+
@test first_odd_card([2, 4, 1, 3]) == 1
37+
@test first_odd_card([1, 2]) == 1
38+
@test isnothing(first_odd_card([4, 2, 6]))
39+
end
3840
end

0 commit comments

Comments
 (0)