Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions exercises/practice/leap/.meta/template.j2
Original file line number Diff line number Diff line change
@@ -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 %}

54 changes: 36 additions & 18 deletions exercises/practice/leap/leap_test.gd
Original file line number Diff line number Diff line change
@@ -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]
Loading