mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-01-13 16:57:54 -05:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
859ab7583f | ||
|
|
3eedd5bb50 | ||
|
|
5b7e695f6c | ||
|
|
1e3182727b | ||
|
|
e595dbfcee | ||
|
|
12b830893d | ||
|
|
cca80342aa | ||
|
|
4412f590cf | ||
|
|
0cd2d78027 | ||
|
|
be672ebfc1 | ||
|
|
9047c87567 | ||
|
|
31d630bb91 | ||
|
|
7a2f5a333f | ||
|
|
66303636dc |
15
Rakefile
15
Rakefile
@@ -10,9 +10,18 @@ task :test do
|
||||
Dir['test/*/**/test_*.rb'].each {|test| require test }
|
||||
end
|
||||
|
||||
desc "Recompile the Racc parser (pass -v and -g for verbose debugging)"
|
||||
task :build, :extra_args do |t, args|
|
||||
sh "racc #{args[:extra_args]} -o lib/coffee_script/parser.rb lib/coffee_script/grammar.y"
|
||||
namespace :build do
|
||||
|
||||
desc "Recompile the Racc parser (pass -v and -g for verbose debugging)"
|
||||
task :parser, :extra_args do |t, args|
|
||||
sh "racc #{args[:extra_args]} -o lib/coffee_script/parser.rb lib/coffee_script/grammar.y"
|
||||
end
|
||||
|
||||
desc "Compile the Narwhal interface for --interactive and --run"
|
||||
task :narwhal do
|
||||
sh "bin/coffee-script lib/coffee_script/narwhal/*.cs -o lib/coffee_script/narwhal/js"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
desc "Build the documentation page"
|
||||
|
||||
3
bin/cs
3
bin/cs
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env narwhal
|
||||
|
||||
require("coffee-script").run(system.args);
|
||||
@@ -1,7 +1,7 @@
|
||||
Gem::Specification.new do |s|
|
||||
s.name = 'coffee-script'
|
||||
s.version = '0.1.2' # Keep version in sync with coffee-script.rb
|
||||
s.date = '2009-12-24'
|
||||
s.version = '0.1.3' # Keep version in sync with coffee-script.rb
|
||||
s.date = '2009-12-25'
|
||||
|
||||
s.homepage = "http://jashkenas.github.com/coffee-script/"
|
||||
s.summary = "The CoffeeScript Compiler"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
launch() if ignition is on
|
||||
|
||||
volume: 10 if band aint spinal_tap
|
||||
volume: 10 if band isnt spinal_tap
|
||||
|
||||
let_the_wild_rumpus_begin() unless answer is no
|
||||
|
||||
|
||||
@@ -37,8 +37,6 @@
|
||||
equivalent in JavaScript, it's just another way of saying it.
|
||||
</p>
|
||||
|
||||
<!-- <%# code_for('intro') %>-->
|
||||
|
||||
<p>
|
||||
<b>Disclaimer:</b>
|
||||
CoffeeScript is just for fun and seriously alpha. I'm sure that there are still
|
||||
@@ -83,7 +81,7 @@
|
||||
<%= code_for('overview', 'cubed_list') %>
|
||||
|
||||
<h2 id="installation">Installation and Usage</h2>
|
||||
|
||||
|
||||
<p>
|
||||
The CoffeeScript compiler is written in pure Ruby, and is available
|
||||
as a Ruby Gem.
|
||||
@@ -95,14 +93,31 @@ gem install coffee-script</pre>
|
||||
<p>
|
||||
Installing the gem provides the <tt>coffee-script</tt> command, which can
|
||||
be used to compile CoffeeScript <tt>.cs</tt> files into JavaScript, as
|
||||
well as debug them. By default, <tt>coffee-script</tt> writes out the
|
||||
JavaScript as <tt>.js</tt> files in the same directory, but output
|
||||
well as debug them. In conjunction with
|
||||
<a href="http://narwhaljs.org/">Narwhal</a>, the <tt>coffee-script</tt>
|
||||
command also provides direct evaluation and an interactive REPL.
|
||||
When compiling to JavaScript, <tt>coffee-script</tt> writes the output
|
||||
as <tt>.js</tt> files in the same directory by default, but output
|
||||
can be customized with the following options:
|
||||
</p>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td width="25%"><code>-o, --output [DIR]</code></td>
|
||||
<td width="25%"><code>-i, --interactive</code></td>
|
||||
<td>
|
||||
Launch an interactive CoffeeScript session.
|
||||
Requires <a href="http://narwhaljs.org/">Narwhal</a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>-r, --run</code></td>
|
||||
<td>
|
||||
Compile and execute the CoffeeScripts without saving the intermediate
|
||||
JavaScript. Requires <a href="http://narwhaljs.org/">Narwhal</a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>-o, --output [DIR]</code></td>
|
||||
<td>
|
||||
Write out all compiled JavaScript files into the specified directory.
|
||||
</td>
|
||||
@@ -125,7 +140,7 @@ gem install coffee-script</pre>
|
||||
<td><code>-l, --lint</code></td>
|
||||
<td>
|
||||
If the <tt>jsl</tt> (JavaScript Lint) command is installed, use it
|
||||
to check the compilation of a CoffeeScript file. (Handy in
|
||||
to check the compilation of a CoffeeScript file. (Handy in
|
||||
conjunction with <tt>--watch</tt>)
|
||||
</td>
|
||||
</tr>
|
||||
@@ -151,6 +166,14 @@ gem install coffee-script</pre>
|
||||
AST.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>-n, --no-wrap</code></td>
|
||||
<td>
|
||||
Compile the JavaScript without the top-level function safety wrapper
|
||||
or var declarations, for situations where you want to add every
|
||||
variable to global scope.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>--install-bundle</code></td>
|
||||
<td>
|
||||
@@ -186,15 +209,15 @@ coffee-script --print app/scripts/*.cs > concatenation.js</pre>
|
||||
the line will do just as well. All other whitespace is
|
||||
not significant. Instead of using curly braces <tt>{ }</tt>
|
||||
to delimit a block of code, use a period <tt>.</tt> to mark the end of a
|
||||
block, for
|
||||
<a href="#functions">functions</a>,
|
||||
<a href="#conditionals">if-statements</a>,
|
||||
block, for
|
||||
<a href="#functions">functions</a>,
|
||||
<a href="#conditionals">if-statements</a>,
|
||||
<a href="#switch">switch</a>, and <a href="#try">try/catch</a>.
|
||||
</p>
|
||||
|
||||
<p id="functions">
|
||||
<b class="header">Functions and Invocation</b>
|
||||
Functions are defined by a list of parameters, an arrow, and the
|
||||
Functions are defined by a list of parameters, an arrow, and the
|
||||
function body. The empty function looks like this: <tt>=>.</tt>
|
||||
</p>
|
||||
<%= code_for('functions', 'cube(5)') %>
|
||||
@@ -270,7 +293,7 @@ coffee-script --print app/scripts/*.cs > concatenation.js</pre>
|
||||
The same mechanism is used to push down assignment through <b>switch</b>
|
||||
statements, and <b>if-elses</b> (although the ternary operator is preferred).
|
||||
</p>
|
||||
|
||||
|
||||
<p id="aliases">
|
||||
<b class="header">Aliases</b>
|
||||
Because the <tt>==</tt> operator frequently causes undesirable coercion,
|
||||
@@ -278,7 +301,7 @@ coffee-script --print app/scripts/*.cs > concatenation.js</pre>
|
||||
CoffeeScript compiles <tt>==</tt> into <tt>===</tt>, and <tt>!=</tt> into
|
||||
<tt>!==</tt>.
|
||||
In addition, <tt>is</tt> compiles into <tt>===</tt>,
|
||||
and <tt>aint</tt> into <tt>!==</tt>.
|
||||
and <tt>isnt</tt> into <tt>!==</tt>.
|
||||
</p>
|
||||
<p>
|
||||
You can use <tt>not</tt> as an alias for <tt>!</tt>.
|
||||
@@ -289,7 +312,7 @@ coffee-script --print app/scripts/*.cs > concatenation.js</pre>
|
||||
</p>
|
||||
<p>
|
||||
Instead of a newline or semicolon, <tt>then</tt> can be used to separate
|
||||
conditions from expressions, in <b>while</b>,
|
||||
conditions from expressions, in <b>while</b>,
|
||||
<b>if</b>/<b>else</b>, and <b>switch</b>/<b>when</b> statements.
|
||||
</p>
|
||||
<p>
|
||||
@@ -382,14 +405,14 @@ coffee-script --print app/scripts/*.cs > concatenation.js</pre>
|
||||
Multiline strings are allowed in CoffeeScript.
|
||||
</p>
|
||||
<%= code_for('strings', 'moby_dick') %>
|
||||
|
||||
|
||||
<h2 id="contributing">Contributing</h2>
|
||||
|
||||
|
||||
<p>
|
||||
Here's a wish list of things that would be wonderful to have in
|
||||
CoffeeScript:
|
||||
</p>
|
||||
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
A JavaScript version of the compiler, perhaps using Alessandro Warth's
|
||||
@@ -404,7 +427,7 @@ coffee-script --print app/scripts/*.cs > concatenation.js</pre>
|
||||
should be able to compile properly.
|
||||
</li>
|
||||
<li>
|
||||
A tutorial that introduces CoffeeScript from the ground up for folks
|
||||
A tutorial that introduces CoffeeScript from the ground up for folks
|
||||
without knowledge of JavaScript.
|
||||
</li>
|
||||
<li>
|
||||
@@ -412,31 +435,45 @@ coffee-script --print app/scripts/*.cs > concatenation.js</pre>
|
||||
having a JavaScript version of the compiler).
|
||||
</li>
|
||||
<li>
|
||||
A lot of the code generation in <tt>nodes.rb</tt> gets into messy
|
||||
A lot of the code generation in <tt>nodes.rb</tt> gets into messy
|
||||
string manipulation. Techniques for cleaning this up across the board
|
||||
would be appreciated.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2 id="change_log">Change Log</h2>
|
||||
|
||||
<p>
|
||||
<b class="header" style="margin-top: 20px;">0.1.3</b>
|
||||
The <tt>coffee-script</tt> command now includes <tt>--interactive</tt>,
|
||||
which launches an interactive CoffeeScript session, and <tt>--run</tt>,
|
||||
which directly compiles and executes a script. Both options depend on a
|
||||
working installation of Narwhal.
|
||||
The <tt>aint</tt> keyword has been replaced by <tt>isnt</tt>, which goes
|
||||
together a little smoother with <tt>is</tt>.
|
||||
Quoted strings are now allowed as identifiers within object literals: eg.
|
||||
<tt>{"5+5": 10}</tt>.
|
||||
All assignment operators now use a colon: <tt>+:</tt>, <tt>-:</tt>,
|
||||
<tt>*:</tt>, etc.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b class="header" style="margin-top: 20px;">0.1.2</b>
|
||||
Fixed a bug with calling <tt>super()</tt> through more than one level of
|
||||
Fixed a bug with calling <tt>super()</tt> through more than one level of
|
||||
inheritance, with the re-addition of the <tt>extends</tt> keyword.
|
||||
Added experimental <a href="http://narwhaljs.org/">Narwhal</a>
|
||||
support (as a Tusk package), contributed by
|
||||
Added experimental <a href="http://narwhaljs.org/">Narwhal</a>
|
||||
support (as a Tusk package), contributed by
|
||||
<a href="http://tlrobinson.net/">Tom Robinson</a>, including
|
||||
<b>bin/cs</b> as a CoffeeScript REPL and interpreter.
|
||||
New <tt>--no-wrap</tt> option to suppress the safety function
|
||||
wrapper.
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<b class="header" style="margin-top: 20px;">0.1.1</b>
|
||||
Added <tt>instanceof</tt> and <tt>typeof</tt> as operators.
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<b class="header" style="margin-top: 20px;">0.1.0</b>
|
||||
Initial CoffeeScript release.
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
|
||||
// Eat lunch.
|
||||
var lunch;
|
||||
var a = ['toast', 'cheese', 'wine'];
|
||||
var d = [];
|
||||
for (var b=0, c=a.length; b<c; b++) {
|
||||
var food = a[b];
|
||||
d[b] = food.eat();
|
||||
var __a = ['toast', 'cheese', 'wine'];
|
||||
var __d = [];
|
||||
for (var __b=0, __c=__a.length; __b<__c; __b++) {
|
||||
var food = __a[__b];
|
||||
__d[__b] = food.eat();
|
||||
}
|
||||
lunch = d;
|
||||
lunch = __d;
|
||||
// Zebra-stripe a table.
|
||||
var e = table;
|
||||
for (var f=0, g=e.length; f<g; f++) {
|
||||
var row = e[f];
|
||||
var i = f;
|
||||
var __e = table;
|
||||
for (var __f=0, __g=__e.length; __f<__g; __f++) {
|
||||
var row = __e[__f];
|
||||
var i = __f;
|
||||
i % 2 === 0 ? highlight(row) : null;
|
||||
}
|
||||
})();
|
||||
@@ -23,11 +23,11 @@
|
||||
};
|
||||
// Array comprehensions:
|
||||
var cubed_list;
|
||||
var a = list;
|
||||
var d = [];
|
||||
for (var b=0, c=a.length; b<c; b++) {
|
||||
var num = a[b];
|
||||
d[b] = math.cube(num);
|
||||
var __a = list;
|
||||
var __d = [];
|
||||
for (var __b=0, __c=__a.length; __b<__c; __b++) {
|
||||
var num = __a[__b];
|
||||
__d[__b] = math.cube(num);
|
||||
}
|
||||
cubed_list = d;
|
||||
cubed_list = __d;
|
||||
})();
|
||||
@@ -5,7 +5,7 @@ sum: x, y => x + y.
|
||||
|
||||
odd: x => x % 2 is 0.
|
||||
|
||||
even: x => x % 2 aint 0.
|
||||
even: x => x % 2 isnt 0.
|
||||
|
||||
run_loop: =>
|
||||
fire_events( e => e.stopPropagation(). )
|
||||
|
||||
@@ -81,9 +81,9 @@ Creature : {
|
||||
hit: damage =>
|
||||
p_up: Math.rand( this.charisma )
|
||||
if p_up % 9 is 7
|
||||
this.life += p_up / 4
|
||||
this.life +: p_up / 4
|
||||
puts( "[" + this.name + " magick powers up " + p_up + "!]" ).
|
||||
this.life -= damage
|
||||
this.life -: damage
|
||||
if this.life <= 0 then puts( "[" + this.name + " has died.]" )..
|
||||
|
||||
# This method takes one turn in a fight.
|
||||
|
||||
@@ -49,7 +49,7 @@ _.each: obj, iterator, context =>
|
||||
return iterator.call(context, item, i, obj) for item, i in obj. if _.isArray(obj) or _.isArguments(obj)
|
||||
iterator.call(context, obj[key], key, obj) for key in _.keys(obj).
|
||||
catch e
|
||||
throw e if e aint breaker.
|
||||
throw e if e isnt breaker.
|
||||
obj.
|
||||
|
||||
# Return the results of applying the iterator to each element. Use JavaScript
|
||||
|
||||
133
index.html
133
index.html
@@ -23,8 +23,6 @@
|
||||
equivalent in JavaScript, it's just another way of saying it.
|
||||
</p>
|
||||
|
||||
<!-- -->
|
||||
|
||||
<p>
|
||||
<b>Disclaimer:</b>
|
||||
CoffeeScript is just for fun and seriously alpha. I'm sure that there are still
|
||||
@@ -112,13 +110,13 @@ cubed_list<span class="Keyword">:</span> math.cube(num) <span class="Keyword">fo
|
||||
};
|
||||
<span class="Comment"><span class="Comment">//</span> Array comprehensions:</span>
|
||||
<span class="Storage">var</span> cubed_list;
|
||||
<span class="Storage">var</span> a <span class="Keyword">=</span> list;
|
||||
<span class="Storage">var</span> d <span class="Keyword">=</span> [];
|
||||
<span class="Keyword">for</span> (<span class="Storage">var</span> b<span class="Keyword">=</span><span class="Number">0</span>, c<span class="Keyword">=</span>a.<span class="LibraryConstant">length</span>; b<span class="Keyword"><</span>c; b<span class="Keyword">++</span>) {
|
||||
<span class="Storage">var</span> num <span class="Keyword">=</span> a[b];
|
||||
d[b] <span class="Keyword">=</span> math.cube(num);
|
||||
<span class="Storage">var</span> __a <span class="Keyword">=</span> list;
|
||||
<span class="Storage">var</span> __d <span class="Keyword">=</span> [];
|
||||
<span class="Keyword">for</span> (<span class="Storage">var</span> __b<span class="Keyword">=</span><span class="Number">0</span>, __c<span class="Keyword">=</span>__a.<span class="LibraryConstant">length</span>; __b<span class="Keyword"><</span>__c; __b<span class="Keyword">++</span>) {
|
||||
<span class="Storage">var</span> num <span class="Keyword">=</span> __a[__b];
|
||||
__d[__b] <span class="Keyword">=</span> math.cube(num);
|
||||
}
|
||||
cubed_list <span class="Keyword">=</span> d;
|
||||
cubed_list <span class="Keyword">=</span> __d;
|
||||
</pre><button onclick='javascript:
|
||||
// Assignment:
|
||||
var number = 42;
|
||||
@@ -143,17 +141,17 @@ var math = {
|
||||
};
|
||||
// Array comprehensions:
|
||||
var cubed_list;
|
||||
var a = list;
|
||||
var d = [];
|
||||
for (var b=0, c=a.length; b<c; b++) {
|
||||
var num = a[b];
|
||||
d[b] = math.cube(num);
|
||||
var __a = list;
|
||||
var __d = [];
|
||||
for (var __b=0, __c=__a.length; __b<__c; __b++) {
|
||||
var num = __a[__b];
|
||||
__d[__b] = math.cube(num);
|
||||
}
|
||||
cubed_list = d;
|
||||
cubed_list = __d;
|
||||
;alert(cubed_list);'>run: cubed_list</button><br class='clear' /></div>
|
||||
|
||||
<h2 id="installation">Installation and Usage</h2>
|
||||
|
||||
|
||||
<p>
|
||||
The CoffeeScript compiler is written in pure Ruby, and is available
|
||||
as a Ruby Gem.
|
||||
@@ -165,14 +163,31 @@ gem install coffee-script</pre>
|
||||
<p>
|
||||
Installing the gem provides the <tt>coffee-script</tt> command, which can
|
||||
be used to compile CoffeeScript <tt>.cs</tt> files into JavaScript, as
|
||||
well as debug them. By default, <tt>coffee-script</tt> writes out the
|
||||
JavaScript as <tt>.js</tt> files in the same directory, but output
|
||||
well as debug them. In conjunction with
|
||||
<a href="http://narwhaljs.org/">Narwhal</a>, the <tt>coffee-script</tt>
|
||||
command also provides direct evaluation and an interactive REPL.
|
||||
When compiling to JavaScript, <tt>coffee-script</tt> writes the output
|
||||
as <tt>.js</tt> files in the same directory by default, but output
|
||||
can be customized with the following options:
|
||||
</p>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td width="25%"><code>-o, --output [DIR]</code></td>
|
||||
<td width="25%"><code>-i, --interactive</code></td>
|
||||
<td>
|
||||
Launch an interactive CoffeeScript session.
|
||||
Requires <a href="http://narwhaljs.org/">Narwhal</a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>-r, --run</code></td>
|
||||
<td>
|
||||
Compile and execute the CoffeeScripts without saving the intermediate
|
||||
JavaScript. Requires <a href="http://narwhaljs.org/">Narwhal</a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>-o, --output [DIR]</code></td>
|
||||
<td>
|
||||
Write out all compiled JavaScript files into the specified directory.
|
||||
</td>
|
||||
@@ -195,7 +210,7 @@ gem install coffee-script</pre>
|
||||
<td><code>-l, --lint</code></td>
|
||||
<td>
|
||||
If the <tt>jsl</tt> (JavaScript Lint) command is installed, use it
|
||||
to check the compilation of a CoffeeScript file. (Handy in
|
||||
to check the compilation of a CoffeeScript file. (Handy in
|
||||
conjunction with <tt>--watch</tt>)
|
||||
</td>
|
||||
</tr>
|
||||
@@ -221,6 +236,14 @@ gem install coffee-script</pre>
|
||||
AST.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>-n, --no-wrap</code></td>
|
||||
<td>
|
||||
Compile the JavaScript without the top-level function safety wrapper
|
||||
or var declarations, for situations where you want to add every
|
||||
variable to global scope.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>--install-bundle</code></td>
|
||||
<td>
|
||||
@@ -256,15 +279,15 @@ coffee-script --print app/scripts/*.cs > concatenation.js</pre>
|
||||
the line will do just as well. All other whitespace is
|
||||
not significant. Instead of using curly braces <tt>{ }</tt>
|
||||
to delimit a block of code, use a period <tt>.</tt> to mark the end of a
|
||||
block, for
|
||||
<a href="#functions">functions</a>,
|
||||
<a href="#conditionals">if-statements</a>,
|
||||
block, for
|
||||
<a href="#functions">functions</a>,
|
||||
<a href="#conditionals">if-statements</a>,
|
||||
<a href="#switch">switch</a>, and <a href="#try">try/catch</a>.
|
||||
</p>
|
||||
|
||||
<p id="functions">
|
||||
<b class="header">Functions and Invocation</b>
|
||||
Functions are defined by a list of parameters, an arrow, and the
|
||||
Functions are defined by a list of parameters, an arrow, and the
|
||||
function body. The empty function looks like this: <tt>=>.</tt>
|
||||
</p>
|
||||
<div class='code'><pre class="idle"><span class="FunctionName">square</span><span class="Keyword">:</span> <span class="FunctionArgument">x</span> <span class="Storage">=></span> x <span class="Keyword">*</span> x.
|
||||
@@ -445,7 +468,7 @@ var eldest = 24 > 21 ? "Liz" : "Ike";
|
||||
The same mechanism is used to push down assignment through <b>switch</b>
|
||||
statements, and <b>if-elses</b> (although the ternary operator is preferred).
|
||||
</p>
|
||||
|
||||
|
||||
<p id="aliases">
|
||||
<b class="header">Aliases</b>
|
||||
Because the <tt>==</tt> operator frequently causes undesirable coercion,
|
||||
@@ -453,7 +476,7 @@ var eldest = 24 > 21 ? "Liz" : "Ike";
|
||||
CoffeeScript compiles <tt>==</tt> into <tt>===</tt>, and <tt>!=</tt> into
|
||||
<tt>!==</tt>.
|
||||
In addition, <tt>is</tt> compiles into <tt>===</tt>,
|
||||
and <tt>aint</tt> into <tt>!==</tt>.
|
||||
and <tt>isnt</tt> into <tt>!==</tt>.
|
||||
</p>
|
||||
<p>
|
||||
You can use <tt>not</tt> as an alias for <tt>!</tt>.
|
||||
@@ -464,7 +487,7 @@ var eldest = 24 > 21 ? "Liz" : "Ike";
|
||||
</p>
|
||||
<p>
|
||||
Instead of a newline or semicolon, <tt>then</tt> can be used to separate
|
||||
conditions from expressions, in <b>while</b>,
|
||||
conditions from expressions, in <b>while</b>,
|
||||
<b>if</b>/<b>else</b>, and <b>switch</b>/<b>when</b> statements.
|
||||
</p>
|
||||
<p>
|
||||
@@ -476,7 +499,7 @@ var eldest = 24 > 21 ? "Liz" : "Ike";
|
||||
</p>
|
||||
<div class='code'><pre class="idle">launch() <span class="Keyword">if</span> ignition <span class="Keyword">is</span> <span class="BuiltInConstant">on</span>
|
||||
|
||||
volume<span class="Keyword">:</span> <span class="Number">10</span> <span class="Keyword">if</span> band <span class="Keyword">aint</span> spinal_tap
|
||||
volume<span class="Keyword">:</span> <span class="Number">10</span> <span class="Keyword">if</span> band <span class="Keyword">isnt</span> spinal_tap
|
||||
|
||||
let_the_wild_rumpus_begin() <span class="Keyword">unless</span> answer <span class="Keyword">is</span> <span class="BuiltInConstant">no</span>
|
||||
|
||||
@@ -535,18 +558,18 @@ highlight(row) <span class="Keyword">for</span> row, i <span class="Keyword">in<
|
||||
</pre><pre class="idle">
|
||||
<span class="Comment"><span class="Comment">//</span> Eat lunch.</span>
|
||||
<span class="Storage">var</span> lunch;
|
||||
<span class="Storage">var</span> a <span class="Keyword">=</span> [<span class="String"><span class="String">'</span>toast<span class="String">'</span></span>, <span class="String"><span class="String">'</span>cheese<span class="String">'</span></span>, <span class="String"><span class="String">'</span>wine<span class="String">'</span></span>];
|
||||
<span class="Storage">var</span> d <span class="Keyword">=</span> [];
|
||||
<span class="Keyword">for</span> (<span class="Storage">var</span> b<span class="Keyword">=</span><span class="Number">0</span>, c<span class="Keyword">=</span>a.<span class="LibraryConstant">length</span>; b<span class="Keyword"><</span>c; b<span class="Keyword">++</span>) {
|
||||
<span class="Storage">var</span> food <span class="Keyword">=</span> a[b];
|
||||
d[b] <span class="Keyword">=</span> food.eat();
|
||||
<span class="Storage">var</span> __a <span class="Keyword">=</span> [<span class="String"><span class="String">'</span>toast<span class="String">'</span></span>, <span class="String"><span class="String">'</span>cheese<span class="String">'</span></span>, <span class="String"><span class="String">'</span>wine<span class="String">'</span></span>];
|
||||
<span class="Storage">var</span> __d <span class="Keyword">=</span> [];
|
||||
<span class="Keyword">for</span> (<span class="Storage">var</span> __b<span class="Keyword">=</span><span class="Number">0</span>, __c<span class="Keyword">=</span>__a.<span class="LibraryConstant">length</span>; __b<span class="Keyword"><</span>__c; __b<span class="Keyword">++</span>) {
|
||||
<span class="Storage">var</span> food <span class="Keyword">=</span> __a[__b];
|
||||
__d[__b] <span class="Keyword">=</span> food.eat();
|
||||
}
|
||||
lunch <span class="Keyword">=</span> d;
|
||||
lunch <span class="Keyword">=</span> __d;
|
||||
<span class="Comment"><span class="Comment">//</span> Zebra-stripe a table.</span>
|
||||
<span class="Storage">var</span> e <span class="Keyword">=</span> table;
|
||||
<span class="Keyword">for</span> (<span class="Storage">var</span> f<span class="Keyword">=</span><span class="Number">0</span>, g<span class="Keyword">=</span>e.<span class="LibraryConstant">length</span>; f<span class="Keyword"><</span>g; f<span class="Keyword">++</span>) {
|
||||
<span class="Storage">var</span> row <span class="Keyword">=</span> e[f];
|
||||
<span class="Storage">var</span> i <span class="Keyword">=</span> f;
|
||||
<span class="Storage">var</span> __e <span class="Keyword">=</span> table;
|
||||
<span class="Keyword">for</span> (<span class="Storage">var</span> __f<span class="Keyword">=</span><span class="Number">0</span>, __g<span class="Keyword">=</span>__e.<span class="LibraryConstant">length</span>; __f<span class="Keyword"><</span>__g; __f<span class="Keyword">++</span>) {
|
||||
<span class="Storage">var</span> row <span class="Keyword">=</span> __e[__f];
|
||||
<span class="Storage">var</span> i <span class="Keyword">=</span> __f;
|
||||
i <span class="Keyword">%</span> <span class="Number">2</span> <span class="Keyword">===</span> <span class="Number">0</span> ? highlight(row) : <span class="BuiltInConstant">null</span>;
|
||||
}
|
||||
</pre><br class='clear' /></div>
|
||||
@@ -761,14 +784,14 @@ to interest me on shore, I thought I would sail \
|
||||
about a little and see the watery part of the \
|
||||
world...";
|
||||
;alert(moby_dick);'>run: moby_dick</button><br class='clear' /></div>
|
||||
|
||||
|
||||
<h2 id="contributing">Contributing</h2>
|
||||
|
||||
|
||||
<p>
|
||||
Here's a wish list of things that would be wonderful to have in
|
||||
CoffeeScript:
|
||||
</p>
|
||||
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
A JavaScript version of the compiler, perhaps using Alessandro Warth's
|
||||
@@ -783,7 +806,7 @@ world...";
|
||||
should be able to compile properly.
|
||||
</li>
|
||||
<li>
|
||||
A tutorial that introduces CoffeeScript from the ground up for folks
|
||||
A tutorial that introduces CoffeeScript from the ground up for folks
|
||||
without knowledge of JavaScript.
|
||||
</li>
|
||||
<li>
|
||||
@@ -791,31 +814,45 @@ world...";
|
||||
having a JavaScript version of the compiler).
|
||||
</li>
|
||||
<li>
|
||||
A lot of the code generation in <tt>nodes.rb</tt> gets into messy
|
||||
A lot of the code generation in <tt>nodes.rb</tt> gets into messy
|
||||
string manipulation. Techniques for cleaning this up across the board
|
||||
would be appreciated.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2 id="change_log">Change Log</h2>
|
||||
|
||||
<p>
|
||||
<b class="header" style="margin-top: 20px;">0.1.3</b>
|
||||
The <tt>coffee-script</tt> command now includes <tt>--interactive</tt>,
|
||||
which launches an interactive CoffeeScript session, and <tt>--run</tt>,
|
||||
which directly compiles and executes a script. Both options depend on a
|
||||
working installation of Narwhal.
|
||||
The <tt>aint</tt> keyword has been replaced by <tt>isnt</tt>, which goes
|
||||
together a little smoother with <tt>is</tt>.
|
||||
Quoted strings are now allowed as identifiers within object literals: eg.
|
||||
<tt>{"5+5": 10}</tt>.
|
||||
All assignment operators now use a colon: <tt>+:</tt>, <tt>-:</tt>,
|
||||
<tt>*:</tt>, etc.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b class="header" style="margin-top: 20px;">0.1.2</b>
|
||||
Fixed a bug with calling <tt>super()</tt> through more than one level of
|
||||
Fixed a bug with calling <tt>super()</tt> through more than one level of
|
||||
inheritance, with the re-addition of the <tt>extends</tt> keyword.
|
||||
Added experimental <a href="http://narwhaljs.org/">Narwhal</a>
|
||||
support (as a Tusk package), contributed by
|
||||
Added experimental <a href="http://narwhaljs.org/">Narwhal</a>
|
||||
support (as a Tusk package), contributed by
|
||||
<a href="http://tlrobinson.net/">Tom Robinson</a>, including
|
||||
<b>bin/cs</b> as a CoffeeScript REPL and interpreter.
|
||||
New <tt>--no-wrap</tt> option to suppress the safety function
|
||||
wrapper.
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<b class="header" style="margin-top: 20px;">0.1.1</b>
|
||||
Added <tt>instanceof</tt> and <tt>typeof</tt> as operators.
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<b class="header" style="margin-top: 20px;">0.1.0</b>
|
||||
Initial CoffeeScript release.
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
var FILE = require("file");
|
||||
var OS = require("os");
|
||||
|
||||
exports.run = function(args) {
|
||||
// TODO: non-REPL
|
||||
|
||||
args.shift();
|
||||
|
||||
if (args.length) {
|
||||
require(FILE.absolute(args[0]));
|
||||
return;
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
try {
|
||||
system.stdout.write("cs> ").flush();
|
||||
|
||||
var result = exports.cs_eval(require("readline").readline());
|
||||
|
||||
if (result !== undefined)
|
||||
print(result);
|
||||
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// executes the coffee-script Ruby program to convert from CoffeeScript to Objective-J.
|
||||
// eventually this will hopefully be replaced by a JavaScript program.
|
||||
var coffeePath = FILE.path(module.path).dirname().dirname().join("bin", "coffee-script");
|
||||
|
||||
exports.compileFile = function(path) {
|
||||
var coffee = OS.popen([coffeePath, "--print", path]);
|
||||
|
||||
if (coffee.wait() !== 0)
|
||||
throw new Error("coffee compiler error");
|
||||
|
||||
return coffee.stdout.read();
|
||||
}
|
||||
|
||||
exports.compile = function(source) {
|
||||
var coffee = OS.popen([coffeePath, "-e"]);
|
||||
|
||||
coffee.stdin.write(source).flush().close();
|
||||
|
||||
if (coffee.wait() !== 0)
|
||||
throw new Error("coffee compiler error");
|
||||
|
||||
return coffee.stdout.read();
|
||||
}
|
||||
|
||||
// these two functions are equivalent to objective-j's objj_eval/make_narwhal_factory.
|
||||
// implemented as a call to coffee and objj_eval/make_narwhal_factory
|
||||
exports.cs_eval = function(source) {
|
||||
init();
|
||||
|
||||
var code = exports.compile(source);
|
||||
|
||||
// strip the function wrapper, we add our own.
|
||||
// TODO: this is very fragile
|
||||
code = code.split("\n").slice(1,-2).join("\n");
|
||||
|
||||
return eval(code);
|
||||
}
|
||||
|
||||
exports.make_narwhal_factory = function(path) {
|
||||
init();
|
||||
|
||||
var code = exports.compileFile(path);
|
||||
|
||||
// strip the function wrapper, we add our own.
|
||||
// TODO: this is very fragile
|
||||
code = code.split("\n").slice(1,-2).join("\n");
|
||||
|
||||
var factoryText = "function(require,exports,module,system,print){" + code + "/**/\n}";
|
||||
|
||||
if (system.engine === "rhino")
|
||||
return Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(global, factoryText, path, 0, null);
|
||||
|
||||
// eval requires parenthesis, but parenthesis break compileFunction.
|
||||
else
|
||||
return eval("(" + factoryText + ")");
|
||||
}
|
||||
|
||||
|
||||
var init = function() {
|
||||
// make sure it's only done once
|
||||
init = function(){}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
var coffeescript = null;
|
||||
|
||||
function CoffeeScriptLoader() {
|
||||
var loader = {};
|
||||
var factories = {};
|
||||
|
||||
loader.reload = function(topId, path) {
|
||||
if (!coffeescript) coffeescript = require("coffee-script");
|
||||
|
||||
//print("loading objective-j: " + topId + " (" + path + ")");
|
||||
factories[topId] = coffeescript.make_narwhal_factory(path);
|
||||
}
|
||||
|
||||
loader.load = function(topId, path) {
|
||||
if (!factories.hasOwnProperty(topId))
|
||||
loader.reload(topId, path);
|
||||
return factories[topId];
|
||||
}
|
||||
|
||||
return loader;
|
||||
};
|
||||
|
||||
require.loader.loaders.unshift([".cs", CoffeeScriptLoader()]);
|
||||
@@ -9,7 +9,7 @@ require "coffee_script/parse_error"
|
||||
# Namespace for all CoffeeScript internal classes.
|
||||
module CoffeeScript
|
||||
|
||||
VERSION = '0.1.2' # Keep in sync with the gemspec.
|
||||
VERSION = '0.1.3' # Keep in sync with the gemspec.
|
||||
|
||||
# Compile a script (String or IO) to JavaScript.
|
||||
def self.compile(script, options={})
|
||||
|
||||
@@ -241,7 +241,7 @@
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\?|\|\||\:|\*=|(?<!\()/=|%=|\+=|\-=|&=|\^=|\b(in|instanceof|new|delete|typeof|and|or|is|aint|not)\b</string>
|
||||
<string>!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\?|\|\||\:|\*:|(?<!\()/=|%:|\+:|\-:|&=|\^=|\b(in|instanceof|new|delete|typeof|and|or|is|isnt|not)\b</string>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.cs</string>
|
||||
</dict>
|
||||
|
||||
@@ -23,8 +23,10 @@ Usage:
|
||||
def initialize
|
||||
@mtimes = {}
|
||||
parse_options
|
||||
return launch_repl if @options[:interactive]
|
||||
return eval_scriptlet if @options[:eval]
|
||||
check_sources
|
||||
return run_scripts if @options[:run]
|
||||
@sources.each {|source| compile_javascript(source) }
|
||||
watch_coffee_scripts if @options[:watch]
|
||||
end
|
||||
@@ -100,6 +102,23 @@ Usage:
|
||||
puts js
|
||||
end
|
||||
|
||||
# Use Narwhal to run an interactive CoffeeScript session.
|
||||
def launch_repl
|
||||
exec "narwhal lib/coffee_script/narwhal/js/launcher.js"
|
||||
rescue Errno::ENOENT
|
||||
puts "Error: Narwhal must be installed to use the interactive REPL."
|
||||
exit(1)
|
||||
end
|
||||
|
||||
# Use Narwhal to compile and execute CoffeeScripts.
|
||||
def run_scripts
|
||||
sources = @sources.join(' ')
|
||||
exec "narwhal lib/coffee_script/narwhal/js/launcher.js #{sources}"
|
||||
rescue Errno::ENOENT
|
||||
puts "Error: Narwhal must be installed in order to execute CoffeeScripts."
|
||||
exit(1)
|
||||
end
|
||||
|
||||
# Print the tokens that the lexer generates from a source script.
|
||||
def tokens(script)
|
||||
puts Lexer.new.tokenize(script).inspect
|
||||
@@ -134,6 +153,12 @@ Usage:
|
||||
def parse_options
|
||||
@options = {}
|
||||
@option_parser = OptionParser.new do |opts|
|
||||
opts.on('-i', '--interactive', 'run a CoffeeScript REPL (requires Narwhal)') do |i|
|
||||
@options[:interactive] = true
|
||||
end
|
||||
opts.on('-r', '--run', 'compile and run a script (requires Narwhal)') do |r|
|
||||
@options[:run] = true
|
||||
end
|
||||
opts.on('-o', '--output [DIR]', 'set the directory for compiled JavaScript') do |d|
|
||||
@options[:output] = d
|
||||
FileUtils.mkdir_p(d) unless File.exists?(d)
|
||||
@@ -147,7 +172,7 @@ Usage:
|
||||
opts.on('-l', '--lint', 'pipe the compiled JavaScript through JSLint') do |l|
|
||||
@options[:lint] = true
|
||||
end
|
||||
opts.on('-e', '--eval', 'eval a little scriptlet or read from stdin') do |e|
|
||||
opts.on('-e', '--eval', 'compile a cli scriptlet or read from stdin') do |e|
|
||||
@options[:eval] = true
|
||||
end
|
||||
opts.on('-t', '--tokens', 'print the tokens that the lexer produces') do |t|
|
||||
@@ -156,7 +181,7 @@ Usage:
|
||||
opts.on('-v', '--verbose', 'print at every step of code generation') do |v|
|
||||
ENV['VERBOSE'] = 'true'
|
||||
end
|
||||
opts.on('-n', '--no-wrap', 'suppress the top-level safety function wrapper') do |n|
|
||||
opts.on('-n', '--no-wrap', 'raw output, no safety wrapper or vars') do |n|
|
||||
@options[:no_wrap] = true
|
||||
end
|
||||
opts.on_tail('--install-bundle', 'install the CoffeeScript TextMate bundle') do |i|
|
||||
|
||||
@@ -24,9 +24,9 @@ prechigh
|
||||
left '<<' '>>' '>>>'
|
||||
left '&' '|' '^'
|
||||
left '<=' '<' '>' '>='
|
||||
right '==' '!=' IS AINT
|
||||
right '==' '!=' IS ISNT
|
||||
left '&&' '||' AND OR
|
||||
right '-=' '+=' '/=' '*='
|
||||
right '-:' '+:' '/:' '*:' '%:'
|
||||
right DELETE INSTANCEOF TYPEOF
|
||||
left "."
|
||||
right THROW FOR IN WHILE NEW SUPER
|
||||
@@ -121,6 +121,7 @@ rule
|
||||
# Assignment within an object literal.
|
||||
AssignObj:
|
||||
IDENTIFIER ":" Expression { result = AssignNode.new(val[0], val[2], :object) }
|
||||
| STRING ":" Expression { result = AssignNode.new(val[0], val[2], :object) }
|
||||
| Comment { result = val[0] }
|
||||
;
|
||||
|
||||
@@ -171,17 +172,18 @@ rule
|
||||
| Expression '==' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
| Expression '!=' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
| Expression IS Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
| Expression AINT Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
| Expression ISNT Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
|
||||
| Expression '&&' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
| Expression '||' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
| Expression AND Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
| Expression OR Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
|
||||
| Expression '-=' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
| Expression '+=' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
| Expression '/=' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
| Expression '*=' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
| Expression '-:' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
| Expression '+:' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
| Expression '/:' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
| Expression '*:' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
| Expression '%:' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
| Expression '||:' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
| Expression '&&:' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ module CoffeeScript
|
||||
# The list of keywords passed verbatim to the parser.
|
||||
KEYWORDS = ["if", "else", "then", "unless",
|
||||
"true", "false", "yes", "no", "on", "off",
|
||||
"and", "or", "is", "aint", "not",
|
||||
"and", "or", "is", "isnt", "not",
|
||||
"new", "return",
|
||||
"try", "catch", "finally", "throw",
|
||||
"break", "continue",
|
||||
|
||||
59
lib/coffee_script/narwhal/coffee-script.cs
Normal file
59
lib/coffee_script/narwhal/coffee-script.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
# This (javascript) file is generated from lib/coffee_script/narwhal/coffee-script.cs
|
||||
|
||||
# Executes the `coffee-script` Ruby program to convert from CoffeeScript
|
||||
# to Javascript. Eventually this will hopefully happen entirely within JS.
|
||||
|
||||
# Require external dependencies.
|
||||
OS: require('os')
|
||||
File: require('file')
|
||||
Readline: require('readline')
|
||||
|
||||
# The path to the CoffeeScript Compiler.
|
||||
coffeePath: File.path(module.path).dirname().dirname().dirname().dirname().dirname().join('bin', 'coffee-script')
|
||||
|
||||
# Our general-purpose error handler.
|
||||
checkForErrors: coffeeProcess =>
|
||||
return true if coffeeProcess.wait() is 0
|
||||
system.stderr.print(coffeeProcess.stderr.read())
|
||||
throw new Error("coffee-script compile error").
|
||||
|
||||
# Run a simple REPL, round-tripping to the CoffeeScript compiler for every
|
||||
# command.
|
||||
exports.run: args =>
|
||||
args.shift()
|
||||
return require(File.absolute(args[0])) if args.length
|
||||
|
||||
while true
|
||||
try
|
||||
system.stdout.write('cs> ').flush()
|
||||
result: exports.evalCS(Readline.readline())
|
||||
print(result) if result isnt undefined
|
||||
catch e
|
||||
print(e)...
|
||||
|
||||
# Compile a given CoffeeScript file into JavaScript.
|
||||
exports.compileFile: path =>
|
||||
coffee: OS.popen([coffeePath, "--print", "--no-wrap", path])
|
||||
checkForErrors(coffee)
|
||||
coffee.stdout.read().
|
||||
|
||||
# Compile a string of CoffeeScript into JavaScript.
|
||||
exports.compile: source =>
|
||||
coffee: OS.popen([coffeePath, "--eval", "--no-wrap"])
|
||||
coffee.stdin.write(source).flush().close()
|
||||
checkForErrors(coffee)
|
||||
coffee.stdout.read().
|
||||
|
||||
# Evaluating a string of CoffeeScript first compiles it externally.
|
||||
exports.evalCS: source =>
|
||||
eval(exports.compile(source)).
|
||||
|
||||
# Make a factory for the CoffeeScript environment.
|
||||
exports.makeNarwhalFactory: path =>
|
||||
code: exports.compileFile(path)
|
||||
factoryText: "function(require,exports,module,system,print){" + code + "/**/\n}"
|
||||
if system.engine is "rhino"
|
||||
Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(global, factoryText, path, 0, null)
|
||||
else
|
||||
# eval requires parenthesis, but parenthesis break compileFunction.
|
||||
eval("(" + factoryText + ")")..
|
||||
65
lib/coffee_script/narwhal/js/coffee-script.js
Normal file
65
lib/coffee_script/narwhal/js/coffee-script.js
Normal file
@@ -0,0 +1,65 @@
|
||||
(function(){
|
||||
|
||||
// This (javascript) file is generated from lib/coffee_script/narwhal/coffee-script.cs Executes the `coffee-script` Ruby program to convert from CoffeeScript
|
||||
// to Javascript. Eventually this will hopefully happen entirely within JS. Require external dependencies.
|
||||
var OS = require('os');
|
||||
var File = require('file');
|
||||
var Readline = require('readline');
|
||||
// The path to the CoffeeScript Compiler.
|
||||
var coffeePath = File.path(module.path).dirname().dirname().dirname().dirname().dirname().join('bin', 'coffee-script');
|
||||
// Our general-purpose error handler.
|
||||
var checkForErrors = function(coffeeProcess) {
|
||||
if (coffeeProcess.wait() === 0) {
|
||||
return true;
|
||||
}
|
||||
system.stderr.print(coffeeProcess.stderr.read());
|
||||
throw new Error("coffee-script compile error");
|
||||
};
|
||||
// Run a simple REPL, round-tripping to the CoffeeScript compiler for every
|
||||
// command.
|
||||
exports.run = function(args) {
|
||||
args.shift();
|
||||
if (args.length) {
|
||||
return require(File.absolute(args[0]));
|
||||
}
|
||||
while (true) {
|
||||
try {
|
||||
system.stdout.write('cs> ').flush();
|
||||
var result = exports.evalCS(Readline.readline());
|
||||
if (result !== undefined) {
|
||||
print(result);
|
||||
}
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
// Compile a given CoffeeScript file into JavaScript.
|
||||
exports.compileFile = function(path) {
|
||||
var coffee = OS.popen([coffeePath, "--print", "--no-wrap", path]);
|
||||
checkForErrors(coffee);
|
||||
return coffee.stdout.read();
|
||||
};
|
||||
// Compile a string of CoffeeScript into JavaScript.
|
||||
exports.compile = function(source) {
|
||||
var coffee = OS.popen([coffeePath, "--eval", "--no-wrap"]);
|
||||
coffee.stdin.write(source).flush().close();
|
||||
checkForErrors(coffee);
|
||||
return coffee.stdout.read();
|
||||
};
|
||||
// Evaluating a string of CoffeeScript first compiles it externally.
|
||||
exports.evalCS = function(source) {
|
||||
return eval(exports.compile(source));
|
||||
};
|
||||
// Make a factory for the CoffeeScript environment.
|
||||
exports.makeNarwhalFactory = function(path) {
|
||||
var code = exports.compileFile(path);
|
||||
var factoryText = "function(require,exports,module,system,print){" + code + "/**/\n}";
|
||||
if (system.engine === "rhino") {
|
||||
return Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(global, factoryText, path, 0, null);
|
||||
} else {
|
||||
// eval requires parenthesis, but parenthesis break compileFunction.
|
||||
return eval("(" + factoryText + ")");
|
||||
}
|
||||
};
|
||||
})();
|
||||
3
lib/coffee_script/narwhal/js/launcher.js
Normal file
3
lib/coffee_script/narwhal/js/launcher.js
Normal file
@@ -0,0 +1,3 @@
|
||||
(function(){
|
||||
require("coffee-script").run(system.args);
|
||||
})();
|
||||
20
lib/coffee_script/narwhal/js/loader.js
Normal file
20
lib/coffee_script/narwhal/js/loader.js
Normal file
@@ -0,0 +1,20 @@
|
||||
(function(){
|
||||
|
||||
// This (javascript) file is generated from lib/coffee_script/narwhal/loader.cs
|
||||
var coffeescript = null;
|
||||
var factories = {
|
||||
};
|
||||
var loader = {
|
||||
// Reload the coffee-script environment from source.
|
||||
reload: function(topId, path) {
|
||||
coffeescript = coffeescript || require('coffee-script');
|
||||
factories[topId] = coffeescript.makeNarwhalFactory(path);
|
||||
return factories[topId];
|
||||
},
|
||||
// Ensure that the coffee-script environment is loaded.
|
||||
load: function(topId, path) {
|
||||
return factories[topId] = factories[topId] || this.reload(topId, path);
|
||||
}
|
||||
};
|
||||
require.loader.loaders.unshift([".cs", loader]);
|
||||
})();
|
||||
1
lib/coffee_script/narwhal/launcher.cs
Normal file
1
lib/coffee_script/narwhal/launcher.cs
Normal file
@@ -0,0 +1 @@
|
||||
require("coffee-script").run(system.args)
|
||||
19
lib/coffee_script/narwhal/loader.cs
Normal file
19
lib/coffee_script/narwhal/loader.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
# This (javascript) file is generated from lib/coffee_script/narwhal/loader.cs
|
||||
|
||||
coffeescript: null
|
||||
factories: {}
|
||||
|
||||
loader: {
|
||||
|
||||
# Reload the coffee-script environment from source.
|
||||
reload: topId, path =>
|
||||
coffeescript ||: require('coffee-script')
|
||||
factories[topId]: coffeescript.makeNarwhalFactory(path).
|
||||
|
||||
# Ensure that the coffee-script environment is loaded.
|
||||
load: topId, path =>
|
||||
factories[topId] ||: this.reload(topId, path).
|
||||
|
||||
}
|
||||
|
||||
require.loader.loaders.unshift([".cs", loader])
|
||||
@@ -77,7 +77,7 @@ module CoffeeScript
|
||||
# If this is the top-level Expressions, wrap everything in a safety closure.
|
||||
def root_compile(o={})
|
||||
indent = o[:no_wrap] ? '' : TAB
|
||||
code = compile(:indent => indent, :scope => Scope.new)
|
||||
code = compile(o.merge(:indent => indent, :scope => Scope.new))
|
||||
code.gsub!(STRIP_TRAILING_WHITESPACE, '')
|
||||
o[:no_wrap] ? code : "(function(){\n#{code}\n})();"
|
||||
end
|
||||
@@ -340,9 +340,9 @@ module CoffeeScript
|
||||
return write("#{@variable}: #{@value.compile(o)}") if @context == :object
|
||||
return write("#{name} = #{@value.compile(o)}#{postfix}") if @variable.properties? && !@value.custom_assign?
|
||||
defined = o[:scope].find(name)
|
||||
def_part = defined || @variable.properties? ? "" : "var #{name};\n#{o[:indent]}"
|
||||
def_part = defined || @variable.properties? || o[:no_wrap] ? "" : "var #{name};\n#{o[:indent]}"
|
||||
return write(def_part + @value.compile(o)) if @value.custom_assign?
|
||||
def_part = defined ? name : "var #{name}"
|
||||
def_part = defined || o[:no_wrap] ? name : "var #{name}"
|
||||
val_part = @value.compile(o).sub(LEADING_VAR, '')
|
||||
write("#{def_part} = #{val_part}#{postfix}")
|
||||
end
|
||||
@@ -357,8 +357,13 @@ module CoffeeScript
|
||||
'and' => '&&',
|
||||
'or' => '||',
|
||||
'is' => '===',
|
||||
"aint" => "!==",
|
||||
"isnt" => "!==",
|
||||
'not' => '!',
|
||||
'+:' => '+=',
|
||||
'-:' => '-=',
|
||||
'*:' => '*=',
|
||||
'/:' => '/=',
|
||||
'%:' => '%='
|
||||
}
|
||||
CONDITIONALS = ['||:', '&&:']
|
||||
PREFIX_OPERATORS = ['typeof', 'delete']
|
||||
@@ -411,6 +416,7 @@ module CoffeeScript
|
||||
indent = o[:indent]
|
||||
o[:indent] += TAB
|
||||
o.delete(:assign)
|
||||
o.delete(:no_wrap)
|
||||
@params.each {|id| o[:scope].find(id.to_s) }
|
||||
code = @body.compile(o)
|
||||
write("function(#{@params.join(', ')}) {\n#{code}\n#{indent}}")
|
||||
@@ -473,6 +479,7 @@ module CoffeeScript
|
||||
|
||||
def compile(o={})
|
||||
o = super(o)
|
||||
o.delete(:return)
|
||||
indent = o[:indent] + TAB
|
||||
cond = @condition.compile(o.merge(:no_paren => true))
|
||||
write("while (#{cond}) {\n#{@body.compile(o.merge(:indent => indent))}\n#{o[:indent]}}")
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,7 @@ module CoffeeScript
|
||||
def initialize(parent=nil)
|
||||
@parent = parent
|
||||
@variables = {}
|
||||
@temp_variable = @parent ? @parent.temp_variable : 'a'
|
||||
@temp_variable = @parent ? @parent.temp_variable : '__a'
|
||||
end
|
||||
|
||||
# Look up a variable in lexical scope, or declare it if not found.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "coffee-script",
|
||||
"lib": "lib-js",
|
||||
"preload": ["coffee-script/loader"],
|
||||
"lib": "lib/coffee_script/narwhal/js",
|
||||
"preload": ["loader"],
|
||||
"description": "Unfancy JavaScript",
|
||||
"keywords": ["javascript", "language"],
|
||||
"author": "Jeremy Ashkenas",
|
||||
"version": "0.1.2"
|
||||
"version": "0.1.3"
|
||||
}
|
||||
|
||||
2
test/fixtures/each.cs
vendored
2
test/fixtures/each.cs
vendored
@@ -10,5 +10,5 @@ _.each: obj, iterator, context =>
|
||||
else
|
||||
iterator.call(context, obj[key], key, obj) for key in _.keys(obj)..
|
||||
catch e
|
||||
throw e if e aint breaker.
|
||||
throw e if e isnt breaker.
|
||||
obj.
|
||||
14
test/fixtures/each.js
vendored
14
test/fixtures/each.js
vendored
@@ -8,16 +8,16 @@
|
||||
if (obj.forEach) {
|
||||
obj.forEach(iterator, context);
|
||||
} else if (_.isArray(obj) || _.isArguments(obj)) {
|
||||
var a = obj;
|
||||
for (var b=0, c=a.length; b<c; b++) {
|
||||
var item = a[b];
|
||||
var i = b;
|
||||
var __a = obj;
|
||||
for (var __b=0, __c=__a.length; __b<__c; __b++) {
|
||||
var item = __a[__b];
|
||||
var i = __b;
|
||||
iterator.call(context, item, i, obj);
|
||||
}
|
||||
} else {
|
||||
var d = _.keys(obj);
|
||||
for (var e=0, f=d.length; e<f; e++) {
|
||||
var key = d[e];
|
||||
var __d = _.keys(obj);
|
||||
for (var __e=0, __f=__d.length; __e<__f; __e++) {
|
||||
var key = __d[__e];
|
||||
iterator.call(context, obj[key], key, obj);
|
||||
}
|
||||
}
|
||||
|
||||
2
test/fixtures/each.tokens
vendored
2
test/fixtures/each.tokens
vendored
@@ -1 +1 @@
|
||||
[[:COMMENT, [" The cornerstone, an each implementation.", " Handles objects implementing forEach, arrays, and raw objects."]], ["\n", "\n"], [:IDENTIFIER, "_"], [:PROPERTY_ACCESS, "."], [:IDENTIFIER, "each"], [":", ":"], [:PARAM, "obj"], [",", ","], [:PARAM, "iterator"], [",", ","], [:PARAM, "context"], ["=>", "=>"], ["\n", "\n"], [:IDENTIFIER, "index"], [":", ":"], [:NUMBER, "0"], ["\n", "\n"], [:TRY, "try"], ["\n", "\n"], [:IF, "if"], [:IDENTIFIER, "obj"], [:PROPERTY_ACCESS, "."], [:IDENTIFIER, "forEach"], ["\n", "\n"], [:IDENTIFIER, "obj"], [:PROPERTY_ACCESS, "."], [:IDENTIFIER, "forEach"], ["(", "("], [:IDENTIFIER, "iterator"], [",", ","], [:IDENTIFIER, "context"], [")", ")"], ["\n", "\n"], [:ELSE, "else"], [:IF, "if"], [:IDENTIFIER, "_"], [:PROPERTY_ACCESS, "."], [:IDENTIFIER, "isArray"], ["(", "("], [:IDENTIFIER, "obj"], [")", ")"], [:OR, "or"], [:IDENTIFIER, "_"], [:PROPERTY_ACCESS, "."], [:IDENTIFIER, "isArguments"], ["(", "("], [:IDENTIFIER, "obj"], [")", ")"], ["\n", "\n"], [:IDENTIFIER, "iterator"], [:PROPERTY_ACCESS, "."], [:IDENTIFIER, "call"], ["(", "("], [:IDENTIFIER, "context"], [",", ","], [:IDENTIFIER, "item"], [",", ","], [:IDENTIFIER, "i"], [",", ","], [:IDENTIFIER, "obj"], [")", ")"], [:FOR, "for"], [:IDENTIFIER, "item"], [",", ","], [:IDENTIFIER, "i"], [:IN, "in"], [:IDENTIFIER, "obj"], [".", "."], ["\n", "\n"], [:ELSE, "else"], ["\n", "\n"], [:IDENTIFIER, "iterator"], [:PROPERTY_ACCESS, "."], [:IDENTIFIER, "call"], ["(", "("], [:IDENTIFIER, "context"], [",", ","], [:IDENTIFIER, "obj"], ["[", "["], [:IDENTIFIER, "key"], ["]", "]"], [",", ","], [:IDENTIFIER, "key"], [",", ","], [:IDENTIFIER, "obj"], [")", ")"], [:FOR, "for"], [:IDENTIFIER, "key"], [:IN, "in"], [:IDENTIFIER, "_"], [:PROPERTY_ACCESS, "."], [:IDENTIFIER, "keys"], ["(", "("], [:IDENTIFIER, "obj"], [")", ")"], [".", "."], [".", "."], ["\n", "\n"], [:CATCH, "catch"], [:IDENTIFIER, "e"], ["\n", "\n"], [:THROW, "throw"], [:IDENTIFIER, "e"], [:IF, "if"], [:IDENTIFIER, "e"], [:AINT, "aint"], [:IDENTIFIER, "breaker"], [".", "."], ["\n", "\n"], [:IDENTIFIER, "obj"], [".", "."]]
|
||||
[[:COMMENT, [" The cornerstone, an each implementation.", " Handles objects implementing forEach, arrays, and raw objects."]], ["\n", "\n"], [:IDENTIFIER, "_"], [:PROPERTY_ACCESS, "."], [:IDENTIFIER, "each"], [":", ":"], [:PARAM, "obj"], [",", ","], [:PARAM, "iterator"], [",", ","], [:PARAM, "context"], ["=>", "=>"], ["\n", "\n"], [:IDENTIFIER, "index"], [":", ":"], [:NUMBER, "0"], ["\n", "\n"], [:TRY, "try"], ["\n", "\n"], [:IF, "if"], [:IDENTIFIER, "obj"], [:PROPERTY_ACCESS, "."], [:IDENTIFIER, "forEach"], ["\n", "\n"], [:IDENTIFIER, "obj"], [:PROPERTY_ACCESS, "."], [:IDENTIFIER, "forEach"], ["(", "("], [:IDENTIFIER, "iterator"], [",", ","], [:IDENTIFIER, "context"], [")", ")"], ["\n", "\n"], [:ELSE, "else"], [:IF, "if"], [:IDENTIFIER, "_"], [:PROPERTY_ACCESS, "."], [:IDENTIFIER, "isArray"], ["(", "("], [:IDENTIFIER, "obj"], [")", ")"], [:OR, "or"], [:IDENTIFIER, "_"], [:PROPERTY_ACCESS, "."], [:IDENTIFIER, "isArguments"], ["(", "("], [:IDENTIFIER, "obj"], [")", ")"], ["\n", "\n"], [:IDENTIFIER, "iterator"], [:PROPERTY_ACCESS, "."], [:IDENTIFIER, "call"], ["(", "("], [:IDENTIFIER, "context"], [",", ","], [:IDENTIFIER, "item"], [",", ","], [:IDENTIFIER, "i"], [",", ","], [:IDENTIFIER, "obj"], [")", ")"], [:FOR, "for"], [:IDENTIFIER, "item"], [",", ","], [:IDENTIFIER, "i"], [:IN, "in"], [:IDENTIFIER, "obj"], [".", "."], ["\n", "\n"], [:ELSE, "else"], ["\n", "\n"], [:IDENTIFIER, "iterator"], [:PROPERTY_ACCESS, "."], [:IDENTIFIER, "call"], ["(", "("], [:IDENTIFIER, "context"], [",", ","], [:IDENTIFIER, "obj"], ["[", "["], [:IDENTIFIER, "key"], ["]", "]"], [",", ","], [:IDENTIFIER, "key"], [",", ","], [:IDENTIFIER, "obj"], [")", ")"], [:FOR, "for"], [:IDENTIFIER, "key"], [:IN, "in"], [:IDENTIFIER, "_"], [:PROPERTY_ACCESS, "."], [:IDENTIFIER, "keys"], ["(", "("], [:IDENTIFIER, "obj"], [")", ")"], [".", "."], [".", "."], ["\n", "\n"], [:CATCH, "catch"], [:IDENTIFIER, "e"], ["\n", "\n"], [:THROW, "throw"], [:IDENTIFIER, "e"], [:IF, "if"], [:IDENTIFIER, "e"], [:ISNT, "isnt"], [:IDENTIFIER, "breaker"], [".", "."], ["\n", "\n"], [:IDENTIFIER, "obj"], [".", "."]]
|
||||
14
test/fixtures/each_no_wrap.js
vendored
14
test/fixtures/each_no_wrap.js
vendored
@@ -7,16 +7,16 @@ _.each = function(obj, iterator, context) {
|
||||
if (obj.forEach) {
|
||||
obj.forEach(iterator, context);
|
||||
} else if (_.isArray(obj) || _.isArguments(obj)) {
|
||||
var a = obj;
|
||||
for (var b=0, c=a.length; b<c; b++) {
|
||||
var item = a[b];
|
||||
var i = b;
|
||||
var __a = obj;
|
||||
for (var __b=0, __c=__a.length; __b<__c; __b++) {
|
||||
var item = __a[__b];
|
||||
var i = __b;
|
||||
iterator.call(context, item, i, obj);
|
||||
}
|
||||
} else {
|
||||
var d = _.keys(obj);
|
||||
for (var e=0, f=d.length; e<f; e++) {
|
||||
var key = d[e];
|
||||
var __d = _.keys(obj);
|
||||
for (var __e=0, __f=__d.length; __e<__f; __e++) {
|
||||
var key = __d[__e];
|
||||
iterator.call(context, obj[key], key, obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
nums: n * n for n in [1, 2, 3] if n % 2 aint 0.
|
||||
nums: n * n for n in [1, 2, 3] if n % 2 isnt 0.
|
||||
result: n * 2 for n in nums.
|
||||
|
||||
print(result.join(',') is '2,18')
|
||||
21
test/fixtures/execution/array_comprehension.js
vendored
21
test/fixtures/execution/array_comprehension.js
vendored
@@ -1,21 +0,0 @@
|
||||
(function(){
|
||||
var nums;
|
||||
var a = [1, 2, 3];
|
||||
var d = [];
|
||||
for (var b=0, c=a.length; b<c; b++) {
|
||||
var n = a[b];
|
||||
if (n % 2 !== 0) {
|
||||
nums = d.push(n * n);
|
||||
}
|
||||
}
|
||||
nums = d;
|
||||
var result;
|
||||
var e = nums;
|
||||
var h = [];
|
||||
for (var f=0, g=e.length; f<g; f++) {
|
||||
n = e[f];
|
||||
h[f] = n * 2;
|
||||
}
|
||||
result = h;
|
||||
print(result.join(',') === '2,18');
|
||||
})();
|
||||
@@ -1,9 +0,0 @@
|
||||
(function(){
|
||||
var result;
|
||||
try {
|
||||
result = nonexistent * missing;
|
||||
} catch (error) {
|
||||
result = true;
|
||||
}
|
||||
print(result);
|
||||
})();
|
||||
27
test/fixtures/execution/calling_super.js
vendored
27
test/fixtures/execution/calling_super.js
vendored
@@ -1,27 +0,0 @@
|
||||
(function(){
|
||||
var Base = function() {
|
||||
};
|
||||
Base.prototype.func = function(string) {
|
||||
return 'zero/' + string;
|
||||
};
|
||||
var FirstChild = function() {
|
||||
};
|
||||
FirstChild.prototype.__proto__ = new Base();
|
||||
FirstChild.prototype.func = function(string) {
|
||||
return FirstChild.prototype.__proto__.func.call(this, 'one/') + string;
|
||||
};
|
||||
var SecondChild = function() {
|
||||
};
|
||||
SecondChild.prototype.__proto__ = new FirstChild();
|
||||
SecondChild.prototype.func = function(string) {
|
||||
return SecondChild.prototype.__proto__.func.call(this, 'two/') + string;
|
||||
};
|
||||
var ThirdChild = function() {
|
||||
};
|
||||
ThirdChild.prototype.__proto__ = new SecondChild();
|
||||
ThirdChild.prototype.func = function(string) {
|
||||
return ThirdChild.prototype.__proto__.func.call(this, 'three/') + string;
|
||||
};
|
||||
var result = (new ThirdChild()).func('four');
|
||||
print(result === 'zero/one/two/three/four');
|
||||
})();
|
||||
@@ -1,6 +0,0 @@
|
||||
(function(){
|
||||
var a = b = d = true;
|
||||
var c = false;
|
||||
var result = a ? b ? c ? false : d ? true : null : null : null;
|
||||
print(result);
|
||||
})();
|
||||
10
test/fixtures/execution/keyword_operators.js
vendored
10
test/fixtures/execution/keyword_operators.js
vendored
@@ -1,10 +0,0 @@
|
||||
(function(){
|
||||
var a = 5;
|
||||
var atype = typeof a;
|
||||
var b = "hello";
|
||||
var btype = typeof b;
|
||||
var Klass = function() {
|
||||
};
|
||||
var k = new Klass();
|
||||
print(atype === 'number' && btype === 'string' && k instanceof Klass);
|
||||
})();
|
||||
4
test/fixtures/execution/test_everything.cs
vendored
4
test/fixtures/execution/test_everything.cs
vendored
@@ -6,7 +6,7 @@ func: =>
|
||||
a--.
|
||||
|
||||
c: {
|
||||
text: b
|
||||
"text": b
|
||||
}
|
||||
|
||||
c: 'error' unless 42 > 41
|
||||
@@ -16,7 +16,7 @@ func: =>
|
||||
else
|
||||
c.text + '---'.
|
||||
|
||||
c.list: let for let in c.text.split('') if let is '-'.
|
||||
c.list: l for l in c.text.split('') if l is '-'.
|
||||
|
||||
c.single: c.list[1, 1][0].
|
||||
|
||||
|
||||
29
test/fixtures/execution/test_everything.js
vendored
29
test/fixtures/execution/test_everything.js
vendored
@@ -1,29 +0,0 @@
|
||||
(function(){
|
||||
var func = function() {
|
||||
var a = 3;
|
||||
var b = [];
|
||||
while (a >= 0) {
|
||||
b.push('o');
|
||||
a--;
|
||||
}
|
||||
var c = {
|
||||
text: b
|
||||
};
|
||||
if (!(42 > 41)) {
|
||||
c = 'error';
|
||||
}
|
||||
c.text = false ? 'error' : c.text + '---';
|
||||
var d = c.text.split('');
|
||||
var g = [];
|
||||
for (var e=0, f=d.length; e<f; e++) {
|
||||
var let = d[e];
|
||||
if (let === '-') {
|
||||
c.list = g.push(let);
|
||||
}
|
||||
}
|
||||
c.list = g;
|
||||
c.single = c.list.slice(1, 1 + 1)[0];
|
||||
return c.single;
|
||||
};
|
||||
print(func() === '-');
|
||||
})();
|
||||
16
test/fixtures/execution/test_switch.js
vendored
16
test/fixtures/execution/test_switch.js
vendored
@@ -1,16 +0,0 @@
|
||||
(function(){
|
||||
var num = 10;
|
||||
var result;
|
||||
if (num === 5) {
|
||||
result = false;
|
||||
} else if (num === 'a') {
|
||||
result = false;
|
||||
} else if (num === 10) {
|
||||
result = true;
|
||||
} else if (num === 11) {
|
||||
result = false;
|
||||
} else {
|
||||
result = false;
|
||||
}
|
||||
print(result);
|
||||
})();
|
||||
@@ -3,19 +3,11 @@ require 'test_helper'
|
||||
class ExecutionTest < Test::Unit::TestCase
|
||||
|
||||
NO_WARNINGS = /\A(0 error\(s\), 0 warning\(s\)\n)+\Z/
|
||||
ALLS_WELL = /\A\n?(true\n)+\Z/
|
||||
|
||||
def test_execution_of_coffeescript
|
||||
`bin/coffee-script test/fixtures/execution/*.cs`
|
||||
sources = Dir['test/fixtures/execution/*.js'].map {|f| File.expand_path(f) }
|
||||
starting_place = File.expand_path(Dir.pwd)
|
||||
Dir.chdir('/Users/jashkenas/Desktop/Beauty/Code/v8')
|
||||
sources.each do |source|
|
||||
suceeded = `./shell #{source}`.chomp.to_sym == :true
|
||||
puts "failed: #{source}" unless suceeded
|
||||
assert suceeded
|
||||
end
|
||||
ensure
|
||||
Dir.chdir(starting_place)
|
||||
sources = ['test/fixtures/execution/*.cs'].join(' ')
|
||||
assert `bin/coffee-script -r #{sources}`.match(ALLS_WELL)
|
||||
end
|
||||
|
||||
def test_lintless_coffeescript
|
||||
|
||||
Reference in New Issue
Block a user