# You are in the context of the Uttk module. # You can access the table of symbols with this local variable: symtbl. # You can factorize some code this way: def self.check_for_zombies S::KillAll.new('check for zombies') do regexp(/sleep/) end end S::Suite.new('Test the basic features of Strategy and Suite (base.rb)') do contents [ S::Pass.new('pass'), S::Fail.new('fail') { weight(-1) }, S::Error.new('error') { weight(-1) }, S::Stub.new('stub') { returned_value 'foo' => 'bar', 'toto' => 'tata' }, S::Abort.new('abort') { weight(-1) }, S::Sleep.new('timeout_strategy') { delay 0.5 timeout 0.2 weight(-1) }, S::Suite.new('timeout_suite') { timeout 0.3 weight(-1) attributes :strategy => S::Sleep, :delay => 0.1 contents [ 'a', 'b', 'c', 'd' ] }, S::Pool.new('timeout_pool') do weight(-1) timeout 0.3 attributes({ :strategy => S::Sleep, :delay => 0.4 }) contents %w(a b c d) end, S::Cmd.new('cmd') do command 'true' exit 0 end, S::Cmd.new('bad cmd') do weight(-1) command '/bin/unexisting_command' exit 0 end, S::Suite.new('abort cmd') do contents [ S::Cmd.new('cmd') { weight(-1) timeout 0.1 command 'sleep' args 1 }, Uttk.check_for_zombies ] end, S::Suite.new('abort suite cmd') do contents [ S::Suite.new('suite') { weight(-1) timeout 0.1 contents [ S::Cmd.new('cmd') { command 'sleep' args 1 } ] }, Uttk.check_for_zombies ] end, S::Suite.new('timeout suite of suite') do weight(-1) timeout { 0.01 } # May use a block too contents [ S::Suite.new('suite') { contents [ S::Sleep.new('pass') { delay 0.1 } ] } ] end, # Must create a block for {pre,post}_assertion otherwise it is not evaluate # at runtime but at creation time. S::Pass.new('true pre assertion and pass') do pre_assertion lambda { true } end, S::Fail.new('true pre assertion and fail') do weight(-1) pre_assertion Proc.new { true } end, S::Pass.new('false pre assertion and pass') do weight(-1) pre_assertion proc { false } end, S::Pass.new('exception pre assertion and pass') do weight(-1) pre_assertion proc { raise 'ASSERT' } end, S::Pass.new('true post assertion and pass') do post_assertion proc { true } end, S::Fail.new('true post assertion and fail') do weight { -1 } post_assertion proc { true } end, S::Pass.new('false post assertion and pass') do weight { -1 } post_assertion proc { false } end, S::Pass.new('exception post assertion and pass') do weight { -1 } post_assertion proc { raise 'ASSERT' } end ] end