Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6ebd8296a437
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1fff297b7f15
Choose a head ref
  • 3 commits
  • 8 files changed
  • 1 contributor

Commits on Jun 2, 2014

  1. Copy the full SHA
    0e9cb95 View commit details
  2. Copy the full SHA
    4c35c8a View commit details
  3. 1
    Copy the full SHA
    1fff297 View commit details
Showing with 39 additions and 8 deletions.
  1. +2 −0 CHANGELOG.md
  2. +5 −1 lib/opal/nodes/literal.rb
  3. +7 −3 lib/opal/parser/grammar.rb
  4. +3 −0 lib/opal/parser/grammar.y
  5. +1 −1 opal/opal.rb
  6. +7 −0 spec/cli/parser/string_spec.rb
  7. +11 −0 spec/opal/core/string_spec.rb
  8. +3 −3 spec/opal/stdlib/erb/erb_spec.rb
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@
* Fix Range.new to raise `ArgumentError` on contructor values that cannot
be compared

* Fix compiler bug where Contiguous strings were not getting concatenated.

## 0.6.2 2014-04-25

* Added Range#size
6 changes: 5 additions & 1 deletion lib/opal/nodes/literal.rb
Original file line number Diff line number Diff line change
@@ -112,8 +112,12 @@ def compile
push ")"
elsif part.type == :str
push part[1].inspect
elsif part.type == :dstr
push "("
push expr(part)
push ")"
else
raise "Bad dstr part"
raise "Bad dstr part #{part.inspect}"
end

wrap '(', ')' if recv?
10 changes: 7 additions & 3 deletions lib/opal/parser/grammar.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lib/opal/parser/grammar.y
Original file line number Diff line number Diff line change
@@ -1188,6 +1188,9 @@ opt_block_args_tail: tCOMMA block_args_tail

string: string1
| string string1
{
result = str_append val[0], val[1]
}

string1: tSTRING_BEG string_contents tSTRING_END
{
2 changes: 1 addition & 1 deletion opal/opal.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'corelib/runtime.js'
require 'corelib/runtime'
require 'corelib/helpers'
require 'corelib/module'
require 'corelib/class'
7 changes: 7 additions & 0 deletions spec/cli/parser/string_spec.rb
Original file line number Diff line number Diff line change
@@ -237,6 +237,13 @@
}.should raise_error(Exception)
end
end

describe "contiguous strings" do
it "concatenates parts" do
parsed('"a" "b"').should == [:dstr, "a", [:str, "b"]]
end
end

end

describe "Heredocs" do
11 changes: 11 additions & 0 deletions spec/opal/core/string_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'spec_helper'

describe "String" do
it "handles contiguous parts correctly" do
str = "a" "b"
str.should == "ab"

str2 = "d" "#{str}"
str2.should == "dab"
end
end
6 changes: 3 additions & 3 deletions spec/opal/stdlib/erb/erb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'erb'
require File.expand_path('../simple.opalerb', __FILE__)
require File.expand_path('../quoted.opalerb', __FILE__)
require File.expand_path('../inline_block.opalerb', __FILE__)
require File.expand_path('../simple', __FILE__)
require File.expand_path('../quoted', __FILE__)
require File.expand_path('../inline_block', __FILE__)

describe "ERB files" do
before :each do