Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Haml support from to Haml 5.x #1397

Merged
merged 7 commits into from Sep 12, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Handle `String.new <<` as a string

  • Loading branch information...
Justin Collins
Justin Collins committed Sep 11, 2019
commit 931bed18481679086a7102bc063ecf9b1d727d40
@@ -249,6 +249,9 @@ def process_call exp
end
env[target_var] = target
return first_arg
elsif new_string? target
env[target_var] = first_arg
return first_arg
elsif array? target
target << first_arg
env[target_var] = target
@@ -1198,6 +1201,13 @@ def raise? exp
call? exp and exp.method == :raise
end

STRING_NEW = s(:call, s(:const, :String), :new)

# String.new ?
def new_string? exp
exp == STRING_NEW
end

#Set variable to given value.
#Creates "branched" versions of values when appropriate.
#Avoids creating multiple branched versions inside same
@@ -66,6 +66,14 @@ def test_string_append
RUBY
end

def test_string_new_append
assert_alias "'hello world'", <<-RUBY
x = String.new
x << "hello" << " " << "world"
x
RUBY
end

def test_string_append_call
assert_alias "'hello ' << params[:x]", <<-RUBY
x = ""
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.