Skip to content

Commit

Permalink
Merge pull request #1454 from mbj/fix/ast-docs
Browse files Browse the repository at this point in the history
Change to verified mutation generation
  • Loading branch information
mbj authored Jun 29, 2024
2 parents e0f16de + ff688d8 commit 147627e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/ast-pattern.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ specific:
```
send
{ selector = info
, receiver = send{selector=logger}
receiver = send{selector=logger}
}
```

Expand Down Expand Up @@ -84,7 +84,7 @@ But could be made required via:
block
{ receiver = send
{ selector = log
, receiver = send{selector=logger}
receiver = send{selector=logger}
}
}
```
42 changes: 42 additions & 0 deletions spec/unit/mutant/ast/pattern_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,47 @@ def apply
expect(apply).to eql(right(expected_node))
end
end

context 'example from docs' do
let(:string) { <<~'PATTERN' }
block
{ receiver = send
{ selector = log
receiver = send{selector=logger}
}
}
PATTERN

let(:expected_node) do
Mutant::AST::Pattern::Node.new(
type: :block,
descendant: Mutant::AST::Pattern::Node::Descendant.new(
name: :receiver,
pattern: Mutant::AST::Pattern::Node.new(
type: :send,
attribute: Mutant::AST::Pattern::Node::Attribute.new(
name: :selector,
value: Mutant::AST::Pattern::Node::Attribute::Value::Single.new(value: :log)
),
descendant: Mutant::AST::Pattern::Node::Descendant.new(
name: :receiver,
pattern: Mutant::AST::Pattern::Node.new(
type: :send,
attribute: Mutant::AST::Pattern::Node::Attribute.new(
name: :selector,
value: Mutant::AST::Pattern::Node::Attribute::Value::Single.new(value: :logger)
)
)
)
)
)
)
end

it 'returns expected node' do
expect(apply).to eql(right(expected_node))
end
end

end
end

0 comments on commit 147627e

Please sign in to comment.