-
-
Save JT5D/7403356 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Compile the coffee in bare joined mode. | |
| {exec, spawn} = require 'child_process' | |
| fs = require 'fs' | |
| util = require 'util' | |
| print = (data) -> | |
| console.log data.trimRight() | |
| task 'build', 'Compile Coffeescript to Javascript', -> | |
| exec 'mkdir -p lib && coffee --bare --output lib --compile --join weird.js src/*.coffee' | |
| task 'clean', 'Remove generated Javascripts', -> | |
| exec 'rm -fr lib' | |
| task 'test', 'Run the tests', -> | |
| vows = exec "vows --spec test/*test*" | |
| vows.stdout.on 'data', print | |
| vows.stderr.on 'data', print |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # test/helper.coffee | |
| # Create globals for the classes under test. | |
| global.util = require 'util' | |
| global.assert = require 'assert' | |
| require '../src/array' | |
| global.World = require('../src/world').World | |
| global.Inspector = require('../src/inspector').Inspector | |
| global.Lseq = require('../src/lseq').Lseq | |
| vows = require 'vows' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| w = new World 16, 8 | |
| gw = new Global "world" | |
| @bang = -> | |
| post w.cells.length |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # src/world.coffee | |
| # Define classes as top level vars. | |
| @World = class | |
| constructor: (@lseq, @cells) -> | |
| unless @cells? | |
| @cells = @generateCells() | |
| @reset() | |
| generateCells: -> | |
| len = @length() - 1 | |
| @lseq.toCoords(i) for i in [0..len] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # test/world_test.coffee | |
| # Test the globals defined in helper.coffee. | |
| require './helper' | |
| test module, 'World', | |
| 'constructor with an lseq and no provided cells': | |
| topic: -> | |
| @lseq = new Lseq({x:0, y:0}, 2, 2) | |
| @world = new World @lseq | |
| 'has an lseq': -> | |
| @world.lseq.should eq @lseq | |
| 'has an array of cells with 0 state': -> | |
| cells = [ | |
| {x: 0, y: 0, state: 0}, | |
| {x: 1, y: 0, state: 0}, | |
| {x: 0, y: 1, state: 0}, | |
| {x: 1, y: 1, state: 0} | |
| ] | |
| @world.cells.should deq cells |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment