summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2006-03-16 00:27:58 +0000
committermurphy <murphy@rubychan.de>2006-03-16 00:27:58 +0000
commit8948c623203aace20aa537f362a114624f1b0d63 (patch)
tree3652d0ac1876086174c156627398f15fc2797dfe
parent98d88326976c140d7a12f7b3b5f3224a2c44dfa5 (diff)
downloadcoderay-8948c623203aace20aa537f362a114624f1b0d63.tar.gz
Added a test with one-liners (jarh.in.rb)
-rw-r--r--test/ruby/jarh.in.rb371
1 files changed, 371 insertions, 0 deletions
diff --git a/test/ruby/jarh.in.rb b/test/ruby/jarh.in.rb
new file mode 100644
index 0000000..df2176e
--- /dev/null
+++ b/test/ruby/jarh.in.rb
@@ -0,0 +1,371 @@
+
+print ',rekcah ybuR rehtona tsuJ'.reverse
+
+print %q/92G5S="!A;F]T:&5R(%)U8GD@:&%C:V5R+```/.unpack('u')
+
+print %q/SnVzdCBhbm90aGVyIFJ1YnkgaGFja2VyLA==/.unpack('m')
+
+print 'Whfg nabgure Ehol unpxre,'.tr('A-Za-z', 'N-ZA-Mn-za-m')
+
+print({'ruby' => 'Just another Ruby hacker,'}['ruby'])
+
+print 'jUsT aNoThEr '.capitalize, 'RuBy HaCkEr,'.capitalize
+
+print ['Just another Ruby hacker,'][0]
+
+print ['hacker,', 'Ruby ', 'another ', 'Just '].reverse
+
+proc {print 'Just another Ruby hacker,'}.call
+
+def pri() print 'Just another Ruby hacker,' end; pri
+
+for i in 'Just another Ruby hacker,' do print i end
+
+print `echo -n Just another Ruby hacker,`
+
+print 'Just another Ruby hacker,'.split('')
+
+print 'JQust aQnotQher RQuby hQackQer,'.delete('Q')
+
+'Just another Ruby hacker,'.scan(/(.)/) {print $1}
+
+print 'Just ' + 'another ' + 'Ruby ' + 'hacker,'
+
+print ['4a75737420616e6f746865722052756279206861636b65722c'].pack('H*')
+
+print 'Just another Ruby hacker,'.split(/(.)/)
+
+print %w(Just another Ruby hacker,).join(' ')
+
+print({'another '=>'Just ', 'hacker,'=>'Ruby '}.invert.sort)
+
+print eval(%-eval %: %|Just another Ruby hacker,| :-)
+
+#;eval %qPprint eval %-eval %:'Just another Ruby hacker,' :-P
+
+print Hash.new('Just another Ruby hacker,')[:Ruby]
+
+print ['Just ', ['another ', ['Ruby ', ['hacker,']]]].flatten
+
+print Struct.new(*%w|Ruby Just another Ruby hacker,|)[*[0]*4].members.join(' ')
+
+print Time.now.strftime('Just another Ruby hacker,')
+
+print " Just another Ruby hacker, \r\n".strip
+
+print ['Just ', nil, 'another ', nil, 'Ruby ', nil, 'hacker,'].compact
+
+['hacker,', 'Ruby ', 'another ', 'Just '].reverse_each do |x| print x end
+
+/Just another Ruby hacker,/.source.display
+
+send :print, 'Just another Ruby hacker,'
+
+print ['Just ', 'another ', 'Ruby '] | ['another ', 'Ruby ', 'hacker,']
+
+print ['Just ', 'another ', 'Perl', 'Ruby ', 'hacker,'] - ['Perl']
+
+print [['', 'Just another Ruby hacker,']].assoc('')
+
+print ['Just another Ruby hacker,'].pack('a*')
+
+print 'Just another Ruby hacker,'.unpack('a*')
+
+print [['Just another Ruby hacker,'].pop].sort.shift
+
+print [['Just another Ruby hacker,', '']].rassoc('')
+
+{'Just another ' => 'Ruby hacker,'}.to_a.display
+
+print 'Just another Ruby hackeq,'.succ
+
+print 'jUST ANOTHER rUBY HACKER,'.swapcase
+
+print ['Just another Ruby hacker,'].find {|x| x}
+
+print %w(Just another Ruby hacker,).find_all {|x| x}.join(' ')
+
+print %w(Just another Ruby hacker,).grep(/./).join(' ')
+
+Ruby = 'Just another Ruby hacker,' and print Object.const_get(:Ruby)
+
+Proc.new {print 'Just another Ruby hacker,'}[]
+
+print 'JJuusstt aannootthheerr RRuubbyy hhaacckkeerr,,'.squeeze
+
+print [1249211252, 543256175, 1952998770, 542274914, 2032167009, 1667982706].pack('N*'), ','
+
+$> << 'Just ' << 'another ' << 'Ruby ' << 'hacker,'
+
+5.times do|i|'Jaebcunrykso ettRhr hua,'.scan(/.{5}/) do print $&[i,1] end end
+
+a=',rekcah ybuR rehtona tsuJ'.split('');print a.pop while not a.empty?
+
+print ',Pr-eok,c"a$h! kypbquuRA %roeqhbtaoon;ab rtesbujJ&'.gsub(/(.)./, '\1').reverse
+
+print /.*/.match('Just another Ruby hacker,')
+
+print $& if /.*/ === 'Just another Ruby hacker,'
+
+case 'Just another Ruby hacker,' when /.*/; print $~[0] end
+
+print Marshal.load(Marshal.dump("Just another Ruby hacker,"))
+
+'Just another Ruby hacker,'.each_byte do |x| print x.chr end
+
+print '/hacker,/another /Ruby /Just '.split('/').sort.values_at(1,3,2,4)
+
+print 'Just another Perl hacker,'.sub('Perl', 'Ruby')
+
+#$><<'RbyckJust another,'.split('').values_at(5..16,9,0,6,1,2,9,14,10,3,4,15..17)
+
+('a'..'y').to_a.join.tr('a-y','Just another Ruby hacker,').display
+
+begin print 'Just another ' ensure print 'Ruby hacker,' end
+
+'J,ursetk caanho tyhbeurR Rruebhyt ohnaac ktesru,J'.scan(/.(.)/).reverse.display
+
+'J,ursetk caanho tyhbeurR Rruebhyt ohnaac ktesru,J'.gsub(/(.)./,'\1').display
+
+a='J,ursetk caanho tyhbeurR ';0.step(24,2){|i|print a[i,1]};23.step(1,-2){|i|print a[i,1]}
+
+a='Js nte uyhce,rka bRrhoatu'.split('');12.times{print a.shift,a.pop};print a
+
+a='Js nte uyhce,rka bRrhoatu';begin a.sub!(/^(.)(.*)(.)$/){print $1,$3;$2}end while$1;print a
+
+a='J Ruby hacker,ust another';11.times{a.sub!(/^(.)(.*)(.)$/,'\1\3\2')};print a
+
+print 'Just. another! -Ruby? $hacker,'.tr_s('-.!?$ ', ' ')
+
+' e m r,yJaRnafatbpcuekewhjhskvngohrlrxsctdtiubuoyq'.scan(/(.)(.)/).collect!{|x|[x[1],x[0]]}.sort.collect!{|x|x[1]}.display
+
+'e m r y,aJnRfatapbuckewejhshvkgnholrxrcsdtitbuouqy'.scan(/../).sort.collect!{|x|x[1,1]}.display
+
+'4a75737420616e6f746865722052756279206861636b65722c'.scan(/../){print $&.hex.chr}
+
+print ['Just another Perl hacker,'].fill('Just another Ruby hacker,')
+
+$><<{1=>'Just ',2=>'another ',3=>'Ruby ',4=>'hacker,'}.sort.to_s.delete('1-4')
+
+Kernel.print %q<Just another Ruby hacker,>
+
+class Just_another_Ruby_hackerq;end;print Just_another_Ruby_hackerq.to_s.tr('_q',' ,')
+
+Kust_another_Ruby_hacker=0;print Module.constants.grep(/Kust/)[0].tr('K_','J '), ','
+
+module Lust_another_Ruby_hackerq; print name.tr('L_q', 'J ,') end
+
+class Bar; print 'Just another Ruby hacker,' end
+
+class Baz; def initialize() print 'Just another Ruby hacker,' end end; Baz.new
+
+eval "A<')I;G0@)TIU<W0@86YO=&AE<B!2=6)Y(&AA8VME<BPG".unpack('u')[0]
+
+eval "cHJpbnQgJ0p1c3QgYW5vdGhlciBSdWJ5IGhhY2tlciwn".unpack('m')[0]
+
+$stdout.write 'Just another Ruby hacker,'
+
+"Just \nanother \nRuby \nhacker,\n".each do |x| print x.chomp end
+
+print $' if /\n/x === "\nJust another Ruby hacker,"
+
+raise 'Just another Ruby hacker,' rescue print $!
+
+print File.basename('~/Just another Ruby hacker,.rb','.*')
+
+proc{|x|x['Just another Ruby hacker,']}[proc{|x|print x}]
+
+method(:print)['Just another Ruby hacker,']
+
+'Just another Ruby hacker,'.method(:display)[]
+
+print ''.replace('Just another Ruby hacker,')
+
+instance_eval do print 'Just another Ruby hacker,' end
+
+Kernel.module_eval do print 'Just another Ruby hacker,' end
+
+print %%\%s%%%%Just another Ruby hacker,%%%%%%%%%
+
+print !?????:???%?Just another Ruby hacker,?:??
+
+#({}.default='Just another Ruby hacker,')[0].display
+
+print Hash['Just another ', 'Ruby hacker,']
+
+print 'Just ' 'another ' 'Ruby ' 'hacker,'
+
+print File.dirname('Just another Ruby hacker,/Just another Ruby porter,')
+
+def $_.singleton_method_added(*) print 'Just another Ruby hacker,' end
+
+print ['Just another Ruby hacker,'].delete_at(0)
+
+print '%s %s %s %s' % %w[Just another Ruby hacker,]
+
+'cker,by haer RuanothJust '.scan(/.{5}/).reverse.display
+
+(97..121).to_a.pack('c*').tr('a-y','Just another Ruby hacker,').display
+
+'abcdefghijklmnopqrstuvwxy'.tr('a-y','Just another Ruby hacker,').display
+
+',rekcah ybuR rehtona tsuJ'.scan(/.{1}/).reverse.display
+
+print 'Just another Ruby hacker,'%%; (^_^;;;
+
+print('Just another Ruby hacker,'% %- ;-)
+
+'r,keac hbyRur heotant usJ'.scan(/.{1,2}/).reverse.display
+
+print 'Just another Ruby hacker,' * ('Just another Ruby hacker,' =~ /u/)
+
+print 'uJtsa onhtreR bu yahkcre,'.unpack('v12c').pack('n12c')
+
+print 'uJtsa onhtreR bu yahkcre,'.gsub(/(.)(.?)/, '\2\1')
+
+'uJtsa onhtreR bu yahkcre,'.scan(/(.)(.?)/){|x,y| print y+x}
+
+print 'Just another Ruby hacker,'['Just another Ruby hacker,']
+
+print 'Just another Ruby hacker,'[/.*/]
+
+print [].push('Just ', 'another ', 'Ruby ', 'hacker,')
+
+print 'Just another Ruby hacker,'[0..-1]
+
+print 'Just another Ruby hacker,'.instance_eval{self}
+
+class String; def +@() print self end; +'Just another Ruby hacker,' end
+
+print '1J2u3s4t5 6a7n8o9t0h1e2r3 4R5u6b7y8 9h0a1c2k3e4r5,'.delete('0-9')
+
+'Jaubsctd eafngohtihjekrl mRnuobpyq rhsatcukvewrx,y'.gsub(/(.)./, '\1').display
+
+#$><<{'Just another Ruby hacker,'=>''}.default=0
+
+print eval('Just another Ruby hacker,'.dump)
+
+print 'Just another Ruby hacker'.concat(?,)
+
+print 'Just another Ruby hacker,'.intern.to_s
+
+print 'Just another Ruby hacker,'.dump[1..-2]
+
+'Just another Ruby hacker,'.each_line do |x| print x end
+
+['JUST ANOTHER ', 'RUBY HACKER,'].each do |x| print x.capitalize end
+
+printf '%.25s', 'Just another Ruby hacker,JARH'
+
+print 'Just another Ruby hacker,'.split(/Z/)[0]
+
+print 'Just another Ruby hacker,'.split(//)
+
+print %w.J u s t \ a n o t h e r \ R u b y \ h a c k e r ,.
+
+print String([%[Just another Ruby hacker,]])
+
+print catch(:x){throw :x, 'Just another Ruby hacker,'}
+
+r,w = IO::pipe;w.print 'Just another Ruby hacker,';w.close;print r.gets
+
+print sprintf('%s', format('%s' % '%s', 'Just another Ruby hacker,'))
+
+print eval('Just another Ruby hacker,'.inspect)
+
+/#{print 'Just another Ruby hacker,'}/
+
+print 'Just another Ruby hacker,'.scan(/./).collect{|x|x[0]}.pack('U*')
+
+print 'Just another Ruby hacker,'.scan(/./).pack('a'*25)
+
+'Just another Ruby hacker,'.send 'yalpsid'.reverse.intern
+
+print %w.Just another Ruby Ruby Ruby hacker,..uniq.join(' ')
+
+{}.fetch(:x){'Just another Ruby hacker,'}.display
+
+{}.delete(:x){'Just another Ruby hacker,'}.display
+
+print [:x].map{'Just another Ruby hacker,'}
+
+{'Ruby hacker,'=>'Just another'}.each{|*x|print x.reverse.join(' ')}
+
+print [].unshift('Ruby hacker,').unshift('Just another').join(' ')
+
+{3=>'Ruby ',2=>'another ',4=>'hacker,',1=>'Just '}.values_at(1,2,3,4).display
+
+print [[0,'Just another Ruby hacker,'],1].first.last
+
+{''=>'JARH'}.update(''=>'Just another Ruby hacker,').display
+
+{:JARH => 'Just another Ruby hacker,'}.values.display
+
+{'Just another Ruby hacker,'=>:JARH}.invert[:JARH].display
+
+print ['Just another Ruby hacker,'=>:JARH][0].keys
+
+print [{}].slice(0..0)[0].store('', 'Just another Ruby hacker,')
+
+print 'Just another Ruby hacker,'.split.join(' ')
+
+begin print 'Just another Ruby hacker,' end while false
+
+begin rescue then else print 'Just another Ruby hacker,' end
+
+print //.match('Just another Ruby hacker,').string
+
+callcc{print 'Just another Ruby hacker,'}
+
+Thread.start{print'Just another Ruby hacker,'}.join
+
+('JARH'..'Just another Ruby hacker,').end.display
+
+('Just another'..'Ruby hacker,').to_s.tr_s('.', ' ').display
+
+unless true then else 'Just another Ruby hacker,' end.display
+
+loop do print 'Just another Ruby hacker,'; break end
+
+1.times do print 'Just another Ruby hacker,' end
+
+0.upto(0) do print 'Just another Ruby hacker,' end
+
+0.downto(0) do print 'Just another Ruby hacker,' end
+
+print Struct.new('Just_another_Ruby_hacker').to_s.split(':')[2].tr('_',' '),','
+
+def (x='Just another Ruby hacker,').foo() print self end; x.foo
+
+begin print 'Just another Ruby hacker,' end until true
+
+for i in %w[Just\ another\ Ruby\ hacker,] do print i end
+
+'Just another Ruby hacker,'.each_byte do |x| putc x end
+
+',rekcah ybuR rehtona tsuJ'.scan(/./).reverse_each do |x| putc x end
+
+print Regexp.quote('Just another Ruby hacker,').delete('\\')
+
+print true ? "Just another Ruby hacker," :-P
+
+print true ? "Just another Ruby hacker," :-D
+
+print *("Just another Ruby hacker,".."Just another Ruby hacker,").to_a
+
+print eval(%<%%Just another Ruby hacker,%>)
+
+print case when true then "Just another Ruby hacker," end
+
+print %w[Just another Ruby hacker,] * " "
+
+begin end if print "Just another Ruby hacker,"
+
+print begin "Just another Ruby hacker," end
+
+print "Just another Ruby hacker,".center(10000).strip
+
+print "Just " or print "another " or print "Ruby " or print "hacker,"
+
+print :"Just another Ruby hacker,"
+