Class: Mutant::Meta::Example::DSL Private

Inherits:
Object
  • Object
show all
Includes:
AST::Sexp
Defined in:
lib/mutant/meta/example/dsl.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Example DSL

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location, types, operators) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize object



28
29
30
31
32
33
34
# File 'lib/mutant/meta/example/dsl.rb', line 28

def initialize(location, types, operators)
  @expected  = []
  @location  = location
  @lvars     = []
  @operators = operators
  @types     = types
end

Class Method Details

.call(location:, types:, operators:, block:) ⇒ Example

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Run DSL on block

Parameters:

Returns:



18
19
20
21
22
# File 'lib/mutant/meta/example/dsl.rb', line 18

def self.call(location:, types:, operators:, block:) # rubocop:disable Metrics/ParameterLists
  instance = new(location, types, operators)
  instance.instance_eval(&block)
  instance.example
end

Instance Method Details

#declare_lvar(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Declare a local variable

Parameters:

  • (Symbol)


59
60
61
# File 'lib/mutant/meta/example/dsl.rb', line 59

def declare_lvar(name)
  @lvars << name
end

#exampleExample

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Example captured by DSL

Returns:

Raises:

  • (RuntimeError)

    in case the example cannot be built



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/mutant/meta/example/dsl.rb', line 42

def example
  fail 'source not defined' unless @source

  Example.new(
    expected:        @expected,
    location:        @location,
    lvars:           @lvars,
    node:            @node,
    operators:       @operators,
    original_source: @source,
    types:           @types
  )
end