• Stars
    star
    445
  • Rank 95,053 (Top 2 %)
  • Language
    CoffeeScript
  • License
    Other
  • Created almost 13 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Koans: learn CoffeeScript by doing it

CoffeeScript Koans

The goal of the CoffeeScript koans is to teach you CoffeeScript programming through actually doing it, in a test-first fashion.

When you first run the Koans, you'll be presented with a run-time error and a stack trace indicating where the error occurred. Your goal is to make the error go away. As you fix each error, you should learn something about the CoffeeScript language and functional programming in general.

Your journey towards CoffeeScript enlightenment starts in the Koans folder with the AboutExpects.coffee file.

These Koans will be very simple, so don't over-think them! As you progress through more Koans, more and more CoffeeScript syntax will be introduced which will allow you to solve more complicated problems and use more advanced techniques.

Getting Started

This project requires Node.js - if you haven't already installed it I would recommend installing the Node Version Manager - NVM - and using that to install Node.

Install dependencies by using npm from the command line:

npm install

Running the Koans

Start with copying the file koans/AboutShould.coffee to the completed-koans/ folder.

Run the tests with Mocha on the command line:

npm test

You should see the following output:

About Should
    1) should expect true
    - should have filled in values
    - should understand type coercion is fixed
    - should expect equality
    - should assert equality a better way

0 passing (7ms) <- this is how long the tests took to run
4 pending
1 failing

You'll see that one of the tests is failing, and that the other 4 have been temporarily disabled (marked as 'pending').

Edit the AboutShould.coffee file (your copy in the completed-koans/ folder) with the editor or IDE of your choice and follow the directions to fix the problem in the first test.

When you think you've fixed the problem, run the tests again.

npm test

When that test passes, enable the next pending test. Rinse and repeat until all tests turn green, simples :-)

When you're done with AboutShould.coffee, copy another file from the koans/ folder to the completed-koans/ folder and start work on that.

I would suggest trying them in the following order, but it is not prescriptive:

  1. AboutShould.coffee
  2. AboutFunctions.coffee
  3. AboutArrays.coffee
  4. AboutMutability.coffee
  5. AboutObjects.coffee
  6. AboutInheritance.coffee
  7. AboutHigherOrderFunctions.coffee
  8. AboutApplyingWhatWeHaveLearnt.coffee

If you want to just test a single test file, you can do it like this: (remember to add in the name of your file)

mocha --compilers coffee:coffee-script/register -R spec completed-koans/FILE-NAME-GOES-HERE.coffee

If you want mocha to watch your files for changes and rerun the tests automagically when you save changes to a test file, simply use:

npm run watch

Have fun, and I hope you enjoy playing with CoffeeScript!

Endorse this project

To say 'thanks' please endorse this project on Coderwall by clicking the button below:

endorse

Or, if you happen to be in London, please drop by for a chat and buy me a beer!

Inspirations & thanks

  • David Laing & Greg Malcolm - for their JavaScript/Jasmine port of the Ruby koans
  • Edgecase - for the great Ruby Koans
  • Jeremy Ashkenas and the CoffeeScript crew on GitHub - for making CoffeeScript in the first place
  • Douglas Crockford - for JavaScript; the good bits
  • Daniel P. Friedman & Matthias Felleisen - for 'The Little LISPer' book, where it all started

License (legal deed)

The text below is a human-readable summary of (and not a substitute for) the license, contained in the LICENSE file.


CC BY-NC-SA 4.0

Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)

You are free to:

  • Share β€” copy and redistribute the material in any medium or format
  • Adapt β€” remix, transform, and build upon the material

The licensor cannot revoke these freedoms as long as you follow the license terms.

Under the following terms:

  • Attribution β€” You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • NonCommercial β€” You may not use the material for commercial purposes.
  • ShareAlike β€” If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
  • No additional restrictions β€” You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.

Notices:

You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation. No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.

More Repositories

1

code-dojo-39

Code for the 39th London Code Dojo meetup in Oct 2016, Song refactoring kata
Java
11
star
2

janet-lang-docker

A docker runtime image for janet-lang development.
Dockerfile
5
star
3

pugilism

Because pair-boxes, in bash.
HCL
4
star
4

Code-Dojo-15

Code for the 15th London Code Dojo meetup in Dec 2012, Gilded Rose kata
Python
3
star
5

world-of-workcraft

An MMORPG-flavoured exploration of management and leadership
2
star
6

Martian-Robots

A code kata revolving around automata processing Turning machine style instructions in a bounded universe
CoffeeScript
2
star
7

Code-Dojo-8

Code for the 8th London Code Dojo meetup in June 2012
CoffeeScript
1
star
8

event-driven

Kata for exploring event-driven asynchronicity
1
star
9

go-with-the-flow

Some simple koan-like exercises to help you come up to speed with Flow
JavaScript
1
star
10

code-dojo-41

Code for the 41st London Code Dojo meetup in Jan 2017, Hunt the Wumpus kata.
NewLisp
1
star
11

7L7W-Erlang

London Code dojo worked examples for their 7 Languages in 7 Weeks sessions for the Erlang language
Erlang
1
star
12

Code-Dojo-3

Code for the 3rd meeting of the London Code Dojo using the Data Munge kata
Clojure
1
star
13

Code-Dojo-27

Code for the 27th London Code Dojo meetup in early October 2013 using the Pub kata
CoffeeScript
1
star
14

Code-Dojo-5

Code for the fifth London Code Dojo meetup using the Elephant carpaccio kata
CoffeeScript
1
star
15

minimalisp

A minimal LISP/Scheme implementation for pedagogical purposes.
JavaScript
1
star
16

Code-Dojo-45

Code for the 45th London Code Dojo meetup in Jul 2019, using the Calculator kata
JavaScript
1
star
17

Code-Dojo-9

Code for the 9th London Code Dojo meetup in July 2012 using the OCP kata
CoffeeScript
1
star
18

Code-Dojo-7

Code for the 7th London Code Dojo meetup in May 2012 using the Roman Numeral kata
CoffeeScript
1
star
19

hy-dev

Docker development image for HyLang
Makefile
1
star
20

mp3-name-homogeniser

Simple node.js script to make names of mp3 files in a directory consistent
JavaScript
1
star
21

elm-develop

A Docker-based development environment for working with Elm-lang
Elm
1
star
22

Code-Dojo-4

Solution from the fourth London Code Dojo using the LOC - Lines Of Code kata
CoffeeScript
1
star