Class: Yadriggy::Assert::Reason

Inherits:
Object
  • Object
show all
Defined in:
lib/yadriggy/assert.rb

Overview

Reason that an assertion fails.

Instance Method Summary collapse

Instance Method Details

#astASTnode

Gets the AST of the block given to assertion.

Returns:

  • (ASTnode)

    an abstract syntax tree.



63
# File 'lib/yadriggy/assert.rb', line 63

def ast() @ast end

#resultsHash<ASTnode,Pair<String,Object>>

Gets the detailed results.

Returns:

  • (Hash<ASTnode,Pair<String,Object>>)

    a map from sub-expressions to their source and resulting vales. The sub-expressions are Yadriggy::ASTnode objects.



69
# File 'lib/yadriggy/assert.rb', line 69

def results() @results end

#showArray<String>

Gets the text showing the values of the sub-expressions.

Returns:

  • (Array<String>)

    an array of lines.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/yadriggy/assert.rb', line 73

def show
  output = []
  header = show2(@ast, '', output)
  output << header
  src, value = @results[ast]
  if src.nil?
    pp = PrettyPrinter.new(Printer.new(2))
    pp.print(ast)
    output << pp.printer.output
  else
    output << src
  end
  output.reverse!
end