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.
2374 2375 2376 |
# File 'lib/oktest.rb', line 2374 def initialize(styleoption=nil) @styleoption = styleoption end |
Instance Attribute Details
#styleoption ⇒ Object (readonly)
Returns the value of attribute styleoption.
2377 2378 2379 |
# File 'lib/oktest.rb', line 2377 def styleoption @styleoption end |
Instance Method Details
#generate(io) ⇒ Object
2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 |
# File 'lib/oktest.rb', line 2449 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
2379 2380 2381 2382 2383 |
# File 'lib/oktest.rb', line 2379 def parse(io) #; [!5mzd3] parses ruby code. tree = _parse(io, [], nil) return tree end |
#transform(tree, depth = 1) ⇒ Object
2410 2411 2412 2413 2414 2415 2416 2417 2418 |
# File 'lib/oktest.rb', line 2410 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 |