File indexing completed on 2024-05-19 04:38:18
0001 0002 # BEGIN: TestRocket code 0003 module TestRocket 0004 extend Module.new { attr_accessor :out } 0005 0006 def _test(a, b); send((call rescue()) ? a : b); end 0007 0008 def +@; _show _test :_pass, :_fail end 0009 def -@; _show _test :_fail, :_pass end 0010 def ~@; _show _pend; end 0011 def !@; _show _desc; end 0012 0013 def _show(r); (TestRocket.out || $>) << r; r end 0014 def _pass; " OK\n"; end 0015 def _fail; " FAIL @ #{source_location * ':'}\n"; end 0016 def _pend; "PENDING '#{call}' @ #{source_location * ':'}\n"; end 0017 def _desc; " FIRE '#{call}'!\n"; end 0018 end 0019 0020 Proc.send :include, TestRocket 0021 0022 +-> { Die.new(2) } 0023 --> { raise } 0024 +-> { 2 + 2 == 4 } 0025 +-> { raise } 0026 --> { true } 0027 ~-> { "this is a pending test" } 0028 !-> { "use this for descriptive output and to separate your test parts" } 0029 # END: TestRocket code 0030 0031 class MagicString < String 0032 def +@ 0033 upcase 0034 end 0035 0036 def ! 0037 swapcase 0038 end 0039 end 0040 0041 str = MagicString.new("This is my string!") 0042 p +str # => "THIS IS MY STRING!" 0043 p !str # => "tHIS IS MY STRING!" 0044 p -str