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
6 changes: 3 additions & 3 deletions exercises/accumulate/accumulate.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ describe '[].accumulate()', ->
accumulator = (word) -> word.split('').reverse().join('')
result = 'the quick brown fox etc'.split(/\s/).accumulate accumulator

expect(result).toEqual ["eht", "kciuq", "nworb", "xof", "cte"]
expect(result).toEqual ['eht', 'kciuq', 'nworb', 'xof', 'cte']

xit 'accumulate recursively', ->
result = 'a b c'.split(/\s+/).accumulate (char) ->
'1 2 3'.split(/\s+/).accumulate (digit) -> "#{char}#{digit}"
'1 2 3'.split(/\s+/).accumulate (digit) -> '#{char}#{digit}'

expect(result).toEqual([["a1", "a2", "a3"], ["b1", "b2", "b3"], ["c1", "c2", "c3"]])
expect(result).toEqual([['a1', 'a2', 'a3'], ['b1', 'b2', 'b3'], ['c1', 'c2', 'c3']])
84 changes: 42 additions & 42 deletions exercises/anagram/anagram.spec.coffee
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
Anagram = require "./anagram"
describe "Anagram", ->
it "no matches", ->
detector = new Anagram "diaper"
matches = detector.match ["hello", "world", "zombies", "pants"]
Anagram = require './anagram'
describe 'Anagram', ->
it 'no matches', ->
detector = new Anagram 'diaper'
matches = detector.match ['hello', 'world', 'zombies', 'pants']
expect(matches).toEqual []

xit "detects simple anagram", ->
detector = new Anagram "ant"
matches = detector.match ["tan", "stand", "at"]
expect(matches).toEqual ["tan"]
xit 'detects simple anagram', ->
detector = new Anagram 'ant'
matches = detector.match ['tan', 'stand', 'at']
expect(matches).toEqual ['tan']

xit "does not detect false positives", ->
detector = new Anagram "galea"
matches = detector.match ["eagle"]
xit 'does not detect false positives', ->
detector = new Anagram 'galea'
matches = detector.match ['eagle']
expect(matches).toEqual []

xit "detects multiple anagrams", ->
detector = new Anagram "master"
matches = detector.match ["stream", "pigeon", "maters"]
expect(matches).toEqual ["stream", "maters"]
xit 'detects multiple anagrams', ->
detector = new Anagram 'master'
matches = detector.match ['stream', 'pigeon', 'maters']
expect(matches).toEqual ['stream', 'maters']

xit "does not detect anagram subsets", ->
detector = new Anagram "good"
matches = detector.match ["dog", "goody"]
xit 'does not detect anagram subsets', ->
detector = new Anagram 'good'
matches = detector.match ['dog', 'goody']
expect(matches).toEqual []

xit "detects anagram", ->
detector = new Anagram "listen"
matches = detector.match ["enlists", "google", "inlets", "banana"]
expect(matches).toEqual ["inlets"]
xit 'detects anagram', ->
detector = new Anagram 'listen'
matches = detector.match ['enlists', 'google', 'inlets', 'banana']
expect(matches).toEqual ['inlets']

xit "detects multiple anagrams", ->
detector = new Anagram "allergy"
matches = detector.match ["gallery", "ballerina", "regally", "clergy", "largely", "leading"]
expect(matches).toEqual ["gallery", "regally", "largely"]
xit 'detects multiple anagrams', ->
detector = new Anagram 'allergy'
matches = detector.match ['gallery', 'ballerina', 'regally', 'clergy', 'largely', 'leading']
expect(matches).toEqual ['gallery', 'regally', 'largely']

xit "does not detect identical words", ->
detector = new Anagram "corn"
matches = detector.match ["corn", "dark", "Corn", "rank", "CORN", "cron", "park"]
expect(matches).toEqual ["cron"]
xit 'does not detect identical words', ->
detector = new Anagram 'corn'
matches = detector.match ['corn', 'dark', 'Corn', 'rank', 'CORN', 'cron', 'park']
expect(matches).toEqual ['cron']

xit "does not detect non-anagrams with identical checksum", ->
detector = new Anagram "mass"
matches = detector.match ["last"]
xit 'does not detect non-anagrams with identical checksum', ->
detector = new Anagram 'mass'
matches = detector.match ['last']
expect(matches).toEqual []

xit "detects anagrams using case-insensitive subject", ->
detector = new Anagram "Orchestra"
matches = detector.match ["cashregister", "carthorse", "radishes"]
expect(matches).toEqual ["carthorse"]
xit 'detects anagrams using case-insensitive subject', ->
detector = new Anagram 'Orchestra'
matches = detector.match ['cashregister', 'carthorse', 'radishes']
expect(matches).toEqual ['carthorse']

xit "detects anagrams using case-insensitive candidates", ->
detector = new Anagram "orchestra"
matches = detector.match ["cashregister", "Carthorse", "radishes"]
expect(matches).toEqual ["carthorse"]
xit 'detects anagrams using case-insensitive candidates', ->
detector = new Anagram 'orchestra'
matches = detector.match ['cashregister', 'Carthorse', 'radishes']
expect(matches).toEqual ['carthorse']
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Atbash = require './atbash'
Atbash = require './atbash-cipher'

describe 'Atbash', ->
it 'encodes no', ->
Expand Down
36 changes: 17 additions & 19 deletions exercises/beer-song/beer-song.spec.coffee
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
Beer = require("./beer")
describe "Beer", ->
it "prints an arbitrary verse", ->
expect(Beer.verse 8).toEqual """
Beer = require './beer-song'
describe 'Beer', ->
it 'prints an arbitrary verse', ->
expect(Beer.verse 8).toEqual '
8 bottles of beer on the wall, 8 bottles of beer.
Take one down and pass it around, 7 bottles of beer on the wall.
"""
'

xit "handles 1 bottle", ->
expect(Beer.verse 1).toEqual """
xit 'handles 1 bottle', ->
expect(Beer.verse 1).toEqual '
1 bottle of beer on the wall, 1 bottle of beer.
Take it down and pass it around, no more bottles of beer on the wall.
"""
'

xit "handles 0 bottles", ->
expect(Beer.verse 0).toEqual """
xit 'handles 0 bottles', ->
expect(Beer.verse 0).toEqual '
No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.
"""
'

xit "sings several verses", ->
expect(Beer.sing 8, 6).toEqual """
xit 'sings several verses', ->
expect(Beer.sing 8, 6).toEqual '
8 bottles of beer on the wall, 8 bottles of beer.
Take one down and pass it around, 7 bottles of beer on the wall.

Expand All @@ -29,10 +29,10 @@ describe "Beer", ->
6 bottles of beer on the wall, 6 bottles of beer.
Take one down and pass it around, 5 bottles of beer on the wall.

"""
'

xit "sings the rest of the verses", ->
expect(Beer.sing 3).toEqual """
xit 'sings the rest of the verses', ->
expect(Beer.sing 3).toEqual '
3 bottles of beer on the wall, 3 bottles of beer.
Take one down and pass it around, 2 bottles of beer on the wall.

Expand All @@ -45,6 +45,4 @@ describe "Beer", ->
No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.

"""


'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Bst = require './bst'
Bst = require './binary-search-tree'

recordAllData = (bst) ->
out = []
Expand Down
88 changes: 44 additions & 44 deletions exercises/bob/bob.spec.coffee
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
Bob = require "./bob"
describe "Bob", ->
Bob = require './bob'
describe 'Bob', ->
bob = new Bob()
it "stating something", ->
result = bob.hey "Tom-ay-to, tom-aaaah-to."
expect(result).toEqual "Whatever."
it 'stating something', ->
result = bob.hey 'Tom-ay-to, tom-aaaah-to.'
expect(result).toEqual 'Whatever.'

xit "shouting", ->
result = bob.hey "WATCH OUT!"
expect(result).toEqual "Whoa, chill out!"
xit 'shouting', ->
result = bob.hey 'WATCH OUT!'
expect(result).toEqual 'Whoa, chill out!'

xit "asking a question", ->
result = bob.hey "Does this cryogenic chamber make me look fat?"
expect(result).toEqual "Sure."
xit 'asking a question', ->
result = bob.hey 'Does this cryogenic chamber make me look fat?'
expect(result).toEqual 'Sure.'

xit "talking forcefully", ->
result = bob.hey "Let's go make out behind the gym!"
expect(result).toEqual "Whatever."
xit 'talking forcefully', ->
result = bob.hey 'Let's go make out behind the gym!'
expect(result).toEqual 'Whatever.'

xit "using acronyms in regular speech", ->
result = bob.hey "It's OK if you don't want to go to the DMV."
expect(result).toEqual "Whatever."
xit 'using acronyms in regular speech', ->
result = bob.hey 'It's OK if you don't want to go to the DMV.'
expect(result).toEqual 'Whatever.'

xit "forceful questions", ->
result = bob.hey "WHAT THE HELL WERE YOU THINKING?"
expect(result).toEqual "Whoa, chill out!"
xit 'forceful questions', ->
result = bob.hey 'WHAT THE HELL WERE YOU THINKING?'
expect(result).toEqual 'Whoa, chill out!'

xit "shouting numbers", ->
result = bob.hey "1, 2, 3 GO!"
expect(result).toEqual "Whoa, chill out!"
xit 'shouting numbers', ->
result = bob.hey '1, 2, 3 GO!'
expect(result).toEqual 'Whoa, chill out!'

xit "only number", ->
result = bob.hey "1, 2, 3"
expect(result).toEqual "Whatever."
xit 'only number', ->
result = bob.hey '1, 2, 3'
expect(result).toEqual 'Whatever.'

xit "shouting with special characters", ->
result = bob.hey "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!"
expect(result).toEqual "Whoa, chill out!"
xit 'shouting with special characters', ->
result = bob.hey 'ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!'
expect(result).toEqual 'Whoa, chill out!'

xit "shouting with no exclamation mark", ->
result = bob.hey "I HATE YOU"
expect(result).toEqual "Whoa, chill out!"
xit 'shouting with no exclamation mark', ->
result = bob.hey 'I HATE YOU'
expect(result).toEqual 'Whoa, chill out!'

xit "statement containing question mark", ->
result = bob.hey "Ending with a ? means a question."
expect(result).toEqual "Whatever."
xit 'statement containing question mark', ->
result = bob.hey 'Ending with a ? means a question.'
expect(result).toEqual 'Whatever.'

xit "prattling on", ->
result = bob.hey "Wait! Hang on. Are you going to be OK?"
expect(result).toEqual "Sure."
xit 'prattling on', ->
result = bob.hey 'Wait! Hang on. Are you going to be OK?'
expect(result).toEqual 'Sure.'

xit "silence", ->
result = bob.hey ""
expect(result).toEqual "Fine. Be that way!"
xit 'silence', ->
result = bob.hey ''
expect(result).toEqual 'Fine. Be that way!'

xit "prolonged silence", ->
result = bob.hey " "
expect(result).toEqual "Fine. Be that way!"
xit 'prolonged silence', ->
result = bob.hey ' '
expect(result).toEqual 'Fine. Be that way!'
45 changes: 22 additions & 23 deletions exercises/clock/clock.spec.coffee
Original file line number Diff line number Diff line change
@@ -1,47 +1,46 @@
Clock = require './clock'

describe "Clock", ->
it "prints the hour", ->
expect(Clock.at(8).toString()).toEqual "08:00"
expect(Clock.at(9).toString()).toEqual "09:00"
describe 'Clock', ->
it 'prints the hour', ->
expect(Clock.at(8).toString()).toEqual '08:00'
expect(Clock.at(9).toString()).toEqual '09:00'

xit "prints past the hour", ->
expect(Clock.at(11, 9).toString()).toEqual "11:09"
expect(Clock.at(11, 19).toString()).toEqual "11:19"
xit 'prints past the hour', ->
expect(Clock.at(11, 9).toString()).toEqual '11:09'
expect(Clock.at(11, 19).toString()).toEqual '11:19'

xit "can add minutes", ->
xit 'can add minutes', ->
clock = Clock.at(10).plus 3
expect(clock.toString()).toEqual "10:03"
expect(clock.toString()).toEqual '10:03'

xit "can add over an hour", ->
xit 'can add over an hour', ->
clock = Clock.at(10).plus 61
expect(clock.toString()).toEqual "11:01"
expect(clock.toString()).toEqual '11:01'

xit "wraps around midnight", ->
xit 'wraps around midnight', ->
clock = Clock.at(23, 59).plus 2
expect(clock.toString()).toEqual "00:01"
expect(clock.toString()).toEqual '00:01'

xit "can subtract minutes", ->
xit 'can subtract minutes', ->
clock = Clock.at(10, 3).minus 3
expect(clock.toString()).toEqual "10:00"
expect(clock.toString()).toEqual '10:00'

xit "can subtract over an hour", ->
xit 'can subtract over an hour', ->
clock = Clock.at(10, 3).minus 30
expect(clock.toString()).toEqual "09:33"
expect(clock.toString()).toEqual '09:33'
clock = Clock.at(10, 3).minus 70
expect(clock.toString()).toEqual "08:53"
expect(clock.toString()).toEqual '08:53'

xit "can know if it's equal to another clock", ->
xit 'can know if it's equal to another clock', ->
clock1 = Clock.at(10, 3)
clock2 = Clock.at(10, 3)
expect(clock1.equals clock2).toBe true

xit "can know if it's not equal to another clock", ->
xit 'can know if it's not equal to another clock', ->
clock1 = Clock.at(10, 3)
clock2 = Clock.at(10, 4)
expect(clock1.equals clock2).toBe false

xit "wraps around midnight backwards", ->
xit 'wraps around midnight backwards', ->
clock = Clock.at(0, 3).minus 4
expect(clock.toString()).toEqual "23:59"

expect(clock.toString()).toEqual '23:59'
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
HelloWorld = require "./hello_world"
HelloWorld = require './hello-world'

describe 'HelloWorld', ->
hello_world = new HelloWorld()

it "says 'Hello, World!'", ->
it 'says \'Hello, World!\'', ->
result = hello_world.hello()
expect(result).toEqual 'Hello, World!'
Loading