From 0111b0451c29185e23c2d3ecc80efa77e3049a67 Mon Sep 17 00:00:00 2001 From: Cohen Carlisle Date: Thu, 1 Mar 2018 19:13:45 -0500 Subject: [PATCH] more number koans --- lib/koans/03_numbers.ex | 32 +++++++++++++++++++++++++++++++ test/koans/numbers_koans_test.exs | 8 ++++++++ 2 files changed, 40 insertions(+) diff --git a/lib/koans/03_numbers.ex b/lib/koans/03_numbers.ex index 4b70f99..712c05c 100644 --- a/lib/koans/03_numbers.ex +++ b/lib/koans/03_numbers.ex @@ -4,6 +4,38 @@ defmodule Numbers do @intro "Why is the number six so scared? Because seven eight nine!\nWe should get to know numbers a bit more!" + koan "Is an integer equal to its float equivalent?" do + assert 1 == 1.0 == ___ + end + + koan "Is an integer threequal to its float equivalent?" do + assert 1 === 1.0 == ___ + end + + koan "Revisit divison with threequal" do + assert 2 / 2 === ___ + end + + koan "Another way to divide" do + assert div(5, 2) == ___ + end + + koan "Other math operators may produce this" do + assert 2 * 2 === ___ + end + + koan "Or other math operators may produce this" do + assert 2 * 2.0 === ___ + end + + koan "Two ways to round, are they exactly the same?" do + assert Float.round(1.2) === round(1.2) == ___ + end + + koan "Release the decimals into the void" do + assert trunc(5.6) === ___ + end + koan "Are you odd?" do assert Integer.is_odd(3) == ___ end diff --git a/test/koans/numbers_koans_test.exs b/test/koans/numbers_koans_test.exs index 0c3847c..4cb54c5 100644 --- a/test/koans/numbers_koans_test.exs +++ b/test/koans/numbers_koans_test.exs @@ -4,6 +4,14 @@ defmodule NumbersTests do test "Numbers" do answers = [ + true, + false, + 1.0, + 2, + 4, + 4.0, + false, + 5, true, true, [5, 8, 1, 2, 7],