UNPKG

1.37 kBtext/coffeescriptView Raw
1util = require 'util'
2inspect = (o) -> util.inspect o, no, 2, yes
3
4global[name] = func for name, func of require 'assert'
5
6# See http://wiki.ecmascript.org/doku.php?id=harmony:egal
7egal = (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# A recursive functional equivalence helper; uses egal for testing equivalence.
14arrayEgal = (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
21global.eq = (a, b, msg) -> ok egal(a, b), msg ? "#{inspect a} === #{inspect b}"
22global.arrayEq = (a, b, msg) -> ok arrayEgal(a,b), msg ? "#{inspect a} === #{inspect b}"
23
24
25libDir = if typeof _$jscoverage is 'undefined' then 'lib' else 'instrumented'
26global.CoffeeScript = require '..'
27global.CS = require "../#{libDir}/coffee-script/nodes"
28global.JS = require "../#{libDir}/coffee-script/js-nodes"
29global.Repl = require "../#{libDir}/coffee-script/repl"
30global.Parser = require "../#{libDir}/coffee-script/parser"
31{Optimiser: global.Optimiser} = require "../#{libDir}/coffee-script/optimiser"
32{Preprocessor} = require "../#{libDir}/coffee-script/preprocessor"
33
34global.parse = (input) -> Parser.parse Preprocessor.processSync input
35optimiser = new Optimiser
36global.optimise = (ast) -> optimiser.optimise ast