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.
2608 2609 2610 |
# File 'lib/oktest.rb', line 2608 def initialize(styleoption=nil) @styleoption = styleoption end |
Instance Attribute Details
#styleoption ⇒ Object (readonly)
Returns the value of attribute styleoption.
2611 2612 2613 |
# File 'lib/oktest.rb', line 2611 def styleoption @styleoption end |
Instance Method Details
#generate(io) ⇒ Object
2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 |
# File 'lib/oktest.rb', line 2684 def generate(io) #; [!5hdw4] generates test code. tree = parse(io) return <<END # coding: utf-8 require 'oktest' Oktest.scope do #{transform(tree, 1)} end END end |
#parse(io) ⇒ Object
2613 2614 2615 2616 2617 |
# File 'lib/oktest.rb', line 2613 def parse(io) #; [!5mzd3] parses ruby code. tree = _parse(io, [], nil) return tree end |
#transform(tree, depth = 1) ⇒ Object
2644 2645 2646 2647 2648 2649 2650 2651 2652 |
# File 'lib/oktest.rb', line 2644 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 |