1 | util = require 'util'
|
2 | inspect = (o) -> util.inspect o, no, 2, yes
|
3 |
|
4 | global[name] = func for name, func of require 'assert'
|
5 |
|
6 |
|
7 | egal = (a, b) ->
|
8 | if a is b
|
9 | a isnt 0 or 1/a is 1/b
|
10 | else
|
11 | a isnt a and b isnt b
|
12 |
|
13 |
|
14 | arrayEgal = (a, b) ->
|
15 | if egal a, b then yes
|
16 | else if a instanceof Array and b instanceof Array
|
17 | return no unless a.length is b.length
|
18 | return no for el, idx in a when not arrayEgal el, b[idx]
|
19 | yes
|
20 |
|
21 | global.eq = (a, b, msg) -> ok egal(a, b), msg ? "#{inspect a} === #{inspect b}"
|
22 | global.arrayEq = (a, b, msg) -> ok arrayEgal(a,b), msg ? "#{inspect a} === #{inspect b}"
|
23 |
|
24 |
|
25 | libDir = if typeof _$jscoverage is 'undefined' then 'lib' else 'instrumented'
|
26 | global.CoffeeScript = require '..'
|
27 | global.CS = require "../#{libDir}/coffee-script/nodes"
|
28 | global.JS = require "../#{libDir}/coffee-script/js-nodes"
|
29 | global.Repl = require "../#{libDir}/coffee-script/repl"
|
30 | global.Parser = require "../#{libDir}/coffee-script/parser"
|
31 | {Optimiser: global.Optimiser} = require "../#{libDir}/coffee-script/optimiser"
|
32 | {Preprocessor} = require "../#{libDir}/coffee-script/preprocessor"
|
33 |
|
34 | global.parse = (input) -> Parser.parse Preprocessor.processSync input
|
35 | optimiser = new Optimiser
|
36 | global.optimise = (ast) -> optimiser.optimise ast
|