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) ⇒ 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



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

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

Class Method Details

.call(location, types, 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:

  • location (Thread::Backtrace::Location)
  • types (Set<Symbol>)

Returns:



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

def self.call(location, types, block)
  instance = new(location, types)
  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)


57
58
59
# File 'lib/mutant/meta/example/dsl.rb', line 57

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



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

def example
  fail 'source not defined' unless @source

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