Permalink
Browse files

added some execution test

  • Loading branch information...
1 parent 417753b commit b743e3219a219b60b420ebc2c4d7f6d1a614d329 @jashkenas committed Dec 24, 2009
View
2 README
@@ -35,4 +35,4 @@
http://github.com/jashkenas/coffee-script/issues/
The source repository:
- git://github.com/jashkenas/coffee-script.git
+ git://github.com/jashkenas/coffee-script.git
View
13 TODO
@@ -1,13 +0,0 @@
-TODO:
-
-* Finish the doc page.
-
-* Write a test suite that checks the JS evaluation.
-
-* Is it possible to close blocks (functions, ifs, trys) without an explicit
- block delimiter or significant whitespace?
-
-* Is it possible to pass comments through cleanly and have them show up on
- the other end? This includes comments in the middle of array and object
- literals, and argument lists.
-
@@ -32,7 +32,7 @@
<p>
CoffeeScript is a little language that compiles into JavaScript. Think
of it as JavaScript's less ostentatious kid brother &mdash; the same genes,
- the same accent, but a different sense of style. Apart from a handful of
+ roughly the same height, but a different sense of style. Apart from a handful of
bonus goodies, statements in CoffeeScript correspond one-to-one with their
equivalent in JavaScript, it's just another way of saying it.
</p>
@@ -72,6 +72,7 @@
<a href="#switch">Switch/Case/Else</a><br />
<a href="#try">Try/Catch/Finally</a><br />
<a href="#strings">Multiline Strings</a><br />
+ <a href="#change_log">Change Log</a><br />
</p>
<h2 id="overview">Mini Overview</h2>
@@ -81,9 +82,14 @@
<%= 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.
+ </p>
<pre>
-sudo gem install coffee-script</pre>
+gem install coffee-script</pre>
<p>
Installing the gem provides the <tt>coffee-script</tt> command, which can
@@ -339,7 +345,7 @@ coffee-script --print app/scripts/*.cs > concatenation.js</pre>
<p id="switch">
<b class="header">Switch/Case/Else</b>
<b>Switch</b> statements in JavaScript are rather broken. You can only
- do string comparisons, and need to remember to <b>break</b> at the end of
+ do comparisons based on string equality, and need to remember to <b>break</b> at the end of
every <b>case</b> statement to avoid accidentally falling through to
the default case. CoffeeScript
compiles <b>switch</b> statements into JavaScript if-else chains, allowing you to
@@ -352,7 +358,7 @@ coffee-script --print app/scripts/*.cs > concatenation.js</pre>
<p id="try">
<b class="header">Try/Catch/Finally</b>
Try/catch statements are just about the same as JavaScript (although
- they work as expressions). No braces required.
+ they work as expressions).
</p>
<%= code_for('try') %>
@@ -361,6 +367,13 @@ coffee-script --print app/scripts/*.cs > concatenation.js</pre>
Multiline strings are allowed in CoffeeScript.
</p>
<%= code_for('strings', 'moby_dick') %>
+
+ <h2 id="change_log">Change Log</h2>
+
+ <p>
+ <b class="header" style="margin-top: 25px;">0.1.0</b>
+ Initial CoffeeScript release.
+ </p>
</div>
View
@@ -18,7 +18,7 @@ <h1><sub style="font-size: 100px;">&#9749;</sub> CoffeeScript</h1>
<p>
CoffeeScript is a little language that compiles into JavaScript. Think
of it as JavaScript's less ostentatious kid brother &mdash; the same genes,
- the same accent, but a different sense of style. Apart from a handful of
+ roughly the same height, but a different sense of style. Apart from a handful of
bonus goodies, statements in CoffeeScript correspond one-to-one with their
equivalent in JavaScript, it's just another way of saying it.
</p>
@@ -58,6 +58,7 @@ <h2>Table of Contents</h2>
<a href="#switch">Switch/Case/Else</a><br />
<a href="#try">Try/Catch/Finally</a><br />
<a href="#strings">Multiline Strings</a><br />
+ <a href="#change_log">Change Log</a><br />
</p>
<h2 id="overview">Mini Overview</h2>
@@ -151,9 +152,14 @@ <h2 id="overview">Mini Overview</h2>
;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.
+ </p>
<pre>
-sudo gem install coffee-script</pre>
+gem install coffee-script</pre>
<p>
Installing the gem provides the <tt>coffee-script</tt> command, which can
@@ -654,7 +660,7 @@ <h2>Language Reference</h2>
<p id="switch">
<b class="header">Switch/Case/Else</b>
<b>Switch</b> statements in JavaScript are rather broken. You can only
- do string comparisons, and need to remember to <b>break</b> at the end of
+ do comparisons based on string equality, and need to remember to <b>break</b> at the end of
every <b>case</b> statement to avoid accidentally falling through to
the default case. CoffeeScript
compiles <b>switch</b> statements into JavaScript if-else chains, allowing you to
@@ -690,7 +696,7 @@ <h2>Language Reference</h2>
<p id="try">
<b class="header">Try/Catch/Finally</b>
Try/catch statements are just about the same as JavaScript (although
- they work as expressions). No braces required.
+ they work as expressions).
</p>
<div class='code'><pre class="idle"><span class="Keyword">try</span>
all_hell_breaks_loose()
@@ -733,6 +739,13 @@ <h2>Language Reference</h2>
about a little and see the watery part of the \
world...";
;alert(moby_dick);'>run: moby_dick</button><br class='clear' /></div>
+
+ <h2 id="change_log">Change Log</h2>
+
+ <p>
+ <b class="header" style="margin-top: 25px;">0.1.0</b>
+ Initial CoffeeScript release.
+ </p>
</div>
@@ -507,7 +507,7 @@ def compile(o={})
return_result = "\n#{o[:indent]}#{return_result}"
if @filter
body = CallNode.new(ValueNode.new(LiteralNode.new(rvar), [AccessorNode.new('push')]), [@body])
- body = IfNode.new(@filter, body, nil, :statement)
+ body = IfNode.new(@filter, body, nil, :statement => true)
save_result = ''
suffix = ''
end
@@ -0,0 +1,4 @@
+nums: n * n for n in [1, 2, 3] if n % 2 aint 0.
+result: n * 2 for n in nums.
+
+print(result.join(',') is '2,18')
@@ -0,0 +1,21 @@
+(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');
+})();
@@ -0,0 +1,6 @@
+result: try
+ nonexistent * missing
+catch error
+ true.
+
+print(result)
@@ -0,0 +1,9 @@
+(function(){
+ var result;
+ try {
+ result = nonexistent * missing;
+ } catch (error) {
+ result = true;
+ }
+ print(result);
+})();
@@ -0,0 +1,11 @@
+a: b: d: true
+c: false
+
+result: if a
+ if b
+ if c then false
+ else
+ if d
+ true....
+
+print(result)
@@ -0,0 +1,6 @@
+(function(){
+ var a = b = d = true;
+ var c = false;
+ var result = a ? b ? c ? false : d ? true : null : null : null;
+ print(result);
+})();
@@ -0,0 +1,17 @@
+require 'test_helper'
+
+class ExecutionTest < Test::Unit::TestCase
+
+ 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|
+ assert `./shell #{source}`.chomp.to_sym == :true
+ end
+ ensure
+ Dir.chdir(starting_place)
+ end
+
+end

0 comments on commit b743e32

Please sign in to comment.