Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## HEAD (unreleased)

- Parse error once and not twice if there's more than one available (https://github.com/zombocom/dead_end/pull/57)

## 1.1.4

- Avoid including demo gif in built gem (https://github.com/zombocom/dead_end/pull/53)
Expand Down
2 changes: 2 additions & 0 deletions lib/dead_end/who_dis_syntax_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def call
end

def on_parse_error(msg)
return if @error_symbol && @unmatched_symbol

@error = msg
@unmatched_symbol = :unknown

Expand Down
27 changes: 25 additions & 2 deletions spec/unit/who_dis_syntax_error_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module DeadEnd
RSpec.describe WhoDisSyntaxError do
it "determines the type of syntax error" do
it "determines the type of syntax error to be an unmatched end" do
expect(
WhoDisSyntaxError.new("def foo;").call.error_symbol
).to eq(:missing_end)
Expand All @@ -18,7 +18,7 @@ module DeadEnd
).to eq(:end)
end

it "" do
it "determines the type of syntax error to be an unmatched pipe" do
source = <<~EOM
class Blerg
Foo.call do |a
Expand All @@ -38,5 +38,28 @@ class Foo
DeadEnd.invalid_type(source).unmatched_symbol
).to eq(:|)
end

it "determines the type of syntax error to be an unmatched bracket" do
source = <<~EOM
module Hey
class Foo
def initialize
[1,2,3
end

def call
end
end
end
EOM

expect(
DeadEnd.invalid_type(source).error_symbol
).to eq(:unmatched_syntax)

expect(
DeadEnd.invalid_type(source).unmatched_symbol
).to eq(:"]")
end
end
end