lib/rubyqc/prelude.rb in rubyqc-0.0.1 vs lib/rubyqc/prelude.rb in rubyqc-0.0.2

- old
+ new

@@ -1,8 +1,13 @@ module RubyQC - FixnumMax = 2 ** (0.size * 8 - 2) - 1 + big = 2 ** (0.size * 8 - 2) + FixnumMax = if big.kind_of?(Bignum) + big - 1 + else # probably jruby... + 2 ** (0.size * 8 - 1) - 1 + end FixnumMin = - FixnumMax - 1 FixnumSuc = FixnumMax + 1 BignumMax = FixnumMax * 10 BignumMin = FixnumMin * 10 end @@ -18,10 +23,13 @@ end class Class def rubyqc new + rescue => e + warn "Cannot new #{self}: #{e}" + raise end end ### ### class level implementation @@ -63,39 +71,38 @@ klass = Class.rubyqc klass.instance_method(klass.instance_methods.sample) end end -# TODO class Binding def self.rubyqc binding end end -# TODO class Symbol def self.rubyqc - String.rubyqc.to_sym + all_symbols.sample end end class Encoding def self.rubyqc list.sample end end -# TODO class Dir def self.rubyqc - Dir.open(__dir__) + Dir.open(File.dirname($LOADED_FEATURES.sample)) end end class File def self.rubyqc + File.open($LOADED_FEATURES.sample) + rescue Errno::ENOENT # e.g. thread.rb, enumerator.so File.open(__FILE__) end end class IO @@ -123,13 +130,14 @@ end end class Class def self.rubyqc - Object.constants.map{ |name| - unless [:Class, :BasicObject, :Data, - :Config, :RubyVM, :TracePoint].include?(name) + Object.constants.map{ |name| # rubinius # jruby + if ![:BasicObject, :Class, :Config, :Data, :Autoload, :Continuation, + :RubyVM, :Struct, :WeakRef, :TracePoint].include?(name) && + name !~ /Java/ const_get(name) end }.select{ |const| const.kind_of?(Class) }.sample end end @@ -195,30 +203,30 @@ def self.rubyqc rand end end -class Thread::SizedQueue +class Fiber def self.rubyqc - new(rand(0..100)) + new(&Proc.rubyqc) end end -class Fiber +class Thread def self.rubyqc new(&Proc.rubyqc) end end -class Thread +class SizedQueue def self.rubyqc - new(&Proc.rubyqc) + new(rand(1..100)) end end class SignalException def self.rubyqc - new(rand(0..32)) + new(rand(0..31)) end end class SystemCallError def self.rubyqc