diff --git a/config/generator_macros.j2 b/config/generator_macros.j2 index 1249d5413..ff7bd3573 100644 --- a/config/generator_macros.j2 +++ b/config/generator_macros.j2 @@ -31,12 +31,17 @@ include("{{ exercise }}.jl") {%- endif %} {%- endmacro %} -{# A Julia string literal, with \, " and $ escaped #} +{# A Julia string literal, with \, ", $, newlines and tabs escaped #} {% macro julia_string(s) -%} -"{{ s | replace("\\", "\\\\") | replace('"', '\\"') | replace("$", "\\$") }}" +"{{ s | replace("\\", "\\\\") | replace('"', '\\"') | replace("$", "\\$") | replace("\n", "\\n") | replace("\t", "\\t") }}" {%- endmacro %} {# A Julia vector literal; string elements are quoted with julia_string, nested lists become nested vectors #} {% macro julia_vector(xs) -%} [{% for x in xs %}{% if x is string %}{{ julia_string(x) }}{% elif x is sequence %}{{ julia_vector(x) }}{% else %}{{ x }}{% endif %}{% if not loop.last %}, {% endif %}{% endfor %}] {%- endmacro %} + +{# A Julia Dict literal; string keys are quoted with julia_string, or as Chars if char_keys is true #} +{% macro julia_dict(d, char_keys=false) -%} +Dict({% for k, v in d.items() %}{% if char_keys %}'{{ k }}'{% else %}{{ julia_string(k) }}{% endif %} => {% if v is string %}{{ julia_string(v) }}{% elif v is sequence %}{{ julia_vector(v) }}{% else %}{{ v }}{% endif %}{% if not loop.last %}, {% endif %}{% endfor %}) +{%- endmacro %} diff --git a/exercises/practice/etl/.meta/template.j2 b/exercises/practice/etl/.meta/template.j2 new file mode 100644 index 000000000..7d9dab40f --- /dev/null +++ b/exercises/practice/etl/.meta/template.j2 @@ -0,0 +1,10 @@ +{%- import "generator_macros.j2" as macros with context -%} +{{ macros.canonical_ref() }} + +{{ macros.header() }} +{% for case in cases %} + @testset "{{ case["description"] }}" begin + @test transform(Dict({% for score, letters in case["input"]["legacy"].items() %}{{ score }} => [{% for c in letters %}'{{ c }}'{% if not loop.last %}, {% endif %}{% endfor %}]{% if not loop.last %}, {% endif %}{% endfor %})) == {{ macros.julia_dict(case["expected"], char_keys=true) }} + end +{% endfor %} +end diff --git a/exercises/practice/etl/runtests.jl b/exercises/practice/etl/runtests.jl index e618deb0a..c2a64bce6 100644 --- a/exercises/practice/etl/runtests.jl +++ b/exercises/practice/etl/runtests.jl @@ -1,37 +1,34 @@ +# These tests are auto-generated with test data from: +# https://github.com/exercism/problem-specifications/tree/main/exercises/etl/canonical-data.json +# File last updated on 2026-10-24 + using Test include("etl.jl") @testset verbose = true "tests" begin @testset "single letter" begin - input = Dict(1=>['A']) - output = Dict('a'=>1) - @test transform(input) == output + @test transform(Dict(1 => ['A'])) == Dict('a' => 1) end @testset "single score with multiple letters" begin - input = Dict(1=>['A', 'E', 'I', 'O', 'U']) - output = Dict('a'=>1, 'e'=>1, 'i'=>1, 'o'=>1, 'u'=>1) - @test transform(input) == output + @test transform(Dict(1 => ['A', 'E', 'I', 'O', 'U'])) == + Dict('a' => 1, 'e' => 1, 'i' => 1, 'o' => 1, 'u' => 1) end @testset "multiple scores with multiple letters" begin - input = Dict(1=>['A', 'E'], 2=>['D', 'G']) - output = Dict('g'=>2, 'e'=>1, 'a'=>1, 'd'=>2) - @test transform(input) == output + @test transform(Dict(1 => ['A', 'E'], 2 => ['D', 'G'])) == + Dict('a' => 1, 'd' => 2, 'e' => 1, 'g' => 2) end @testset "multiple scores with differing numbers of letters" begin - input = Dict(1=>[ 'A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T' ], - 2=>[ 'D', 'G' ], 3=>[ 'B', 'C', 'M', 'P' ], - 4=>[ 'F', 'H', 'V', 'W', 'Y' ], 5=>[ 'K' ], - 8=>[ 'J', 'X' ], 10=>[ 'Q', 'Z' ]) - output = Dict('a'=>1, 'b'=>3, 'c'=>3, 'd'=>2, 'e'=>1, - 'f'=>4, 'g'=>2, 'h'=>4, 'i'=>1, 'j'=>8, - 'k'=>5, 'l'=>1, 'm'=>3, 'n'=>1, 'o'=>1, - 'p'=>3, 'q'=>10, 'r'=>1, 's'=>1, 't'=>1, - 'u'=>1, 'v'=>4, 'w'=>4, 'x'=>8, 'y'=>4, - 'z'=>10) - @test transform(input) == output + @test transform(Dict(1 => ['A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T'], + 2 => ['D', 'G'], 3 => ['B', 'C', 'M', 'P'], + 4 => ['F', 'H', 'V', 'W', 'Y'], 5 => ['K'], 8 => ['J', 'X'], + 10 => ['Q', 'Z'])) == + Dict('a' => 1, 'b' => 3, 'c' => 3, 'd' => 2, 'e' => 1, 'f' => 4, 'g' => 2, + 'h' => 4, 'i' => 1, 'j' => 8, 'k' => 5, 'l' => 1, 'm' => 3, 'n' => 1, + 'o' => 1, 'p' => 3, 'q' => 10, 'r' => 1, 's' => 1, 't' => 1, 'u' => 1, + 'v' => 4, 'w' => 4, 'x' => 8, 'y' => 4, 'z' => 10) end end diff --git a/exercises/practice/food-chain/.meta/template.j2 b/exercises/practice/food-chain/.meta/template.j2 new file mode 100644 index 000000000..b31a221d3 --- /dev/null +++ b/exercises/practice/food-chain/.meta/template.j2 @@ -0,0 +1,10 @@ +{%- import "generator_macros.j2" as macros with context -%} +{{ macros.canonical_ref() }} + +{{ macros.header() }} +{% for case in cases %} + @testset "{{ case["description"] }}" begin + @test recite({{ case["input"]["startVerse"] }}, {{ case["input"]["endVerse"] }}) == {{ macros.julia_vector(case["expected"]) }} + end +{% endfor %} +end diff --git a/exercises/practice/food-chain/runtests.jl b/exercises/practice/food-chain/runtests.jl index cb80528d4..27903f1c1 100644 --- a/exercises/practice/food-chain/runtests.jl +++ b/exercises/practice/food-chain/runtests.jl @@ -1,172 +1,131 @@ +# These tests are auto-generated with test data from: +# https://github.com/exercism/problem-specifications/tree/main/exercises/food-chain/canonical-data.json +# File last updated on 2026-10-24 + using Test include("food-chain.jl") @testset verbose = true "tests" begin - @testset "fly" begin - expected = [ - "I know an old lady who swallowed a fly.", - "I don't know why she swallowed the fly. Perhaps she'll die." - ] - @test recite(1, 1) == expected + @test recite(1, 1) == ["I know an old lady who swallowed a fly.", + "I don't know why she swallowed the fly. Perhaps she'll die."] end @testset "spider" begin - expected = [ - "I know an old lady who swallowed a spider.", - "It wriggled and jiggled and tickled inside her.", - "She swallowed the spider to catch the fly.", - "I don't know why she swallowed the fly. Perhaps she'll die.", - ] - @test recite(2, 2) == expected + @test recite(2, 2) == ["I know an old lady who swallowed a spider.", + "It wriggled and jiggled and tickled inside her.", + "She swallowed the spider to catch the fly.", + "I don't know why she swallowed the fly. Perhaps she'll die."] end @testset "bird" begin - expected = [ - "I know an old lady who swallowed a bird.", - "How absurd to swallow a bird!", - "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.", - "She swallowed the spider to catch the fly.", - "I don't know why she swallowed the fly. Perhaps she'll die.", - ] - @test recite(3, 3) == expected + @test recite(3, 3) == + ["I know an old lady who swallowed a bird.", "How absurd to swallow a bird!", + "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.", + "She swallowed the spider to catch the fly.", + "I don't know why she swallowed the fly. Perhaps she'll die."] end @testset "cat" begin - expected = [ - "I know an old lady who swallowed a cat.", - "Imagine that, to swallow a cat!", - "She swallowed the cat to catch the bird.", - "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.", - "She swallowed the spider to catch the fly.", - "I don't know why she swallowed the fly. Perhaps she'll die.", - ] - @test recite(4, 4) == expected + @test recite(4, 4) == + ["I know an old lady who swallowed a cat.", "Imagine that, to swallow a cat!", + "She swallowed the cat to catch the bird.", + "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.", + "She swallowed the spider to catch the fly.", + "I don't know why she swallowed the fly. Perhaps she'll die."] end @testset "dog" begin - expected = [ - "I know an old lady who swallowed a dog.", - "What a hog, to swallow a dog!", - "She swallowed the dog to catch the cat.", - "She swallowed the cat to catch the bird.", - "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.", - "She swallowed the spider to catch the fly.", - "I don't know why she swallowed the fly. Perhaps she'll die.", - ] - @test recite(5, 5) == expected + @test recite(5, 5) == + ["I know an old lady who swallowed a dog.", "What a hog, to swallow a dog!", + "She swallowed the dog to catch the cat.", + "She swallowed the cat to catch the bird.", + "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.", + "She swallowed the spider to catch the fly.", + "I don't know why she swallowed the fly. Perhaps she'll die."] end @testset "goat" begin - expected = [ - "I know an old lady who swallowed a goat.", - "Just opened her throat and swallowed a goat!", - "She swallowed the goat to catch the dog.", - "She swallowed the dog to catch the cat.", - "She swallowed the cat to catch the bird.", - "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.", - "She swallowed the spider to catch the fly.", - "I don't know why she swallowed the fly. Perhaps she'll die.", - ] - @test recite(6, 6) == expected + @test recite(6, 6) == ["I know an old lady who swallowed a goat.", + "Just opened her throat and swallowed a goat!", + "She swallowed the goat to catch the dog.", + "She swallowed the dog to catch the cat.", + "She swallowed the cat to catch the bird.", + "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.", + "She swallowed the spider to catch the fly.", + "I don't know why she swallowed the fly. Perhaps she'll die."] end @testset "cow" begin - expected = [ - "I know an old lady who swallowed a cow.", - "I don't know how she swallowed a cow!", - "She swallowed the cow to catch the goat.", - "She swallowed the goat to catch the dog.", - "She swallowed the dog to catch the cat.", - "She swallowed the cat to catch the bird.", - "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.", - "She swallowed the spider to catch the fly.", - "I don't know why she swallowed the fly. Perhaps she'll die.", - ] - @test recite(7, 7) == expected + @test recite(7, 7) == ["I know an old lady who swallowed a cow.", + "I don't know how she swallowed a cow!", + "She swallowed the cow to catch the goat.", + "She swallowed the goat to catch the dog.", + "She swallowed the dog to catch the cat.", + "She swallowed the cat to catch the bird.", + "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.", + "She swallowed the spider to catch the fly.", + "I don't know why she swallowed the fly. Perhaps she'll die."] end @testset "horse" begin - expected = [ - "I know an old lady who swallowed a horse.", "She's dead, of course!", - ] - @test recite(8, 8) == expected + @test recite(8, 8) == + ["I know an old lady who swallowed a horse.", "She's dead, of course!"] end @testset "multiple verses" begin - expected = [ - "I know an old lady who swallowed a fly.", - "I don't know why she swallowed the fly. Perhaps she'll die.", - "", - "I know an old lady who swallowed a spider.", - "It wriggled and jiggled and tickled inside her.", - "She swallowed the spider to catch the fly.", - "I don't know why she swallowed the fly. Perhaps she'll die.", - "", - "I know an old lady who swallowed a bird.", - "How absurd to swallow a bird!", - "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.", - "She swallowed the spider to catch the fly.", - "I don't know why she swallowed the fly. Perhaps she'll die.", - ] - @test recite(1, 3) == expected + @test recite(1, 3) == ["I know an old lady who swallowed a fly.", + "I don't know why she swallowed the fly. Perhaps she'll die.", "", + "I know an old lady who swallowed a spider.", + "It wriggled and jiggled and tickled inside her.", + "She swallowed the spider to catch the fly.", + "I don't know why she swallowed the fly. Perhaps she'll die.", "", + "I know an old lady who swallowed a bird.", "How absurd to swallow a bird!", + "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.", + "She swallowed the spider to catch the fly.", + "I don't know why she swallowed the fly. Perhaps she'll die."] end @testset "full song" begin - expected = [ - "I know an old lady who swallowed a fly.", - "I don't know why she swallowed the fly. Perhaps she'll die.", - "", - "I know an old lady who swallowed a spider.", - "It wriggled and jiggled and tickled inside her.", - "She swallowed the spider to catch the fly.", - "I don't know why she swallowed the fly. Perhaps she'll die.", - "", - "I know an old lady who swallowed a bird.", - "How absurd to swallow a bird!", - "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.", - "She swallowed the spider to catch the fly.", - "I don't know why she swallowed the fly. Perhaps she'll die.", - "", - "I know an old lady who swallowed a cat.", - "Imagine that, to swallow a cat!", - "She swallowed the cat to catch the bird.", - "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.", - "She swallowed the spider to catch the fly.", - "I don't know why she swallowed the fly. Perhaps she'll die.", - "", - "I know an old lady who swallowed a dog.", - "What a hog, to swallow a dog!", - "She swallowed the dog to catch the cat.", - "She swallowed the cat to catch the bird.", - "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.", - "She swallowed the spider to catch the fly.", - "I don't know why she swallowed the fly. Perhaps she'll die.", - "", - "I know an old lady who swallowed a goat.", - "Just opened her throat and swallowed a goat!", - "She swallowed the goat to catch the dog.", - "She swallowed the dog to catch the cat.", - "She swallowed the cat to catch the bird.", - "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.", - "She swallowed the spider to catch the fly.", - "I don't know why she swallowed the fly. Perhaps she'll die.", - "", - "I know an old lady who swallowed a cow.", - "I don't know how she swallowed a cow!", - "She swallowed the cow to catch the goat.", - "She swallowed the goat to catch the dog.", - "She swallowed the dog to catch the cat.", - "She swallowed the cat to catch the bird.", - "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.", - "She swallowed the spider to catch the fly.", - "I don't know why she swallowed the fly. Perhaps she'll die.", - "", - "I know an old lady who swallowed a horse.", - "She's dead, of course!", - ] - @test recite(1, 8) == expected + @test recite(1, 8) == ["I know an old lady who swallowed a fly.", + "I don't know why she swallowed the fly. Perhaps she'll die.", "", + "I know an old lady who swallowed a spider.", + "It wriggled and jiggled and tickled inside her.", + "She swallowed the spider to catch the fly.", + "I don't know why she swallowed the fly. Perhaps she'll die.", "", + "I know an old lady who swallowed a bird.", "How absurd to swallow a bird!", + "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.", + "She swallowed the spider to catch the fly.", + "I don't know why she swallowed the fly. Perhaps she'll die.", "", + "I know an old lady who swallowed a cat.", "Imagine that, to swallow a cat!", + "She swallowed the cat to catch the bird.", + "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.", + "She swallowed the spider to catch the fly.", + "I don't know why she swallowed the fly. Perhaps she'll die.", "", + "I know an old lady who swallowed a dog.", "What a hog, to swallow a dog!", + "She swallowed the dog to catch the cat.", + "She swallowed the cat to catch the bird.", + "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.", + "She swallowed the spider to catch the fly.", + "I don't know why she swallowed the fly. Perhaps she'll die.", "", + "I know an old lady who swallowed a goat.", + "Just opened her throat and swallowed a goat!", + "She swallowed the goat to catch the dog.", + "She swallowed the dog to catch the cat.", + "She swallowed the cat to catch the bird.", + "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.", + "She swallowed the spider to catch the fly.", + "I don't know why she swallowed the fly. Perhaps she'll die.", "", + "I know an old lady who swallowed a cow.", + "I don't know how she swallowed a cow!", + "She swallowed the cow to catch the goat.", + "She swallowed the goat to catch the dog.", + "She swallowed the dog to catch the cat.", + "She swallowed the cat to catch the bird.", + "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.", + "She swallowed the spider to catch the fly.", + "I don't know why she swallowed the fly. Perhaps she'll die.", "", + "I know an old lady who swallowed a horse.", "She's dead, of course!"] end - -end \ No newline at end of file +end diff --git a/exercises/practice/kindergarten-garden/.meta/template.j2 b/exercises/practice/kindergarten-garden/.meta/template.j2 new file mode 100644 index 000000000..3d6c97937 --- /dev/null +++ b/exercises/practice/kindergarten-garden/.meta/template.j2 @@ -0,0 +1,21 @@ +{%- import "generator_macros.j2" as macros with context -%} +{{ macros.canonical_ref() }} + +{{ macros.header() }} +{%- macro test_case(case) %} +{%- if case["cases"] %} + @testset "{{ case["description"] }}" begin + {%- for subcase in case["cases"] %} + {{ test_case(subcase) }} + {% endfor %} + end +{%- else %} + @testset "{{ case["description"] }}" begin + @test plants({{ macros.julia_string(case["input"]["diagram"]) }}, "{{ case["input"]["student"] }}") == {{ macros.julia_vector(case["expected"]) }} + end +{%- endif %} +{%- endmacro %} +{% for case in cases %} + {{ test_case(case) }} +{% endfor %} +end diff --git a/exercises/practice/kindergarten-garden/runtests.jl b/exercises/practice/kindergarten-garden/runtests.jl index 876c55a71..1a33eca34 100644 --- a/exercises/practice/kindergarten-garden/runtests.jl +++ b/exercises/practice/kindergarten-garden/runtests.jl @@ -1,3 +1,7 @@ +# These tests are auto-generated with test data from: +# https://github.com/exercism/problem-specifications/tree/main/exercises/kindergarten-garden/canonical-data.json +# File last updated on 2026-10-24 + using Test include("kindergarten-garden.jl") @@ -7,84 +11,87 @@ include("kindergarten-garden.jl") @testset "garden with single student" begin @test plants("RC\nGG", "Alice") == ["radishes", "clover", "grass", "grass"] end - + @testset "different garden with single student" begin @test plants("VC\nRC", "Alice") == ["violets", "clover", "radishes", "clover"] end - + @testset "garden with two students" begin @test plants("VVCG\nVVRC", "Bob") == ["clover", "grass", "radishes", "clover"] end - - @testset "second student's garden" begin - @test plants("VVCCGG\nVVCCGG", "Bob") == ["clover", "clover", "clover", "clover"] - end - - @testset "third student's garden" begin - @test plants("VVCCGG\nVVCCGG", "Charlie") == ["grass", "grass", "grass", "grass"] + + @testset "multiple students for the same garden with three students" begin + @testset "second student's garden" begin + @test plants("VVCCGG\nVVCCGG", "Bob") == + ["clover", "clover", "clover", "clover"] + end + + @testset "third student's garden" begin + @test plants("VVCCGG\nVVCCGG", "Charlie") == + ["grass", "grass", "grass", "grass"] + end end end @testset "full garden" begin @testset "for Alice, first student's garden" begin - diagram = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" - @test plants(diagram, "Alice") == ["violets", "radishes", "violets", "radishes"] + @test plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Alice") == + ["violets", "radishes", "violets", "radishes"] end @testset "for Bob, second student's garden" begin - diagram = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" - @test plants(diagram, "Bob") == ["clover", "grass", "clover", "clover"] + @test plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Bob") == + ["clover", "grass", "clover", "clover"] end @testset "for Charlie" begin - diagram = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" - @test plants(diagram, "Charlie") == ["violets", "violets", "clover", "grass"] + @test plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Charlie") == + ["violets", "violets", "clover", "grass"] end @testset "for David" begin - diagram = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" - @test plants(diagram, "David") == ["radishes", "violets", "clover", "radishes"] + @test plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "David") == + ["radishes", "violets", "clover", "radishes"] end @testset "for Eve" begin - diagram = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" - @test plants(diagram, "Eve") == ["clover", "grass", "radishes", "grass"] + @test plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Eve") == + ["clover", "grass", "radishes", "grass"] end @testset "for Fred" begin - diagram = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" - @test plants(diagram, "Fred") == ["grass", "clover", "violets", "clover"] + @test plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Fred") == + ["grass", "clover", "violets", "clover"] end @testset "for Ginny" begin - diagram = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" - @test plants(diagram, "Ginny") == ["clover", "grass", "grass", "clover"] + @test plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Ginny") == + ["clover", "grass", "grass", "clover"] end @testset "for Harriet" begin - diagram = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" - @test plants(diagram, "Harriet") == ["violets", "radishes", "radishes", "violets"] + @test plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Harriet") == + ["violets", "radishes", "radishes", "violets"] end @testset "for Ileana" begin - diagram = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" - @test plants(diagram, "Ileana") == ["grass", "clover", "violets", "clover"] + @test plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Ileana") == + ["grass", "clover", "violets", "clover"] end @testset "for Joseph" begin - diagram = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" - @test plants(diagram, "Joseph") == ["violets", "clover", "violets", "grass"] + @test plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Joseph") == + ["violets", "clover", "violets", "grass"] end @testset "for Kincaid, second to last student's garden" begin - diagram = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" - @test plants(diagram, "Kincaid") == ["grass", "clover", "clover", "grass"] + @test plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Kincaid") == + ["grass", "clover", "clover", "grass"] end @testset "for Larry, last student's garden" begin - diagram = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" - @test plants(diagram, "Larry") == ["grass", "violets", "clover", "violets"] + @test plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Larry") == + ["grass", "violets", "clover", "violets"] end - end end diff --git a/exercises/practice/nucleotide-count/.meta/template.j2 b/exercises/practice/nucleotide-count/.meta/template.j2 new file mode 100644 index 000000000..7d99aaa7c --- /dev/null +++ b/exercises/practice/nucleotide-count/.meta/template.j2 @@ -0,0 +1,14 @@ +{%- import "generator_macros.j2" as macros with context -%} +{{ macros.canonical_ref() }} + +{{ macros.header() }} +{% for case in cases %} + @testset "{{ case["description"] }}" begin + {%- if case is error_case %} + @test_throws DomainError count_nucleotides("{{ case["input"]["strand"] }}") + {%- else %} + @test count_nucleotides("{{ case["input"]["strand"] }}") == {{ macros.julia_dict(case["expected"], char_keys=true) }} + {%- endif %} + end +{% endfor %} +end diff --git a/exercises/practice/nucleotide-count/runtests.jl b/exercises/practice/nucleotide-count/runtests.jl index c77a08bd8..73f389ce5 100644 --- a/exercises/practice/nucleotide-count/runtests.jl +++ b/exercises/practice/nucleotide-count/runtests.jl @@ -1,3 +1,7 @@ +# These tests are auto-generated with test data from: +# https://github.com/exercism/problem-specifications/tree/main/exercises/nucleotide-count/canonical-data.json +# File last updated on 2026-10-24 + using Test include("nucleotide-count.jl") @@ -7,7 +11,7 @@ include("nucleotide-count.jl") @test count_nucleotides("") == Dict('A' => 0, 'C' => 0, 'G' => 0, 'T' => 0) end - @testset "strand with one nucleotide in single-character input" begin + @testset "can count one nucleotide in single-character input" begin @test count_nucleotides("G") == Dict('A' => 0, 'C' => 0, 'G' => 1, 'T' => 0) end @@ -16,7 +20,8 @@ include("nucleotide-count.jl") end @testset "strand with multiple nucleotides" begin - @test count_nucleotides("AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC") == Dict('A' => 20, 'C' => 12, 'G' => 17, 'T' => 21) + @test count_nucleotides("AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC") == + Dict('A' => 20, 'C' => 12, 'G' => 17, 'T' => 21) end @testset "strand with invalid nucleotides" begin diff --git a/exercises/practice/proverb/.meta/template.j2 b/exercises/practice/proverb/.meta/template.j2 new file mode 100644 index 000000000..37f70dbef --- /dev/null +++ b/exercises/practice/proverb/.meta/template.j2 @@ -0,0 +1,10 @@ +{%- import "generator_macros.j2" as macros with context -%} +{{ macros.canonical_ref() }} + +{{ macros.header() }} +{% for case in cases %} + @testset "{{ case["description"] }}" begin + @test recite({{ macros.julia_vector(case["input"]["strings"]) }}) == {{ macros.julia_string(case["expected"] | join("\n")) }} + end +{% endfor %} +end diff --git a/exercises/practice/proverb/runtests.jl b/exercises/practice/proverb/runtests.jl index 703ef9a63..7e7b9eaa8 100644 --- a/exercises/practice/proverb/runtests.jl +++ b/exercises/practice/proverb/runtests.jl @@ -1,56 +1,37 @@ +# These tests are auto-generated with test data from: +# https://github.com/exercism/problem-specifications/tree/main/exercises/proverb/canonical-data.json +# File last updated on 2026-10-24 + using Test + include("proverb.jl") @testset verbose = true "tests" begin @testset "zero pieces" begin - pieces = [] - expected = "" - @test recite(pieces) == expected + @test recite([]) == "" end @testset "one piece" begin - pieces = ["nail"] - expected = "And all for the want of a nail." - @test recite(pieces) == expected + @test recite(["nail"]) == "And all for the want of a nail." end @testset "two pieces" begin - pieces = ["nail", "shoe"] - expected = """ - For want of a nail the shoe was lost. - And all for the want of a nail.""" - @test recite(pieces) == expected + @test recite(["nail", "shoe"]) == + "For want of a nail the shoe was lost.\nAnd all for the want of a nail." end @testset "three pieces" begin - pieces = ["nail", "shoe", "horse"] - expected = """ - For want of a nail the shoe was lost. - For want of a shoe the horse was lost. - And all for the want of a nail.""" - @test recite(pieces) == expected + @test recite(["nail", "shoe", "horse"]) == + "For want of a nail the shoe was lost.\nFor want of a shoe the horse was lost.\nAnd all for the want of a nail." end @testset "full proverb" begin - pieces = ["nail", "shoe", "horse", "rider", "message", "battle", "kingdom"] - expected = """ - For want of a nail the shoe was lost. - For want of a shoe the horse was lost. - For want of a horse the rider was lost. - For want of a rider the message was lost. - For want of a message the battle was lost. - For want of a battle the kingdom was lost. - And all for the want of a nail.""" - @test recite(pieces) == expected + @test recite(["nail", "shoe", "horse", "rider", "message", "battle", "kingdom"]) == + "For want of a nail the shoe was lost.\nFor want of a shoe the horse was lost.\nFor want of a horse the rider was lost.\nFor want of a rider the message was lost.\nFor want of a message the battle was lost.\nFor want of a battle the kingdom was lost.\nAnd all for the want of a nail." end @testset "four pieces modernized" begin - pieces = ["pin", "gun", "soldier", "battle"] - expected = """ - For want of a pin the gun was lost. - For want of a gun the soldier was lost. - For want of a soldier the battle was lost. - And all for the want of a pin.""" - @test recite(pieces) == expected + @test recite(["pin", "gun", "soldier", "battle"]) == + "For want of a pin the gun was lost.\nFor want of a gun the soldier was lost.\nFor want of a soldier the battle was lost.\nAnd all for the want of a pin." end end diff --git a/exercises/practice/resistor-color-trio/.meta/template.j2 b/exercises/practice/resistor-color-trio/.meta/template.j2 new file mode 100644 index 000000000..27ec89376 --- /dev/null +++ b/exercises/practice/resistor-color-trio/.meta/template.j2 @@ -0,0 +1,10 @@ +{%- import "generator_macros.j2" as macros with context -%} +{{ macros.canonical_ref() }} + +{{ macros.header() }} +{% for case in cases %} + @testset "{{ case["description"] }}" begin + @test label({{ macros.julia_vector(case["input"]["colors"]) }}) == "{{ case["expected"]["value"] }} {{ case["expected"]["unit"] }}" + end +{% endfor %} +end diff --git a/exercises/practice/resistor-color-trio/runtests.jl b/exercises/practice/resistor-color-trio/runtests.jl index 79d9607b4..04aa2f96b 100644 --- a/exercises/practice/resistor-color-trio/runtests.jl +++ b/exercises/practice/resistor-color-trio/runtests.jl @@ -1,3 +1,7 @@ +# These tests are auto-generated with test data from: +# https://github.com/exercism/problem-specifications/tree/main/exercises/resistor-color-trio/canonical-data.json +# File last updated on 2026-10-24 + using Test include("resistor-color-trio.jl") @@ -23,26 +27,6 @@ include("resistor-color-trio.jl") @test label(["yellow", "violet", "yellow"]) == "470 kiloohms" end - @testset "Orange and orange and red" begin - @test label(["orange", "orange", "red"]) == "3.3 kiloohms" - end - - @testset "Orange and orange and green" begin - @test label(["orange", "orange", "green"]) == "3.3 megaohms" - end - - @testset "White and white and violet" begin - @test label(["white", "white", "violet"]) == "990 megaohms" - end - - @testset "White and white and grey" begin - @test label(["white", "white", "grey"]) == "9.9 gigaohms" - end - - @testset "White and black and white" begin - @test label(["white", "black", "white"]) == "90 gigaohms" - end - @testset "Blue and violet and blue" begin @test label(["blue", "violet", "blue"]) == "67 megaohms" end diff --git a/exercises/practice/word-count/.meta/template.j2 b/exercises/practice/word-count/.meta/template.j2 new file mode 100644 index 000000000..64d8ca66a --- /dev/null +++ b/exercises/practice/word-count/.meta/template.j2 @@ -0,0 +1,10 @@ +{%- import "generator_macros.j2" as macros with context -%} +{{ macros.canonical_ref() }} + +{{ macros.header() }} +{% for case in cases %} + @testset "{{ case["description"] }}" begin + @test wordcount({{ macros.julia_string(case["input"]["sentence"]) }}) == {{ macros.julia_dict(case["expected"]) }} + end +{% endfor %} +end diff --git a/exercises/practice/word-count/runtests.jl b/exercises/practice/word-count/runtests.jl index 7347d21b1..061e67a40 100644 --- a/exercises/practice/word-count/runtests.jl +++ b/exercises/practice/word-count/runtests.jl @@ -1,12 +1,12 @@ +# These tests are auto-generated with test data from: +# https://github.com/exercism/problem-specifications/tree/main/exercises/word-count/canonical-data.json +# File last updated on 2026-10-24 + using Test include("word-count.jl") @testset verbose = true "tests" begin - @testset "no words" begin - @test wordcount(" .\n,\t!^&*()~@#\$%{}[]:;'/<>") == Dict() - end - @testset "count one word" begin @test wordcount("word") == Dict("word" => 1) end @@ -16,7 +16,8 @@ include("word-count.jl") 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 @@ -28,7 +29,8 @@ include("word-count.jl") 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 @@ -40,24 +42,30 @@ include("word-count.jl") 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("Should've could've would've") == Dict("should've" => 1, "could've" => 1, "would've" => 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 @testset "substrings from the beginning" begin - @test wordcount("Joe can't tell between app, apple and a.") == Dict("joe" => 1, "can't" => 1, "tell" => 1, "between" => 1, "app" => 1, "apple" => 1, "and" => 1, "a" => 1) + @test wordcount("Joe can't tell between app, apple and a.") == + Dict("joe" => 1, "can't" => 1, "tell" => 1, "between" => 1, "app" => 1, + "apple" => 1, "and" => 1, "a" => 1) end @testset "multiple spaces not detected as a word" begin - @test wordcount(" multiple whitespaces") == Dict("multiple" => 1, "whitespaces" => 1) + @test wordcount(" multiple whitespaces") == + Dict("multiple" => 1, "whitespaces" => 1) end @testset "alternating word separators not detected as a word" begin - @test wordcount(",\n,one,\n ,two \n 'three'") == Dict("one" => 1, "two" => 1, "three" => 1) + @test wordcount(",\n,one,\n ,two \n 'three'") == + Dict("one" => 1, "two" => 1, "three" => 1) end @testset "quotation for word with apostrophe" begin diff --git a/exercises/practice/yacht/.meta/template.j2 b/exercises/practice/yacht/.meta/template.j2 new file mode 100644 index 000000000..336bd823d --- /dev/null +++ b/exercises/practice/yacht/.meta/template.j2 @@ -0,0 +1,10 @@ +{%- import "generator_macros.j2" as macros with context -%} +{{ macros.canonical_ref() }} + +{{ macros.header() }} +{% for case in cases %} + @testset "{{ case["description"] }}" begin + @test score({{ macros.julia_vector(case["input"]["dice"]) }}, "{{ case["input"]["category"] }}") == {{ case["expected"] }} + end +{% endfor %} +end diff --git a/exercises/practice/yacht/runtests.jl b/exercises/practice/yacht/runtests.jl index 540a98fa9..3ec42e086 100644 --- a/exercises/practice/yacht/runtests.jl +++ b/exercises/practice/yacht/runtests.jl @@ -1,3 +1,7 @@ +# These tests are auto-generated with test data from: +# https://github.com/exercism/problem-specifications/tree/main/exercises/yacht/canonical-data.json +# File last updated on 2026-10-24 + using Test include("yacht.jl") @@ -119,4 +123,3 @@ include("yacht.jl") @test score([2, 2, 2, 2, 2], "choice") == 10 end end -