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.



2376
2377
2378
# File 'lib/oktest.rb', line 2376

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

Instance Attribute Details

#styleoptionObject (readonly)

Returns the value of attribute styleoption.



2379
2380
2381
# File 'lib/oktest.rb', line 2379

def styleoption
  @styleoption
end

Instance Method Details

#generate(io) ⇒ Object



2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
# File 'lib/oktest.rb', line 2451

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



2381
2382
2383
2384
2385
# File 'lib/oktest.rb', line 2381

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

#transform(tree, depth = 1) ⇒ Object



2412
2413
2414
2415
2416
2417
2418
2419
2420
# File 'lib/oktest.rb', line 2412

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