Class: Oktest::TestGenerator

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(styleoption = nil) ⇒ TestGenerator

Returns a new instance of TestGenerator.



2011
2012
2013
# File 'lib/oktest.rb', line 2011

def initialize(styleoption=nil)
  @styleoption = styleoption
end

Instance Attribute Details

#styleoptionObject (readonly)

Returns the value of attribute styleoption.



2014
2015
2016
# File 'lib/oktest.rb', line 2014

def styleoption
  @styleoption
end

Instance Method Details

#generate(io) ⇒ Object



2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
# File 'lib/oktest.rb', line 2086

def generate(io)
  #; [!5hdw4] generates test code.
  tree = parse(io)
  return "# coding: utf-8\n\nrequire 'oktest'\n\nOktest.scope do\n\n\#{transform(tree, 1)}\n\nend\n"
end

#parse(io) ⇒ Object



2016
2017
2018
2019
2020
# File 'lib/oktest.rb', line 2016

def parse(io)
  #; [!5mzd3] parses ruby code.
  tree = _parse(io, [], nil)
  return tree
end

#transform(tree, depth = 1) ⇒ Object



2047
2048
2049
2050
2051
2052
2053
2054
2055
# File 'lib/oktest.rb', line 2047

def transform(tree, depth=1)
  #; [!te7zw] converts tree into test code.
  buf = []
  tree.each do |tuple|
    _transform(tuple, depth, buf)
  end
  buf.pop() if buf[-1] == "\n"
  return buf.join()
end