From 5a2f656645f0542613cab003e7645a52c9eece25 Mon Sep 17 00:00:00 2001 From: Isaac Good Date: Fri, 25 Sep 2026 21:56:11 -0700 Subject: [PATCH] [leap] Switch to generated tests --- exercises/practice/leap/.meta/template.j2 | 8 ++++ exercises/practice/leap/leap_test.gd | 54 +++++++++++++++-------- 2 files changed, 44 insertions(+), 18 deletions(-) create mode 100644 exercises/practice/leap/.meta/template.j2 diff --git a/exercises/practice/leap/.meta/template.j2 b/exercises/practice/leap/.meta/template.j2 new file mode 100644 index 0000000..fd65c9f --- /dev/null +++ b/exercises/practice/leap/.meta/template.j2 @@ -0,0 +1,8 @@ +{% for case in cases %} +func test_{{ case["func_name"] }}(solution_script): + var got = solution_script.leap({{ case["input"]["year"] }}) + var want = {{ case["expected"] }} + return [got, want] + +{% endfor %} + diff --git a/exercises/practice/leap/leap_test.gd b/exercises/practice/leap/leap_test.gd index 666f8eb..5bbdad7 100644 --- a/exercises/practice/leap/leap_test.gd +++ b/exercises/practice/leap/leap_test.gd @@ -1,34 +1,52 @@ -func test_year_not_divisible_by_4(solution_script): - return [solution_script.leap(2015), false] +func test_year_not_divisible_by_4_in_common_year(solution_script): + var got = solution_script.leap(2015) + var want = false + return [got, want] -func test_year_divisible_by_2_not_4(solution_script): - return [solution_script.leap(1970), false] +func test_year_divisible_by_2_not_divisible_by_4_in_common_year(solution_script): + var got = solution_script.leap(1970) + var want = false + return [got, want] -func test_year_divisible_by_4_not_100(solution_script): - return [solution_script.leap(1996), true] +func test_year_divisible_by_4_not_divisible_by_100_in_leap_year(solution_script): + var got = solution_script.leap(1996) + var want = true + return [got, want] -func test_year_divisible_by_4_and_5(solution_script): - return [solution_script.leap(1960), true] +func test_year_divisible_by_4_and_5_is_still_a_leap_year(solution_script): + var got = solution_script.leap(1960) + var want = true + return [got, want] -func test_year_divisible_by_100_not_400(solution_script): - return [solution_script.leap(2100), false] +func test_year_divisible_by_100_not_divisible_by_400_in_common_year(solution_script): + var got = solution_script.leap(2100) + var want = false + return [got, want] -func test_year_divisible_by_100_not_3(solution_script): - return [solution_script.leap(1900), false] +func test_year_divisible_by_100_but_not_by_3_is_still_not_a_leap_year(solution_script): + var got = solution_script.leap(1900) + var want = false + return [got, want] -func test_year_divisible_by_400(solution_script): - return [solution_script.leap(2000), true] +func test_year_divisible_by_400_is_leap_year(solution_script): + var got = solution_script.leap(2000) + var want = true + return [got, want] -func test_year_divisible_by_400_not_125(solution_script): - return [solution_script.leap(2400), true] +func test_year_divisible_by_400_but_not_by_125_is_still_a_leap_year(solution_script): + var got = solution_script.leap(2400) + var want = true + return [got, want] -func test_year_divisible_by_200_not_400(solution_script): - return [ solution_script.leap(1800), false] +func test_year_divisible_by_200_not_divisible_by_400_in_common_year(solution_script): + var got = solution_script.leap(1800) + var want = false + return [got, want]