Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Seperate more parser and compiler specs into correct location
- Loading branch information
1 parent
7aeae27
commit 7bd6343
Showing
4 changed files
with
50 additions
and
66 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require File.expand_path('../spec_helper', __FILE__) | ||
|
||
describe Opal::Compiler do | ||
it "should compile simple ruby values" do | ||
expect_compiled("3.142").to include("return 3.142") | ||
expect_compiled("123e1").to include("return 1230") | ||
expect_compiled("123E+10").to include("return 1230000000000") | ||
expect_compiled("false").to include("return false") | ||
expect_compiled("true").to include("return true") | ||
expect_compiled("nil").to include("return nil") | ||
end | ||
|
||
it "should compile ruby strings" do | ||
expect_compiled('"hello world"').to include('return "hello world"') | ||
expect_compiled('"hello #{100}"').to include('"hello "', '100') | ||
end | ||
|
||
it "should compile method calls" do | ||
expect_compiled("self.inspect").to include("$inspect()") | ||
expect_compiled("self.map { |a| a + 10 }").to include("$map") | ||
end | ||
|
||
it "should compile constant lookups" do | ||
expect_compiled("Object").to include("scope.Object") | ||
expect_compiled("Array").to include("scope.Array") | ||
end | ||
|
||
def expect_compiled(source) | ||
expect(Opal::Compiler.new.compile source) | ||
end | ||
end |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require File.expand_path('../../spec_helper', __FILE__) | ||
|
||
describe "Multiline comments" do | ||
it "parses multiline comments and ignores them" do | ||
opal_parse("=begin\nfoo\n=end\n100").should == [:int, 100] | ||
end | ||
|
||
it "raises an exception if not closed before end of file" do | ||
lambda { opal_parse("=begin\nfoo\nbar") }.should raise_error(Exception, /embedded document meets end of file/) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.