Class: Oktest::TestGenerator
- Inherits:
-
Object
- Object
- Oktest::TestGenerator
- Defined in:
- lib/oktest.rb
Instance Attribute Summary collapse
-
#styleoption ⇒ Object
readonly
Returns the value of attribute styleoption.
Instance Method Summary collapse
- #generate(io) ⇒ Object
-
#initialize(styleoption = nil) ⇒ TestGenerator
constructor
A new instance of TestGenerator.
- #parse(io) ⇒ Object
- #transform(tree, depth = 1) ⇒ Object
Constructor Details
#initialize(styleoption = nil) ⇒ TestGenerator
Returns a new instance of TestGenerator.
2514 2515 2516 |
# File 'lib/oktest.rb', line 2514 def initialize(styleoption=nil) @styleoption = styleoption end |
Instance Attribute Details
#styleoption ⇒ Object (readonly)
Returns the value of attribute styleoption.
2517 2518 2519 |
# File 'lib/oktest.rb', line 2517 def styleoption @styleoption end |
Instance Method Details
#generate(io) ⇒ Object
2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 |
# File 'lib/oktest.rb', line 2589 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
2519 2520 2521 2522 2523 |
# File 'lib/oktest.rb', line 2519 def parse(io) #; [!5mzd3] parses ruby code. tree = _parse(io, [], nil) return tree end |
#transform(tree, depth = 1) ⇒ Object
2550 2551 2552 2553 2554 2555 2556 2557 2558 |
# File 'lib/oktest.rb', line 2550 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 |