-
-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix lots of heredoc parsing bugs (needs cleanup)
- Loading branch information
1 parent
0a9aad2
commit b68dc4e
Showing
3 changed files
with
107 additions
and
12 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
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,30 @@ | ||
require 'spec_helper' | ||
|
||
describe "Heredocs" do | ||
|
||
it "parses as a s(:str)" do | ||
opal_parse("a = <<-FOO\nbar\nFOO")[2].should == [:str, "bar\n"] | ||
end | ||
|
||
it "allows start marker to be wrapped in quotes" do | ||
opal_parse("a = <<-'FOO'\nbar\nFOO")[2].should == [:str, "bar\n"] | ||
opal_parse("a = <<-\"FOO\"\nbar\nFOO")[2].should == [:str, "bar\n"] | ||
end | ||
|
||
it "does not parse EOS unless beginning of line" do | ||
opal_parse("<<-FOO\ncontentFOO\nFOO").should == [:str, "contentFOO\n"] | ||
end | ||
|
||
it "does not parse EOS unless end of line" do | ||
opal_parse("<<-FOO\nsome FOO content\nFOO").should == [:str, "some FOO content\n"] | ||
end | ||
|
||
it "parses postfix code as if it appeared after heredoc" do | ||
opal_parse("<<-FOO.class\ncode\nFOO").should == [:call, [:str, "code\n"], :class, [:arglist]] | ||
opal_parse("bar(<<-FOO, 1, 2, 3)\ncode\nFOO").should == [:call, nil, :bar, | ||
[:arglist, [:str, "code\n"], | ||
[:int, 1], | ||
[:int, 2], | ||
[:int, 3]]] | ||
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