This post was originally published on this site

Note: *** This Site is Under Heavy Construction ***

This site is starting out as a copy of the fantastic CoffeeScript web site. Currently the only part of interest is the TestML Playground nav link above.







TestML is data driven software testing language that works with all popular programming languages and their favorite test frameworks. You write up your inputs and expected outputs and a simple assertion statement of how to get from one to the other. TestML takes care of the rest, giving you lots of testing functionality for the minimum input.


git clone https://github.com/testml-lang/testml
source testml/.rc


npm install --global testml-compiler

Overview

TestML on the topleft, TestML Bridge Class (CoffScript) in the middle, test output on the bottomright. The TestML and Bridge are editable!

Installation

The command-line version of testml is…

Usage

Command Line

Once installed, you should have access to the testml command, which can run test, and compile .tml files. The testml --help output is:

usage:   testml <options...> [<testml-file>...]

    See 'man testml' for more help.

    Common commands:

      testml foo.tml
      testml --lang=python foo.tml
      testml --compile foo.tml
      testml --compile --print foo.tml
      testml --list
      testml --env
      testml --clean

    Options:

    -c, --compile         Compile a TestML file to the cache directory
    -e, --eval ...        Specify TestML input on command line
    -i, --input ...       Main input file (prepended to each file arg)
    -a, --all             Combine all input files into one text
    -p, --print           Print compiled TestML to stdout
    -l, --list            List all the TestML langauge/framework runners
    --env                 Show the TestML environment details
    --clean               Remove generated TestML files
    --version             Print TestML version
    -h, --help            Show the command summary

    -R, --run ...         TestML runner to use (see: testml --list)
    -B, --bridge ...      TestML bridge module to use
    -I, --lib ...         Directory path to find bridge modules
    -P, --path ...        Directory path to find test files and imports
    -M, --module ...      TestML runner module to use
    -C, --config ...      TestML config file

    -x, --debug           Print lots of debugging info

Examples:

  • testml -R python test/*.tml
  • testml -cp test/*.tml

Language Reference

This reference is structured so that it can be read from top to bottom, if you like. Later sections use ideas and syntax previously introduced. Familiarity with JavaScript is assumed. In all of the following examples, the source CoffeeScript is provided on the left, and the direct compilation into JavaScript is on the right.

Many of the examples can be run (where it makes sense) by pressing the button on the right. The CoffeeScript on the left is editable, and the JavaScript will update as you edit.

First, the basics: CoffeeScript uses significant whitespace to delimit blocks of code. You don’t need to use semicolons ; to terminate expressions, ending the line will do just as well (although semicolons can still be used to fit multiple expressions onto a single line). Instead of using curly braces { } to surround blocks of code in functions, if-statements, switch, and try/catch, use indentation.

You don’t need to use parentheses to invoke a function if you’re passing arguments. The implicit call wraps forward to the end of the line or block expression.
console.log sys.inspect objectconsole.log(sys.inspect(object));

Functions

Functions are defined by an optional list of parameters in parentheses, an arrow, and the function body. The empty function looks like this: ->

Functions may also have default values for arguments, which will be used if the incoming argument is missing (undefined).

Resources

  • CoffeeScript on GitHub
  • CoffeeScript Issues
    Bug reports, feature proposals, and ideas for changes to the language belong here.
  • CoffeeScript Google Group
    If you’d like to ask a question, the mailing list is a good place to get help.
  • The CoffeeScript Wiki
    If you’ve ever learned a neat CoffeeScript tip or trick, or ran into a gotcha — share it on the wiki. The wiki also serves as a directory of handy text editor extensions, web framework plugins, and general CoffeeScript build tools.
  • The FAQ
    Perhaps your CoffeeScript-related question has been asked before. Check the FAQ first.
  • JS2Coffee
    Is a very well done reverse JavaScript-to-CoffeeScript compiler. It’s not going to be perfect (infer what your JavaScript classes are, when you need bound functions, and so on…) — but it’s a great starting point for converting simple scripts.
  • High-Rez Logo
    The CoffeeScript logo is available in SVG for use in presentations.

Books

There are a number of excellent resources to help you get started with CoffeeScript, some of which are freely available online.

Screencasts

  • A Sip of CoffeeScript is a Code School Course which combines 6 screencasts with in-browser coding to make learning fun. The first level is free to try out.
  • Meet CoffeeScript is a 75-minute long screencast by PeepCode, now PluralSight. Highly memorable for its animations which demonstrate transforming CoffeeScript into the equivalent JS.
  • If you’re looking for less of a time commitment, RailsCasts’ CoffeeScript Basics should have you covered, hitting all of the important notes about CoffeeScript in 11 minutes.

Examples

The best list of open-source CoffeeScript examples can be found on GitHub. But just to throw out a few more:

  • GitHub’s Hubot, a friendly IRC robot that can perform any number of useful and useless tasks.
  • sstephenson’s Pow, a zero-configuration Rack server, with comprehensive annotated source.
  • technoweenie’s Coffee-Resque, a port of Resque for Node.js.
  • stephank’s Orona, a remake of the Bolo tank game for modern browsers.
  • GitHub’s Atom, a hackable text editor built on web technologies.
  • Basecamp’s Trix, a rich text editor for web apps.

Web Chat (IRC)

Quick help and advice can often be found in the CoffeeScript IRC room #coffeescript on irc.freenode.net, which you can join via your web browser.

Contributing

Contributions are welcome! Feel free to fork the repo and submit a pull request.

Some features of ECMAScript are intentionally unsupported. Please review both the open and closed issues on GitHub to see if the feature you’re looking for has already been discussed. As a general rule, we don’t support ECMAScript syntax for features that aren’t yet finalized (at Stage 4 in the proposal approval process).

For more resources on adding to CoffeeScript, please see the Wiki, especially How The Parser Works.

There are several things you can do to increase your odds of having your pull request accepted:

  • Create tests! Any pull request should probably include basic tests to verify you didn’t break anything, or future changes won’t break your code.
  • Follow the style of the rest of the CoffeeScript codebase.
  • Ensure any ECMAScript syntax is mature (at Stage 4), with no further potential changes.
  • Add only features that have broad utility, rather than a feature aimed at a specific use case or framework.

Of course, it’s entirely possible that you have a great addition, but it doesn’t fit within these constraints. Feel free to roll your own solution; you will have plenty of company.

Changelog

0.1.1 — 2009-12-24

Added instanceof and typeof as operators.

0.1.0 — 2009-12-24

Initial CoffeeScript release.