From 21e72614f005b28242c0286e5a0fabe5d84d11ff Mon Sep 17 00:00:00 2001 From: Andrej Makarov Date: Thu, 2 Feb 2017 07:03:12 +0000 Subject: [PATCH] Fix indentation to follow guide rules --- exercises/anagram/example.jl | 59 +++++++------ exercises/anagram/runtests.jl | 33 ++++---- exercises/bob/example.jl | 2 +- exercises/hamming/example.jl | 1 - exercises/leap/runtests.jl | 9 +- exercises/raindrops/example.jl | 18 ++-- exercises/raindrops/runtests.jl | 108 ++++++++++++------------ exercises/rna-transcription/example.jl | 11 ++- exercises/rna-transcription/runtests.jl | 45 +++++----- exercises/scrabble-score/example.jl | 14 +-- exercises/scrabble-score/runtests.jl | 24 +++--- exercises/trinary/example.jl | 4 +- exercises/trinary/runtests.jl | 22 ++--- exercises/word-count/example.jl | 14 +-- exercises/word-count/runtests.jl | 22 ++--- 15 files changed, 190 insertions(+), 196 deletions(-) diff --git a/exercises/anagram/example.jl b/exercises/anagram/example.jl index a81f52ca19361..53788b35147ef 100644 --- a/exercises/anagram/example.jl +++ b/exercises/anagram/example.jl @@ -1,43 +1,42 @@ # Anagrams are two or more words that composed of the same characters but in a different order function is_anagram(s1::AbstractString, s2::AbstractString) - # Disable case sensitivity - s1 = lowercase(s1) - s2 = lowercase(s2) + # Disable case sensitivity + s1 = lowercase(s1) + s2 = lowercase(s2) - # Similar and different-length strings are not anagrams - if length(s1) != length(s2) || s1 == s2 - return false - end + # Similar and different-length strings are not anagrams + if length(s1) != length(s2) || s1 == s2 + return false + end - # Calculate count of every character in the first string - chr_count = Dict() - for c in s1 - chr_count[c] = get(chr_count, c, 0) + 1 - end + # Calculate count of every character in the first string + chr_count = Dict() + for c in s1 + chr_count[c] = get(chr_count, c, 0) + 1 + end - # Reduce the count by every character from the second string - for c in s2 - t = get(chr_count, c, 0) - 1 - if t < 0 - # Got character that not exist in the first string - return false - else - chr_count[c] = t + # Reduce the count by every character from the second string + for c in s2 + t = get(chr_count, c, 0) - 1 + if t < 0 + # Got character that not exist in the first string + return false + else + chr_count[c] = t + end end - end - # Check all counts to be zeroes - return all(i->(i==0), values(chr_count)) + # Check all counts to be zeroes + return all(i->(i==0), values(chr_count)) end function detect_anagrams(subject::AbstractString, candidates::AbstractArray) - result = [] - for candidate = candidates - if is_anagram(subject, candidate) - push!(result, candidate) + result = [] + for candidate = candidates + if is_anagram(subject, candidate) + push!(result, candidate) + end end - end - result + result end - diff --git a/exercises/anagram/runtests.jl b/exercises/anagram/runtests.jl index d71b867cab3cc..a21749b8c87b1 100644 --- a/exercises/anagram/runtests.jl +++ b/exercises/anagram/runtests.jl @@ -3,66 +3,65 @@ using Base.Test include("anagram.jl") @testset "no matches" begin - @test detect_anagrams("diasper", ["hello", "world", "zombies", "pants"]) == [] + @test detect_anagrams("diasper", ["hello", "world", "zombies", "pants"]) == [] end @testset "detects simple anagram" begin - @test detect_anagrams("ant", ["tan", "stand", "at"]) == ["tan"] + @test detect_anagrams("ant", ["tan", "stand", "at"]) == ["tan"] end @testset "does not detect false positives" begin - @test detect_anagrams("galea", ["eagle"]) == [] + @test detect_anagrams("galea", ["eagle"]) == [] end @testset "detects multiple anagrams" begin - @test detect_anagrams("master", ["stream", "pigeon", "maters"]) == ["stream", "maters"] + @test detect_anagrams("master", ["stream", "pigeon", "maters"]) == ["stream", "maters"] end @testset "does not detect anagram subsets" begin - @test detect_anagrams("good", ["dog", "goody"]) == [] + @test detect_anagrams("good", ["dog", "goody"]) == [] end @testset "detects anagram" begin - @test detect_anagrams("listen", ["enlists", "google", "inlets", "banana"]) == ["inlets"] + @test detect_anagrams("listen", ["enlists", "google", "inlets", "banana"]) == ["inlets"] end @testset "detects multiple anagrams" begin - @test detect_anagrams("allergy", ["gallery", "ballerina", "regally", "clergy", "largely", "leading"]) == ["gallery", "regally", "largely"] + @test detect_anagrams("allergy", ["gallery", "ballerina", "regally", "clergy", "largely", "leading"]) == ["gallery", "regally", "largely"] end @testset "does not detect identical words" begin - @test detect_anagrams("corn", ["corn", "dark", "Corn", "rank", "CORN", "cron", "park"]) == ["cron"] + @test detect_anagrams("corn", ["corn", "dark", "Corn", "rank", "CORN", "cron", "park"]) == ["cron"] end @testset "does not detect non-anagrams with identical checksum" begin - @test detect_anagrams("mass", ["last"]) == [] + @test detect_anagrams("mass", ["last"]) == [] end @testset "detects anagrams case-insensitively" begin - @test detect_anagrams("Orchestra", ["cashregister", "Carthorse", "radishes"]) == ["Carthorse"] + @test detect_anagrams("Orchestra", ["cashregister", "Carthorse", "radishes"]) == ["Carthorse"] end @testset "detects anagrams using case-insensitive subject" begin - @test detect_anagrams("Orchestra", ["cashregister", "carthorse", "radishes"]) == ["carthorse"] + @test detect_anagrams("Orchestra", ["cashregister", "carthorse", "radishes"]) == ["carthorse"] end @testset "detects anagrams using case-insensitive possible matches" begin - @test detect_anagrams("orchestra", ["cashregister", "Carthorse", "radishes"]) == ["Carthorse"] + @test detect_anagrams("orchestra", ["cashregister", "Carthorse", "radishes"]) == ["Carthorse"] end @testset "does not detect a word as its own anagram" begin - @test detect_anagrams("banana", ["Banana"]) == [] + @test detect_anagrams("banana", ["Banana"]) == [] end @testset "does not detect a anagram if the original word is repeated" begin - @test detect_anagrams("go", ["go Go GO"]) == [] + @test detect_anagrams("go", ["go Go GO"]) == [] end @testset "anagrams must use all letters exactly once" begin - @test detect_anagrams("tapper", ["patter"]) == [] + @test detect_anagrams("tapper", ["patter"]) == [] end @testset "capital word is not own anagram" begin - @test detect_anagrams("BANANA", ["Banana"]) == [] + @test detect_anagrams("BANANA", ["Banana"]) == [] end - diff --git a/exercises/bob/example.jl b/exercises/bob/example.jl index 338d17a12c34d..9389973bc9856 100644 --- a/exercises/bob/example.jl +++ b/exercises/bob/example.jl @@ -25,6 +25,6 @@ function isshouting(stimulus::AbstractString) return false end end - + return true end diff --git a/exercises/hamming/example.jl b/exercises/hamming/example.jl index a4274674e0d93..013e8ec3a553c 100644 --- a/exercises/hamming/example.jl +++ b/exercises/hamming/example.jl @@ -1,5 +1,4 @@ function distance(s1::AbstractString, s2::AbstractString) length(s1) != length(s2) && throw(ArgumentError("Sequences must have the same length")) - reduce(+, 0, a != b for (a, b) in zip(s1, s2)) end diff --git a/exercises/leap/runtests.jl b/exercises/leap/runtests.jl index 08642402c7e78..7db6dea8514a8 100644 --- a/exercises/leap/runtests.jl +++ b/exercises/leap/runtests.jl @@ -3,18 +3,17 @@ using Base.Test include("leap.jl") @testset "Year not divisible by 4: common year" begin - @test !is_leap_year(2015) + @test !is_leap_year(2015) end @testset "Year divisible by 4, not divisible by 100: leap year" begin - @test is_leap_year(2016) + @test is_leap_year(2016) end @testset "Year divisible by 100, not divisible by 400: common year" begin - @test !is_leap_year(2100) + @test !is_leap_year(2100) end @testset "Year divisible by 400: leap year" begin - @test is_leap_year(2000) + @test is_leap_year(2000) end - diff --git a/exercises/raindrops/example.jl b/exercises/raindrops/example.jl index 128bbd5bad9a5..12cd8d005f60a 100644 --- a/exercises/raindrops/example.jl +++ b/exercises/raindrops/example.jl @@ -4,13 +4,13 @@ # If the number does not have 3, 5, or 7 as a factor, just pass the number's digits straight through. function raindrops(number::Int) - drops = [] - number % 3 == 0 && push!(drops, "Pling") - number % 5 == 0 && push!(drops, "Plang") - number % 7 == 0 && push!(drops, "Plong") - if size(drops, 1) == 0 - repr(number) - else - join(drops) - end + drops = [] + number % 3 == 0 && push!(drops, "Pling") + number % 5 == 0 && push!(drops, "Plang") + number % 7 == 0 && push!(drops, "Plong") + if size(drops, 1) == 0 + repr(number) + else + join(drops) + end end diff --git a/exercises/raindrops/runtests.jl b/exercises/raindrops/runtests.jl index 82700923ded56..32988294a5c62 100644 --- a/exercises/raindrops/runtests.jl +++ b/exercises/raindrops/runtests.jl @@ -3,70 +3,70 @@ using Base.Test include("raindrops.jl") @testset "detect numbers" begin - @testset "the sound for 1 is 1" begin - @test raindrops(1) == "1" - end - @testset "2 to the power 3 does not make a raindrop sound as 3 is the exponent not the base" begin - @test raindrops(8) == "8" - end - @testset "the sound for 52 is 52" begin - @test raindrops(52) == "52" - end + @testset "the sound for 1 is 1" begin + @test raindrops(1) == "1" + end + @testset "2 to the power 3 does not make a raindrop sound as 3 is the exponent not the base" begin + @test raindrops(8) == "8" + end + @testset "the sound for 52 is 52" begin + @test raindrops(52) == "52" + end end @testset "detect pling" begin - @testset "the sound for 3 is Pling" begin - @test raindrops(3) == "Pling" - end - @testset "the sound for 6 is Pling as it has a factor 3" begin - @test raindrops(6) == "Pling" - end - @testset "the sound for 9 is Pling as it has a factor 3" begin - @test raindrops(9) == "Pling" - end - @testset "the sound for 27 is Pling as it has a factor 3" begin - @test raindrops(27) == "Pling" - end + @testset "the sound for 3 is Pling" begin + @test raindrops(3) == "Pling" + end + @testset "the sound for 6 is Pling as it has a factor 3" begin + @test raindrops(6) == "Pling" + end + @testset "the sound for 9 is Pling as it has a factor 3" begin + @test raindrops(9) == "Pling" + end + @testset "the sound for 27 is Pling as it has a factor 3" begin + @test raindrops(27) == "Pling" + end end @testset "detect plang" begin - @testset "the sound for 5 is Plang" begin - @test raindrops(5) == "Plang" - end - @testset "the sound for 10 is Plang as it has a factor 5" begin - @test raindrops(10) == "Plang" - end - @testset "the sound for 25 is Plang as it has a factor 5" begin - @test raindrops(25) == "Plang" - end - @testset "the sound for 3125 is Plang as it has a factor 5" begin - @test raindrops(3125) == "Plang" - end + @testset "the sound for 5 is Plang" begin + @test raindrops(5) == "Plang" + end + @testset "the sound for 10 is Plang as it has a factor 5" begin + @test raindrops(10) == "Plang" + end + @testset "the sound for 25 is Plang as it has a factor 5" begin + @test raindrops(25) == "Plang" + end + @testset "the sound for 3125 is Plang as it has a factor 5" begin + @test raindrops(3125) == "Plang" + end end @testset "detect plong" begin - @testset "the sound for 7 is Plong" begin - @test raindrops(7) == "Plong" - end - @testset "the sound for 14 is Plong as it has a factor of 7" begin - @test raindrops(14) == "Plong" - end - @testset "the sound for 49 is Plong as it has a factor 7" begin - @test raindrops(49) == "Plong" - end + @testset "the sound for 7 is Plong" begin + @test raindrops(7) == "Plong" + end + @testset "the sound for 14 is Plong as it has a factor of 7" begin + @test raindrops(14) == "Plong" + end + @testset "the sound for 49 is Plong as it has a factor 7" begin + @test raindrops(49) == "Plong" + end end @testset "detect multiple sounds" begin - @testset "the sound for 15 is PlingPlang as it has factors 3 and 5" begin - @test raindrops(15) == "PlingPlang" - end - @testset "the sound for 21 is PlingPlong as it has factors 3 and 7" begin - @test raindrops(21) == "PlingPlong" - end - @testset "the sound for 35 is PlangPlong as it has factors 5 and 7" begin - @test raindrops(35) == "PlangPlong" - end - @testset "the sound for 105 is PlingPlangPlong as it has factors 3, 5 and 7" begin - @test raindrops(105) == "PlingPlangPlong" - end + @testset "the sound for 15 is PlingPlang as it has factors 3 and 5" begin + @test raindrops(15) == "PlingPlang" + end + @testset "the sound for 21 is PlingPlong as it has factors 3 and 7" begin + @test raindrops(21) == "PlingPlong" + end + @testset "the sound for 35 is PlangPlong as it has factors 5 and 7" begin + @test raindrops(35) == "PlangPlong" + end + @testset "the sound for 105 is PlingPlangPlong as it has factors 3, 5 and 7" begin + @test raindrops(105) == "PlingPlangPlong" + end end diff --git a/exercises/rna-transcription/example.jl b/exercises/rna-transcription/example.jl index 06f5d63bbde46..99ed6b38d140d 100644 --- a/exercises/rna-transcription/example.jl +++ b/exercises/rna-transcription/example.jl @@ -1,10 +1,9 @@ # Given a DNA strand, its transcribed RNA strand is formed by replacing each nucleotide with its complement: # G -> C, C -> G, T -> A, A -> U function to_rna(dna::AbstractString) - typeof(match(r"^[GCTA]+$", dna)) == Void && error("Invalid RNA strand") - # Define character associations - a_nucleotides = Dict('G'=>'C', 'C'=>'G', 'T'=>'A', 'A'=>'U') - # Replace characters using dictionary - map((x)->a_nucleotides[x], dna) + typeof(match(r"^[GCTA]+$", dna)) == Void && error("Invalid RNA strand") + # Define character associations + a_nucleotides = Dict('G'=>'C', 'C'=>'G', 'T'=>'A', 'A'=>'U') + # Replace characters using dictionary + map((x)->a_nucleotides[x], dna) end - diff --git a/exercises/rna-transcription/runtests.jl b/exercises/rna-transcription/runtests.jl index 5e4f9c43342aa..b3ee2fefe0ba4 100644 --- a/exercises/rna-transcription/runtests.jl +++ b/exercises/rna-transcription/runtests.jl @@ -3,38 +3,37 @@ using Base.Test include("rna-transcription.jl") @testset "basic transformations" begin - @testset "rna complement of cytosine is guanine" begin - @test to_rna("C") == "G" - end + @testset "rna complement of cytosine is guanine" begin + @test to_rna("C") == "G" + end - @testset "rna complement of guanine is cytosine" begin - @test to_rna("G") == "C" - end + @testset "rna complement of guanine is cytosine" begin + @test to_rna("G") == "C" + end - @testset "rna complement of thymine is adenine" begin - @test to_rna("T") == "A" - end + @testset "rna complement of thymine is adenine" begin + @test to_rna("T") == "A" + end - @testset "rna complement of adenine is uracil" begin - @test to_rna("A") == "U" - end + @testset "rna complement of adenine is uracil" begin + @test to_rna("A") == "U" + end end @testset "rna complement" begin - @test to_rna("ACGTGGTCTTAA") == "UGCACCAGAAUU" + @test to_rna("ACGTGGTCTTAA") == "UGCACCAGAAUU" end @testset "error handling" begin - @testset "dna correctly handles invalid input" begin - @test_throws ErrorException to_rna("U") - end + @testset "dna correctly handles invalid input" begin + @test_throws ErrorException to_rna("U") + end - @testset "dna correctly handles completely invalid input" begin - @test_throws ErrorException to_rna("XXX") - end + @testset "dna correctly handles completely invalid input" begin + @test_throws ErrorException to_rna("XXX") + end - @testset "dna correctly handles partially invalid input" begin - @test_throws ErrorException to_rna("ACGTXXXCTTAA") - end + @testset "dna correctly handles partially invalid input" begin + @test_throws ErrorException to_rna("ACGTXXXCTTAA") + end end - diff --git a/exercises/scrabble-score/example.jl b/exercises/scrabble-score/example.jl index f0def35b5022b..c10a3ca43cb35 100644 --- a/exercises/scrabble-score/example.jl +++ b/exercises/scrabble-score/example.jl @@ -1,9 +1,9 @@ function score(str::AbstractString) - rank = Dict('a'=>1, 'e'=>1, 'i'=>1, 'o'=>1, 'u'=>1, 'l'=>1, - 'n'=>1, 'r'=>1, 's'=>1, 't'=>1, 'd'=>2, 'g'=>2, - 'b'=>3, 'c'=>3, 'm'=>3, 'p'=>3, 'f'=>4, 'h'=>4, - 'v'=>4, 'w'=>4, 'y'=>4, 'k'=>5, 'j'=>8, 'x'=>8, - 'q'=>10, 'z'=>10) - length(str) == 0 && return 0 - mapreduce(x->get(rank, x, 0), +, lowercase(str)) + rank = Dict('a'=>1, 'e'=>1, 'i'=>1, 'o'=>1, 'u'=>1, 'l'=>1, + 'n'=>1, 'r'=>1, 's'=>1, 't'=>1, 'd'=>2, 'g'=>2, + 'b'=>3, 'c'=>3, 'm'=>3, 'p'=>3, 'f'=>4, 'h'=>4, + 'v'=>4, 'w'=>4, 'y'=>4, 'k'=>5, 'j'=>8, 'x'=>8, + 'q'=>10, 'z'=>10) + length(str) == 0 && return 0 + mapreduce(x->get(rank, x, 0), +, lowercase(str)) end diff --git a/exercises/scrabble-score/runtests.jl b/exercises/scrabble-score/runtests.jl index fca924cec1d77..b7827ad12dc05 100644 --- a/exercises/scrabble-score/runtests.jl +++ b/exercises/scrabble-score/runtests.jl @@ -3,49 +3,49 @@ using Base.Test include("scrabble-score.jl") @testset "lowercase letter" begin - @test score("a") == 1 + @test score("a") == 1 end @testset "uppercase letter" begin - @test score("A") == 1 + @test score("A") == 1 end @testset "valuable letter" begin - @test score("f") == 4 + @test score("f") == 4 end @testset "short word" begin - @test score("at") == 2 + @test score("at") == 2 end @testset "short, valuable word" begin - @test score("zoo") == 12 + @test score("zoo") == 12 end @testset "medium word" begin - @test score("street") == 6 + @test score("street") == 6 end @testset "medium, valuable word" begin - @test score("quirky") == 22 + @test score("quirky") == 22 end @testset "long, mixed-case word" begin - @test score("OxyphenButazone") == 41 + @test score("OxyphenButazone") == 41 end @testset "english-like word" begin - @test score("pinata") == 8 + @test score("pinata") == 8 end @testset "non-english letter is not scored" begin - @test score("piñata") == 7 + @test score("piñata") == 7 end @testset "empty input" begin - @test score("") == 0 + @test score("") == 0 end @testset "entire alphabet available" begin - @test score("abcdefghijklmnopqrstuvwxyz") == 87 + @test score("abcdefghijklmnopqrstuvwxyz") == 87 end diff --git a/exercises/trinary/example.jl b/exercises/trinary/example.jl index 8b37a77aeb520..9089cc8099020 100644 --- a/exercises/trinary/example.jl +++ b/exercises/trinary/example.jl @@ -1,4 +1,4 @@ function trinary_to_decimal(str::AbstractString) - typeof(match(r"^[0-2]+$", str)) == Void && return 0 - mapreduce(i->(i[2]-'0')*3^i[1], +, zip(0:length(str), reverse(str))) + typeof(match(r"^[0-2]+$", str)) == Void && return 0 + mapreduce(i->(i[2]-'0')*3^i[1], +, zip(0:length(str), reverse(str))) end diff --git a/exercises/trinary/runtests.jl b/exercises/trinary/runtests.jl index c676b1f2a150c..389b12d9b7dcd 100644 --- a/exercises/trinary/runtests.jl +++ b/exercises/trinary/runtests.jl @@ -3,45 +3,45 @@ using Base.Test include("trinary.jl") @testset "trinary 1 is decimal 1" begin - @test trinary_to_decimal("1") == 1 + @test trinary_to_decimal("1") == 1 end @testset "trinary 2 is decimal 2" begin - @test trinary_to_decimal("2") == 2 + @test trinary_to_decimal("2") == 2 end @testset "trinary 10 is decimal 3" begin - @test trinary_to_decimal("10") == 3 + @test trinary_to_decimal("10") == 3 end @testset "trinary 11 is decimal 4" begin - @test trinary_to_decimal("11") == 4 + @test trinary_to_decimal("11") == 4 end @testset "trinary 100 is decimal 9" begin - @test trinary_to_decimal("100") == 9 + @test trinary_to_decimal("100") == 9 end @testset "trinary 112 is decimal 14" begin - @test trinary_to_decimal("112") == 14 + @test trinary_to_decimal("112") == 14 end @testset "trinary 222 is decimal 26" begin - @test trinary_to_decimal("222") == 26 + @test trinary_to_decimal("222") == 26 end @testset "trinary 1122000120 is decimal 32091" begin - @test trinary_to_decimal("1122000120") == 32091 + @test trinary_to_decimal("1122000120") == 32091 end @testset "invalid trinary digits returns 0" begin - @test trinary_to_decimal("1234") == 0 + @test trinary_to_decimal("1234") == 0 end @testset "invalid word as input returns 0" begin - @test trinary_to_decimal("carrot") == 0 + @test trinary_to_decimal("carrot") == 0 end @testset "invalid numbers with letters as input returns 0" begin - @test trinary_to_decimal("0a1b2c") == 0 + @test trinary_to_decimal("0a1b2c") == 0 end diff --git a/exercises/word-count/example.jl b/exercises/word-count/example.jl index 48d7f105b7460..5d8b2b7c5a83f 100644 --- a/exercises/word-count/example.jl +++ b/exercises/word-count/example.jl @@ -1,9 +1,9 @@ function wordcount(sentence::AbstractString) - sentence = lowercase(sentence) - words = Dict() - for rx = eachmatch(r"[a-z]+'[a-z]+|[0-9a-z]+", sentence) - word = rx.match - words[word] = get(words, word, 0) + 1 - end - words + sentence = lowercase(sentence) + words = Dict() + for rx = eachmatch(r"[a-z]+'[a-z]+|[0-9a-z]+", sentence) + word = rx.match + words[word] = get(words, word, 0) + 1 + end + words end diff --git a/exercises/word-count/runtests.jl b/exercises/word-count/runtests.jl index 95a02ddcd8cbd..cf585ab9c915d 100644 --- a/exercises/word-count/runtests.jl +++ b/exercises/word-count/runtests.jl @@ -3,45 +3,45 @@ using Base.Test include("word-count.jl") @testset "no words" begin - @test wordcount(" .\n,\t!^&*()~@#\$%{}[]:;'/<>") == Dict() + @test wordcount(" .\n,\t!^&*()~@#\$%{}[]:;'/<>") == Dict() end @testset "count one word" begin - @test wordcount("word") == Dict("word" => 1) + @test wordcount("word") == Dict("word" => 1) end @testset "count one of each word" begin - @test wordcount("one of each") == Dict("one" => 1, "of" => 1, "each" => 1) + @test wordcount("one of each") == Dict("one" => 1, "of" => 1, "each" => 1) end @testset "multiple occurrences of a word" begin - @test wordcount("one fish two fish red fish blue fish") == Dict("one" => 1, "fish" => 4, "two" => 1, "red" => 1, "blue" => 1) + @test wordcount("one fish two fish red fish blue fish") == Dict("one" => 1, "fish" => 4, "two" => 1, "red" => 1, "blue" => 1) end @testset "handles cramped lists" begin - @test wordcount("one,two,three") == Dict("one" => 1, "two" => 1, "three" => 1) + @test wordcount("one,two,three") == Dict("one" => 1, "two" => 1, "three" => 1) end @testset "handles expanded lists" begin - @test wordcount("one,\ntwo,\nthree") == Dict("one" => 1, "two" => 1, "three" => 1) + @test wordcount("one,\ntwo,\nthree") == Dict("one" => 1, "two" => 1, "three" => 1) end @testset "ignore punctuation" begin - @test wordcount("car: carpet as java: javascript!!&@\$%^&") == Dict("car" => 1, "carpet" => 1, "as" => 1, "java" => 1, "javascript" => 1) + @test wordcount("car: carpet as java: javascript!!&@\$%^&") == Dict("car" => 1, "carpet" => 1, "as" => 1, "java" => 1, "javascript" => 1) end @testset "include numbers" begin - @test wordcount("testing, 1, 2 testing") == Dict("testing" => 2, "1" => 1, "2" => 1) + @test wordcount("testing, 1, 2 testing") == Dict("testing" => 2, "1" => 1, "2" => 1) end @testset "normalize case" begin - @test wordcount("go Go GO Stop stop") == Dict("go" => 3, "stop" => 2) + @test wordcount("go Go GO Stop stop") == Dict("go" => 3, "stop" => 2) end @testset "with apostrophes" begin - @test wordcount("First: don't laugh. Then: don't cry.") == Dict("first" => 1, "don't" => 2, "laugh" => 1, "then" => 1, "cry" => 1) + @test wordcount("First: don't laugh. Then: don't cry.") == Dict("first" => 1, "don't" => 2, "laugh" => 1, "then" => 1, "cry" => 1) end @testset "with quotations" begin - @test wordcount("Joe can't tell between 'large' and large.") == Dict("joe" => 1, "can't" => 1, "tell" => 1, "between" => 1, "large" => 2, "and" => 1) + @test wordcount("Joe can't tell between 'large' and large.") == Dict("joe" => 1, "can't" => 1, "tell" => 1, "between" => 1, "large" => 2, "and" => 1) end