123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- import unittest
- import tables
- import basics / loops_exercises
- proc testLoops* =
- suite "Loops":
- test "Collatz Conjecture":
- check collatzConjecture(5) == @[5, 16, 8, 4, 2, 1]
- test "Vowels from name":
- check vowelsFromName("alexander") == @['a', 'e', 'a', 'e']
- test "Fizz buzz 30":
- check fizzBuzz(30) == @[
- "1",
- "2",
- "fizz",
- "4",
- "buzz",
- "fizz",
- "7",
- "8",
- "fizz",
- "buzz",
- "11",
- "fizz",
- "13",
- "14",
- "fizzbuzz",
- "16",
- "17",
- "fizz",
- "19",
- "buzz",
- "fizz",
- "22",
- "23",
- "fizz",
- "buzz",
- "26",
- "fizz",
- "28",
- "29",
- "fizzbuzz"]
- test "Inches to cents":
- check inchesToCentsTable(1, 19, 3) == {
- 1: 2.54,
- 4: 10.16,
- 7: 17.78,
- 10: 25.4,
- 13: 33.02,
- 16: 40.64,
- 19: 48.26
- }.toOrderedTable
|