From 1c39df758df31b4aacef614775f58130a44661b3 Mon Sep 17 00:00:00 2001 From: Hiro Asari Date: Fri, 7 Dec 2012 10:40:03 -0500 Subject: [PATCH] Revert "Setup .gitattributes for eol normalization" This commit is overly eager on fixing the existing files' EOLs. I also have reservations about enforcing EOL rules, and would like to discuss it a little further. This reverts commit b1119113cfa6f29dc658c1bf0c038827b833b157. --- .gitattributes | 14 - bench/shootout/nsieve.ruby-2.ruby | 42 +- bench/shootout/regexmatch.ruby | 66 +- bench/shootout/sumcol.ruby-2.ruby | 2 +- bench/yarv/bm_app_erb.rb | 52 +- bench/yarv/bm_app_uri.rb | 16 +- bench/yarv/bm_io_file_create.rb | 26 +- bench/yarv/bm_io_file_read.rb | 30 +- bench/yarv/bm_io_file_write.rb | 28 +- bench/yarv/bm_so_binary_trees.rb | 114 +- bench/yarv/bm_so_fannkuch.rb | 90 +- bench/yarv/bm_so_fasta.rb | 162 +- bench/yarv/bm_so_k_nucleotide.rb | 96 +- bench/yarv/bm_so_mandelbrot.rb | 114 +- bench/yarv/bm_so_meteor_contest.rb | 1128 ++++++------ bench/yarv/bm_so_nbody.rb | 296 ++-- bench/yarv/bm_so_nsieve.rb | 70 +- bench/yarv/bm_so_nsieve_bits.rb | 84 +- bench/yarv/bm_so_partial_sums.rb | 62 +- bench/yarv/bm_so_pidigits.rb | 184 +- bench/yarv/bm_so_reverse_complement.rb | 60 +- bench/yarv/bm_so_spectralnorm.rb | 100 +- bench/yarv/bm_vm1_ivar_set.rb | 12 +- bench/yarv/bm_vm2_eval.rb | 12 +- bench/yarv/driver.rb | 476 ++--- bench/yarv/make_fasta_output.rb | 38 +- bench/yarv/prepare_so_count_words.rb | 30 +- bench/yarv/prepare_so_k_nucleotide.rb | 4 +- bench/yarv/prepare_so_reverse_complement.rb | 4 +- bin/gem.bat | 12 +- bin/irb.bat | 12 +- bin/jirb.bat | 12 +- bin/jirb_swing.bat | 12 +- bin/jruby.bat | 12 +- bin/jrubyd.bat | 18 +- bin/rake.bat | 4 +- bin/rdoc.bat | 12 +- bin/ri.bat | 12 +- docs/LICENSE.ant | 98 +- docs/README.coverage | 18 +- install/jruby.install4j | 1524 ++++++++--------- .../ffi/platform/x86_64-windows/platform.conf | 1040 +++++------ ...6570_autoload_from_instance_method_spec.rb | 30 +- ...6748_new_thread_not_in_thread_list_spec.rb | 40 +- src/org/jruby/ast/ArgsPushNode.java | 164 +- src/org/jruby/ast/IArgumentNode.java | 74 +- src/org/jruby/javasupport/ParameterTypes.java | 14 +- src/org/jruby/runtime/builtin/Variable.java | 102 +- .../runtime/component/VariableEntry.java | 88 +- test/externals/ruby1.9/rexml/data/testsrc.xml | 128 +- .../ruby1.9/rexml/data/ticket_61.xml | 8 +- ...est_java_class_resource_methods.properties | 2 +- test/test_block_arg_processing.rb | 428 ++--- test/test_integer_overflows.rb | 1336 +++++++-------- test/test_line_endings-windows.txt | 4 +- test/test_string_sub.rb | 68 +- test/test_string_to_number.rb | 80 +- test/test_variables.rb | 100 +- test/test_vietnamese_charset.rb | 18 +- 59 files changed, 4434 insertions(+), 4448 deletions(-) delete mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index d4f58cc8d27..00000000000 --- a/.gitattributes +++ /dev/null @@ -1,14 +0,0 @@ -* text=auto - -# Windows specific files -*.bat eol=crlf - -# *nix specific files -*.sh eol=lf - -# Binary files -*.svg -text - -# Specially treated files -test/heredoc_CRLF_data.rb -text - diff --git a/bench/shootout/nsieve.ruby-2.ruby b/bench/shootout/nsieve.ruby-2.ruby index deaf79d2bf8..0ffa5d0c883 100644 --- a/bench/shootout/nsieve.ruby-2.ruby +++ b/bench/shootout/nsieve.ruby-2.ruby @@ -1,25 +1,25 @@ # The Computer Language Shootout # http://shootout.alioth.debian.org/ # contributed by Pavel Valodzka - -def nsieve(m) - is_prime = Array.new(m, true) - count = 0 - 2.upto(m){|i| - if is_prime[i] - (2 * i).step(m, i){|v| - is_prime[v] = false - } - count += 1 - end - } - return count -end - -n = (ARGV[0] || 2).to_i -n = 2 if (n < 2) - -3.times {|t| - m = (1< - <%= title %> - -

<%= title %>

-

- <%= content %> -

- - +# +# Create many HTML strings with ERB. +# + +require 'erb' + +data = DATA.read +max = 5_000 +title = "hello world!" +content = "hello world!\n" * 10 + +max.times{ + ERB.new(data).result(binding) +} + +__END__ + + + <%= title %> + +

<%= title %>

+

+ <%= content %> +

+ + diff --git a/bench/yarv/bm_app_uri.rb b/bench/yarv/bm_app_uri.rb index 586edfd5dca..49fe5a81a80 100644 --- a/bench/yarv/bm_app_uri.rb +++ b/bench/yarv/bm_app_uri.rb @@ -1,8 +1,8 @@ -require 'uri' - -100_000.times{ - uri = URI.parse('http://www.ruby-lang.org') - uri.scheme - uri.host - uri.port -} +require 'uri' + +100_000.times{ + uri = URI.parse('http://www.ruby-lang.org') + uri.scheme + uri.host + uri.port +} diff --git a/bench/yarv/bm_io_file_create.rb b/bench/yarv/bm_io_file_create.rb index 7adbe9ea5e7..db4e4dedd2b 100644 --- a/bench/yarv/bm_io_file_create.rb +++ b/bench/yarv/bm_io_file_create.rb @@ -1,13 +1,13 @@ -# -# Create files -# - -max = 50_000 -file = './tmpfile_of_bm_io_file_create' - -max.times{ - f = open(file, 'w') - f.close#(true) -} -File.unlink(file) - +# +# Create files +# + +max = 50_000 +file = './tmpfile_of_bm_io_file_create' + +max.times{ + f = open(file, 'w') + f.close#(true) +} +File.unlink(file) + diff --git a/bench/yarv/bm_io_file_read.rb b/bench/yarv/bm_io_file_read.rb index 2b4212db763..488a4e90ad7 100644 --- a/bench/yarv/bm_io_file_read.rb +++ b/bench/yarv/bm_io_file_read.rb @@ -1,15 +1,15 @@ -# -# Seek and Read file. -# - -require 'tempfile' - -max = 20_000 -str = "Hello world! " * 1000 -f = Tempfile.new('yarv-benchmark') -f.write str - -max.times{ - f.seek 0 - f.read -} +# +# Seek and Read file. +# + +require 'tempfile' + +max = 20_000 +str = "Hello world! " * 1000 +f = Tempfile.new('yarv-benchmark') +f.write str + +max.times{ + f.seek 0 + f.read +} diff --git a/bench/yarv/bm_io_file_write.rb b/bench/yarv/bm_io_file_write.rb index 3cec58c6aea..05c7e7e45e7 100644 --- a/bench/yarv/bm_io_file_write.rb +++ b/bench/yarv/bm_io_file_write.rb @@ -1,14 +1,14 @@ -# -# Seek and Write file. -# - -require 'tempfile' - -max = 20_000 -str = "Hello world! " * 1000 -f = Tempfile.new('yarv-benchmark') - -max.times{ - f.seek 0 - f.write str -} +# +# Seek and Write file. +# + +require 'tempfile' + +max = 20_000 +str = "Hello world! " * 1000 +f = Tempfile.new('yarv-benchmark') + +max.times{ + f.seek 0 + f.write str +} diff --git a/bench/yarv/bm_so_binary_trees.rb b/bench/yarv/bm_so_binary_trees.rb index 6a264655784..138c5290f56 100644 --- a/bench/yarv/bm_so_binary_trees.rb +++ b/bench/yarv/bm_so_binary_trees.rb @@ -1,57 +1,57 @@ -# The Computer Language Shootout Benchmarks -# http://shootout.alioth.debian.org -# -# contributed by Jesse Millikan - -# disable output -def STDOUT.write_ *args -end - -def item_check(tree) - if tree[0] == nil - tree[1] - else - tree[1] + item_check(tree[0]) - item_check(tree[2]) - end -end - -def bottom_up_tree(item, depth) - if depth > 0 - item_item = 2 * item - depth -= 1 - [bottom_up_tree(item_item - 1, depth), item, bottom_up_tree(item_item, depth)] - else - [nil, item, nil] - end -end - -max_depth = 12 # 16 # ARGV[0].to_i -min_depth = 4 - -max_depth = min_depth + 2 if min_depth + 2 > max_depth - -stretch_depth = max_depth + 1 -stretch_tree = bottom_up_tree(0, stretch_depth) - -puts "stretch tree of depth #{stretch_depth}\t check: #{item_check(stretch_tree)}" -stretch_tree = nil - -long_lived_tree = bottom_up_tree(0, max_depth) - -min_depth.step(max_depth + 1, 2) do |depth| - iterations = 2**(max_depth - depth + min_depth) - - check = 0 - - for i in 1..iterations - temp_tree = bottom_up_tree(i, depth) - check += item_check(temp_tree) - - temp_tree = bottom_up_tree(-i, depth) - check += item_check(temp_tree) - end - - puts "#{iterations * 2}\t trees of depth #{depth}\t check: #{check}" -end - -puts "long lived tree of depth #{max_depth}\t check: #{item_check(long_lived_tree)}" +# The Computer Language Shootout Benchmarks +# http://shootout.alioth.debian.org +# +# contributed by Jesse Millikan + +# disable output +def STDOUT.write_ *args +end + +def item_check(tree) + if tree[0] == nil + tree[1] + else + tree[1] + item_check(tree[0]) - item_check(tree[2]) + end +end + +def bottom_up_tree(item, depth) + if depth > 0 + item_item = 2 * item + depth -= 1 + [bottom_up_tree(item_item - 1, depth), item, bottom_up_tree(item_item, depth)] + else + [nil, item, nil] + end +end + +max_depth = 12 # 16 # ARGV[0].to_i +min_depth = 4 + +max_depth = min_depth + 2 if min_depth + 2 > max_depth + +stretch_depth = max_depth + 1 +stretch_tree = bottom_up_tree(0, stretch_depth) + +puts "stretch tree of depth #{stretch_depth}\t check: #{item_check(stretch_tree)}" +stretch_tree = nil + +long_lived_tree = bottom_up_tree(0, max_depth) + +min_depth.step(max_depth + 1, 2) do |depth| + iterations = 2**(max_depth - depth + min_depth) + + check = 0 + + for i in 1..iterations + temp_tree = bottom_up_tree(i, depth) + check += item_check(temp_tree) + + temp_tree = bottom_up_tree(-i, depth) + check += item_check(temp_tree) + end + + puts "#{iterations * 2}\t trees of depth #{depth}\t check: #{check}" +end + +puts "long lived tree of depth #{max_depth}\t check: #{item_check(long_lived_tree)}" diff --git a/bench/yarv/bm_so_fannkuch.rb b/bench/yarv/bm_so_fannkuch.rb index a214f2e205d..23298a8a31a 100644 --- a/bench/yarv/bm_so_fannkuch.rb +++ b/bench/yarv/bm_so_fannkuch.rb @@ -1,45 +1,45 @@ -# The Computer Language Shootout -# http://shootout.alioth.debian.org/ -# Contributed by Sokolov Yura -# Modified by Ryan Williams - -def fannkuch(n) - maxFlips, m, r, check = 0, n-1, n, 0 - count = (1..n).to_a - perm = (1..n).to_a - - while true - if check < 30 - puts "#{perm}" - check += 1 - end - - while r != 1 - count[r-1] = r - r -= 1 - end - - if perm[0] != 1 and perm[m] != n - perml = perm.clone #.dup - flips = 0 - while (k = perml.first ) != 1 - perml = perml.slice!(0, k).reverse + perml - flips += 1 - end - maxFlips = flips if flips > maxFlips - end - while true - if r==n then return maxFlips end - perm.insert r,perm.shift - break if (count[r] -= 1) > 0 - r += 1 - end - end -end - -def puts *args -end - -N = 10 # (ARGV[0] || 1).to_i -puts "Pfannkuchen(#{N}) = #{fannkuch(N)}" - +# The Computer Language Shootout +# http://shootout.alioth.debian.org/ +# Contributed by Sokolov Yura +# Modified by Ryan Williams + +def fannkuch(n) + maxFlips, m, r, check = 0, n-1, n, 0 + count = (1..n).to_a + perm = (1..n).to_a + + while true + if check < 30 + puts "#{perm}" + check += 1 + end + + while r != 1 + count[r-1] = r + r -= 1 + end + + if perm[0] != 1 and perm[m] != n + perml = perm.clone #.dup + flips = 0 + while (k = perml.first ) != 1 + perml = perml.slice!(0, k).reverse + perml + flips += 1 + end + maxFlips = flips if flips > maxFlips + end + while true + if r==n then return maxFlips end + perm.insert r,perm.shift + break if (count[r] -= 1) > 0 + r += 1 + end + end +end + +def puts *args +end + +N = 10 # (ARGV[0] || 1).to_i +puts "Pfannkuchen(#{N}) = #{fannkuch(N)}" + diff --git a/bench/yarv/bm_so_fasta.rb b/bench/yarv/bm_so_fasta.rb index 3f759ba7ae8..b95f5e9f107 100644 --- a/bench/yarv/bm_so_fasta.rb +++ b/bench/yarv/bm_so_fasta.rb @@ -1,81 +1,81 @@ -# The Computer Language Shootout -# http://shootout.alioth.debian.org/ -# Contributed by Sokolov Yura - -$last = 42.0 -def gen_random (max,im=139968,ia=3877,ic=29573) - (max * ($last = ($last * ia + ic) % im)) / im -end - -alu = - "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG"+ - "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA"+ - "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT"+ - "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA"+ - "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG"+ - "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC"+ - "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA" - -iub = [ - ["a", 0.27], - ["c", 0.12], - ["g", 0.12], - ["t", 0.27], - - ["B", 0.02], - ["D", 0.02], - ["H", 0.02], - ["K", 0.02], - ["M", 0.02], - ["N", 0.02], - ["R", 0.02], - ["S", 0.02], - ["V", 0.02], - ["W", 0.02], - ["Y", 0.02], -] -homosapiens = [ - ["a", 0.3029549426680], - ["c", 0.1979883004921], - ["g", 0.1975473066391], - ["t", 0.3015094502008], -] - -def make_repeat_fasta(id, desc, src, n) - puts ">#{id} #{desc}" - v = nil - width = 60 - l = src.length - s = src * ((n / l) + 1) - s.slice!(n, l) - puts(s.scan(/.{1,#{width}}/).join("\n")) -end - -def make_random_fasta(id, desc, table, n) - puts ">#{id} #{desc}" - rand, v = nil,nil - width = 60 - chunk = 1 * width - prob = 0.0 - table.each{|v| v[1]= (prob += v[1])} - for i in 1..(n/width) - puts((1..width).collect{ - rand = gen_random(1.0) - table.find{|v| v[1]>rand}[0] - }.join) - end - if n%width != 0 - puts((1..(n%width)).collect{ - rand = gen_random(1.0) - table.find{|v| v[1]>rand}[0] - }.join) - end -end - - -n = (ARGV[0] or 250_000).to_i - -make_repeat_fasta('ONE', 'Homo sapiens alu', alu, n*2) -make_random_fasta('TWO', 'IUB ambiguity codes', iub, n*3) -make_random_fasta('THREE', 'Homo sapiens frequency', homosapiens, n*5) - +# The Computer Language Shootout +# http://shootout.alioth.debian.org/ +# Contributed by Sokolov Yura + +$last = 42.0 +def gen_random (max,im=139968,ia=3877,ic=29573) + (max * ($last = ($last * ia + ic) % im)) / im +end + +alu = + "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG"+ + "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA"+ + "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT"+ + "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA"+ + "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG"+ + "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC"+ + "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA" + +iub = [ + ["a", 0.27], + ["c", 0.12], + ["g", 0.12], + ["t", 0.27], + + ["B", 0.02], + ["D", 0.02], + ["H", 0.02], + ["K", 0.02], + ["M", 0.02], + ["N", 0.02], + ["R", 0.02], + ["S", 0.02], + ["V", 0.02], + ["W", 0.02], + ["Y", 0.02], +] +homosapiens = [ + ["a", 0.3029549426680], + ["c", 0.1979883004921], + ["g", 0.1975473066391], + ["t", 0.3015094502008], +] + +def make_repeat_fasta(id, desc, src, n) + puts ">#{id} #{desc}" + v = nil + width = 60 + l = src.length + s = src * ((n / l) + 1) + s.slice!(n, l) + puts(s.scan(/.{1,#{width}}/).join("\n")) +end + +def make_random_fasta(id, desc, table, n) + puts ">#{id} #{desc}" + rand, v = nil,nil + width = 60 + chunk = 1 * width + prob = 0.0 + table.each{|v| v[1]= (prob += v[1])} + for i in 1..(n/width) + puts((1..width).collect{ + rand = gen_random(1.0) + table.find{|v| v[1]>rand}[0] + }.join) + end + if n%width != 0 + puts((1..(n%width)).collect{ + rand = gen_random(1.0) + table.find{|v| v[1]>rand}[0] + }.join) + end +end + + +n = (ARGV[0] or 250_000).to_i + +make_repeat_fasta('ONE', 'Homo sapiens alu', alu, n*2) +make_random_fasta('TWO', 'IUB ambiguity codes', iub, n*3) +make_random_fasta('THREE', 'Homo sapiens frequency', homosapiens, n*5) + diff --git a/bench/yarv/bm_so_k_nucleotide.rb b/bench/yarv/bm_so_k_nucleotide.rb index dadab3e79c6..c0a5ba50462 100644 --- a/bench/yarv/bm_so_k_nucleotide.rb +++ b/bench/yarv/bm_so_k_nucleotide.rb @@ -1,48 +1,48 @@ -# The Computer Language Shootout -# http://shootout.alioth.debian.org -# -# contributed by jose fco. gonzalez -# modified by Sokolov Yura - -seq = String.new - -def frecuency( seq,length ) - n, table = seq.length - length + 1, Hash.new(0) - f, i = nil, nil - (0 ... length).each do |f| - (f ... n).step(length) do |i| - table[seq[i,length]] += 1 - end - end - [n,table] - -end - -def sort_by_freq( seq,length ) - n,table = frecuency( seq,length ) - a, b, v = nil, nil, nil - table.sort{|a,b| b[1] <=> a[1]}.each do |v| - puts "%s %.3f" % [v[0].upcase,((v[1]*100).to_f/n)] - end - puts -end - -def find_seq( seq,s ) - n,table = frecuency( seq,s.length ) - puts "#{table[s].to_s}\t#{s.upcase}" -end - -input = open(File.join(File.dirname($0), 'fasta.output.100000'), 'rb') - -line = input.gets while line !~ /^>THREE/ -line = input.gets - -while (line !~ /^>/) & line do - seq << line.chomp - line = input.gets -end - -[1,2].each {|i| sort_by_freq( seq,i ) } - -%w(ggt ggta ggtatt ggtattttaatt ggtattttaatttatagt).each{|s| find_seq( seq,s) } - +# The Computer Language Shootout +# http://shootout.alioth.debian.org +# +# contributed by jose fco. gonzalez +# modified by Sokolov Yura + +seq = String.new + +def frecuency( seq,length ) + n, table = seq.length - length + 1, Hash.new(0) + f, i = nil, nil + (0 ... length).each do |f| + (f ... n).step(length) do |i| + table[seq[i,length]] += 1 + end + end + [n,table] + +end + +def sort_by_freq( seq,length ) + n,table = frecuency( seq,length ) + a, b, v = nil, nil, nil + table.sort{|a,b| b[1] <=> a[1]}.each do |v| + puts "%s %.3f" % [v[0].upcase,((v[1]*100).to_f/n)] + end + puts +end + +def find_seq( seq,s ) + n,table = frecuency( seq,s.length ) + puts "#{table[s].to_s}\t#{s.upcase}" +end + +input = open(File.join(File.dirname($0), 'fasta.output.100000'), 'rb') + +line = input.gets while line !~ /^>THREE/ +line = input.gets + +while (line !~ /^>/) & line do + seq << line.chomp + line = input.gets +end + +[1,2].each {|i| sort_by_freq( seq,i ) } + +%w(ggt ggta ggtatt ggtattttaatt ggtattttaatttatagt).each{|s| find_seq( seq,s) } + diff --git a/bench/yarv/bm_so_mandelbrot.rb b/bench/yarv/bm_so_mandelbrot.rb index 76331c64b8b..2c058788636 100644 --- a/bench/yarv/bm_so_mandelbrot.rb +++ b/bench/yarv/bm_so_mandelbrot.rb @@ -1,57 +1,57 @@ -# The Computer Language Benchmarks Game -# http://shootout.alioth.debian.org/ -# -# contributed by Karl von Laudermann -# modified by Jeremy Echols - -size = 600 # ARGV[0].to_i - -puts "P4\n#{size} #{size}" - -ITER = 49 # Iterations - 1 for easy for..in looping -LIMIT_SQUARED = 4.0 # Presquared limit - -byte_acc = 0 -bit_num = 0 - -count_size = size - 1 # Precomputed size for easy for..in looping - -# For..in loops are faster than .upto, .downto, .times, etc. -for y in 0..count_size - for x in 0..count_size - zr = 0.0 - zi = 0.0 - cr = (2.0*x/size)-1.5 - ci = (2.0*y/size)-1.0 - escape = false - - # To make use of the for..in code, we use a dummy variable, - # like one would in C - for dummy in 0..ITER - tr = zr*zr - zi*zi + cr - ti = 2*zr*zi + ci - zr, zi = tr, ti - - if (zr*zr+zi*zi) > LIMIT_SQUARED - escape = true - break - end - end - - byte_acc = (byte_acc << 1) | (escape ? 0b0 : 0b1) - bit_num += 1 - - # Code is very similar for these cases, but using separate blocks - # ensures we skip the shifting when it's unnecessary, which is most cases. - if (bit_num == 8) - print byte_acc.chr - byte_acc = 0 - bit_num = 0 - elsif (x == count_size) - byte_acc <<= (8 - bit_num) - print byte_acc.chr - byte_acc = 0 - bit_num = 0 - end - end -end +# The Computer Language Benchmarks Game +# http://shootout.alioth.debian.org/ +# +# contributed by Karl von Laudermann +# modified by Jeremy Echols + +size = 600 # ARGV[0].to_i + +puts "P4\n#{size} #{size}" + +ITER = 49 # Iterations - 1 for easy for..in looping +LIMIT_SQUARED = 4.0 # Presquared limit + +byte_acc = 0 +bit_num = 0 + +count_size = size - 1 # Precomputed size for easy for..in looping + +# For..in loops are faster than .upto, .downto, .times, etc. +for y in 0..count_size + for x in 0..count_size + zr = 0.0 + zi = 0.0 + cr = (2.0*x/size)-1.5 + ci = (2.0*y/size)-1.0 + escape = false + + # To make use of the for..in code, we use a dummy variable, + # like one would in C + for dummy in 0..ITER + tr = zr*zr - zi*zi + cr + ti = 2*zr*zi + ci + zr, zi = tr, ti + + if (zr*zr+zi*zi) > LIMIT_SQUARED + escape = true + break + end + end + + byte_acc = (byte_acc << 1) | (escape ? 0b0 : 0b1) + bit_num += 1 + + # Code is very similar for these cases, but using separate blocks + # ensures we skip the shifting when it's unnecessary, which is most cases. + if (bit_num == 8) + print byte_acc.chr + byte_acc = 0 + bit_num = 0 + elsif (x == count_size) + byte_acc <<= (8 - bit_num) + print byte_acc.chr + byte_acc = 0 + bit_num = 0 + end + end +end diff --git a/bench/yarv/bm_so_meteor_contest.rb b/bench/yarv/bm_so_meteor_contest.rb index 30b99715af7..5dd720c340e 100644 --- a/bench/yarv/bm_so_meteor_contest.rb +++ b/bench/yarv/bm_so_meteor_contest.rb @@ -1,564 +1,564 @@ -#!/usr/bin/env ruby -# -# The Computer Language Shootout -# http://shootout.alioth.debian.org -# contributed by Kevin Barnes (Ruby novice) - -# PROGRAM: the main body is at the bottom. -# 1) read about the problem here: http://www-128.ibm.com/developerworks/java/library/j-javaopt/ -# 2) see how I represent a board as a bitmask by reading the blank_board comments -# 3) read as your mental paths take you - -def print *args -end - -# class to represent all information about a particular rotation of a particular piece -class Rotation - # an array (by location) containing a bit mask for how the piece maps at the given location. - # if the rotation is illegal at that location the mask will contain false - attr_reader :start_masks - - # maps a direction to a relative location. these differ depending on whether it is an even or - # odd row being mapped from - @@rotation_even_adder = { :west => -1, :east => 1, :nw => -7, :ne => -6, :sw => 5, :se => 6 } - @@rotation_odd_adder = { :west => -1, :east => 1, :nw => -6, :ne => -5, :sw => 6, :se => 7 } - - def initialize( directions ) - @even_offsets, @odd_offsets = normalize_offsets( get_values( directions )) - - @even_mask = mask_for_offsets( @even_offsets) - @odd_mask = mask_for_offsets( @odd_offsets) - - @start_masks = Array.new(60) - - # create the rotational masks by placing the base mask at the location and seeing if - # 1) it overlaps the boundries and 2) it produces a prunable board. if either of these - # is true the piece cannot be placed - 0.upto(59) do | offset | - mask = is_even(offset) ? (@even_mask << offset) : (@odd_mask << offset) - if (blank_board & mask == 0 && !prunable(blank_board | mask, 0, true)) then - imask = compute_required( mask, offset) - @start_masks[offset] = [ mask, imask, imask | mask ] - else - @start_masks[offset] = false - end - end - end - - def compute_required( mask, offset ) - board = blank_board - 0.upto(offset) { | i | board |= 1 << i } - board |= mask - return 0 if (!prunable(board | mask, offset)) - board = flood_fill(board,58) - count = 0 - imask = 0 - 0.upto(59) do | i | - if (board[i] == 0) then - imask |= (1 << i) - count += 1 - end - end - (count > 0 && count < 5) ? imask : 0 - end - - def flood_fill( board, location) - return board if (board[location] == 1) - board |= 1 << location - row, col = location.divmod(6) - board = flood_fill( board, location - 1) if (col > 0) - board = flood_fill( board, location + 1) if (col < 4) - if (row % 2 == 0) then - board = flood_fill( board, location - 7) if (col > 0 && row > 0) - board = flood_fill( board, location - 6) if (row > 0) - board = flood_fill( board, location + 6) if (row < 9) - board = flood_fill( board, location + 5) if (col > 0 && row < 9) - else - board = flood_fill( board, location - 5) if (col < 4 && row > 0) - board = flood_fill( board, location - 6) if (row > 0) - board = flood_fill( board, location + 6) if (row < 9) - board = flood_fill( board, location + 7) if (col < 4 && row < 9) - end - board - end - - # given a location, produces a list of relative locations covered by the piece at this rotation - def offsets( location) - if is_even( location) then - @even_offsets.collect { | value | value + location } - else - @odd_offsets.collect { | value | value + location } - end - end - - # returns a set of offsets relative to the top-left most piece of the rotation (by even or odd rows) - # this is hard to explain. imagine we have this partial board: - # 0 0 0 0 0 x [positions 0-5] - # 0 0 1 1 0 x [positions 6-11] - # 0 0 1 0 0 x [positions 12-17] - # 0 1 0 0 0 x [positions 18-23] - # 0 1 0 0 0 x [positions 24-29] - # 0 0 0 0 0 x [positions 30-35] - # ... - # The top-left of the piece is at position 8, the - # board would be passed as a set of positions (values array) containing [8,9,14,19,25] not necessarily in that - # sorted order. Since that array starts on an odd row, the offsets for an odd row are: [0,1,6,11,17] obtained - # by subtracting 8 from everything. Now imagine the piece shifted up and to the right so it's on an even row: - # 0 0 0 1 1 x [positions 0-5] - # 0 0 1 0 0 x [positions 6-11] - # 0 0 1 0 0 x [positions 12-17] - # 0 1 0 0 0 x [positions 18-23] - # 0 0 0 0 0 x [positions 24-29] - # 0 0 0 0 0 x [positions 30-35] - # ... - # Now the positions are [3,4,8,14,19] which after subtracting the lowest value (3) gives [0,1,5,11,16] thus, the - # offsets for this particular piece are (in even, odd order) [0,1,5,11,16],[0,1,6,11,17] which is what - # this function would return - def normalize_offsets( values) - min = values.min - even_min = is_even(min) - other_min = even_min ? min + 6 : min + 7 - other_values = values.collect do | value | - if is_even(value) then - value + 6 - other_min - else - value + 7 - other_min - end - end - values.collect! { | value | value - min } - - if even_min then - [values, other_values] - else - [other_values, values] - end - end - - # produce a bitmask representation of an array of offset locations - def mask_for_offsets( offsets ) - mask = 0 - offsets.each { | value | mask = mask + ( 1 << value ) } - mask - end - - # finds a "safe" position that a position as described by a list of directions can be placed - # without falling off any edge of the board. the values returned a location to place the first piece - # at so it will fit after making the described moves - def start_adjust( directions ) - south = east = 0; - directions.each do | direction | - east += 1 if ( direction == :sw || direction == :nw || direction == :west ) - south += 1 if ( direction == :nw || direction == :ne ) - end - south * 6 + east - end - - # given a set of directions places the piece (as defined by a set of directions) on the board at - # a location that will not take it off the edge - def get_values ( directions ) - start = start_adjust(directions) - values = [ start ] - directions.each do | direction | - if (start % 12 >= 6) then - start += @@rotation_odd_adder[direction] - else - start += @@rotation_even_adder[direction] - end - values += [ start ] - end - - # some moves take you back to an existing location, we'll strip duplicates - values.uniq - end -end - -# describes a piece and caches information about its rotations to as to be efficient for iteration -# ATTRIBUTES: -# rotations -- all the rotations of the piece -# type -- a numeic "name" of the piece -# masks -- an array by location of all legal rotational masks (a n inner array) for that location -# placed -- the mask that this piece was last placed at (not a location, but the actual mask used) -class Piece - attr_reader :rotations, :type, :masks - attr_accessor :placed - - # transform hashes that change one direction into another when you either flip or rotate a set of directions - @@flip_converter = { :west => :west, :east => :east, :nw => :sw, :ne => :se, :sw => :nw, :se => :ne } - @@rotate_converter = { :west => :nw, :east => :se, :nw => :ne, :ne => :east, :sw => :west, :se => :sw } - - def initialize( directions, type ) - @type = type - @rotations = Array.new(); - @map = {} - - generate_rotations( directions ) - directions.collect! { | value | @@flip_converter[value] } - generate_rotations( directions ) - - # creates the masks AND a map that returns [location, rotation] for any given mask - # this is used when a board is found and we want to draw it, otherwise the map is unused - @masks = Array.new(); - 0.upto(59) do | i | - even = true - @masks[i] = @rotations.collect do | rotation | - mask = rotation.start_masks[i] - @map[mask[0]] = [ i, rotation ] if (mask) - mask || nil - end - @masks[i].compact! - end - end - - # rotates a set of directions through all six angles and adds a Rotation to the list for each one - def generate_rotations( directions ) - 6.times do - rotations.push( Rotation.new(directions)) - directions.collect! { | value | @@rotate_converter[value] } - end - end - - # given a board string, adds this piece to the board at whatever location/rotation - # important: the outbound board string is 5 wide, the normal location notation is six wide (padded) - def fill_string( board_string) - location, rotation = @map[@placed] - rotation.offsets(location).each do | offset | - row, col = offset.divmod(6) - board_string[ row*5 + col, 1 ] = @type.to_s - end - end -end - -# a blank bit board having this form: -# -# 0 0 0 0 0 1 -# 0 0 0 0 0 1 -# 0 0 0 0 0 1 -# 0 0 0 0 0 1 -# 0 0 0 0 0 1 -# 0 0 0 0 0 1 -# 0 0 0 0 0 1 -# 0 0 0 0 0 1 -# 0 0 0 0 0 1 -# 0 0 0 0 0 1 -# 1 1 1 1 1 1 -# -# where left lest significant bit is the top left and the most significant is the lower right -# the actual board only consists of the 0 places, the 1 places are blockers to keep things from running -# off the edges or bottom -def blank_board - 0b111111100000100000100000100000100000100000100000100000100000100000 -end - -def full_board - 0b111111111111111111111111111111111111111111111111111111111111111111 -end - -# determines if a location (bit position) is in an even row -def is_even( location) - (location % 12) < 6 -end - -# support function that create three utility maps: -# $converter -- for each row an array that maps a five bit row (via array mapping) -# to the a a five bit representation of the bits below it -# $bit_count -- maps a five bit row (via array mapping) to the number of 1s in the row -# @@new_regions -- maps a five bit row (via array mapping) to an array of "region" arrays -# a region array has three values the first is a mask of bits in the region, -# the second is the count of those bits and the third is identical to the first -# examples: -# 0b10010 => [ 0b01100, 2, 0b01100 ], [ 0b00001, 1, 0b00001] -# 0b01010 => [ 0b10000, 1, 0b10000 ], [ 0b00100, 1, 0b00100 ], [ 0b00001, 1, 0b00001] -# 0b10001 => [ 0b01110, 3, 0b01110 ] -def create_collector_support - odd_map = [0b11, 0b110, 0b1100, 0b11000, 0b10000] - even_map = [0b1, 0b11, 0b110, 0b1100, 0b11000] - - all_odds = Array.new(0b100000) - all_evens = Array.new(0b100000) - bit_counts = Array.new(0b100000) - new_regions = Array.new(0b100000) - 0.upto(0b11111) do | i | - bit_count = odd = even = 0 - 0.upto(4) do | bit | - if (i[bit] == 1) then - bit_count += 1 - odd |= odd_map[bit] - even |= even_map[bit] - end - end - all_odds[i] = odd - all_evens[i] = even - bit_counts[i] = bit_count - new_regions[i] = create_regions( i) - end - - $converter = [] - 10.times { | row | $converter.push((row % 2 == 0) ? all_evens : all_odds) } - $bit_counts = bit_counts - $regions = new_regions.collect { | set | set.collect { | value | [ value, bit_counts[value], value] } } -end - -# determines if a board is punable, meaning that there is no possibility that it -# can be filled up with pieces. A board is prunable if there is a grouping of unfilled spaces -# that are not a multiple of five. The following board is an example of a prunable board: -# 0 0 1 0 0 -# 0 1 0 0 0 -# 1 1 0 0 0 -# 0 1 0 0 0 -# 0 0 0 0 0 -# ... -# -# This board is prunable because the top left corner is only 3 bits in area, no piece will ever fit it -# parameters: -# board -- an initial bit board (6 bit padded rows, see blank_board for format) -# location -- starting location, everything above and to the left is already full -# slotting -- set to true only when testing initial pieces, when filling normally -# additional assumptions are possible -# -# Algorithm: -# The algorithm starts at the top row (as determined by location) and iterates a row at a time -# maintainng counts of active open areas (kept in the collector array) each collector contains -# three values at the start of an iteration: -# 0: mask of bits that would be adjacent to the collector in this row -# 1: the number of bits collected so far -# 2: a scratch space starting as zero, but used during the computation to represent -# the empty bits in the new row that are adjacent (position 0) -# The exact procedure is described in-code -def prunable( board, location, slotting = false) - collectors = [] - # loop accross the rows - (location / 6).to_i.upto(9) do | row_on | - # obtain a set of regions representing the bits of the curent row. - regions = $regions[(board >> (row_on * 6)) & 0b11111] - converter = $converter[row_on] - - # track the number of collectors at the start of the cycle so that - # we don't compute against newly created collectors, only existing collectors - initial_collector_count = collectors.length - - # loop against the regions. For each region of the row - # we will see if it connects to one or more existing collectors. - # if it connects to 1 collector, the bits from the region are added to the - # bits of the collector and the mask is placed in collector[2] - # If the region overlaps more than one collector then all the collectors - # it overlaps with are merged into the first one (the others are set to nil in the array) - # if NO collectors are found then the region is copied as a new collector - regions.each do | region | - collector_found = nil - region_mask = region[2] - initial_collector_count.times do | collector_num | - collector = collectors[collector_num] - if (collector) then - collector_mask = collector[0] - if (collector_mask & region_mask != 0) then - if (collector_found) then - collector_found[0] |= collector_mask - collector_found[1] += collector[1] - collector_found[2] |= collector[2] - collectors[collector_num] = nil - else - collector_found = collector - collector[1] += region[1] - collector[2] |= region_mask - end - end - end - end - if (collector_found == nil) then - collectors.push(Array.new(region)) - end - end - - # check the existing collectors, if any collector overlapped no bits in the region its [2] value will - # be zero. The size of any such reaason is tested if it is not a muliple of five true is returned since - # the board is prunable. if it is a multiple of five it is removed. - # Collector that are still active have a new adjacent value [0] set based n the matched bits - # and have [2] cleared out for the next cycle. - collectors.length.times do | collector_num | - collector = collectors[collector_num] - if (collector) then - if (collector[2] == 0) then - return true if (collector[1] % 5 != 0) - collectors[collector_num] = nil - else - # if a collector matches all bits in the row then we can return unprunable early for the - # follwing reasons: - # 1) there can be no more unavailable bits bince we fill from the top left downward - # 2) all previous regions have been closed or joined so only this region can fail - # 3) this region must be good since there can never be only 1 region that is nuot - # a multiple of five - # this rule only applies when filling normally, so we ignore the rule if we are "slotting" - # in pieces to see what configurations work for them (the only other time this algorithm is used). - return false if (collector[2] == 0b11111 && !slotting) - collector[0] = converter[collector[2]] - collector[2] = 0 - end - end - end - - # get rid of all the empty converters for the next round - collectors.compact! - end - return false if (collectors.length <= 1) # 1 collector or less and the region is fine - collectors.any? { | collector | (collector[1] % 5) != 0 } # more than 1 and we test them all for bad size -end - -# creates a region given a row mask. see prunable for what a "region" is -def create_regions( value ) - regions = [] - cur_region = 0 - 5.times do | bit | - if (value[bit] == 0) then - cur_region |= 1 << bit - else - if (cur_region != 0 ) then - regions.push( cur_region) - cur_region = 0; - end - end - end - regions.push(cur_region) if (cur_region != 0) - regions -end - -# find up to the counted number of solutions (or all solutions) and prints the final result -def find_all - find_top( 1) - find_top( 0) - print_results -end - -# show the board -def print_results - print "#{@boards_found} solutions found\n\n" - print_full_board( @min_board) - print "\n" - print_full_board( @max_board) - print "\n" -end - -# finds solutions. This special version of the main function is only used for the top level -# the reason for it is basically to force a particular ordering on how the rotations are tested for -# the first piece. It is called twice, first looking for placements of the odd rotations and then -# looking for placements of the even locations. -# -# WHY? -# Since any found solution has an inverse we want to maximize finding solutions that are not already found -# as an inverse. The inverse will ALWAYS be 3 one of the piece configurations that is exactly 3 rotations away -# (an odd number). Checking even vs odd then produces a higher probability of finding more pieces earlier -# in the cycle. We still need to keep checking all the permutations, but our probability of finding one will -# diminsh over time. Since we are TOLD how many to search for this lets us exit before checking all pieces -# this bennifit is very great when seeking small numbers of solutions and is 0 when looking for more than the -# maximum number -def find_top( rotation_skip) - board = blank_board - (@pieces.length-1).times do - piece = @pieces.shift - piece.masks[0].each do | mask, imask, cmask | - if ((rotation_skip += 1) % 2 == 0) then - piece.placed = mask - find( 1, 1, board | mask) - end - end - @pieces.push(piece) - end - piece = @pieces.shift - @pieces.push(piece) -end - -# the normail find routine, iterates through the available pieces, checks all rotations at the current location -# and adds any boards found. depth is acheived via recursion. the overall approach is described -# here: http://www-128.ibm.com/developerworks/java/library/j-javaopt/ -# parameters: -# start_location -- where to start looking for place for the next piece at -# placed -- number of pieces placed -# board -- current state of the board -# -# see in-code comments -def find( start_location, placed, board) - # find the next location to place a piece by looking for an empty bit - while board[start_location] == 1 - start_location += 1 - end - - @pieces.length.times do - piece = @pieces.shift - piece.masks[start_location].each do | mask, imask, cmask | - if ( board & cmask == imask) then - piece.placed = mask - if (placed == 9) then - add_board - else - find( start_location + 1, placed + 1, board | mask) - end - end - end - @pieces.push(piece) - end -end - -# print the board -def print_full_board( board_string) - 10.times do | row | - print " " if (row % 2 == 1) - 5.times do | col | - print "#{board_string[row*5 + col,1]} " - end - print "\n" - end -end - -# when a board is found we "draw it" into a string and then flip that string, adding both to -# the list (hash) of solutions if they are unique. -def add_board - board_string = "99999999999999999999999999999999999999999999999999" - @all_pieces.each { | piece | piece.fill_string( board_string ) } - save( board_string) - save( board_string.reverse) -end - -# adds a board string to the list (if new) and updates the current best/worst board -def save( board_string) - if (@all_boards[board_string] == nil) then - @min_board = board_string if (board_string < @min_board) - @max_board = board_string if (board_string > @max_board) - @all_boards.store(board_string,true) - @boards_found += 1 - - # the exit motif is a time saver. Ideally the function should return, but those tests - # take noticable time (performance). - if (@boards_found == @stop_count) then - print_results - exit(0) - end - end -end - - -## -## MAIN BODY :) -## -create_collector_support -@pieces = [ - Piece.new( [ :nw, :ne, :east, :east ], 2), - Piece.new( [ :ne, :se, :east, :ne ], 7), - Piece.new( [ :ne, :east, :ne, :nw ], 1), - Piece.new( [ :east, :sw, :sw, :se ], 6), - Piece.new( [ :east, :ne, :se, :ne ], 5), - Piece.new( [ :east, :east, :east, :se ], 0), - Piece.new( [ :ne, :nw, :se, :east, :se ], 4), - Piece.new( [ :se, :se, :se, :west ], 9), - Piece.new( [ :se, :se, :east, :se ], 8), - Piece.new( [ :east, :east, :sw, :se ], 3) - ]; - -@all_pieces = Array.new( @pieces) - -@min_board = "99999999999999999999999999999999999999999999999999" -@max_board = "00000000000000000000000000000000000000000000000000" -@stop_count = ARGV[0].to_i || 2089 -@all_boards = {} -@boards_found = 0 - -find_all ######## DO IT!!! - +#!/usr/bin/env ruby +# +# The Computer Language Shootout +# http://shootout.alioth.debian.org +# contributed by Kevin Barnes (Ruby novice) + +# PROGRAM: the main body is at the bottom. +# 1) read about the problem here: http://www-128.ibm.com/developerworks/java/library/j-javaopt/ +# 2) see how I represent a board as a bitmask by reading the blank_board comments +# 3) read as your mental paths take you + +def print *args +end + +# class to represent all information about a particular rotation of a particular piece +class Rotation + # an array (by location) containing a bit mask for how the piece maps at the given location. + # if the rotation is illegal at that location the mask will contain false + attr_reader :start_masks + + # maps a direction to a relative location. these differ depending on whether it is an even or + # odd row being mapped from + @@rotation_even_adder = { :west => -1, :east => 1, :nw => -7, :ne => -6, :sw => 5, :se => 6 } + @@rotation_odd_adder = { :west => -1, :east => 1, :nw => -6, :ne => -5, :sw => 6, :se => 7 } + + def initialize( directions ) + @even_offsets, @odd_offsets = normalize_offsets( get_values( directions )) + + @even_mask = mask_for_offsets( @even_offsets) + @odd_mask = mask_for_offsets( @odd_offsets) + + @start_masks = Array.new(60) + + # create the rotational masks by placing the base mask at the location and seeing if + # 1) it overlaps the boundries and 2) it produces a prunable board. if either of these + # is true the piece cannot be placed + 0.upto(59) do | offset | + mask = is_even(offset) ? (@even_mask << offset) : (@odd_mask << offset) + if (blank_board & mask == 0 && !prunable(blank_board | mask, 0, true)) then + imask = compute_required( mask, offset) + @start_masks[offset] = [ mask, imask, imask | mask ] + else + @start_masks[offset] = false + end + end + end + + def compute_required( mask, offset ) + board = blank_board + 0.upto(offset) { | i | board |= 1 << i } + board |= mask + return 0 if (!prunable(board | mask, offset)) + board = flood_fill(board,58) + count = 0 + imask = 0 + 0.upto(59) do | i | + if (board[i] == 0) then + imask |= (1 << i) + count += 1 + end + end + (count > 0 && count < 5) ? imask : 0 + end + + def flood_fill( board, location) + return board if (board[location] == 1) + board |= 1 << location + row, col = location.divmod(6) + board = flood_fill( board, location - 1) if (col > 0) + board = flood_fill( board, location + 1) if (col < 4) + if (row % 2 == 0) then + board = flood_fill( board, location - 7) if (col > 0 && row > 0) + board = flood_fill( board, location - 6) if (row > 0) + board = flood_fill( board, location + 6) if (row < 9) + board = flood_fill( board, location + 5) if (col > 0 && row < 9) + else + board = flood_fill( board, location - 5) if (col < 4 && row > 0) + board = flood_fill( board, location - 6) if (row > 0) + board = flood_fill( board, location + 6) if (row < 9) + board = flood_fill( board, location + 7) if (col < 4 && row < 9) + end + board + end + + # given a location, produces a list of relative locations covered by the piece at this rotation + def offsets( location) + if is_even( location) then + @even_offsets.collect { | value | value + location } + else + @odd_offsets.collect { | value | value + location } + end + end + + # returns a set of offsets relative to the top-left most piece of the rotation (by even or odd rows) + # this is hard to explain. imagine we have this partial board: + # 0 0 0 0 0 x [positions 0-5] + # 0 0 1 1 0 x [positions 6-11] + # 0 0 1 0 0 x [positions 12-17] + # 0 1 0 0 0 x [positions 18-23] + # 0 1 0 0 0 x [positions 24-29] + # 0 0 0 0 0 x [positions 30-35] + # ... + # The top-left of the piece is at position 8, the + # board would be passed as a set of positions (values array) containing [8,9,14,19,25] not necessarily in that + # sorted order. Since that array starts on an odd row, the offsets for an odd row are: [0,1,6,11,17] obtained + # by subtracting 8 from everything. Now imagine the piece shifted up and to the right so it's on an even row: + # 0 0 0 1 1 x [positions 0-5] + # 0 0 1 0 0 x [positions 6-11] + # 0 0 1 0 0 x [positions 12-17] + # 0 1 0 0 0 x [positions 18-23] + # 0 0 0 0 0 x [positions 24-29] + # 0 0 0 0 0 x [positions 30-35] + # ... + # Now the positions are [3,4,8,14,19] which after subtracting the lowest value (3) gives [0,1,5,11,16] thus, the + # offsets for this particular piece are (in even, odd order) [0,1,5,11,16],[0,1,6,11,17] which is what + # this function would return + def normalize_offsets( values) + min = values.min + even_min = is_even(min) + other_min = even_min ? min + 6 : min + 7 + other_values = values.collect do | value | + if is_even(value) then + value + 6 - other_min + else + value + 7 - other_min + end + end + values.collect! { | value | value - min } + + if even_min then + [values, other_values] + else + [other_values, values] + end + end + + # produce a bitmask representation of an array of offset locations + def mask_for_offsets( offsets ) + mask = 0 + offsets.each { | value | mask = mask + ( 1 << value ) } + mask + end + + # finds a "safe" position that a position as described by a list of directions can be placed + # without falling off any edge of the board. the values returned a location to place the first piece + # at so it will fit after making the described moves + def start_adjust( directions ) + south = east = 0; + directions.each do | direction | + east += 1 if ( direction == :sw || direction == :nw || direction == :west ) + south += 1 if ( direction == :nw || direction == :ne ) + end + south * 6 + east + end + + # given a set of directions places the piece (as defined by a set of directions) on the board at + # a location that will not take it off the edge + def get_values ( directions ) + start = start_adjust(directions) + values = [ start ] + directions.each do | direction | + if (start % 12 >= 6) then + start += @@rotation_odd_adder[direction] + else + start += @@rotation_even_adder[direction] + end + values += [ start ] + end + + # some moves take you back to an existing location, we'll strip duplicates + values.uniq + end +end + +# describes a piece and caches information about its rotations to as to be efficient for iteration +# ATTRIBUTES: +# rotations -- all the rotations of the piece +# type -- a numeic "name" of the piece +# masks -- an array by location of all legal rotational masks (a n inner array) for that location +# placed -- the mask that this piece was last placed at (not a location, but the actual mask used) +class Piece + attr_reader :rotations, :type, :masks + attr_accessor :placed + + # transform hashes that change one direction into another when you either flip or rotate a set of directions + @@flip_converter = { :west => :west, :east => :east, :nw => :sw, :ne => :se, :sw => :nw, :se => :ne } + @@rotate_converter = { :west => :nw, :east => :se, :nw => :ne, :ne => :east, :sw => :west, :se => :sw } + + def initialize( directions, type ) + @type = type + @rotations = Array.new(); + @map = {} + + generate_rotations( directions ) + directions.collect! { | value | @@flip_converter[value] } + generate_rotations( directions ) + + # creates the masks AND a map that returns [location, rotation] for any given mask + # this is used when a board is found and we want to draw it, otherwise the map is unused + @masks = Array.new(); + 0.upto(59) do | i | + even = true + @masks[i] = @rotations.collect do | rotation | + mask = rotation.start_masks[i] + @map[mask[0]] = [ i, rotation ] if (mask) + mask || nil + end + @masks[i].compact! + end + end + + # rotates a set of directions through all six angles and adds a Rotation to the list for each one + def generate_rotations( directions ) + 6.times do + rotations.push( Rotation.new(directions)) + directions.collect! { | value | @@rotate_converter[value] } + end + end + + # given a board string, adds this piece to the board at whatever location/rotation + # important: the outbound board string is 5 wide, the normal location notation is six wide (padded) + def fill_string( board_string) + location, rotation = @map[@placed] + rotation.offsets(location).each do | offset | + row, col = offset.divmod(6) + board_string[ row*5 + col, 1 ] = @type.to_s + end + end +end + +# a blank bit board having this form: +# +# 0 0 0 0 0 1 +# 0 0 0 0 0 1 +# 0 0 0 0 0 1 +# 0 0 0 0 0 1 +# 0 0 0 0 0 1 +# 0 0 0 0 0 1 +# 0 0 0 0 0 1 +# 0 0 0 0 0 1 +# 0 0 0 0 0 1 +# 0 0 0 0 0 1 +# 1 1 1 1 1 1 +# +# where left lest significant bit is the top left and the most significant is the lower right +# the actual board only consists of the 0 places, the 1 places are blockers to keep things from running +# off the edges or bottom +def blank_board + 0b111111100000100000100000100000100000100000100000100000100000100000 +end + +def full_board + 0b111111111111111111111111111111111111111111111111111111111111111111 +end + +# determines if a location (bit position) is in an even row +def is_even( location) + (location % 12) < 6 +end + +# support function that create three utility maps: +# $converter -- for each row an array that maps a five bit row (via array mapping) +# to the a a five bit representation of the bits below it +# $bit_count -- maps a five bit row (via array mapping) to the number of 1s in the row +# @@new_regions -- maps a five bit row (via array mapping) to an array of "region" arrays +# a region array has three values the first is a mask of bits in the region, +# the second is the count of those bits and the third is identical to the first +# examples: +# 0b10010 => [ 0b01100, 2, 0b01100 ], [ 0b00001, 1, 0b00001] +# 0b01010 => [ 0b10000, 1, 0b10000 ], [ 0b00100, 1, 0b00100 ], [ 0b00001, 1, 0b00001] +# 0b10001 => [ 0b01110, 3, 0b01110 ] +def create_collector_support + odd_map = [0b11, 0b110, 0b1100, 0b11000, 0b10000] + even_map = [0b1, 0b11, 0b110, 0b1100, 0b11000] + + all_odds = Array.new(0b100000) + all_evens = Array.new(0b100000) + bit_counts = Array.new(0b100000) + new_regions = Array.new(0b100000) + 0.upto(0b11111) do | i | + bit_count = odd = even = 0 + 0.upto(4) do | bit | + if (i[bit] == 1) then + bit_count += 1 + odd |= odd_map[bit] + even |= even_map[bit] + end + end + all_odds[i] = odd + all_evens[i] = even + bit_counts[i] = bit_count + new_regions[i] = create_regions( i) + end + + $converter = [] + 10.times { | row | $converter.push((row % 2 == 0) ? all_evens : all_odds) } + $bit_counts = bit_counts + $regions = new_regions.collect { | set | set.collect { | value | [ value, bit_counts[value], value] } } +end + +# determines if a board is punable, meaning that there is no possibility that it +# can be filled up with pieces. A board is prunable if there is a grouping of unfilled spaces +# that are not a multiple of five. The following board is an example of a prunable board: +# 0 0 1 0 0 +# 0 1 0 0 0 +# 1 1 0 0 0 +# 0 1 0 0 0 +# 0 0 0 0 0 +# ... +# +# This board is prunable because the top left corner is only 3 bits in area, no piece will ever fit it +# parameters: +# board -- an initial bit board (6 bit padded rows, see blank_board for format) +# location -- starting location, everything above and to the left is already full +# slotting -- set to true only when testing initial pieces, when filling normally +# additional assumptions are possible +# +# Algorithm: +# The algorithm starts at the top row (as determined by location) and iterates a row at a time +# maintainng counts of active open areas (kept in the collector array) each collector contains +# three values at the start of an iteration: +# 0: mask of bits that would be adjacent to the collector in this row +# 1: the number of bits collected so far +# 2: a scratch space starting as zero, but used during the computation to represent +# the empty bits in the new row that are adjacent (position 0) +# The exact procedure is described in-code +def prunable( board, location, slotting = false) + collectors = [] + # loop accross the rows + (location / 6).to_i.upto(9) do | row_on | + # obtain a set of regions representing the bits of the curent row. + regions = $regions[(board >> (row_on * 6)) & 0b11111] + converter = $converter[row_on] + + # track the number of collectors at the start of the cycle so that + # we don't compute against newly created collectors, only existing collectors + initial_collector_count = collectors.length + + # loop against the regions. For each region of the row + # we will see if it connects to one or more existing collectors. + # if it connects to 1 collector, the bits from the region are added to the + # bits of the collector and the mask is placed in collector[2] + # If the region overlaps more than one collector then all the collectors + # it overlaps with are merged into the first one (the others are set to nil in the array) + # if NO collectors are found then the region is copied as a new collector + regions.each do | region | + collector_found = nil + region_mask = region[2] + initial_collector_count.times do | collector_num | + collector = collectors[collector_num] + if (collector) then + collector_mask = collector[0] + if (collector_mask & region_mask != 0) then + if (collector_found) then + collector_found[0] |= collector_mask + collector_found[1] += collector[1] + collector_found[2] |= collector[2] + collectors[collector_num] = nil + else + collector_found = collector + collector[1] += region[1] + collector[2] |= region_mask + end + end + end + end + if (collector_found == nil) then + collectors.push(Array.new(region)) + end + end + + # check the existing collectors, if any collector overlapped no bits in the region its [2] value will + # be zero. The size of any such reaason is tested if it is not a muliple of five true is returned since + # the board is prunable. if it is a multiple of five it is removed. + # Collector that are still active have a new adjacent value [0] set based n the matched bits + # and have [2] cleared out for the next cycle. + collectors.length.times do | collector_num | + collector = collectors[collector_num] + if (collector) then + if (collector[2] == 0) then + return true if (collector[1] % 5 != 0) + collectors[collector_num] = nil + else + # if a collector matches all bits in the row then we can return unprunable early for the + # follwing reasons: + # 1) there can be no more unavailable bits bince we fill from the top left downward + # 2) all previous regions have been closed or joined so only this region can fail + # 3) this region must be good since there can never be only 1 region that is nuot + # a multiple of five + # this rule only applies when filling normally, so we ignore the rule if we are "slotting" + # in pieces to see what configurations work for them (the only other time this algorithm is used). + return false if (collector[2] == 0b11111 && !slotting) + collector[0] = converter[collector[2]] + collector[2] = 0 + end + end + end + + # get rid of all the empty converters for the next round + collectors.compact! + end + return false if (collectors.length <= 1) # 1 collector or less and the region is fine + collectors.any? { | collector | (collector[1] % 5) != 0 } # more than 1 and we test them all for bad size +end + +# creates a region given a row mask. see prunable for what a "region" is +def create_regions( value ) + regions = [] + cur_region = 0 + 5.times do | bit | + if (value[bit] == 0) then + cur_region |= 1 << bit + else + if (cur_region != 0 ) then + regions.push( cur_region) + cur_region = 0; + end + end + end + regions.push(cur_region) if (cur_region != 0) + regions +end + +# find up to the counted number of solutions (or all solutions) and prints the final result +def find_all + find_top( 1) + find_top( 0) + print_results +end + +# show the board +def print_results + print "#{@boards_found} solutions found\n\n" + print_full_board( @min_board) + print "\n" + print_full_board( @max_board) + print "\n" +end + +# finds solutions. This special version of the main function is only used for the top level +# the reason for it is basically to force a particular ordering on how the rotations are tested for +# the first piece. It is called twice, first looking for placements of the odd rotations and then +# looking for placements of the even locations. +# +# WHY? +# Since any found solution has an inverse we want to maximize finding solutions that are not already found +# as an inverse. The inverse will ALWAYS be 3 one of the piece configurations that is exactly 3 rotations away +# (an odd number). Checking even vs odd then produces a higher probability of finding more pieces earlier +# in the cycle. We still need to keep checking all the permutations, but our probability of finding one will +# diminsh over time. Since we are TOLD how many to search for this lets us exit before checking all pieces +# this bennifit is very great when seeking small numbers of solutions and is 0 when looking for more than the +# maximum number +def find_top( rotation_skip) + board = blank_board + (@pieces.length-1).times do + piece = @pieces.shift + piece.masks[0].each do | mask, imask, cmask | + if ((rotation_skip += 1) % 2 == 0) then + piece.placed = mask + find( 1, 1, board | mask) + end + end + @pieces.push(piece) + end + piece = @pieces.shift + @pieces.push(piece) +end + +# the normail find routine, iterates through the available pieces, checks all rotations at the current location +# and adds any boards found. depth is acheived via recursion. the overall approach is described +# here: http://www-128.ibm.com/developerworks/java/library/j-javaopt/ +# parameters: +# start_location -- where to start looking for place for the next piece at +# placed -- number of pieces placed +# board -- current state of the board +# +# see in-code comments +def find( start_location, placed, board) + # find the next location to place a piece by looking for an empty bit + while board[start_location] == 1 + start_location += 1 + end + + @pieces.length.times do + piece = @pieces.shift + piece.masks[start_location].each do | mask, imask, cmask | + if ( board & cmask == imask) then + piece.placed = mask + if (placed == 9) then + add_board + else + find( start_location + 1, placed + 1, board | mask) + end + end + end + @pieces.push(piece) + end +end + +# print the board +def print_full_board( board_string) + 10.times do | row | + print " " if (row % 2 == 1) + 5.times do | col | + print "#{board_string[row*5 + col,1]} " + end + print "\n" + end +end + +# when a board is found we "draw it" into a string and then flip that string, adding both to +# the list (hash) of solutions if they are unique. +def add_board + board_string = "99999999999999999999999999999999999999999999999999" + @all_pieces.each { | piece | piece.fill_string( board_string ) } + save( board_string) + save( board_string.reverse) +end + +# adds a board string to the list (if new) and updates the current best/worst board +def save( board_string) + if (@all_boards[board_string] == nil) then + @min_board = board_string if (board_string < @min_board) + @max_board = board_string if (board_string > @max_board) + @all_boards.store(board_string,true) + @boards_found += 1 + + # the exit motif is a time saver. Ideally the function should return, but those tests + # take noticable time (performance). + if (@boards_found == @stop_count) then + print_results + exit(0) + end + end +end + + +## +## MAIN BODY :) +## +create_collector_support +@pieces = [ + Piece.new( [ :nw, :ne, :east, :east ], 2), + Piece.new( [ :ne, :se, :east, :ne ], 7), + Piece.new( [ :ne, :east, :ne, :nw ], 1), + Piece.new( [ :east, :sw, :sw, :se ], 6), + Piece.new( [ :east, :ne, :se, :ne ], 5), + Piece.new( [ :east, :east, :east, :se ], 0), + Piece.new( [ :ne, :nw, :se, :east, :se ], 4), + Piece.new( [ :se, :se, :se, :west ], 9), + Piece.new( [ :se, :se, :east, :se ], 8), + Piece.new( [ :east, :east, :sw, :se ], 3) + ]; + +@all_pieces = Array.new( @pieces) + +@min_board = "99999999999999999999999999999999999999999999999999" +@max_board = "00000000000000000000000000000000000000000000000000" +@stop_count = ARGV[0].to_i || 2089 +@all_boards = {} +@boards_found = 0 + +find_all ######## DO IT!!! + diff --git a/bench/yarv/bm_so_nbody.rb b/bench/yarv/bm_so_nbody.rb index d6c5bb9e61f..709d58b7ff8 100644 --- a/bench/yarv/bm_so_nbody.rb +++ b/bench/yarv/bm_so_nbody.rb @@ -1,148 +1,148 @@ -# The Computer Language Shootout -# http://shootout.alioth.debian.org -# -# Optimized for Ruby by Jesse Millikan -# From version ported by Michael Neumann from the C gcc version, -# which was written by Christoph Bauer. - -SOLAR_MASS = 4 * Math::PI**2 -DAYS_PER_YEAR = 365.24 - -def _puts *args -end - -class Planet - attr_accessor :x, :y, :z, :vx, :vy, :vz, :mass - - def initialize(x, y, z, vx, vy, vz, mass) - @x, @y, @z = x, y, z - @vx, @vy, @vz = vx * DAYS_PER_YEAR, vy * DAYS_PER_YEAR, vz * DAYS_PER_YEAR - @mass = mass * SOLAR_MASS - end - - def move_from_i(bodies, nbodies, dt, i) - while i < nbodies - b2 = bodies[i] - dx = @x - b2.x - dy = @y - b2.y - dz = @z - b2.z - - distance = Math.sqrt(dx * dx + dy * dy + dz * dz) - mag = dt / (distance * distance * distance) - b_mass_mag, b2_mass_mag = @mass * mag, b2.mass * mag - - @vx -= dx * b2_mass_mag - @vy -= dy * b2_mass_mag - @vz -= dz * b2_mass_mag - b2.vx += dx * b_mass_mag - b2.vy += dy * b_mass_mag - b2.vz += dz * b_mass_mag - i += 1 - end - - @x += dt * @vx - @y += dt * @vy - @z += dt * @vz - end -end - -def energy(bodies) - e = 0.0 - nbodies = bodies.size - - for i in 0 ... nbodies - b = bodies[i] - e += 0.5 * b.mass * (b.vx * b.vx + b.vy * b.vy + b.vz * b.vz) - for j in (i + 1) ... nbodies - b2 = bodies[j] - dx = b.x - b2.x - dy = b.y - b2.y - dz = b.z - b2.z - distance = Math.sqrt(dx * dx + dy * dy + dz * dz) - e -= (b.mass * b2.mass) / distance - end - end - e -end - -def offset_momentum(bodies) - px, py, pz = 0.0, 0.0, 0.0 - - for b in bodies - m = b.mass - px += b.vx * m - py += b.vy * m - pz += b.vz * m - end - - b = bodies[0] - b.vx = - px / SOLAR_MASS - b.vy = - py / SOLAR_MASS - b.vz = - pz / SOLAR_MASS -end - -BODIES = [ - # sun - Planet.new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0), - - # jupiter - Planet.new( - 4.84143144246472090e+00, - -1.16032004402742839e+00, - -1.03622044471123109e-01, - 1.66007664274403694e-03, - 7.69901118419740425e-03, - -6.90460016972063023e-05, - 9.54791938424326609e-04), - - # saturn - Planet.new( - 8.34336671824457987e+00, - 4.12479856412430479e+00, - -4.03523417114321381e-01, - -2.76742510726862411e-03, - 4.99852801234917238e-03, - 2.30417297573763929e-05, - 2.85885980666130812e-04), - - # uranus - Planet.new( - 1.28943695621391310e+01, - -1.51111514016986312e+01, - -2.23307578892655734e-01, - 2.96460137564761618e-03, - 2.37847173959480950e-03, - -2.96589568540237556e-05, - 4.36624404335156298e-05), - - # neptune - Planet.new( - 1.53796971148509165e+01, - -2.59193146099879641e+01, - 1.79258772950371181e-01, - 2.68067772490389322e-03, - 1.62824170038242295e-03, - -9.51592254519715870e-05, - 5.15138902046611451e-05) -] - -init = 200_000 # ARGV[0] -n = Integer(init) - -offset_momentum(BODIES) - -puts "%.9f" % energy(BODIES) - -nbodies = BODIES.size -dt = 0.01 - -n.times do - i = 0 - while i < nbodies - b = BODIES[i] - b.move_from_i(BODIES, nbodies, dt, i + 1) - i += 1 - end -end - -puts "%.9f" % energy(BODIES) +# The Computer Language Shootout +# http://shootout.alioth.debian.org +# +# Optimized for Ruby by Jesse Millikan +# From version ported by Michael Neumann from the C gcc version, +# which was written by Christoph Bauer. + +SOLAR_MASS = 4 * Math::PI**2 +DAYS_PER_YEAR = 365.24 + +def _puts *args +end + +class Planet + attr_accessor :x, :y, :z, :vx, :vy, :vz, :mass + + def initialize(x, y, z, vx, vy, vz, mass) + @x, @y, @z = x, y, z + @vx, @vy, @vz = vx * DAYS_PER_YEAR, vy * DAYS_PER_YEAR, vz * DAYS_PER_YEAR + @mass = mass * SOLAR_MASS + end + + def move_from_i(bodies, nbodies, dt, i) + while i < nbodies + b2 = bodies[i] + dx = @x - b2.x + dy = @y - b2.y + dz = @z - b2.z + + distance = Math.sqrt(dx * dx + dy * dy + dz * dz) + mag = dt / (distance * distance * distance) + b_mass_mag, b2_mass_mag = @mass * mag, b2.mass * mag + + @vx -= dx * b2_mass_mag + @vy -= dy * b2_mass_mag + @vz -= dz * b2_mass_mag + b2.vx += dx * b_mass_mag + b2.vy += dy * b_mass_mag + b2.vz += dz * b_mass_mag + i += 1 + end + + @x += dt * @vx + @y += dt * @vy + @z += dt * @vz + end +end + +def energy(bodies) + e = 0.0 + nbodies = bodies.size + + for i in 0 ... nbodies + b = bodies[i] + e += 0.5 * b.mass * (b.vx * b.vx + b.vy * b.vy + b.vz * b.vz) + for j in (i + 1) ... nbodies + b2 = bodies[j] + dx = b.x - b2.x + dy = b.y - b2.y + dz = b.z - b2.z + distance = Math.sqrt(dx * dx + dy * dy + dz * dz) + e -= (b.mass * b2.mass) / distance + end + end + e +end + +def offset_momentum(bodies) + px, py, pz = 0.0, 0.0, 0.0 + + for b in bodies + m = b.mass + px += b.vx * m + py += b.vy * m + pz += b.vz * m + end + + b = bodies[0] + b.vx = - px / SOLAR_MASS + b.vy = - py / SOLAR_MASS + b.vz = - pz / SOLAR_MASS +end + +BODIES = [ + # sun + Planet.new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0), + + # jupiter + Planet.new( + 4.84143144246472090e+00, + -1.16032004402742839e+00, + -1.03622044471123109e-01, + 1.66007664274403694e-03, + 7.69901118419740425e-03, + -6.90460016972063023e-05, + 9.54791938424326609e-04), + + # saturn + Planet.new( + 8.34336671824457987e+00, + 4.12479856412430479e+00, + -4.03523417114321381e-01, + -2.76742510726862411e-03, + 4.99852801234917238e-03, + 2.30417297573763929e-05, + 2.85885980666130812e-04), + + # uranus + Planet.new( + 1.28943695621391310e+01, + -1.51111514016986312e+01, + -2.23307578892655734e-01, + 2.96460137564761618e-03, + 2.37847173959480950e-03, + -2.96589568540237556e-05, + 4.36624404335156298e-05), + + # neptune + Planet.new( + 1.53796971148509165e+01, + -2.59193146099879641e+01, + 1.79258772950371181e-01, + 2.68067772490389322e-03, + 1.62824170038242295e-03, + -9.51592254519715870e-05, + 5.15138902046611451e-05) +] + +init = 200_000 # ARGV[0] +n = Integer(init) + +offset_momentum(BODIES) + +puts "%.9f" % energy(BODIES) + +nbodies = BODIES.size +dt = 0.01 + +n.times do + i = 0 + while i < nbodies + b = BODIES[i] + b.move_from_i(BODIES, nbodies, dt, i + 1) + i += 1 + end +end + +puts "%.9f" % energy(BODIES) diff --git a/bench/yarv/bm_so_nsieve.rb b/bench/yarv/bm_so_nsieve.rb index a65cc782331..59aead58938 100644 --- a/bench/yarv/bm_so_nsieve.rb +++ b/bench/yarv/bm_so_nsieve.rb @@ -1,35 +1,35 @@ -# The Computer Language Shootout -# http://shootout.alioth.debian.org/ -# -# contributed by Glenn Parker, March 2005 -# modified by Evan Phoenix, Sept 2006 - -def sieve(m) - flags = Flags.dup[0,m] - count = 0 - pmax = m - 1 - p = 2 - while p <= pmax - unless flags[p].zero? - count += 1 - mult = p - while mult <= pmax - flags[mult] = 0 - mult += p - end - end - p += 1 - end - count -end - -n = 9 # (ARGV[0] || 2).to_i -Flags = ("\x1" * ( 2 ** n * 10_000)).unpack("c*") - -n.downto(n-2) do |exponent| - break if exponent < 0 - m = (1 << exponent) * 10_000 - # m = (2 ** exponent) * 10_000 - count = sieve(m) - printf "Primes up to %8d %8d\n", m, count -end +# The Computer Language Shootout +# http://shootout.alioth.debian.org/ +# +# contributed by Glenn Parker, March 2005 +# modified by Evan Phoenix, Sept 2006 + +def sieve(m) + flags = Flags.dup[0,m] + count = 0 + pmax = m - 1 + p = 2 + while p <= pmax + unless flags[p].zero? + count += 1 + mult = p + while mult <= pmax + flags[mult] = 0 + mult += p + end + end + p += 1 + end + count +end + +n = 9 # (ARGV[0] || 2).to_i +Flags = ("\x1" * ( 2 ** n * 10_000)).unpack("c*") + +n.downto(n-2) do |exponent| + break if exponent < 0 + m = (1 << exponent) * 10_000 + # m = (2 ** exponent) * 10_000 + count = sieve(m) + printf "Primes up to %8d %8d\n", m, count +end diff --git a/bench/yarv/bm_so_nsieve_bits.rb b/bench/yarv/bm_so_nsieve_bits.rb index 019b8b6382c..693b2f246dd 100644 --- a/bench/yarv/bm_so_nsieve_bits.rb +++ b/bench/yarv/bm_so_nsieve_bits.rb @@ -1,42 +1,42 @@ -#!/usr/bin/ruby -# -# The Great Computer Language Shootout -# http://shootout.alioth.debian.org/ -# -# nsieve-bits in Ruby -# Contributed by Glenn Parker, March 2005 - -CharExponent = 3 -BitsPerChar = 1 << CharExponent -LowMask = BitsPerChar - 1 - -def sieve(m) - items = "\xFF" * ((m / BitsPerChar) + 1) - masks = "" - BitsPerChar.times do |b| - masks << (1 << b).chr - end - - count = 0 - pmax = m - 1 - 2.step(pmax, 1) do |p| - if items[p >> CharExponent][p & LowMask] == 1 - count += 1 - p.step(pmax, p) do |mult| - a = mult >> CharExponent - b = mult & LowMask - items[a] -= masks[b] if items[a][b] != 0 - end - end - end - count -end - -n = 9 # (ARGV[0] || 2).to_i -n.step(n - 2, -1) do |exponent| - break if exponent < 0 - m = 2 ** exponent * 10_000 - count = sieve(m) - printf "Primes up to %8d %8d\n", m, count -end - +#!/usr/bin/ruby +# +# The Great Computer Language Shootout +# http://shootout.alioth.debian.org/ +# +# nsieve-bits in Ruby +# Contributed by Glenn Parker, March 2005 + +CharExponent = 3 +BitsPerChar = 1 << CharExponent +LowMask = BitsPerChar - 1 + +def sieve(m) + items = "\xFF" * ((m / BitsPerChar) + 1) + masks = "" + BitsPerChar.times do |b| + masks << (1 << b).chr + end + + count = 0 + pmax = m - 1 + 2.step(pmax, 1) do |p| + if items[p >> CharExponent][p & LowMask] == 1 + count += 1 + p.step(pmax, p) do |mult| + a = mult >> CharExponent + b = mult & LowMask + items[a] -= masks[b] if items[a][b] != 0 + end + end + end + count +end + +n = 9 # (ARGV[0] || 2).to_i +n.step(n - 2, -1) do |exponent| + break if exponent < 0 + m = 2 ** exponent * 10_000 + count = sieve(m) + printf "Primes up to %8d %8d\n", m, count +end + diff --git a/bench/yarv/bm_so_partial_sums.rb b/bench/yarv/bm_so_partial_sums.rb index 630b45cb8de..41f0a5fb874 100644 --- a/bench/yarv/bm_so_partial_sums.rb +++ b/bench/yarv/bm_so_partial_sums.rb @@ -1,31 +1,31 @@ -n = 2_500_000 # (ARGV.shift || 1).to_i - -alt = 1.0 ; s0 = s1 = s2 = s3 = s4 = s5 = s6 = s7 = s8 = 0.0 - -1.upto(n) do |d| - d = d.to_f ; d2 = d * d ; d3 = d2 * d ; ds = Math.sin(d) ; dc = Math.cos(d) - - s0 += (2.0 / 3.0) ** (d - 1.0) - s1 += 1.0 / Math.sqrt(d) - s2 += 1.0 / (d * (d + 1.0)) - s3 += 1.0 / (d3 * ds * ds) - s4 += 1.0 / (d3 * dc * dc) - s5 += 1.0 / d - s6 += 1.0 / d2 - s7 += alt / d - s8 += alt / (2.0 * d - 1.0) - - alt = -alt -end - -if false - printf("%.9f\t(2/3)^k\n", s0) - printf("%.9f\tk^-0.5\n", s1) - printf("%.9f\t1/k(k+1)\n", s2) - printf("%.9f\tFlint Hills\n", s3) - printf("%.9f\tCookson Hills\n", s4) - printf("%.9f\tHarmonic\n", s5) - printf("%.9f\tRiemann Zeta\n", s6) - printf("%.9f\tAlternating Harmonic\n", s7) - printf("%.9f\tGregory\n", s8) -end +n = 2_500_000 # (ARGV.shift || 1).to_i + +alt = 1.0 ; s0 = s1 = s2 = s3 = s4 = s5 = s6 = s7 = s8 = 0.0 + +1.upto(n) do |d| + d = d.to_f ; d2 = d * d ; d3 = d2 * d ; ds = Math.sin(d) ; dc = Math.cos(d) + + s0 += (2.0 / 3.0) ** (d - 1.0) + s1 += 1.0 / Math.sqrt(d) + s2 += 1.0 / (d * (d + 1.0)) + s3 += 1.0 / (d3 * ds * ds) + s4 += 1.0 / (d3 * dc * dc) + s5 += 1.0 / d + s6 += 1.0 / d2 + s7 += alt / d + s8 += alt / (2.0 * d - 1.0) + + alt = -alt +end + +if false + printf("%.9f\t(2/3)^k\n", s0) + printf("%.9f\tk^-0.5\n", s1) + printf("%.9f\t1/k(k+1)\n", s2) + printf("%.9f\tFlint Hills\n", s3) + printf("%.9f\tCookson Hills\n", s4) + printf("%.9f\tHarmonic\n", s5) + printf("%.9f\tRiemann Zeta\n", s6) + printf("%.9f\tAlternating Harmonic\n", s7) + printf("%.9f\tGregory\n", s8) +end diff --git a/bench/yarv/bm_so_pidigits.rb b/bench/yarv/bm_so_pidigits.rb index c7d6fbfb4d2..acffe71ae78 100644 --- a/bench/yarv/bm_so_pidigits.rb +++ b/bench/yarv/bm_so_pidigits.rb @@ -1,92 +1,92 @@ -# The Great Computer Language Shootout -# http://shootout.alioth.debian.org/ -# -# contributed by Gabriele Renzi - -class PiDigitSpigot - - def initialize() - @z = Transformation.new 1,0,0,1 - @x = Transformation.new 0,0,0,0 - @inverse = Transformation.new 0,0,0,0 - end - - def next! - @y = @z.extract(3) - if safe? @y - @z = produce(@y) - @y - else - @z = consume @x.next!() - next!() - end - end - - def safe?(digit) - digit == @z.extract(4) - end - - def produce(i) - @inverse.qrst(10,-10*i,0,1).compose(@z) - end - - def consume(a) - @z.compose(a) - end -end - - -class Transformation - attr_reader :q, :r, :s, :t - def initialize (q, r, s, t) - @q,@r,@s,@t,@k = q,r,s,t,0 - end - - def next!() - @q = @k = @k + 1 - @r = 4 * @k + 2 - @s = 0 - @t = 2 * @k + 1 - self - end - - def extract(j) - (@q * j + @r) / (@s * j + @t) - end - - def compose(a) - self.class.new( @q * a.q, - @q * a.r + r * a.t, - @s * a.q + t * a.s, - @s * a.r + t * a.t - ) - end - - def qrst *args - initialize *args - self - end - - -end - - -WIDTH = 10 -n = 2_500 # Integer(ARGV[0]) -j = 0 - -digits = PiDigitSpigot.new - -while n > 0 - if n >= WIDTH - WIDTH.times {print digits.next!} - j += WIDTH - else - n.times {print digits.next!} - (WIDTH-n).times {print " "} - j += n - end - puts "\t:"+j.to_s - n -= WIDTH -end - +# The Great Computer Language Shootout +# http://shootout.alioth.debian.org/ +# +# contributed by Gabriele Renzi + +class PiDigitSpigot + + def initialize() + @z = Transformation.new 1,0,0,1 + @x = Transformation.new 0,0,0,0 + @inverse = Transformation.new 0,0,0,0 + end + + def next! + @y = @z.extract(3) + if safe? @y + @z = produce(@y) + @y + else + @z = consume @x.next!() + next!() + end + end + + def safe?(digit) + digit == @z.extract(4) + end + + def produce(i) + @inverse.qrst(10,-10*i,0,1).compose(@z) + end + + def consume(a) + @z.compose(a) + end +end + + +class Transformation + attr_reader :q, :r, :s, :t + def initialize (q, r, s, t) + @q,@r,@s,@t,@k = q,r,s,t,0 + end + + def next!() + @q = @k = @k + 1 + @r = 4 * @k + 2 + @s = 0 + @t = 2 * @k + 1 + self + end + + def extract(j) + (@q * j + @r) / (@s * j + @t) + end + + def compose(a) + self.class.new( @q * a.q, + @q * a.r + r * a.t, + @s * a.q + t * a.s, + @s * a.r + t * a.t + ) + end + + def qrst *args + initialize *args + self + end + + +end + + +WIDTH = 10 +n = 2_500 # Integer(ARGV[0]) +j = 0 + +digits = PiDigitSpigot.new + +while n > 0 + if n >= WIDTH + WIDTH.times {print digits.next!} + j += WIDTH + else + n.times {print digits.next!} + (WIDTH-n).times {print " "} + j += n + end + puts "\t:"+j.to_s + n -= WIDTH +end + diff --git a/bench/yarv/bm_so_reverse_complement.rb b/bench/yarv/bm_so_reverse_complement.rb index 82ea666994a..5cf1a86adac 100644 --- a/bench/yarv/bm_so_reverse_complement.rb +++ b/bench/yarv/bm_so_reverse_complement.rb @@ -1,30 +1,30 @@ -#!/usr/bin/ruby -# The Great Computer Language Shootout -# http://shootout.alioth.debian.org/ -# -# Contributed by Peter Bjarke Olsen -# Modified by Doug King - -seq=Array.new - -def revcomp(seq) - seq.reverse!.tr!('wsatugcyrkmbdhvnATUGCYRKMBDHVN','WSTAACGRYMKVHDBNTAACGRYMKVHDBN') - stringlen=seq.length - 0.step(stringlen-1,60) {|x| print seq.slice(x,60) , "\n"} -end - -input = open(File.join(File.dirname($0), 'fasta.output.2500000'), 'rb') - -while input.gets - if $_ =~ />/ - if seq.length != 0 - revcomp(seq.join) - seq=Array.new - end - puts $_ - else - $_.sub(/\n/,'') - seq.push $_ - end -end -revcomp(seq.join) +#!/usr/bin/ruby +# The Great Computer Language Shootout +# http://shootout.alioth.debian.org/ +# +# Contributed by Peter Bjarke Olsen +# Modified by Doug King + +seq=Array.new + +def revcomp(seq) + seq.reverse!.tr!('wsatugcyrkmbdhvnATUGCYRKMBDHVN','WSTAACGRYMKVHDBNTAACGRYMKVHDBN') + stringlen=seq.length + 0.step(stringlen-1,60) {|x| print seq.slice(x,60) , "\n"} +end + +input = open(File.join(File.dirname($0), 'fasta.output.2500000'), 'rb') + +while input.gets + if $_ =~ />/ + if seq.length != 0 + revcomp(seq.join) + seq=Array.new + end + puts $_ + else + $_.sub(/\n/,'') + seq.push $_ + end +end +revcomp(seq.join) diff --git a/bench/yarv/bm_so_spectralnorm.rb b/bench/yarv/bm_so_spectralnorm.rb index 6b972066891..3617da5236f 100644 --- a/bench/yarv/bm_so_spectralnorm.rb +++ b/bench/yarv/bm_so_spectralnorm.rb @@ -1,50 +1,50 @@ -# The Computer Language Shootout -# http://shootout.alioth.debian.org/ -# Contributed by Sokolov Yura - -def eval_A(i,j) - return 1.0/((i+j)*(i+j+1)/2+i+1) -end - -def eval_A_times_u(u) - v, i = nil, nil - (0..u.length-1).collect { |i| - v = 0 - for j in 0..u.length-1 - v += eval_A(i,j)*u[j] - end - v - } -end - -def eval_At_times_u(u) - v, i = nil, nil - (0..u.length-1).collect{|i| - v = 0 - for j in 0..u.length-1 - v += eval_A(j,i)*u[j] - end - v - } -end - -def eval_AtA_times_u(u) - return eval_At_times_u(eval_A_times_u(u)) -end - -n = 500 # ARGV[0].to_i - -u=[1]*n -for i in 1..10 - v=eval_AtA_times_u(u) - u=eval_AtA_times_u(v) -end -vBv=0 -vv=0 -for i in 0..n-1 - vBv += u[i]*v[i] - vv += v[i]*v[i] -end - -str = "%0.9f" % (Math.sqrt(vBv/vv)), "\n" -# print str +# The Computer Language Shootout +# http://shootout.alioth.debian.org/ +# Contributed by Sokolov Yura + +def eval_A(i,j) + return 1.0/((i+j)*(i+j+1)/2+i+1) +end + +def eval_A_times_u(u) + v, i = nil, nil + (0..u.length-1).collect { |i| + v = 0 + for j in 0..u.length-1 + v += eval_A(i,j)*u[j] + end + v + } +end + +def eval_At_times_u(u) + v, i = nil, nil + (0..u.length-1).collect{|i| + v = 0 + for j in 0..u.length-1 + v += eval_A(j,i)*u[j] + end + v + } +end + +def eval_AtA_times_u(u) + return eval_At_times_u(eval_A_times_u(u)) +end + +n = 500 # ARGV[0].to_i + +u=[1]*n +for i in 1..10 + v=eval_AtA_times_u(u) + u=eval_AtA_times_u(v) +end +vBv=0 +vv=0 +for i in 0..n-1 + vBv += u[i]*v[i] + vv += v[i]*v[i] +end + +str = "%0.9f" % (Math.sqrt(vBv/vv)), "\n" +# print str diff --git a/bench/yarv/bm_vm1_ivar_set.rb b/bench/yarv/bm_vm1_ivar_set.rb index c8076c6ab6b..023e397e922 100644 --- a/bench/yarv/bm_vm1_ivar_set.rb +++ b/bench/yarv/bm_vm1_ivar_set.rb @@ -1,6 +1,6 @@ -i = 0 -while i<30_000_000 # while loop 1 - i+= 1 - @a = 1 - @b = 2 -end +i = 0 +while i<30_000_000 # while loop 1 + i+= 1 + @a = 1 + @b = 2 +end diff --git a/bench/yarv/bm_vm2_eval.rb b/bench/yarv/bm_vm2_eval.rb index 375dccc00e9..9ab781edd4a 100644 --- a/bench/yarv/bm_vm2_eval.rb +++ b/bench/yarv/bm_vm2_eval.rb @@ -1,6 +1,6 @@ -i=0 -while i<6000000 # benchmark loop 2 - i+=1 - eval("1") -end - +i=0 +while i<6000000 # benchmark loop 2 + i+=1 + eval("1") +end + diff --git a/bench/yarv/driver.rb b/bench/yarv/driver.rb index 861d54f904a..dd6e1bf5977 100644 --- a/bench/yarv/driver.rb +++ b/bench/yarv/driver.rb @@ -1,238 +1,238 @@ -# -# Ruby Benchmark driver -# - -require 'optparse' -require 'benchmark' -require 'pp' - -class BenchmarkDriver - def self.benchmark(opt) - driver = self.new(opt[:execs], opt[:dir], opt) - begin - driver.run - ensure - driver.show_results - end - end - - def output *args - puts(*args) - @output and @output.puts(*args) - end - - def message *args - output(*args) if @verbose - end - - def message_print *args - if @verbose - print(*args) - STDOUT.flush - @output and @output.print(*args) - end - end - - def progress_message *args - unless STDOUT.tty? - STDERR.print(*args) - STDERR.flush - end - end - - def initialize execs, dir, opt = {} - @execs = execs.map{|e| - e.strip! - next if e.empty? - - if /(.+)::(.+)/ =~ e - # ex) ruby-a::/path/to/ruby-a - v = $1.strip - e = $2 - else - v = `#{e} -v`.chomp - v.sub!(/ patchlevel \d+/, '') - end - [e, v] - }.compact - - @dir = dir - @repeat = opt[:repeat] || 1 - @repeat = 1 if @repeat < 1 - @pattern = opt[:pattern] || nil - @verbose = opt[:quiet] ? false : (opt[:verbose] || false) - @output = opt[:output] ? open(opt[:output], 'w') : nil - @loop_wl1 = @loop_wl2 = nil - @opt = opt - - # [[name, [[r-1-1, r-1-2, ...], [r-2-1, r-2-2, ...]]], ...] - @results = [] - - if @verbose - @start_time = Time.now - message @start_time - @execs.each_with_index{|(e, v), i| - message "target #{i}: #{v}" - } - end - end - - def show_results - output - - if @verbose - message '-----------------------------------------------------------' - message 'raw data:' - message - message PP.pp(@results, "", 79) - message - message "Elapesed time: #{Time.now - @start_time} (sec)" - end - - output '-----------------------------------------------------------' - output 'benchmark results:' - - if @verbose and @repeat > 1 - output "minimum results in each #{@repeat} measurements." - end - - output "name\t#{@execs.map{|(e, v)| v}.join("\t")}" - @results.each{|v, result| - rets = [] - s = nil - result.each_with_index{|e, i| - r = e.min - case v - when /^vm1_/ - if @loop_wl1 - r -= @loop_wl1[i] - s = '*' - end - when /^vm2_/ - if @loop_wl2 - r -= @loop_wl2[i] - s = '*' - end - end - rets << sprintf("%.3f", r) - } - output "#{v}#{s}\t#{rets.join("\t")}" - } - end - - def files - flag = {} - vm1 = vm2 = wl1 = wl2 = false - @files = Dir.glob(File.join(@dir, 'bm*.rb')).map{|file| - next if @pattern && /#{@pattern}/ !~ File.basename(file) - case file - when /bm_(vm[12])_/, /bm_loop_(whileloop2?).rb/ - flag[$1] = true - end - file - }.compact - - if flag['vm1'] && !flag['whileloop'] - @files << File.join(@dir, 'bm_loop_whileloop.rb') - elsif flag['vm2'] && !flag['whileloop2'] - @files << File.join(@dir, 'bm_loop_whileloop2.rb') - end - - @files.sort! - progress_message "total: #{@files.size * @repeat} trial(s) (#{@repeat} trial(s) for #{@files.size} benchmark(s))\n" - @files - end - - def run - files.each_with_index{|file, i| - @i = i - r = measure_file(file) - - if /bm_loop_whileloop.rb/ =~ file - @loop_wl1 = r[1].map{|e| e.min} - elsif /bm_loop_whileloop2.rb/ =~ file - @loop_wl2 = r[1].map{|e| e.min} - end - } - end - - def measure_file file - name = File.basename(file, '.rb').sub(/^bm_/, '') - prepare_file = File.join(File.dirname(file), "prepare_#{name}.rb") - load prepare_file if FileTest.exist?(prepare_file) - - if @verbose - output - output '-----------------------------------------------------------' - output name - output - output File.read(file) - output - end - - result = [name] - result << @execs.map{|(e, v)| - (0...@repeat).map{ - message_print "#{v}\t" - progress_message '.' - - m = measure(e, file) - message "#{m}" - m - } - } - @results << result - result - end - - def measure executable, file - cmd = "#{executable} #{file}" - m = Benchmark.measure{ - `#{cmd}` - } - - if $? != 0 - raise "Benchmark process exited with abnormal status (#{$?})" - end - - m.real - end -end - -if __FILE__ == $0 - opt = { - :execs => ['ruby'], - :dir => './', - :repeat => 1, - :output => "bmlog-#{Time.now.strftime('%Y%m%d-%H%M%S')}.#{$$}", - } - - parser = OptionParser.new{|o| - o.on('-e', '--executables [EXECS]', - "Specify benchmark one or more targets. (exec1; exec2; exec3, ...)"){|e| - opt[:execs] = e.split(/;/) - } - o.on('-d', '--directory [DIRECTORY]', "Benchmark suites directory"){|d| - opt[:dir] = d - } - o.on('-p', '--pattern [PATTERN]', "Benchmark name pattern"){|p| - opt[:pattern] = p - } - o.on('-r', '--repeat-count [NUM]', "Repeat count"){|n| - opt[:repeat] = n.to_i - } - o.on('-o', '--output-file [FILE]', "Output file"){|o| - opt[:output] = o - } - o.on('-q', '--quiet', "Run without notify information except result table."){|q| - opt[:quiet] = q - } - o.on('-v', '--verbose'){|v| - opt[:verbose] = v - } - } - - parser.parse!(ARGV) - BenchmarkDriver.benchmark(opt) -end - +# +# Ruby Benchmark driver +# + +require 'optparse' +require 'benchmark' +require 'pp' + +class BenchmarkDriver + def self.benchmark(opt) + driver = self.new(opt[:execs], opt[:dir], opt) + begin + driver.run + ensure + driver.show_results + end + end + + def output *args + puts(*args) + @output and @output.puts(*args) + end + + def message *args + output(*args) if @verbose + end + + def message_print *args + if @verbose + print(*args) + STDOUT.flush + @output and @output.print(*args) + end + end + + def progress_message *args + unless STDOUT.tty? + STDERR.print(*args) + STDERR.flush + end + end + + def initialize execs, dir, opt = {} + @execs = execs.map{|e| + e.strip! + next if e.empty? + + if /(.+)::(.+)/ =~ e + # ex) ruby-a::/path/to/ruby-a + v = $1.strip + e = $2 + else + v = `#{e} -v`.chomp + v.sub!(/ patchlevel \d+/, '') + end + [e, v] + }.compact + + @dir = dir + @repeat = opt[:repeat] || 1 + @repeat = 1 if @repeat < 1 + @pattern = opt[:pattern] || nil + @verbose = opt[:quiet] ? false : (opt[:verbose] || false) + @output = opt[:output] ? open(opt[:output], 'w') : nil + @loop_wl1 = @loop_wl2 = nil + @opt = opt + + # [[name, [[r-1-1, r-1-2, ...], [r-2-1, r-2-2, ...]]], ...] + @results = [] + + if @verbose + @start_time = Time.now + message @start_time + @execs.each_with_index{|(e, v), i| + message "target #{i}: #{v}" + } + end + end + + def show_results + output + + if @verbose + message '-----------------------------------------------------------' + message 'raw data:' + message + message PP.pp(@results, "", 79) + message + message "Elapesed time: #{Time.now - @start_time} (sec)" + end + + output '-----------------------------------------------------------' + output 'benchmark results:' + + if @verbose and @repeat > 1 + output "minimum results in each #{@repeat} measurements." + end + + output "name\t#{@execs.map{|(e, v)| v}.join("\t")}" + @results.each{|v, result| + rets = [] + s = nil + result.each_with_index{|e, i| + r = e.min + case v + when /^vm1_/ + if @loop_wl1 + r -= @loop_wl1[i] + s = '*' + end + when /^vm2_/ + if @loop_wl2 + r -= @loop_wl2[i] + s = '*' + end + end + rets << sprintf("%.3f", r) + } + output "#{v}#{s}\t#{rets.join("\t")}" + } + end + + def files + flag = {} + vm1 = vm2 = wl1 = wl2 = false + @files = Dir.glob(File.join(@dir, 'bm*.rb')).map{|file| + next if @pattern && /#{@pattern}/ !~ File.basename(file) + case file + when /bm_(vm[12])_/, /bm_loop_(whileloop2?).rb/ + flag[$1] = true + end + file + }.compact + + if flag['vm1'] && !flag['whileloop'] + @files << File.join(@dir, 'bm_loop_whileloop.rb') + elsif flag['vm2'] && !flag['whileloop2'] + @files << File.join(@dir, 'bm_loop_whileloop2.rb') + end + + @files.sort! + progress_message "total: #{@files.size * @repeat} trial(s) (#{@repeat} trial(s) for #{@files.size} benchmark(s))\n" + @files + end + + def run + files.each_with_index{|file, i| + @i = i + r = measure_file(file) + + if /bm_loop_whileloop.rb/ =~ file + @loop_wl1 = r[1].map{|e| e.min} + elsif /bm_loop_whileloop2.rb/ =~ file + @loop_wl2 = r[1].map{|e| e.min} + end + } + end + + def measure_file file + name = File.basename(file, '.rb').sub(/^bm_/, '') + prepare_file = File.join(File.dirname(file), "prepare_#{name}.rb") + load prepare_file if FileTest.exist?(prepare_file) + + if @verbose + output + output '-----------------------------------------------------------' + output name + output + output File.read(file) + output + end + + result = [name] + result << @execs.map{|(e, v)| + (0...@repeat).map{ + message_print "#{v}\t" + progress_message '.' + + m = measure(e, file) + message "#{m}" + m + } + } + @results << result + result + end + + def measure executable, file + cmd = "#{executable} #{file}" + m = Benchmark.measure{ + `#{cmd}` + } + + if $? != 0 + raise "Benchmark process exited with abnormal status (#{$?})" + end + + m.real + end +end + +if __FILE__ == $0 + opt = { + :execs => ['ruby'], + :dir => './', + :repeat => 1, + :output => "bmlog-#{Time.now.strftime('%Y%m%d-%H%M%S')}.#{$$}", + } + + parser = OptionParser.new{|o| + o.on('-e', '--executables [EXECS]', + "Specify benchmark one or more targets. (exec1; exec2; exec3, ...)"){|e| + opt[:execs] = e.split(/;/) + } + o.on('-d', '--directory [DIRECTORY]', "Benchmark suites directory"){|d| + opt[:dir] = d + } + o.on('-p', '--pattern [PATTERN]', "Benchmark name pattern"){|p| + opt[:pattern] = p + } + o.on('-r', '--repeat-count [NUM]', "Repeat count"){|n| + opt[:repeat] = n.to_i + } + o.on('-o', '--output-file [FILE]', "Output file"){|o| + opt[:output] = o + } + o.on('-q', '--quiet', "Run without notify information except result table."){|q| + opt[:quiet] = q + } + o.on('-v', '--verbose'){|v| + opt[:verbose] = v + } + } + + parser.parse!(ARGV) + BenchmarkDriver.benchmark(opt) +end + diff --git a/bench/yarv/make_fasta_output.rb b/bench/yarv/make_fasta_output.rb index b6d787ae273..158d8fd1614 100644 --- a/bench/yarv/make_fasta_output.rb +++ b/bench/yarv/make_fasta_output.rb @@ -1,19 +1,19 @@ -# prepare 'fasta.output' - -def prepare_fasta_output n - filebase = File.join(File.dirname($0), 'fasta.output') - script = File.join(File.dirname($0), 'bm_so_fasta.rb') - file = "#{filebase}.#{n}" - - unless FileTest.exist?(file) - STDERR.puts "preparing #{file}" - - open(file, 'w'){|f| - ARGV[0] = n - $stdout = f - load script - $stdout = STDOUT - } - end -end - +# prepare 'fasta.output' + +def prepare_fasta_output n + filebase = File.join(File.dirname($0), 'fasta.output') + script = File.join(File.dirname($0), 'bm_so_fasta.rb') + file = "#{filebase}.#{n}" + + unless FileTest.exist?(file) + STDERR.puts "preparing #{file}" + + open(file, 'w'){|f| + ARGV[0] = n + $stdout = f + load script + $stdout = STDOUT + } + end +end + diff --git a/bench/yarv/prepare_so_count_words.rb b/bench/yarv/prepare_so_count_words.rb index ee2138cdb24..54ea72b8ed8 100644 --- a/bench/yarv/prepare_so_count_words.rb +++ b/bench/yarv/prepare_so_count_words.rb @@ -1,15 +1,15 @@ -# prepare 'wc.input' - -def prepare_wc_input - wcinput = File.join(File.dirname($0), 'wc.input') - wcbase = File.join(File.dirname($0), 'wc.input.base') - unless FileTest.exist?(wcinput) - data = File.read(wcbase) - 13.times{ - data << data - } - open(wcinput, 'w'){|f| f.write data} - end -end - -prepare_wc_input +# prepare 'wc.input' + +def prepare_wc_input + wcinput = File.join(File.dirname($0), 'wc.input') + wcbase = File.join(File.dirname($0), 'wc.input.base') + unless FileTest.exist?(wcinput) + data = File.read(wcbase) + 13.times{ + data << data + } + open(wcinput, 'w'){|f| f.write data} + end +end + +prepare_wc_input diff --git a/bench/yarv/prepare_so_k_nucleotide.rb b/bench/yarv/prepare_so_k_nucleotide.rb index f28f4460a10..62e0c76fb9b 100644 --- a/bench/yarv/prepare_so_k_nucleotide.rb +++ b/bench/yarv/prepare_so_k_nucleotide.rb @@ -1,2 +1,2 @@ -require File.join(File.dirname(__FILE__), 'make_fasta_output') -prepare_fasta_output(100_000) +require File.join(File.dirname(__FILE__), 'make_fasta_output') +prepare_fasta_output(100_000) diff --git a/bench/yarv/prepare_so_reverse_complement.rb b/bench/yarv/prepare_so_reverse_complement.rb index 7f089109de4..b1cd837626f 100644 --- a/bench/yarv/prepare_so_reverse_complement.rb +++ b/bench/yarv/prepare_so_reverse_complement.rb @@ -1,2 +1,2 @@ -require File.join(File.dirname(__FILE__), 'make_fasta_output') -prepare_fasta_output(2_500_000) +require File.join(File.dirname(__FILE__), 'make_fasta_output') +prepare_fasta_output(2_500_000) diff --git a/bin/gem.bat b/bin/gem.bat index 22e524a55d5..dc28ef16a67 100644 --- a/bin/gem.bat +++ b/bin/gem.bat @@ -1,6 +1,6 @@ -@ECHO OFF -IF NOT "%~f0" == "~f0" GOTO :WinNT -@"jruby" -S "gem" %1 %2 %3 %4 %5 %6 %7 %8 %9 -GOTO :EOF -:WinNT -@"%~dp0jruby.exe" "%~dpn0" %* +@ECHO OFF +IF NOT "%~f0" == "~f0" GOTO :WinNT +@"jruby" -S "gem" %1 %2 %3 %4 %5 %6 %7 %8 %9 +GOTO :EOF +:WinNT +@"%~dp0jruby.exe" "%~dpn0" %* diff --git a/bin/irb.bat b/bin/irb.bat index b8c3ea7ba00..b4386126697 100644 --- a/bin/irb.bat +++ b/bin/irb.bat @@ -1,6 +1,6 @@ -@ECHO OFF -IF NOT "%~f0" == "~f0" GOTO :WinNT -@"jruby" -S "jirb" %1 %2 %3 %4 %5 %6 %7 %8 %9 -GOTO :EOF -:WinNT -@"%~dp0jruby.exe" "%~dpn0" %* +@ECHO OFF +IF NOT "%~f0" == "~f0" GOTO :WinNT +@"jruby" -S "jirb" %1 %2 %3 %4 %5 %6 %7 %8 %9 +GOTO :EOF +:WinNT +@"%~dp0jruby.exe" "%~dpn0" %* diff --git a/bin/jirb.bat b/bin/jirb.bat index b8c3ea7ba00..b4386126697 100644 --- a/bin/jirb.bat +++ b/bin/jirb.bat @@ -1,6 +1,6 @@ -@ECHO OFF -IF NOT "%~f0" == "~f0" GOTO :WinNT -@"jruby" -S "jirb" %1 %2 %3 %4 %5 %6 %7 %8 %9 -GOTO :EOF -:WinNT -@"%~dp0jruby.exe" "%~dpn0" %* +@ECHO OFF +IF NOT "%~f0" == "~f0" GOTO :WinNT +@"jruby" -S "jirb" %1 %2 %3 %4 %5 %6 %7 %8 %9 +GOTO :EOF +:WinNT +@"%~dp0jruby.exe" "%~dpn0" %* diff --git a/bin/jirb_swing.bat b/bin/jirb_swing.bat index de61df91733..286b4060179 100644 --- a/bin/jirb_swing.bat +++ b/bin/jirb_swing.bat @@ -1,6 +1,6 @@ -@ECHO OFF -IF NOT "%~f0" == "~f0" GOTO :WinNT -@"jruby" -S "jirb_swing" %1 %2 %3 %4 %5 %6 %7 %8 %9 -GOTO :EOF -:WinNT -@"%~dp0jruby.exe" "%~dpn0" %* +@ECHO OFF +IF NOT "%~f0" == "~f0" GOTO :WinNT +@"jruby" -S "jirb_swing" %1 %2 %3 %4 %5 %6 %7 %8 %9 +GOTO :EOF +:WinNT +@"%~dp0jruby.exe" "%~dpn0" %* diff --git a/bin/jruby.bat b/bin/jruby.bat index 4dac33393e9..1450ae0a2f1 100644 --- a/bin/jruby.bat +++ b/bin/jruby.bat @@ -1,6 +1,6 @@ -@ECHO OFF -IF NOT "%~f0" == "~f0" GOTO :WinNT -@"jruby.exe" %1 %2 %3 %4 %5 %6 %7 %8 %9 -GOTO :EOF -:WinNT -@"%~dpn0.exe" %* +@ECHO OFF +IF NOT "%~f0" == "~f0" GOTO :WinNT +@"jruby.exe" %1 %2 %3 %4 %5 %6 %7 %8 %9 +GOTO :EOF +:WinNT +@"%~dpn0.exe" %* diff --git a/bin/jrubyd.bat b/bin/jrubyd.bat index 778fe08eaed..fa3298b3edd 100644 --- a/bin/jrubyd.bat +++ b/bin/jrubyd.bat @@ -1,9 +1,9 @@ -@ECHO OFF - -@set debug_args=-J-Xdebug -J-Xrunjdwp:transport=dt_shmem,server=y,suspend=y - -IF NOT "%~f0" == "~f0" GOTO :WinNT -@"jruby.exe" %debug_args% %1 %2 %3 %4 %5 %6 %7 %8 %9 -GOTO :EOF -:WinNT -@"%~dp0jruby.exe" %debug_args% "%~dpn0" %* +@ECHO OFF + +@set debug_args=-J-Xdebug -J-Xrunjdwp:transport=dt_shmem,server=y,suspend=y + +IF NOT "%~f0" == "~f0" GOTO :WinNT +@"jruby.exe" %debug_args% %1 %2 %3 %4 %5 %6 %7 %8 %9 +GOTO :EOF +:WinNT +@"%~dp0jruby.exe" %debug_args% "%~dpn0" %* diff --git a/bin/rake.bat b/bin/rake.bat index a536fdbde63..fa628f75051 100644 --- a/bin/rake.bat +++ b/bin/rake.bat @@ -1,2 +1,2 @@ -@ECHO OFF -@"%~dp0jruby.exe" -S rake %* +@ECHO OFF +@"%~dp0jruby.exe" -S rake %* diff --git a/bin/rdoc.bat b/bin/rdoc.bat index 720def89cd7..6ca0792ef20 100644 --- a/bin/rdoc.bat +++ b/bin/rdoc.bat @@ -1,6 +1,6 @@ -@ECHO OFF -IF NOT "%~f0" == "~f0" GOTO :WinNT -@"jruby" -S "rdoc" %1 %2 %3 %4 %5 %6 %7 %8 %9 -GOTO :EOF -:WinNT -@"%~dp0jruby.exe" "%~dpn0" %* +@ECHO OFF +IF NOT "%~f0" == "~f0" GOTO :WinNT +@"jruby" -S "rdoc" %1 %2 %3 %4 %5 %6 %7 %8 %9 +GOTO :EOF +:WinNT +@"%~dp0jruby.exe" "%~dpn0" %* diff --git a/bin/ri.bat b/bin/ri.bat index a6d957dbde9..7d0e8354d95 100644 --- a/bin/ri.bat +++ b/bin/ri.bat @@ -1,6 +1,6 @@ -@ECHO OFF -IF NOT "%~f0" == "~f0" GOTO :WinNT -@"jruby" -S "ri" %1 %2 %3 %4 %5 %6 %7 %8 %9 -GOTO :EOF -:WinNT -@"%~dp0jruby.exe" "%~dpn0" %* +@ECHO OFF +IF NOT "%~f0" == "~f0" GOTO :WinNT +@"jruby" -S "ri" %1 %2 %3 %4 %5 %6 %7 %8 %9 +GOTO :EOF +:WinNT +@"%~dp0jruby.exe" "%~dpn0" %* diff --git a/docs/LICENSE.ant b/docs/LICENSE.ant index b279c7a20d8..0f8706c6fc2 100644 --- a/docs/LICENSE.ant +++ b/docs/LICENSE.ant @@ -1,49 +1,49 @@ -/* - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 2000-2002 The Apache Software Foundation. All - * rights reserved. - * - * Redistribution and use in source and binary forms, with or without modifica- - * tion, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The end-user documentation included with the redistribution, if any, must - * include the following acknowledgment: "This product includes software - * developed by the Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, if - * and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Ant" and "Apache Software Foundation" must not be used to - * endorse or promote products derived from this software without prior - * written permission. For written permission, please contact - * apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", nor may - * "Apache" appear in their name, without prior written permission of the - * Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- - * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software consists of voluntary contributions made by many individuals - * on behalf of the Apache Software Foundation. For more information on the - * Apache Software Foundation, please see . - * - */ +/* + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 2000-2002 The Apache Software Foundation. All + * rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Ant" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation. For more information on the + * Apache Software Foundation, please see . + * + */ diff --git a/docs/README.coverage b/docs/README.coverage index 041c368e79c..e89ffb68bac 100644 --- a/docs/README.coverage +++ b/docs/README.coverage @@ -1,10 +1,10 @@ -Running Emma -============ -To run the emma coverage report: -ant clean emma test - -A coverage report will be created (build/test-results/html-coverage/coverage.html) - -To run the unit tests and without emma instrumentation or the emma coverage report just ommit -the "emma" target from the line above: +Running Emma +============ +To run the emma coverage report: +ant clean emma test + +A coverage report will be created (build/test-results/html-coverage/coverage.html) + +To run the unit tests and without emma instrumentation or the emma coverage report just ommit +the "emma" target from the line above: ant clean test \ No newline at end of file diff --git a/install/jruby.install4j b/install/jruby.install4j index 4fe0c22746c..06e3ce3d4e5 100644 --- a/install/jruby.install4j +++ b/install/jruby.install4j @@ -1,762 +1,762 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 255 - 255 - 255 - 255 - - - - - jruby_logo_collage.png - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - context.getVariable("sys.responseFile") == null - - - - - - - - - - - - - - - - - - - - - - The installer will by default set up your PATH so you can run JRuby easily. Some users have special needs and want to do this step manually. Unless you are one of those users just press next. - - - - - - - - - - - - - - - - - - - - - - Configure Path for me (recommended) - - - true - - - configure.path - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - ${installer:sys.installationDir}\bin - - - PATH - - - - - context.getBooleanVariable("configure.path") - - - - - - - true - - - ${installer:sys.preferredJre} - - - JAVA_HOME - - - - - Util.isWindows() && WinEnvVars.getenv("JAVA_HOME") == null - - - - - - - false - - - ${compiler:sys.fullName} ${compiler:sys.version} - - - - - - - - - - - - ${compiler:sys.fullName} ${compiler:sys.version} - - - - - - - - - - - - - INSTALL_DIR - ${installer:sys.installationDir} - - - - - install/update_path - - - - true - - - true - - - true - - - - . - - - - - - - - - - - - - Software\RubyInstaller - - - - - - - - - - - - - - - Software\RubyInstaller\JRuby\${compiler:ruby.version} - - - - - - ${installer:sys.installationDir} - - - InstallLocation - - - - - - - - - - - - Software\RubyInstaller\JRuby\${compiler:ruby.version} - - - - - - ${compiler:sys.date} - - - InstallDate - - - - - - - - - - - - Software\RubyInstaller\JRuby\${compiler:ruby.version} - - - - - - ${compiler:ruby.patchlevel} - - - PatchLevel - - - - - - - - - - - - Software\RubyInstaller\JRuby\${compiler:ruby.version} - - - - - - ${compiler:ruby.buildplatform} - - - BuildPlatform - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Software\RubyInstaller\JRuby - - - false - - - - - - - - - - - - - - - Software\RubyInstaller - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 255 + 255 + 255 + 255 + + + + + jruby_logo_collage.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + context.getVariable("sys.responseFile") == null + + + + + + + + + + + + + + + + + + + + + + The installer will by default set up your PATH so you can run JRuby easily. Some users have special needs and want to do this step manually. Unless you are one of those users just press next. + + + + + + + + + + + + + + + + + + + + + + Configure Path for me (recommended) + + + true + + + configure.path + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + ${installer:sys.installationDir}\bin + + + PATH + + + + + context.getBooleanVariable("configure.path") + + + + + + + true + + + ${installer:sys.preferredJre} + + + JAVA_HOME + + + + + Util.isWindows() && WinEnvVars.getenv("JAVA_HOME") == null + + + + + + + false + + + ${compiler:sys.fullName} ${compiler:sys.version} + + + + + + + + + + + + ${compiler:sys.fullName} ${compiler:sys.version} + + + + + + + + + + + + + INSTALL_DIR + ${installer:sys.installationDir} + + + + + install/update_path + + + + true + + + true + + + true + + + + . + + + + + + + + + + + + + Software\RubyInstaller + + + + + + + + + + + + + + + Software\RubyInstaller\JRuby\${compiler:ruby.version} + + + + + + ${installer:sys.installationDir} + + + InstallLocation + + + + + + + + + + + + Software\RubyInstaller\JRuby\${compiler:ruby.version} + + + + + + ${compiler:sys.date} + + + InstallDate + + + + + + + + + + + + Software\RubyInstaller\JRuby\${compiler:ruby.version} + + + + + + ${compiler:ruby.patchlevel} + + + PatchLevel + + + + + + + + + + + + Software\RubyInstaller\JRuby\${compiler:ruby.version} + + + + + + ${compiler:ruby.buildplatform} + + + BuildPlatform + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Software\RubyInstaller\JRuby + + + false + + + + + + + + + + + + + + + Software\RubyInstaller + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/ruby/shared/ffi/platform/x86_64-windows/platform.conf b/lib/ruby/shared/ffi/platform/x86_64-windows/platform.conf index ee948d6780e..4becb2320ca 100644 --- a/lib/ruby/shared/ffi/platform/x86_64-windows/platform.conf +++ b/lib/ruby/shared/ffi/platform/x86_64-windows/platform.conf @@ -1,520 +1,520 @@ -rbx.platform.dirent.sizeof = 276 -rbx.platform.dirent.d_ino.offset = 4 -rbx.platform.dirent.d_ino.size = 8 -rbx.platform.dirent.d_ino.type = ino_t -rbx.platform.dirent.d_name.offset = 20 -rbx.platform.dirent.d_name.size = 256 -rbx.platform.dirent.d_name.type = char_array -rbx.platform.timeval.sizeof = 8 -rbx.platform.timeval.tv_sec.offset = 0 -rbx.platform.timeval.tv_sec.size = 4 -rbx.platform.timeval.tv_sec.type = time_t -rbx.platform.timeval.tv_usec.offset = 4 -rbx.platform.timeval.tv_usec.size = 4 -rbx.platform.timeval.tv_usec.type = suseconds_t -rbx.platform.sockaddr_in.sizeof = 16 -rbx.platform.sockaddr_in.sin_family.offset = 0 -rbx.platform.sockaddr_in.sin_family.size = 2 -rbx.platform.sockaddr_in.sin_family.type = sa_family_t -rbx.platform.sockaddr_in.sin_port.offset = 2 -rbx.platform.sockaddr_in.sin_port.size = 2 -rbx.platform.sockaddr_in.sin_port.type = ushort -rbx.platform.sockaddr_in.sin_addr.offset = 4 -rbx.platform.sockaddr_in.sin_addr.size = 4 -rbx.platform.sockaddr_in.sin_zero.offset = 8 -rbx.platform.sockaddr_in.sin_zero.size = 8 -rbx.platform.sockaddr_in.sin_zero.type = char_array -rbx.platform.sockaddr_un.sizeof = 110 -rbx.platform.sockaddr_un.sun_family.offset = 0 -rbx.platform.sockaddr_un.sun_family.size = 2 -rbx.platform.sockaddr_un.sun_family.type = sa_family_t -rbx.platform.sockaddr_un.sun_path.offset = 2 -rbx.platform.sockaddr_un.sun_path.size = 108 -rbx.platform.sockaddr_un.sun_path.type = char_array -rbx.platform.servent.sizeof = 16 -rbx.platform.servent.s_name.offset = 0 -rbx.platform.servent.s_name.size = 4 -rbx.platform.servent.s_name.type = pointer -rbx.platform.servent.s_aliases.offset = 4 -rbx.platform.servent.s_aliases.size = 4 -rbx.platform.servent.s_aliases.type = pointer -rbx.platform.servent.s_port.offset = 8 -rbx.platform.servent.s_port.size = 2 -rbx.platform.servent.s_port.type = int -rbx.platform.servent.s_proto.offset = 12 -rbx.platform.servent.s_proto.size = 4 -rbx.platform.servent.s_proto.type = pointer -rbx.platform.stat.sizeof = 96 -rbx.platform.stat.st_dev.offset = 0 -rbx.platform.stat.st_dev.size = 4 -rbx.platform.stat.st_dev.type = dev_t -rbx.platform.stat.st_ino.offset = 8 -rbx.platform.stat.st_ino.size = 8 -rbx.platform.stat.st_ino.type = ino_t -rbx.platform.stat.st_mode.offset = 16 -rbx.platform.stat.st_mode.size = 4 -rbx.platform.stat.st_mode.type = mode_t -rbx.platform.stat.st_nlink.offset = 20 -rbx.platform.stat.st_nlink.size = 2 -rbx.platform.stat.st_nlink.type = nlink_t -rbx.platform.stat.st_uid.offset = 24 -rbx.platform.stat.st_uid.size = 4 -rbx.platform.stat.st_uid.type = uid_t -rbx.platform.stat.st_gid.offset = 28 -rbx.platform.stat.st_gid.size = 4 -rbx.platform.stat.st_gid.type = gid_t -rbx.platform.stat.st_rdev.offset = 32 -rbx.platform.stat.st_rdev.size = 4 -rbx.platform.stat.st_rdev.type = dev_t -rbx.platform.stat.st_size.offset = 40 -rbx.platform.stat.st_size.size = 8 -rbx.platform.stat.st_size.type = off_t -rbx.platform.stat.st_blksize.offset = 72 -rbx.platform.stat.st_blksize.size = 4 -rbx.platform.stat.st_blocks.offset = 80 -rbx.platform.stat.st_blocks.size = 8 -rbx.platform.stat.st_atime.offset = 48 -rbx.platform.stat.st_atime.size = 4 -rbx.platform.stat.st_atime.type = time_t -rbx.platform.stat.st_mtime.offset = 56 -rbx.platform.stat.st_mtime.size = 4 -rbx.platform.stat.st_mtime.type = time_t -rbx.platform.stat.st_ctime.offset = 64 -rbx.platform.stat.st_ctime.size = 4 -rbx.platform.stat.st_ctime.type = time_t -rbx.platform.rlimit.sizeof = 8 -rbx.platform.rlimit.rlim_cur.offset = 0 -rbx.platform.rlimit.rlim_cur.size = 4 -rbx.platform.rlimit.rlim_cur.type = rlim_t -rbx.platform.rlimit.rlim_max.offset = 4 -rbx.platform.rlimit.rlim_max.size = 4 -rbx.platform.rlimit.rlim_max.type = rlim_t -rbx.platform.file.O_RDONLY = 0 -rbx.platform.file.O_WRONLY = 1 -rbx.platform.file.O_RDWR = 2 -rbx.platform.file.O_CREAT = 512 -rbx.platform.file.O_EXCL = 2048 -rbx.platform.file.O_NOCTTY = 32768 -rbx.platform.file.O_TRUNC = 1024 -rbx.platform.file.O_APPEND = 8 -rbx.platform.file.O_NONBLOCK = 16384 -rbx.platform.file.O_SYNC = 8192 -rbx.platform.file.S_IRUSR = 256 -rbx.platform.file.S_IWUSR = 128 -rbx.platform.file.S_IXUSR = 64 -rbx.platform.file.S_IRGRP = 32 -rbx.platform.file.S_IWGRP = 16 -rbx.platform.file.S_IXGRP = 8 -rbx.platform.file.S_IROTH = 4 -rbx.platform.file.S_IWOTH = 2 -rbx.platform.file.S_IXOTH = 1 -rbx.platform.file.S_IFMT = 61440 -rbx.platform.file.S_IFIFO = 4096 -rbx.platform.file.S_IFCHR = 8192 -rbx.platform.file.S_IFDIR = 16384 -rbx.platform.file.S_IFBLK = 24576 -rbx.platform.file.S_IFREG = 32768 -rbx.platform.file.S_IFLNK = 40960 -rbx.platform.file.S_IFSOCK = 49152 -rbx.platform.file.S_IFWHT = -rbx.platform.file.S_ISUID = 2048 -rbx.platform.file.S_ISGID = 1024 -rbx.platform.io.SEEK_SET = 0 -rbx.platform.io.SEEK_CUR = 1 -rbx.platform.io.SEEK_END = 2 -rbx.platform.fcntl.F_GETFL = 3 -rbx.platform.fcntl.F_SETFL = 4 -rbx.platform.fcntl.O_ACCMODE = 3 -rbx.platform.socket.AF_APPLETALK = 16 -rbx.platform.socket.AF_ATM = -rbx.platform.socket.AF_AX25 = -rbx.platform.socket.AF_CCITT = 10 -rbx.platform.socket.AF_CHAOS = 5 -rbx.platform.socket.AF_CNT = -rbx.platform.socket.AF_COIP = -rbx.platform.socket.AF_DATAKIT = 9 -rbx.platform.socket.AF_DEC = -rbx.platform.socket.AF_DLI = 13 -rbx.platform.socket.AF_E164 = -rbx.platform.socket.AF_ECMA = 8 -rbx.platform.socket.AF_HYLINK = 15 -rbx.platform.socket.AF_IMPLINK = 3 -rbx.platform.socket.AF_INET = 2 -rbx.platform.socket.AF_INET6 = 23 -rbx.platform.socket.AF_IPX = -rbx.platform.socket.AF_ISDN = -rbx.platform.socket.AF_ISO = 7 -rbx.platform.socket.AF_LAT = 14 -rbx.platform.socket.AF_LINK = -rbx.platform.socket.AF_LOCAL = 1 -rbx.platform.socket.AF_MAX = 32 -rbx.platform.socket.AF_NATM = -rbx.platform.socket.AF_NDRV = -rbx.platform.socket.AF_NETBIOS = 17 -rbx.platform.socket.AF_NETGRAPH = -rbx.platform.socket.AF_NS = 6 -rbx.platform.socket.AF_OSI = 7 -rbx.platform.socket.AF_PPP = -rbx.platform.socket.AF_PUP = 4 -rbx.platform.socket.AF_ROUTE = -rbx.platform.socket.AF_SIP = -rbx.platform.socket.AF_SNA = 11 -rbx.platform.socket.AF_SYSTEM = -rbx.platform.socket.AF_UNIX = 1 -rbx.platform.socket.AF_UNSPEC = 0 -rbx.platform.socket.AI_ADDRCONFIG = 1024 -rbx.platform.socket.AI_ALL = 256 -rbx.platform.socket.AI_CANONNAME = 2 -rbx.platform.socket.AI_DEFAULT = -rbx.platform.socket.AI_MASK = -rbx.platform.socket.AI_NUMERICHOST = 4 -rbx.platform.socket.AI_PASSIVE = 1 -rbx.platform.socket.AI_V4MAPPED = 2048 -rbx.platform.socket.AI_V4MAPPED_CFG = -rbx.platform.socket.EAI_ADDRFAMILY = 1 -rbx.platform.socket.EAI_AGAIN = 2 -rbx.platform.socket.EAI_BADFLAGS = 3 -rbx.platform.socket.EAI_BADHINTS = 12 -rbx.platform.socket.EAI_FAIL = 4 -rbx.platform.socket.EAI_FAMILY = 5 -rbx.platform.socket.EAI_MAX = -rbx.platform.socket.EAI_MEMORY = 6 -rbx.platform.socket.EAI_NODATA = 7 -rbx.platform.socket.EAI_NONAME = 8 -rbx.platform.socket.EAI_PROTOCOL = 13 -rbx.platform.socket.EAI_SERVICE = 9 -rbx.platform.socket.EAI_SOCKTYPE = 10 -rbx.platform.socket.EAI_SYSTEM = 11 -rbx.platform.socket.INADDR_ALLHOSTS_GROUP = -536870911 -rbx.platform.socket.INADDR_ANY = 0 -rbx.platform.socket.INADDR_BROADCAST = -1 -rbx.platform.socket.INADDR_LOOPBACK = 2130706433 -rbx.platform.socket.INADDR_MAX_LOCAL_GROUP = -536870657 -rbx.platform.socket.INADDR_NONE = -1 -rbx.platform.socket.INADDR_UNSPEC_GROUP = -536870912 -rbx.platform.socket.IPPORT_RESERVED = -rbx.platform.socket.IPPORT_USERRESERVED = -rbx.platform.socket.IPPROTO_BIP = -rbx.platform.socket.IPPROTO_EGP = 8 -rbx.platform.socket.IPPROTO_EON = -rbx.platform.socket.IPPROTO_GGP = -rbx.platform.socket.IPPROTO_HELLO = -rbx.platform.socket.IPPROTO_ICMP = 1 -rbx.platform.socket.IPPROTO_IDP = 22 -rbx.platform.socket.IPPROTO_IGMP = 2 -rbx.platform.socket.IPPROTO_IP = 0 -rbx.platform.socket.IPPROTO_MAX = -rbx.platform.socket.IPPROTO_ND = -rbx.platform.socket.IPPROTO_PUP = 12 -rbx.platform.socket.IPPROTO_RAW = 255 -rbx.platform.socket.IPPROTO_TCP = 6 -rbx.platform.socket.IPPROTO_TP = -rbx.platform.socket.IPPROTO_UDP = 17 -rbx.platform.socket.IPPROTO_XTP = -rbx.platform.socket.IPX_TYPE = 1 -rbx.platform.socket.IP_ADD_MEMBERSHIP = 12 -rbx.platform.socket.IP_DEFAULT_MULTICAST_LOOP = 1 -rbx.platform.socket.IP_DEFAULT_MULTICAST_TTL = 1 -rbx.platform.socket.IP_DROP_MEMBERSHIP = 13 -rbx.platform.socket.IP_HDRINCL = 2 -rbx.platform.socket.IP_MAX_MEMBERSHIPS = 20 -rbx.platform.socket.IP_MULTICAST_IF = 9 -rbx.platform.socket.IP_MULTICAST_LOOP = 11 -rbx.platform.socket.IP_MULTICAST_TTL = 10 -rbx.platform.socket.IP_OPTIONS = 1 -rbx.platform.socket.IP_RECVDSTADDR = -rbx.platform.socket.IP_RECVOPTS = -rbx.platform.socket.IP_RECVRETOPTS = -rbx.platform.socket.IP_RETOPTS = -rbx.platform.socket.IP_TOS = 3 -rbx.platform.socket.IP_TTL = 4 -rbx.platform.socket.MSG_COMPAT = -rbx.platform.socket.MSG_CTRUNC = 512 -rbx.platform.socket.MSG_DONTROUTE = 4 -rbx.platform.socket.MSG_DONTWAIT = 16 -rbx.platform.socket.MSG_EOF = -rbx.platform.socket.MSG_EOR = -rbx.platform.socket.MSG_FLUSH = -rbx.platform.socket.MSG_HAVEMORE = -rbx.platform.socket.MSG_HOLD = -rbx.platform.socket.MSG_OOB = 1 -rbx.platform.socket.MSG_PEEK = 2 -rbx.platform.socket.MSG_RCVMORE = -rbx.platform.socket.MSG_SEND = -rbx.platform.socket.MSG_TRUNC = 256 -rbx.platform.socket.MSG_WAITALL = 8 -rbx.platform.socket.NI_DGRAM = 16 -rbx.platform.socket.NI_MAXHOST = 1025 -rbx.platform.socket.NI_MAXSERV = 32 -rbx.platform.socket.NI_NAMEREQD = 4 -rbx.platform.socket.NI_NOFQDN = 1 -rbx.platform.socket.NI_NUMERICHOST = 2 -rbx.platform.socket.NI_NUMERICSERV = 8 -rbx.platform.socket.PF_APPLETALK = 16 -rbx.platform.socket.PF_AX25 = -rbx.platform.socket.PF_CCITT = 10 -rbx.platform.socket.PF_CHAOS = 5 -rbx.platform.socket.PF_CNT = -rbx.platform.socket.PF_COIP = -rbx.platform.socket.PF_DATAKIT = 9 -rbx.platform.socket.PF_DLI = 13 -rbx.platform.socket.PF_ECMA = 8 -rbx.platform.socket.PF_HYLINK = 15 -rbx.platform.socket.PF_IMPLINK = 3 -rbx.platform.socket.PF_INET = 2 -rbx.platform.socket.PF_INET6 = 23 -rbx.platform.socket.PF_IPX = -rbx.platform.socket.PF_ISDN = -rbx.platform.socket.PF_ISO = 7 -rbx.platform.socket.PF_KEY = -rbx.platform.socket.PF_LAT = 14 -rbx.platform.socket.PF_LINK = -rbx.platform.socket.PF_LOCAL = 1 -rbx.platform.socket.PF_MAX = 32 -rbx.platform.socket.PF_NATM = -rbx.platform.socket.PF_NDRV = -rbx.platform.socket.PF_NETBIOS = 17 -rbx.platform.socket.PF_NETGRAPH = -rbx.platform.socket.PF_NS = 6 -rbx.platform.socket.PF_OSI = 7 -rbx.platform.socket.PF_PIP = -rbx.platform.socket.PF_PPP = -rbx.platform.socket.PF_PUP = 4 -rbx.platform.socket.PF_ROUTE = -rbx.platform.socket.PF_RTIP = -rbx.platform.socket.PF_SIP = -rbx.platform.socket.PF_SNA = 11 -rbx.platform.socket.PF_SYSTEM = -rbx.platform.socket.PF_UNIX = 1 -rbx.platform.socket.PF_UNSPEC = 0 -rbx.platform.socket.PF_XTP = -rbx.platform.socket.SHUT_RD = 0 -rbx.platform.socket.SHUT_RDWR = 2 -rbx.platform.socket.SHUT_WR = 1 -rbx.platform.socket.SOCK_DGRAM = 2 -rbx.platform.socket.SOCK_PACKET = -rbx.platform.socket.SOCK_RAW = 3 -rbx.platform.socket.SOCK_RDM = 4 -rbx.platform.socket.SOCK_SEQPACKET = 5 -rbx.platform.socket.SOCK_STREAM = 1 -rbx.platform.socket.SOL_ATALK = 258 -rbx.platform.socket.SOL_AX25 = 257 -rbx.platform.socket.SOL_IP = 0 -rbx.platform.socket.SOL_IPX = 256 -rbx.platform.socket.SOL_SOCKET = 65535 -rbx.platform.socket.SOL_TCP = 6 -rbx.platform.socket.SOL_UDP = 17 -rbx.platform.socket.SOPRI_BACKGROUND = 2 -rbx.platform.socket.SOPRI_INTERACTIVE = 0 -rbx.platform.socket.SOPRI_NORMAL = 1 -rbx.platform.socket.SO_ACCEPTCONN = 2 -rbx.platform.socket.SO_ACCEPTFILTER = -rbx.platform.socket.SO_ATTACH_FILTER = -rbx.platform.socket.SO_BINDTODEVICE = -rbx.platform.socket.SO_BROADCAST = 32 -rbx.platform.socket.SO_DEBUG = 1 -rbx.platform.socket.SO_DETACH_FILTER = -rbx.platform.socket.SO_DONTROUTE = 16 -rbx.platform.socket.SO_DONTTRUNC = -rbx.platform.socket.SO_ERROR = 4103 -rbx.platform.socket.SO_KEEPALIVE = 8 -rbx.platform.socket.SO_LINGER = 128 -rbx.platform.socket.SO_NKE = -rbx.platform.socket.SO_NOSIGPIPE = -rbx.platform.socket.SO_NO_CHECK = -rbx.platform.socket.SO_NREAD = -rbx.platform.socket.SO_OOBINLINE = 256 -rbx.platform.socket.SO_PASSCRED = -rbx.platform.socket.SO_PEERCRED = 512 -rbx.platform.socket.SO_PEERNAME = -rbx.platform.socket.SO_PRIORITY = -rbx.platform.socket.SO_RCVBUF = 4098 -rbx.platform.socket.SO_RCVLOWAT = 4100 -rbx.platform.socket.SO_RCVTIMEO = 4102 -rbx.platform.socket.SO_REUSEADDR = 4 -rbx.platform.socket.SO_REUSEPORT = -rbx.platform.socket.SO_SECURITY_AUTHENTICATION = -rbx.platform.socket.SO_SECURITY_ENCRYPTION_NETWORK = -rbx.platform.socket.SO_SECURITY_ENCRYPTION_TRANSPORT = -rbx.platform.socket.SO_SNDBUF = 4097 -rbx.platform.socket.SO_SNDLOWAT = 4099 -rbx.platform.socket.SO_SNDTIMEO = 4101 -rbx.platform.socket.SO_TIMESTAMP = -rbx.platform.socket.SO_TYPE = 4104 -rbx.platform.socket.SO_USELOOPBACK = 64 -rbx.platform.socket.SO_WANTMORE = -rbx.platform.socket.SO_WANTOOBFLAG = -rbx.platform.socket.TCP_MAXSEG = 2 -rbx.platform.socket.TCP_NODELAY = 1 -rbx.platform.process.WNOHANG = 1 -rbx.platform.process.WUNTRACED = 2 -rbx.platform.process.PRIO_PROCESS = 0 -rbx.platform.process.PRIO_PGRP = 1 -rbx.platform.process.PRIO_USER = 2 -rbx.platform.process.RLIMIT_CPU = 0 -rbx.platform.process.RLIMIT_FSIZE = 1 -rbx.platform.process.RLIMIT_DATA = 2 -rbx.platform.process.RLIMIT_STACK = 3 -rbx.platform.process.RLIMIT_CORE = 4 -rbx.platform.process.RLIMIT_RSS = -rbx.platform.process.RLIMIT_NPROC = -rbx.platform.process.RLIMIT_NOFILE = 5 -rbx.platform.process.RLIMIT_MEMLOCK = -rbx.platform.process.RLIMIT_AS = 6 -rbx.platform.process.RLIMIT_SBSIZE = -rbx.platform.process.RLIM_INFINITY = 4294967295 -rbx.platform.process.RLIM_SAVED_MAX = 4294967295 -rbx.platform.process.RLIM_SAVED_CUR = 4294967295 -rbx.platform.signal.SIGHUP = 1 -rbx.platform.signal.SIGINT = 2 -rbx.platform.signal.SIGQUIT = 3 -rbx.platform.signal.SIGILL = 4 -rbx.platform.signal.SIGTRAP = 5 -rbx.platform.signal.SIGIOT = -rbx.platform.signal.SIGABRT = 6 -rbx.platform.signal.SIGEMT = 7 -rbx.platform.signal.SIGFPE = 8 -rbx.platform.signal.SIGKILL = 9 -rbx.platform.signal.SIGBUS = 10 -rbx.platform.signal.SIGSEGV = 11 -rbx.platform.signal.SIGSYS = 12 -rbx.platform.signal.SIGPIPE = 13 -rbx.platform.signal.SIGALRM = 14 -rbx.platform.signal.SIGTERM = 15 -rbx.platform.signal.SIGURG = 16 -rbx.platform.signal.SIGSTOP = 17 -rbx.platform.signal.SIGTSTP = 18 -rbx.platform.signal.SIGCONT = 19 -rbx.platform.signal.SIGCHLD = 20 -rbx.platform.signal.SIGCLD = 20 -rbx.platform.signal.SIGTTIN = 21 -rbx.platform.signal.SIGTTOU = 22 -rbx.platform.signal.SIGIO = 23 -rbx.platform.signal.SIGXCPU = 24 -rbx.platform.signal.SIGXFSZ = 25 -rbx.platform.signal.SIGVTALRM = 26 -rbx.platform.signal.SIGPROF = 27 -rbx.platform.signal.SIGWINCH = 28 -rbx.platform.signal.SIGUSR1 = 30 -rbx.platform.signal.SIGUSR2 = 31 -rbx.platform.signal.SIGLOST = 29 -rbx.platform.signal.SIGMSG = -rbx.platform.signal.SIGPWR = 29 -rbx.platform.signal.SIGPOLL = 23 -rbx.platform.signal.SIGDANGER = -rbx.platform.signal.SIGMIGRATE = -rbx.platform.signal.SIGPRE = -rbx.platform.signal.SIGGRANT = -rbx.platform.signal.SIGRETRACT = -rbx.platform.signal.SIGSOUND = -rbx.platform.signal.SIGINFO = -rbx.platform.zlib.ZLIB_VERSION = 1.2.5 -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int_least16_t = short -rbx.platform.typedef.__uint_least16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int_least32_t = int -rbx.platform.typedef.__uint_least32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef._off_t = long -rbx.platform.typedef.__dev_t = short -rbx.platform.typedef.__uid_t = ushort -rbx.platform.typedef.__gid_t = ushort -rbx.platform.typedef._off64_t = long_long -rbx.platform.typedef._fpos_t = long -rbx.platform.typedef._fpos64_t = long_long -rbx.platform.typedef._ssize_t = int -rbx.platform.typedef.wint_t = uint -rbx.platform.typedef.ptrdiff_t = int -rbx.platform.typedef.size_t = uint -rbx.platform.typedef.__off_t = long -rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__loff_t = long_long -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.clock_t = ulong -rbx.platform.typedef.time_t = long -rbx.platform.typedef.daddr_t = long -rbx.platform.typedef.caddr_t = string -rbx.platform.typedef.pid_t = int -rbx.platform.typedef.ssize_t = int -rbx.platform.typedef.nlink_t = ushort -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.clockid_t = ulong -rbx.platform.typedef.timer_t = ulong -rbx.platform.typedef.useconds_t = ulong -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.uint8_t = uchar -rbx.platform.typedef.uint16_t = ushort -rbx.platform.typedef.uint32_t = uint -rbx.platform.typedef.uint64_t = ulong_long -rbx.platform.typedef.int_least8_t = char -rbx.platform.typedef.int_least16_t = short -rbx.platform.typedef.int_least32_t = int -rbx.platform.typedef.int_least64_t = long_long -rbx.platform.typedef.uint_least8_t = uchar -rbx.platform.typedef.uint_least16_t = ushort -rbx.platform.typedef.uint_least32_t = uint -rbx.platform.typedef.uint_least64_t = ulong_long -rbx.platform.typedef.int_fast8_t = char -rbx.platform.typedef.int_fast16_t = int -rbx.platform.typedef.int_fast32_t = int -rbx.platform.typedef.int_fast64_t = long_long -rbx.platform.typedef.uint_fast8_t = uchar -rbx.platform.typedef.uint_fast16_t = uint -rbx.platform.typedef.uint_fast32_t = uint -rbx.platform.typedef.uint_fast64_t = ulong_long -rbx.platform.typedef.intptr_t = int -rbx.platform.typedef.uintptr_t = uint -rbx.platform.typedef.intmax_t = long_long -rbx.platform.typedef.uintmax_t = ulong_long -rbx.platform.typedef.off_t = long_long -rbx.platform.typedef.loff_t = long_long -rbx.platform.typedef.__dev16_t = short -rbx.platform.typedef.__dev32_t = ulong -rbx.platform.typedef.dev_t = ulong -rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.__blkcnt32_t = long -rbx.platform.typedef.__blkcnt64_t = long_long -rbx.platform.typedef.blkcnt_t = long_long -rbx.platform.typedef.fsblkcnt_t = ulong -rbx.platform.typedef.fsfilcnt_t = ulong -rbx.platform.typedef.__uid16_t = ushort -rbx.platform.typedef.__uid32_t = ulong -rbx.platform.typedef.uid_t = ulong -rbx.platform.typedef.__gid16_t = ushort -rbx.platform.typedef.__gid32_t = ulong -rbx.platform.typedef.gid_t = ulong -rbx.platform.typedef.__ino32_t = ulong -rbx.platform.typedef.__ino64_t = ulong_long -rbx.platform.typedef.ino_t = ulong_long -rbx.platform.typedef.id_t = ulong -rbx.platform.typedef.key_t = long_long -rbx.platform.typedef.vm_offset_t = ulong -rbx.platform.typedef.vm_size_t = ulong -rbx.platform.typedef.u_int8_t = uchar -rbx.platform.typedef.u_int16_t = ushort -rbx.platform.typedef.u_int32_t = uint -rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = int -rbx.platform.typedef.*addr_t = char -rbx.platform.typedef.socklen_t = int -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.__ULong = ulong -rbx.platform.typedef.sigset_t = ulong -rbx.platform.typedef.sig_atomic_t = int -rbx.platform.typedef.rlim_t = ulong +rbx.platform.dirent.sizeof = 276 +rbx.platform.dirent.d_ino.offset = 4 +rbx.platform.dirent.d_ino.size = 8 +rbx.platform.dirent.d_ino.type = ino_t +rbx.platform.dirent.d_name.offset = 20 +rbx.platform.dirent.d_name.size = 256 +rbx.platform.dirent.d_name.type = char_array +rbx.platform.timeval.sizeof = 8 +rbx.platform.timeval.tv_sec.offset = 0 +rbx.platform.timeval.tv_sec.size = 4 +rbx.platform.timeval.tv_sec.type = time_t +rbx.platform.timeval.tv_usec.offset = 4 +rbx.platform.timeval.tv_usec.size = 4 +rbx.platform.timeval.tv_usec.type = suseconds_t +rbx.platform.sockaddr_in.sizeof = 16 +rbx.platform.sockaddr_in.sin_family.offset = 0 +rbx.platform.sockaddr_in.sin_family.size = 2 +rbx.platform.sockaddr_in.sin_family.type = sa_family_t +rbx.platform.sockaddr_in.sin_port.offset = 2 +rbx.platform.sockaddr_in.sin_port.size = 2 +rbx.platform.sockaddr_in.sin_port.type = ushort +rbx.platform.sockaddr_in.sin_addr.offset = 4 +rbx.platform.sockaddr_in.sin_addr.size = 4 +rbx.platform.sockaddr_in.sin_zero.offset = 8 +rbx.platform.sockaddr_in.sin_zero.size = 8 +rbx.platform.sockaddr_in.sin_zero.type = char_array +rbx.platform.sockaddr_un.sizeof = 110 +rbx.platform.sockaddr_un.sun_family.offset = 0 +rbx.platform.sockaddr_un.sun_family.size = 2 +rbx.platform.sockaddr_un.sun_family.type = sa_family_t +rbx.platform.sockaddr_un.sun_path.offset = 2 +rbx.platform.sockaddr_un.sun_path.size = 108 +rbx.platform.sockaddr_un.sun_path.type = char_array +rbx.platform.servent.sizeof = 16 +rbx.platform.servent.s_name.offset = 0 +rbx.platform.servent.s_name.size = 4 +rbx.platform.servent.s_name.type = pointer +rbx.platform.servent.s_aliases.offset = 4 +rbx.platform.servent.s_aliases.size = 4 +rbx.platform.servent.s_aliases.type = pointer +rbx.platform.servent.s_port.offset = 8 +rbx.platform.servent.s_port.size = 2 +rbx.platform.servent.s_port.type = int +rbx.platform.servent.s_proto.offset = 12 +rbx.platform.servent.s_proto.size = 4 +rbx.platform.servent.s_proto.type = pointer +rbx.platform.stat.sizeof = 96 +rbx.platform.stat.st_dev.offset = 0 +rbx.platform.stat.st_dev.size = 4 +rbx.platform.stat.st_dev.type = dev_t +rbx.platform.stat.st_ino.offset = 8 +rbx.platform.stat.st_ino.size = 8 +rbx.platform.stat.st_ino.type = ino_t +rbx.platform.stat.st_mode.offset = 16 +rbx.platform.stat.st_mode.size = 4 +rbx.platform.stat.st_mode.type = mode_t +rbx.platform.stat.st_nlink.offset = 20 +rbx.platform.stat.st_nlink.size = 2 +rbx.platform.stat.st_nlink.type = nlink_t +rbx.platform.stat.st_uid.offset = 24 +rbx.platform.stat.st_uid.size = 4 +rbx.platform.stat.st_uid.type = uid_t +rbx.platform.stat.st_gid.offset = 28 +rbx.platform.stat.st_gid.size = 4 +rbx.platform.stat.st_gid.type = gid_t +rbx.platform.stat.st_rdev.offset = 32 +rbx.platform.stat.st_rdev.size = 4 +rbx.platform.stat.st_rdev.type = dev_t +rbx.platform.stat.st_size.offset = 40 +rbx.platform.stat.st_size.size = 8 +rbx.platform.stat.st_size.type = off_t +rbx.platform.stat.st_blksize.offset = 72 +rbx.platform.stat.st_blksize.size = 4 +rbx.platform.stat.st_blocks.offset = 80 +rbx.platform.stat.st_blocks.size = 8 +rbx.platform.stat.st_atime.offset = 48 +rbx.platform.stat.st_atime.size = 4 +rbx.platform.stat.st_atime.type = time_t +rbx.platform.stat.st_mtime.offset = 56 +rbx.platform.stat.st_mtime.size = 4 +rbx.platform.stat.st_mtime.type = time_t +rbx.platform.stat.st_ctime.offset = 64 +rbx.platform.stat.st_ctime.size = 4 +rbx.platform.stat.st_ctime.type = time_t +rbx.platform.rlimit.sizeof = 8 +rbx.platform.rlimit.rlim_cur.offset = 0 +rbx.platform.rlimit.rlim_cur.size = 4 +rbx.platform.rlimit.rlim_cur.type = rlim_t +rbx.platform.rlimit.rlim_max.offset = 4 +rbx.platform.rlimit.rlim_max.size = 4 +rbx.platform.rlimit.rlim_max.type = rlim_t +rbx.platform.file.O_RDONLY = 0 +rbx.platform.file.O_WRONLY = 1 +rbx.platform.file.O_RDWR = 2 +rbx.platform.file.O_CREAT = 512 +rbx.platform.file.O_EXCL = 2048 +rbx.platform.file.O_NOCTTY = 32768 +rbx.platform.file.O_TRUNC = 1024 +rbx.platform.file.O_APPEND = 8 +rbx.platform.file.O_NONBLOCK = 16384 +rbx.platform.file.O_SYNC = 8192 +rbx.platform.file.S_IRUSR = 256 +rbx.platform.file.S_IWUSR = 128 +rbx.platform.file.S_IXUSR = 64 +rbx.platform.file.S_IRGRP = 32 +rbx.platform.file.S_IWGRP = 16 +rbx.platform.file.S_IXGRP = 8 +rbx.platform.file.S_IROTH = 4 +rbx.platform.file.S_IWOTH = 2 +rbx.platform.file.S_IXOTH = 1 +rbx.platform.file.S_IFMT = 61440 +rbx.platform.file.S_IFIFO = 4096 +rbx.platform.file.S_IFCHR = 8192 +rbx.platform.file.S_IFDIR = 16384 +rbx.platform.file.S_IFBLK = 24576 +rbx.platform.file.S_IFREG = 32768 +rbx.platform.file.S_IFLNK = 40960 +rbx.platform.file.S_IFSOCK = 49152 +rbx.platform.file.S_IFWHT = +rbx.platform.file.S_ISUID = 2048 +rbx.platform.file.S_ISGID = 1024 +rbx.platform.io.SEEK_SET = 0 +rbx.platform.io.SEEK_CUR = 1 +rbx.platform.io.SEEK_END = 2 +rbx.platform.fcntl.F_GETFL = 3 +rbx.platform.fcntl.F_SETFL = 4 +rbx.platform.fcntl.O_ACCMODE = 3 +rbx.platform.socket.AF_APPLETALK = 16 +rbx.platform.socket.AF_ATM = +rbx.platform.socket.AF_AX25 = +rbx.platform.socket.AF_CCITT = 10 +rbx.platform.socket.AF_CHAOS = 5 +rbx.platform.socket.AF_CNT = +rbx.platform.socket.AF_COIP = +rbx.platform.socket.AF_DATAKIT = 9 +rbx.platform.socket.AF_DEC = +rbx.platform.socket.AF_DLI = 13 +rbx.platform.socket.AF_E164 = +rbx.platform.socket.AF_ECMA = 8 +rbx.platform.socket.AF_HYLINK = 15 +rbx.platform.socket.AF_IMPLINK = 3 +rbx.platform.socket.AF_INET = 2 +rbx.platform.socket.AF_INET6 = 23 +rbx.platform.socket.AF_IPX = +rbx.platform.socket.AF_ISDN = +rbx.platform.socket.AF_ISO = 7 +rbx.platform.socket.AF_LAT = 14 +rbx.platform.socket.AF_LINK = +rbx.platform.socket.AF_LOCAL = 1 +rbx.platform.socket.AF_MAX = 32 +rbx.platform.socket.AF_NATM = +rbx.platform.socket.AF_NDRV = +rbx.platform.socket.AF_NETBIOS = 17 +rbx.platform.socket.AF_NETGRAPH = +rbx.platform.socket.AF_NS = 6 +rbx.platform.socket.AF_OSI = 7 +rbx.platform.socket.AF_PPP = +rbx.platform.socket.AF_PUP = 4 +rbx.platform.socket.AF_ROUTE = +rbx.platform.socket.AF_SIP = +rbx.platform.socket.AF_SNA = 11 +rbx.platform.socket.AF_SYSTEM = +rbx.platform.socket.AF_UNIX = 1 +rbx.platform.socket.AF_UNSPEC = 0 +rbx.platform.socket.AI_ADDRCONFIG = 1024 +rbx.platform.socket.AI_ALL = 256 +rbx.platform.socket.AI_CANONNAME = 2 +rbx.platform.socket.AI_DEFAULT = +rbx.platform.socket.AI_MASK = +rbx.platform.socket.AI_NUMERICHOST = 4 +rbx.platform.socket.AI_PASSIVE = 1 +rbx.platform.socket.AI_V4MAPPED = 2048 +rbx.platform.socket.AI_V4MAPPED_CFG = +rbx.platform.socket.EAI_ADDRFAMILY = 1 +rbx.platform.socket.EAI_AGAIN = 2 +rbx.platform.socket.EAI_BADFLAGS = 3 +rbx.platform.socket.EAI_BADHINTS = 12 +rbx.platform.socket.EAI_FAIL = 4 +rbx.platform.socket.EAI_FAMILY = 5 +rbx.platform.socket.EAI_MAX = +rbx.platform.socket.EAI_MEMORY = 6 +rbx.platform.socket.EAI_NODATA = 7 +rbx.platform.socket.EAI_NONAME = 8 +rbx.platform.socket.EAI_PROTOCOL = 13 +rbx.platform.socket.EAI_SERVICE = 9 +rbx.platform.socket.EAI_SOCKTYPE = 10 +rbx.platform.socket.EAI_SYSTEM = 11 +rbx.platform.socket.INADDR_ALLHOSTS_GROUP = -536870911 +rbx.platform.socket.INADDR_ANY = 0 +rbx.platform.socket.INADDR_BROADCAST = -1 +rbx.platform.socket.INADDR_LOOPBACK = 2130706433 +rbx.platform.socket.INADDR_MAX_LOCAL_GROUP = -536870657 +rbx.platform.socket.INADDR_NONE = -1 +rbx.platform.socket.INADDR_UNSPEC_GROUP = -536870912 +rbx.platform.socket.IPPORT_RESERVED = +rbx.platform.socket.IPPORT_USERRESERVED = +rbx.platform.socket.IPPROTO_BIP = +rbx.platform.socket.IPPROTO_EGP = 8 +rbx.platform.socket.IPPROTO_EON = +rbx.platform.socket.IPPROTO_GGP = +rbx.platform.socket.IPPROTO_HELLO = +rbx.platform.socket.IPPROTO_ICMP = 1 +rbx.platform.socket.IPPROTO_IDP = 22 +rbx.platform.socket.IPPROTO_IGMP = 2 +rbx.platform.socket.IPPROTO_IP = 0 +rbx.platform.socket.IPPROTO_MAX = +rbx.platform.socket.IPPROTO_ND = +rbx.platform.socket.IPPROTO_PUP = 12 +rbx.platform.socket.IPPROTO_RAW = 255 +rbx.platform.socket.IPPROTO_TCP = 6 +rbx.platform.socket.IPPROTO_TP = +rbx.platform.socket.IPPROTO_UDP = 17 +rbx.platform.socket.IPPROTO_XTP = +rbx.platform.socket.IPX_TYPE = 1 +rbx.platform.socket.IP_ADD_MEMBERSHIP = 12 +rbx.platform.socket.IP_DEFAULT_MULTICAST_LOOP = 1 +rbx.platform.socket.IP_DEFAULT_MULTICAST_TTL = 1 +rbx.platform.socket.IP_DROP_MEMBERSHIP = 13 +rbx.platform.socket.IP_HDRINCL = 2 +rbx.platform.socket.IP_MAX_MEMBERSHIPS = 20 +rbx.platform.socket.IP_MULTICAST_IF = 9 +rbx.platform.socket.IP_MULTICAST_LOOP = 11 +rbx.platform.socket.IP_MULTICAST_TTL = 10 +rbx.platform.socket.IP_OPTIONS = 1 +rbx.platform.socket.IP_RECVDSTADDR = +rbx.platform.socket.IP_RECVOPTS = +rbx.platform.socket.IP_RECVRETOPTS = +rbx.platform.socket.IP_RETOPTS = +rbx.platform.socket.IP_TOS = 3 +rbx.platform.socket.IP_TTL = 4 +rbx.platform.socket.MSG_COMPAT = +rbx.platform.socket.MSG_CTRUNC = 512 +rbx.platform.socket.MSG_DONTROUTE = 4 +rbx.platform.socket.MSG_DONTWAIT = 16 +rbx.platform.socket.MSG_EOF = +rbx.platform.socket.MSG_EOR = +rbx.platform.socket.MSG_FLUSH = +rbx.platform.socket.MSG_HAVEMORE = +rbx.platform.socket.MSG_HOLD = +rbx.platform.socket.MSG_OOB = 1 +rbx.platform.socket.MSG_PEEK = 2 +rbx.platform.socket.MSG_RCVMORE = +rbx.platform.socket.MSG_SEND = +rbx.platform.socket.MSG_TRUNC = 256 +rbx.platform.socket.MSG_WAITALL = 8 +rbx.platform.socket.NI_DGRAM = 16 +rbx.platform.socket.NI_MAXHOST = 1025 +rbx.platform.socket.NI_MAXSERV = 32 +rbx.platform.socket.NI_NAMEREQD = 4 +rbx.platform.socket.NI_NOFQDN = 1 +rbx.platform.socket.NI_NUMERICHOST = 2 +rbx.platform.socket.NI_NUMERICSERV = 8 +rbx.platform.socket.PF_APPLETALK = 16 +rbx.platform.socket.PF_AX25 = +rbx.platform.socket.PF_CCITT = 10 +rbx.platform.socket.PF_CHAOS = 5 +rbx.platform.socket.PF_CNT = +rbx.platform.socket.PF_COIP = +rbx.platform.socket.PF_DATAKIT = 9 +rbx.platform.socket.PF_DLI = 13 +rbx.platform.socket.PF_ECMA = 8 +rbx.platform.socket.PF_HYLINK = 15 +rbx.platform.socket.PF_IMPLINK = 3 +rbx.platform.socket.PF_INET = 2 +rbx.platform.socket.PF_INET6 = 23 +rbx.platform.socket.PF_IPX = +rbx.platform.socket.PF_ISDN = +rbx.platform.socket.PF_ISO = 7 +rbx.platform.socket.PF_KEY = +rbx.platform.socket.PF_LAT = 14 +rbx.platform.socket.PF_LINK = +rbx.platform.socket.PF_LOCAL = 1 +rbx.platform.socket.PF_MAX = 32 +rbx.platform.socket.PF_NATM = +rbx.platform.socket.PF_NDRV = +rbx.platform.socket.PF_NETBIOS = 17 +rbx.platform.socket.PF_NETGRAPH = +rbx.platform.socket.PF_NS = 6 +rbx.platform.socket.PF_OSI = 7 +rbx.platform.socket.PF_PIP = +rbx.platform.socket.PF_PPP = +rbx.platform.socket.PF_PUP = 4 +rbx.platform.socket.PF_ROUTE = +rbx.platform.socket.PF_RTIP = +rbx.platform.socket.PF_SIP = +rbx.platform.socket.PF_SNA = 11 +rbx.platform.socket.PF_SYSTEM = +rbx.platform.socket.PF_UNIX = 1 +rbx.platform.socket.PF_UNSPEC = 0 +rbx.platform.socket.PF_XTP = +rbx.platform.socket.SHUT_RD = 0 +rbx.platform.socket.SHUT_RDWR = 2 +rbx.platform.socket.SHUT_WR = 1 +rbx.platform.socket.SOCK_DGRAM = 2 +rbx.platform.socket.SOCK_PACKET = +rbx.platform.socket.SOCK_RAW = 3 +rbx.platform.socket.SOCK_RDM = 4 +rbx.platform.socket.SOCK_SEQPACKET = 5 +rbx.platform.socket.SOCK_STREAM = 1 +rbx.platform.socket.SOL_ATALK = 258 +rbx.platform.socket.SOL_AX25 = 257 +rbx.platform.socket.SOL_IP = 0 +rbx.platform.socket.SOL_IPX = 256 +rbx.platform.socket.SOL_SOCKET = 65535 +rbx.platform.socket.SOL_TCP = 6 +rbx.platform.socket.SOL_UDP = 17 +rbx.platform.socket.SOPRI_BACKGROUND = 2 +rbx.platform.socket.SOPRI_INTERACTIVE = 0 +rbx.platform.socket.SOPRI_NORMAL = 1 +rbx.platform.socket.SO_ACCEPTCONN = 2 +rbx.platform.socket.SO_ACCEPTFILTER = +rbx.platform.socket.SO_ATTACH_FILTER = +rbx.platform.socket.SO_BINDTODEVICE = +rbx.platform.socket.SO_BROADCAST = 32 +rbx.platform.socket.SO_DEBUG = 1 +rbx.platform.socket.SO_DETACH_FILTER = +rbx.platform.socket.SO_DONTROUTE = 16 +rbx.platform.socket.SO_DONTTRUNC = +rbx.platform.socket.SO_ERROR = 4103 +rbx.platform.socket.SO_KEEPALIVE = 8 +rbx.platform.socket.SO_LINGER = 128 +rbx.platform.socket.SO_NKE = +rbx.platform.socket.SO_NOSIGPIPE = +rbx.platform.socket.SO_NO_CHECK = +rbx.platform.socket.SO_NREAD = +rbx.platform.socket.SO_OOBINLINE = 256 +rbx.platform.socket.SO_PASSCRED = +rbx.platform.socket.SO_PEERCRED = 512 +rbx.platform.socket.SO_PEERNAME = +rbx.platform.socket.SO_PRIORITY = +rbx.platform.socket.SO_RCVBUF = 4098 +rbx.platform.socket.SO_RCVLOWAT = 4100 +rbx.platform.socket.SO_RCVTIMEO = 4102 +rbx.platform.socket.SO_REUSEADDR = 4 +rbx.platform.socket.SO_REUSEPORT = +rbx.platform.socket.SO_SECURITY_AUTHENTICATION = +rbx.platform.socket.SO_SECURITY_ENCRYPTION_NETWORK = +rbx.platform.socket.SO_SECURITY_ENCRYPTION_TRANSPORT = +rbx.platform.socket.SO_SNDBUF = 4097 +rbx.platform.socket.SO_SNDLOWAT = 4099 +rbx.platform.socket.SO_SNDTIMEO = 4101 +rbx.platform.socket.SO_TIMESTAMP = +rbx.platform.socket.SO_TYPE = 4104 +rbx.platform.socket.SO_USELOOPBACK = 64 +rbx.platform.socket.SO_WANTMORE = +rbx.platform.socket.SO_WANTOOBFLAG = +rbx.platform.socket.TCP_MAXSEG = 2 +rbx.platform.socket.TCP_NODELAY = 1 +rbx.platform.process.WNOHANG = 1 +rbx.platform.process.WUNTRACED = 2 +rbx.platform.process.PRIO_PROCESS = 0 +rbx.platform.process.PRIO_PGRP = 1 +rbx.platform.process.PRIO_USER = 2 +rbx.platform.process.RLIMIT_CPU = 0 +rbx.platform.process.RLIMIT_FSIZE = 1 +rbx.platform.process.RLIMIT_DATA = 2 +rbx.platform.process.RLIMIT_STACK = 3 +rbx.platform.process.RLIMIT_CORE = 4 +rbx.platform.process.RLIMIT_RSS = +rbx.platform.process.RLIMIT_NPROC = +rbx.platform.process.RLIMIT_NOFILE = 5 +rbx.platform.process.RLIMIT_MEMLOCK = +rbx.platform.process.RLIMIT_AS = 6 +rbx.platform.process.RLIMIT_SBSIZE = +rbx.platform.process.RLIM_INFINITY = 4294967295 +rbx.platform.process.RLIM_SAVED_MAX = 4294967295 +rbx.platform.process.RLIM_SAVED_CUR = 4294967295 +rbx.platform.signal.SIGHUP = 1 +rbx.platform.signal.SIGINT = 2 +rbx.platform.signal.SIGQUIT = 3 +rbx.platform.signal.SIGILL = 4 +rbx.platform.signal.SIGTRAP = 5 +rbx.platform.signal.SIGIOT = +rbx.platform.signal.SIGABRT = 6 +rbx.platform.signal.SIGEMT = 7 +rbx.platform.signal.SIGFPE = 8 +rbx.platform.signal.SIGKILL = 9 +rbx.platform.signal.SIGBUS = 10 +rbx.platform.signal.SIGSEGV = 11 +rbx.platform.signal.SIGSYS = 12 +rbx.platform.signal.SIGPIPE = 13 +rbx.platform.signal.SIGALRM = 14 +rbx.platform.signal.SIGTERM = 15 +rbx.platform.signal.SIGURG = 16 +rbx.platform.signal.SIGSTOP = 17 +rbx.platform.signal.SIGTSTP = 18 +rbx.platform.signal.SIGCONT = 19 +rbx.platform.signal.SIGCHLD = 20 +rbx.platform.signal.SIGCLD = 20 +rbx.platform.signal.SIGTTIN = 21 +rbx.platform.signal.SIGTTOU = 22 +rbx.platform.signal.SIGIO = 23 +rbx.platform.signal.SIGXCPU = 24 +rbx.platform.signal.SIGXFSZ = 25 +rbx.platform.signal.SIGVTALRM = 26 +rbx.platform.signal.SIGPROF = 27 +rbx.platform.signal.SIGWINCH = 28 +rbx.platform.signal.SIGUSR1 = 30 +rbx.platform.signal.SIGUSR2 = 31 +rbx.platform.signal.SIGLOST = 29 +rbx.platform.signal.SIGMSG = +rbx.platform.signal.SIGPWR = 29 +rbx.platform.signal.SIGPOLL = 23 +rbx.platform.signal.SIGDANGER = +rbx.platform.signal.SIGMIGRATE = +rbx.platform.signal.SIGPRE = +rbx.platform.signal.SIGGRANT = +rbx.platform.signal.SIGRETRACT = +rbx.platform.signal.SIGSOUND = +rbx.platform.signal.SIGINFO = +rbx.platform.zlib.ZLIB_VERSION = 1.2.5 +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef._off_t = long +rbx.platform.typedef.__dev_t = short +rbx.platform.typedef.__uid_t = ushort +rbx.platform.typedef.__gid_t = ushort +rbx.platform.typedef._off64_t = long_long +rbx.platform.typedef._fpos_t = long +rbx.platform.typedef._fpos64_t = long_long +rbx.platform.typedef._ssize_t = int +rbx.platform.typedef.wint_t = uint +rbx.platform.typedef.ptrdiff_t = int +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__loff_t = long_long +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.clock_t = ulong +rbx.platform.typedef.time_t = long +rbx.platform.typedef.daddr_t = long +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.nlink_t = ushort +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.clockid_t = ulong +rbx.platform.typedef.timer_t = ulong +rbx.platform.typedef.useconds_t = ulong +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long_long +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_fast16_t = int +rbx.platform.typedef.int_fast32_t = int +rbx.platform.typedef.int_fast64_t = long_long +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_fast16_t = uint +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong_long +rbx.platform.typedef.intptr_t = int +rbx.platform.typedef.uintptr_t = uint +rbx.platform.typedef.intmax_t = long_long +rbx.platform.typedef.uintmax_t = ulong_long +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.loff_t = long_long +rbx.platform.typedef.__dev16_t = short +rbx.platform.typedef.__dev32_t = ulong +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.__blkcnt32_t = long +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.__uid16_t = ushort +rbx.platform.typedef.__uid32_t = ulong +rbx.platform.typedef.uid_t = ulong +rbx.platform.typedef.__gid16_t = ushort +rbx.platform.typedef.__gid32_t = ulong +rbx.platform.typedef.gid_t = ulong +rbx.platform.typedef.__ino32_t = ulong +rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.id_t = ulong +rbx.platform.typedef.key_t = long_long +rbx.platform.typedef.vm_offset_t = ulong +rbx.platform.typedef.vm_size_t = ulong +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.register_t = int +rbx.platform.typedef.*addr_t = char +rbx.platform.typedef.socklen_t = int +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.__ULong = ulong +rbx.platform.typedef.sigset_t = ulong +rbx.platform.typedef.sig_atomic_t = int +rbx.platform.typedef.rlim_t = ulong diff --git a/spec/regression/JRUBY-6570_autoload_from_instance_method_spec.rb b/spec/regression/JRUBY-6570_autoload_from_instance_method_spec.rb index 07d031c1512..5f8c3c6d098 100644 --- a/spec/regression/JRUBY-6570_autoload_from_instance_method_spec.rb +++ b/spec/regression/JRUBY-6570_autoload_from_instance_method_spec.rb @@ -1,16 +1,16 @@ -require 'rspec' - -describe "JRUBY-6570: autoload called from instance method" do - it "defines an autoload on the current object's class" do - cls = Class.new do - def go - autoload :Time, 'time' - autoload? :Time - end - end - - obj = cls.new - obj.go.should == 'time' - cls.autoload?(:Time).should == 'time' - end +require 'rspec' + +describe "JRUBY-6570: autoload called from instance method" do + it "defines an autoload on the current object's class" do + cls = Class.new do + def go + autoload :Time, 'time' + autoload? :Time + end + end + + obj = cls.new + obj.go.should == 'time' + cls.autoload?(:Time).should == 'time' + end end \ No newline at end of file diff --git a/spec/regression/JRUBY-6748_new_thread_not_in_thread_list_spec.rb b/spec/regression/JRUBY-6748_new_thread_not_in_thread_list_spec.rb index 21ed4fffa08..edd8045b216 100644 --- a/spec/regression/JRUBY-6748_new_thread_not_in_thread_list_spec.rb +++ b/spec/regression/JRUBY-6748_new_thread_not_in_thread_list_spec.rb @@ -1,20 +1,20 @@ -require 'rspec' - -describe "A newly created thread" do - it "should always appear in Thread.list" do - threads = [] - - 100.times do - threads << Thread.new do - 1000.times do - objects = Thread.list.map{|t|t.object_id} - objects.should include(Thread.current.object_id) - end - end - end - - threads.each do |t| - t.join - end - end -end +require 'rspec' + +describe "A newly created thread" do + it "should always appear in Thread.list" do + threads = [] + + 100.times do + threads << Thread.new do + 1000.times do + objects = Thread.list.map{|t|t.object_id} + objects.should include(Thread.current.object_id) + end + end + end + + threads.each do |t| + t.join + end + end +end diff --git a/src/org/jruby/ast/ArgsPushNode.java b/src/org/jruby/ast/ArgsPushNode.java index 01a0114b811..6f412887fd2 100644 --- a/src/org/jruby/ast/ArgsPushNode.java +++ b/src/org/jruby/ast/ArgsPushNode.java @@ -1,82 +1,82 @@ -/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2006-2007 Thomas E Enebo - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby.ast; - -import java.util.Arrays; -import java.util.List; - -import org.jruby.Ruby; -import org.jruby.RubyArray; -import org.jruby.ast.visitor.NodeVisitor; -import org.jruby.lexer.yacc.ISourcePosition; -import org.jruby.runtime.Block; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; - -public class ArgsPushNode extends Node { - private Node firstNode; - private Node secondNode; - - public ArgsPushNode(ISourcePosition position, Node firstNode, Node secondNode) { - super(position); - - assert firstNode != null : "ArgsPushNode.first == null"; - assert secondNode != null : "ArgsPushNode.second == null"; - - this.firstNode = firstNode; - this.secondNode = secondNode; - } - - public NodeType getNodeType() { - return NodeType.ARGSPUSHNODE; - } - - public Object accept(NodeVisitor visitor) { - return visitor.visitArgsPushNode(this); - } - - public Node getFirstNode() { - return firstNode; - } - - public Node getSecondNode() { - return secondNode; - } - - public List childNodes() { - return Arrays.asList(firstNode, secondNode); - } - - @Override - public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) { - RubyArray args = (RubyArray) firstNode.interpret(runtime, context, self, aBlock).dup(); - - return args.append(secondNode.interpret(runtime, context, self, aBlock)); - } -} +/* + ***** BEGIN LICENSE BLOCK ***** + * Version: CPL 1.0/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Common Public + * License Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.eclipse.org/legal/cpl-v10.html + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * Copyright (C) 2006-2007 Thomas E Enebo + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the CPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the CPL, the GPL or the LGPL. + ***** END LICENSE BLOCK *****/ +package org.jruby.ast; + +import java.util.Arrays; +import java.util.List; + +import org.jruby.Ruby; +import org.jruby.RubyArray; +import org.jruby.ast.visitor.NodeVisitor; +import org.jruby.lexer.yacc.ISourcePosition; +import org.jruby.runtime.Block; +import org.jruby.runtime.ThreadContext; +import org.jruby.runtime.builtin.IRubyObject; + +public class ArgsPushNode extends Node { + private Node firstNode; + private Node secondNode; + + public ArgsPushNode(ISourcePosition position, Node firstNode, Node secondNode) { + super(position); + + assert firstNode != null : "ArgsPushNode.first == null"; + assert secondNode != null : "ArgsPushNode.second == null"; + + this.firstNode = firstNode; + this.secondNode = secondNode; + } + + public NodeType getNodeType() { + return NodeType.ARGSPUSHNODE; + } + + public Object accept(NodeVisitor visitor) { + return visitor.visitArgsPushNode(this); + } + + public Node getFirstNode() { + return firstNode; + } + + public Node getSecondNode() { + return secondNode; + } + + public List childNodes() { + return Arrays.asList(firstNode, secondNode); + } + + @Override + public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) { + RubyArray args = (RubyArray) firstNode.interpret(runtime, context, self, aBlock).dup(); + + return args.append(secondNode.interpret(runtime, context, self, aBlock)); + } +} diff --git a/src/org/jruby/ast/IArgumentNode.java b/src/org/jruby/ast/IArgumentNode.java index 18ab656f64f..ee83836e655 100644 --- a/src/org/jruby/ast/IArgumentNode.java +++ b/src/org/jruby/ast/IArgumentNode.java @@ -1,37 +1,37 @@ -/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2007 Thomas E Enebo - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby.ast; - -/** - * Does the node contain an argument list? - */ -public interface IArgumentNode { - public Node getArgsNode(); - public Node setArgsNode(Node argsNode); -} +/* + ***** BEGIN LICENSE BLOCK ***** + * Version: CPL 1.0/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Common Public + * License Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.eclipse.org/legal/cpl-v10.html + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * Copyright (C) 2007 Thomas E Enebo + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the CPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the CPL, the GPL or the LGPL. + ***** END LICENSE BLOCK *****/ +package org.jruby.ast; + +/** + * Does the node contain an argument list? + */ +public interface IArgumentNode { + public Node getArgsNode(); + public Node setArgsNode(Node argsNode); +} diff --git a/src/org/jruby/javasupport/ParameterTypes.java b/src/org/jruby/javasupport/ParameterTypes.java index 48a47e25d71..be0f2f484cf 100644 --- a/src/org/jruby/javasupport/ParameterTypes.java +++ b/src/org/jruby/javasupport/ParameterTypes.java @@ -1,7 +1,7 @@ -package org.jruby.javasupport; - -public interface ParameterTypes { - Class[] getParameterTypes(); - Class[] getExceptionTypes(); - boolean isVarArgs(); -} +package org.jruby.javasupport; + +public interface ParameterTypes { + Class[] getParameterTypes(); + Class[] getExceptionTypes(); + boolean isVarArgs(); +} diff --git a/src/org/jruby/runtime/builtin/Variable.java b/src/org/jruby/runtime/builtin/Variable.java index bbf99abca70..4d42a5ec8fb 100644 --- a/src/org/jruby/runtime/builtin/Variable.java +++ b/src/org/jruby/runtime/builtin/Variable.java @@ -1,51 +1,51 @@ -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2007 William N Dortch - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby.runtime.builtin; - -public interface Variable { - - String getName(); - - BaseObjectType getValue(); - - boolean isInstanceVariable(); - - boolean isClassVariable(); - - boolean isConstant(); - - /** - * Returns true if the variable is an instance variable, class variable, or constant; - * otherwise, false. - * - * @return true if the variable is an instance variable, class variable, or constant, - * else false - */ - boolean isRubyVariable(); - -} +/***** BEGIN LICENSE BLOCK ***** + * Version: CPL 1.0/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Common Public + * License Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.eclipse.org/legal/cpl-v10.html + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * Copyright (C) 2007 William N Dortch + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the CPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the CPL, the GPL or the LGPL. + ***** END LICENSE BLOCK *****/ +package org.jruby.runtime.builtin; + +public interface Variable { + + String getName(); + + BaseObjectType getValue(); + + boolean isInstanceVariable(); + + boolean isClassVariable(); + + boolean isConstant(); + + /** + * Returns true if the variable is an instance variable, class variable, or constant; + * otherwise, false. + * + * @return true if the variable is an instance variable, class variable, or constant, + * else false + */ + boolean isRubyVariable(); + +} diff --git a/src/org/jruby/runtime/component/VariableEntry.java b/src/org/jruby/runtime/component/VariableEntry.java index 0678bd68fba..f8192c060de 100644 --- a/src/org/jruby/runtime/component/VariableEntry.java +++ b/src/org/jruby/runtime/component/VariableEntry.java @@ -1,44 +1,44 @@ -package org.jruby.runtime.component; - -import org.jruby.runtime.builtin.Variable; -import org.jruby.util.IdUtil; - -public class VariableEntry implements Variable { - public final String name; - public final BaseObjectType value; - - public VariableEntry(String name, BaseObjectType value) { - this.name = name; - this.value = value; - } - - public String getName() { - return name; - } - - public BaseObjectType getValue() { - return value; - } - - public boolean isClassVariable() { - return IdUtil.isClassVariable(name); - } - - public boolean isConstant() { - return IdUtil.isConstant(name); - } - - public boolean isInstanceVariable() { - return IdUtil.isInstanceVariable(name); - } - - public boolean isRubyVariable() { - char c; - return name.length() > 0 && ((c = name.charAt(0)) == '@' || (c <= 'Z' && c >= 'A')); - } - - @Override - public String toString() { - return "Name: " + getName(); - } -} +package org.jruby.runtime.component; + +import org.jruby.runtime.builtin.Variable; +import org.jruby.util.IdUtil; + +public class VariableEntry implements Variable { + public final String name; + public final BaseObjectType value; + + public VariableEntry(String name, BaseObjectType value) { + this.name = name; + this.value = value; + } + + public String getName() { + return name; + } + + public BaseObjectType getValue() { + return value; + } + + public boolean isClassVariable() { + return IdUtil.isClassVariable(name); + } + + public boolean isConstant() { + return IdUtil.isConstant(name); + } + + public boolean isInstanceVariable() { + return IdUtil.isInstanceVariable(name); + } + + public boolean isRubyVariable() { + char c; + return name.length() > 0 && ((c = name.charAt(0)) == '@' || (c <= 'Z' && c >= 'A')); + } + + @Override + public String toString() { + return "Name: " + getName(); + } +} diff --git a/test/externals/ruby1.9/rexml/data/testsrc.xml b/test/externals/ruby1.9/rexml/data/testsrc.xml index 9c7a78212f2..e18ba20daef 100644 --- a/test/externals/ruby1.9/rexml/data/testsrc.xml +++ b/test/externals/ruby1.9/rexml/data/testsrc.xml @@ -1,64 +1,64 @@ - - - - - xmlhack - http://www.xmlhack.com - Developer news from the XML community - en-us - Copyright 1999-2001, xmlhack team. - editor@xmlhack.com - webmaster@xmlhack.com - - xmlhack - http://www.xmlhack.com/images/mynetscape88.gif - http://www.xmlhack.com - 88 - 31 - News, opinions, tips and issues concerning XML development - - -Experimental non-XML syntax for RELAX NG -http://www.xmlhack.com/read.php?item=1343 - - James Clark has announced the release of an experimental non-XML syntax for RELAX - NG and a Java translator implementation that converts - instances of the syntax into RELAX NG's XML syntax. - -Schemas - - -Long-awaited entity-resolver Java classes finally released -http://www.xmlhack.com/read.php?item=1342 -Norman Walsh has - announced the release of SAX entityResolver() and JAXP - URIResolver() Java - classes he wrote to implement the OASIS XML Catalogs - Committee Specification (in addition to the TR9401 and - Apache XCatalogs specifications). - -SGML/XML -Java - - - -Beepcore-C framework released -http://www.xmlhack.com/read.php?item=1341 -Invisible Worlds have announced the publication of Beepcore-C, an implementation of the BEEP framework written in C. -Protocols -C++ - - -SVG and XSL-FO by example -http://www.xmlhack.com/read.php?item=1340 -Jirka Jirat has announced the -addition of an XSL-FO and SVG examples repository to the Zvon developer -reference site. -SVG -XSL-FO - - - - - + + + + + xmlhack + http://www.xmlhack.com + Developer news from the XML community + en-us + Copyright 1999-2001, xmlhack team. + editor@xmlhack.com + webmaster@xmlhack.com + + xmlhack + http://www.xmlhack.com/images/mynetscape88.gif + http://www.xmlhack.com + 88 + 31 + News, opinions, tips and issues concerning XML development + + +Experimental non-XML syntax for RELAX NG +http://www.xmlhack.com/read.php?item=1343 + + James Clark has announced the release of an experimental non-XML syntax for RELAX + NG and a Java translator implementation that converts + instances of the syntax into RELAX NG's XML syntax. + +Schemas + + +Long-awaited entity-resolver Java classes finally released +http://www.xmlhack.com/read.php?item=1342 +Norman Walsh has + announced the release of SAX entityResolver() and JAXP + URIResolver() Java + classes he wrote to implement the OASIS XML Catalogs + Committee Specification (in addition to the TR9401 and + Apache XCatalogs specifications). + +SGML/XML +Java + + + +Beepcore-C framework released +http://www.xmlhack.com/read.php?item=1341 +Invisible Worlds have announced the publication of Beepcore-C, an implementation of the BEEP framework written in C. +Protocols +C++ + + +SVG and XSL-FO by example +http://www.xmlhack.com/read.php?item=1340 +Jirka Jirat has announced the +addition of an XSL-FO and SVG examples repository to the Zvon developer +reference site. +SVG +XSL-FO + + + + + diff --git a/test/externals/ruby1.9/rexml/data/ticket_61.xml b/test/externals/ruby1.9/rexml/data/ticket_61.xml index 4df1cc9b866..10ab7ebb4be 100644 --- a/test/externals/ruby1.9/rexml/data/ticket_61.xml +++ b/test/externals/ruby1.9/rexml/data/ticket_61.xml @@ -1,4 +1,4 @@ - - -



ListMatters

Open | Closed | All
Open Matters











- + + +



ListMatters

Open | Closed | All
Open Matters











+ diff --git a/test/org/jruby/javasupport/test/test_java_class_resource_methods.properties b/test/org/jruby/javasupport/test/test_java_class_resource_methods.properties index 5c7434f9ec7..f6ba564f51e 100644 --- a/test/org/jruby/javasupport/test/test_java_class_resource_methods.properties +++ b/test/org/jruby/javasupport/test/test_java_class_resource_methods.properties @@ -1,2 +1,2 @@ -foo=bar +foo=bar bool=true \ No newline at end of file diff --git a/test/test_block_arg_processing.rb b/test/test_block_arg_processing.rb index bbcbcb2339e..bad66d318fc 100644 --- a/test/test_block_arg_processing.rb +++ b/test/test_block_arg_processing.rb @@ -1,214 +1,214 @@ -require 'test/unit' - -class TestVarArgBlock < Test::Unit::TestCase - def blockyield(arg) - yield arg - end - - def blockarg(arg, &b) - b.call(arg) - end - - def test_vararg_blocks - Proc.new { |*element| assert_equal [["a"]], element }.call( ["a"] ) - Proc.new { |*element| assert_equal ["a"], element }.call( "a" ) - proc { |*element| assert_equal [["a"]], element }.call( ["a"] ) - proc { |*element| assert_equal ["a"], element }.call( "a" ) - lambda { |*element| assert_equal [["a"]], element }.call( ["a"] ) - lambda { |*element| assert_equal ["a"], element }.call( "a" ) - blockyield(["a"]) { |*element| assert_equal [["a"]], element } - blockyield("a") { |*element| assert_equal ["a"], element } - blockyield(["a"], &Proc.new { |*element| assert_equal [["a"]], element }) - blockyield("a", &Proc.new { |*element| assert_equal ["a"], element }) - blockyield(["a"], &proc { |*element| assert_equal [["a"]], element }) - blockyield("a", &proc { |*element| assert_equal ["a"], element }) - blockyield(["a"], &lambda { |*element| assert_equal [["a"]], element }) - blockyield("a", &lambda { |*element| assert_equal ["a"], element }) - blockarg(["a"]) { |*element| assert_equal [["a"]], element } - blockarg("a") { |*element| assert_equal ["a"], element } - blockarg(["a"], &Proc.new { |*element| assert_equal [["a"]], element }) - blockarg("a", &Proc.new { |*element| assert_equal ["a"], element }) - blockarg(["a"], &proc { |*element| assert_equal [["a"]], element }) - blockarg("a", &proc { |*element| assert_equal ["a"], element }) - blockarg(["a"], &lambda { |*element| assert_equal [["a"]], element }) - blockarg("a", &lambda { |*element| assert_equal ["a"], element }) - end - - def test_requiredarg_blocks - Proc.new { |element| assert_equal ["a"], element }.call( ["a"] ) - Proc.new { |element| assert_equal "a", element }.call( "a" ) - proc { |element| assert_equal ["a"], element }.call( ["a"] ) - proc { |element| assert_equal "a", element }.call( "a" ) - lambda { |element| assert_equal ["a"], element }.call( ["a"] ) - lambda { |element| assert_equal "a", element }.call( "a" ) - blockyield(["a"]) { |element| assert_equal ["a"], element } - blockyield("a") { |element| assert_equal "a", element } - blockyield(["a"], &Proc.new { |element| assert_equal ["a"], element }) - blockyield("a", &Proc.new { |element| assert_equal "a", element }) - blockyield(["a"], &proc { |element| assert_equal ["a"], element }) - blockyield("a", &proc { |element| assert_equal "a", element }) - blockyield(["a"], &lambda { |element| assert_equal ["a"], element }) - blockyield("a", &lambda { |element| assert_equal "a", element }) - blockarg(["a"]) { |element| assert_equal ["a"], element } - blockarg("a") { |element| assert_equal "a", element } - blockarg(["a"], &Proc.new { |element| assert_equal ["a"], element }) - blockarg("a", &Proc.new { |element| assert_equal "a", element }) - blockarg(["a"], &proc { |element| assert_equal ["a"], element }) - blockarg("a", &proc { |element| assert_equal "a", element }) - blockarg(["a"], &lambda { |element| assert_equal ["a"], element }) - blockarg("a", &lambda { |element| assert_equal "a", element }) - end - - def test_requiredargs_blocks - Proc.new { |element, a| assert_equal "a", element }.call( ["a"] ) - Proc.new { |element, a| assert_equal "a", element }.call( "a" ) - assert_raises(ArgumentError) { - proc { |element, a| assert_equal ["a"], element }.call( ["a"] ) - } - assert_raises(ArgumentError) { - proc { |element, a| assert_equal "a", element }.call( "a" ) - } - assert_raises(ArgumentError) { - lambda { |element, a| assert_equal ["a"], element }.call( ["a"] ) - } - assert_raises(ArgumentError) { - lambda { |element, a| assert_equal "a", element }.call( "a" ) - } - blockyield(["a"]) { |element, a| assert_equal "a", element } - blockyield("a") { |element, a| assert_equal "a", element } - blockyield(["a"], &Proc.new { |element, a| assert_equal "a", element }) - blockyield("a", &Proc.new { |element, a| assert_equal "a", element }) - blockyield(["a"], &proc { |element, a| assert_equal "a", element }) - blockyield("a", &proc { |element, a| assert_equal "a", element }) - blockyield(["a"], &lambda { |element, a| assert_equal "a", element }) - blockyield("a", &lambda { |element, a| assert_equal "a", element }) - blockarg(["a"]) { |element, a| assert_equal "a", element } - blockarg("a") { |element, a| assert_equal "a", element } - blockarg(["a"], &Proc.new { |element, a| assert_equal "a", element }) - blockarg("a", &Proc.new { |element, a| assert_equal "a", element }) - assert_raises(ArgumentError) { - blockarg(["a"], &proc { |element, a| assert_equal ["a"], element }) - } - assert_raises(ArgumentError) { - blockarg("a", &proc { |element, a| assert_equal "a", element }) - } - assert_raises(ArgumentError) { - blockarg(["a"], &lambda { |element, a| assert_equal ["a"], element }) - } - assert_raises(ArgumentError) { - blockarg("a", &lambda { |element, a| assert_equal "a", element }) - } - end - - def check_all_definemethods(obj) - results = obj.foo1 ["a"] - assert_equal(results[0], results[1]) - results = obj.foo2 "a" - assert_equal(results[0], results[1]) - results = obj.foo3 ["a"] - assert_equal(results[0], results[1]) - results = obj.foo4 "a" - assert_equal(results[0], results[1]) - results = obj.foo5 ["a"] - assert_equal(results[0], results[1]) - results = obj.foo6 "a" - assert_equal(results[0], results[1]) - results = obj.foo7 ["a"] - assert_equal(results[0], results[1]) - results = obj.foo8 "a" - assert_equal(results[0], results[1]) - results = obj.foo9 ["a"] - assert_equal(results[0], results[1]) - results = obj.foo10 "a" - assert_equal(results[0], results[1]) - results = obj.foo11 ["a"] - assert_equal(results[0], results[1]) - results = obj.foo12 "a" - assert_equal(results[0], results[1]) - results = obj.foo13 ["a"] - assert_equal(results[0], results[1]) - results = obj.foo14 "a" - assert_equal(results[0], results[1]) - end - - def check_requiredargs_definemethods(obj) - results = obj.foo1 ["a"] - assert_equal(results[0], results[1]) - results = obj.foo2 "a" - assert_equal(results[0], results[1]) - assert_raises(ArgumentError) { results = obj.foo3 ["a"] } - assert_raises(ArgumentError) { results = obj.foo4 "a" } - assert_raises(ArgumentError) { results = obj.foo5 ["a"] } - assert_raises(ArgumentError) { results = obj.foo6 "a" } - assert_raises(ArgumentError) { results = obj.foo7 ["a"] } - assert_raises(ArgumentError) { results = obj.foo8 "a" } - assert_raises(ArgumentError) { results = obj.foo9 ["a"] } - assert_raises(ArgumentError) { results = obj.foo10 "a" } - assert_raises(ArgumentError) { results = obj.foo11 ["a"] } - assert_raises(ArgumentError) { results = obj.foo12 "a" } - assert_raises(ArgumentError) { results = obj.foo13 ["a"] } - assert_raises(ArgumentError) { results = obj.foo14 "a" } - end - - def test_definemethods - obj = Object.new - - class << obj - define_method :foo1, Proc.new { |*element| [[["a"]], element] } - define_method :foo2, Proc.new { |*element| [["a"], element] } - define_method :foo3, proc { |*element| [[["a"]], element] } - define_method :foo4, proc { |*element| [["a"], element] } - define_method :foo5, lambda { |*element| [[["a"]], element] } - define_method :foo6, lambda { |*element| [["a"], element] } - define_method(:foo7) { |*element| [[["a"]], element] } - define_method(:foo8) { |*element| [["a"], element] } - define_method :foo9, &Proc.new { |*element| [[["a"]], element] } - define_method :foo10, &Proc.new { |*element| [["a"], element] } - define_method :foo11, &proc { |*element| [[["a"]], element] } - define_method :foo12, &proc { |*element| [["a"], element] } - define_method :foo13, &lambda { |*element| [[["a"]], element] } - define_method :foo14, &lambda { |*element| [["a"], element] } - end - - check_all_definemethods(obj) - - class << obj - define_method :foo1, Proc.new { |element| [["a"], element] } - define_method :foo2, Proc.new { |element| ["a", element] } - define_method :foo3, proc { |element| [["a"], element] } - define_method :foo4, proc { |element| ["a", element] } - define_method :foo5, lambda { |element| [["a"], element] } - define_method :foo6, lambda { |element| ["a", element] } - define_method(:foo7) { |element| [["a"], element] } - define_method(:foo8) { |element| ["a", element] } - define_method :foo9, &Proc.new { |element| [["a"], element] } - define_method :foo10, &Proc.new { |element| ["a", element] } - define_method :foo11, &proc { |element| [["a"], element] } - define_method :foo12, &proc { |element| ["a", element] } - define_method :foo13, &lambda { |element| [["a"], element] } - define_method :foo14, &lambda { |element| ["a", element] } - end - - check_all_definemethods(obj) - - class << obj - define_method :foo1, Proc.new { |element, a| ["a", element] } - define_method :foo2, Proc.new { |element, a| ["a", element] } - define_method :foo3, proc { |element, a| [["a"], element] } - define_method :foo4, proc { |element, a| ["a", element] } - define_method :foo5, lambda { |element, a| [["a"], element] } - define_method :foo6, lambda { |element, a| ["a", element] } - define_method(:foo7) { |element, a| [["a"], element] } - define_method(:foo8) { |element, a| ["a", element] } - define_method :foo9, &Proc.new { |element, a| [["a"], element] } - define_method :foo10, &Proc.new { |element, a| ["a", element] } - define_method :foo11, &proc { |element, a| [["a"], element] } - define_method :foo12, &proc { |element, a| ["a", element] } - define_method :foo13, &lambda { |element, a| [["a"], element] } - define_method :foo14, &lambda { |element, a| ["a", element] } - end - - check_requiredargs_definemethods(obj) - end -end - +require 'test/unit' + +class TestVarArgBlock < Test::Unit::TestCase + def blockyield(arg) + yield arg + end + + def blockarg(arg, &b) + b.call(arg) + end + + def test_vararg_blocks + Proc.new { |*element| assert_equal [["a"]], element }.call( ["a"] ) + Proc.new { |*element| assert_equal ["a"], element }.call( "a" ) + proc { |*element| assert_equal [["a"]], element }.call( ["a"] ) + proc { |*element| assert_equal ["a"], element }.call( "a" ) + lambda { |*element| assert_equal [["a"]], element }.call( ["a"] ) + lambda { |*element| assert_equal ["a"], element }.call( "a" ) + blockyield(["a"]) { |*element| assert_equal [["a"]], element } + blockyield("a") { |*element| assert_equal ["a"], element } + blockyield(["a"], &Proc.new { |*element| assert_equal [["a"]], element }) + blockyield("a", &Proc.new { |*element| assert_equal ["a"], element }) + blockyield(["a"], &proc { |*element| assert_equal [["a"]], element }) + blockyield("a", &proc { |*element| assert_equal ["a"], element }) + blockyield(["a"], &lambda { |*element| assert_equal [["a"]], element }) + blockyield("a", &lambda { |*element| assert_equal ["a"], element }) + blockarg(["a"]) { |*element| assert_equal [["a"]], element } + blockarg("a") { |*element| assert_equal ["a"], element } + blockarg(["a"], &Proc.new { |*element| assert_equal [["a"]], element }) + blockarg("a", &Proc.new { |*element| assert_equal ["a"], element }) + blockarg(["a"], &proc { |*element| assert_equal [["a"]], element }) + blockarg("a", &proc { |*element| assert_equal ["a"], element }) + blockarg(["a"], &lambda { |*element| assert_equal [["a"]], element }) + blockarg("a", &lambda { |*element| assert_equal ["a"], element }) + end + + def test_requiredarg_blocks + Proc.new { |element| assert_equal ["a"], element }.call( ["a"] ) + Proc.new { |element| assert_equal "a", element }.call( "a" ) + proc { |element| assert_equal ["a"], element }.call( ["a"] ) + proc { |element| assert_equal "a", element }.call( "a" ) + lambda { |element| assert_equal ["a"], element }.call( ["a"] ) + lambda { |element| assert_equal "a", element }.call( "a" ) + blockyield(["a"]) { |element| assert_equal ["a"], element } + blockyield("a") { |element| assert_equal "a", element } + blockyield(["a"], &Proc.new { |element| assert_equal ["a"], element }) + blockyield("a", &Proc.new { |element| assert_equal "a", element }) + blockyield(["a"], &proc { |element| assert_equal ["a"], element }) + blockyield("a", &proc { |element| assert_equal "a", element }) + blockyield(["a"], &lambda { |element| assert_equal ["a"], element }) + blockyield("a", &lambda { |element| assert_equal "a", element }) + blockarg(["a"]) { |element| assert_equal ["a"], element } + blockarg("a") { |element| assert_equal "a", element } + blockarg(["a"], &Proc.new { |element| assert_equal ["a"], element }) + blockarg("a", &Proc.new { |element| assert_equal "a", element }) + blockarg(["a"], &proc { |element| assert_equal ["a"], element }) + blockarg("a", &proc { |element| assert_equal "a", element }) + blockarg(["a"], &lambda { |element| assert_equal ["a"], element }) + blockarg("a", &lambda { |element| assert_equal "a", element }) + end + + def test_requiredargs_blocks + Proc.new { |element, a| assert_equal "a", element }.call( ["a"] ) + Proc.new { |element, a| assert_equal "a", element }.call( "a" ) + assert_raises(ArgumentError) { + proc { |element, a| assert_equal ["a"], element }.call( ["a"] ) + } + assert_raises(ArgumentError) { + proc { |element, a| assert_equal "a", element }.call( "a" ) + } + assert_raises(ArgumentError) { + lambda { |element, a| assert_equal ["a"], element }.call( ["a"] ) + } + assert_raises(ArgumentError) { + lambda { |element, a| assert_equal "a", element }.call( "a" ) + } + blockyield(["a"]) { |element, a| assert_equal "a", element } + blockyield("a") { |element, a| assert_equal "a", element } + blockyield(["a"], &Proc.new { |element, a| assert_equal "a", element }) + blockyield("a", &Proc.new { |element, a| assert_equal "a", element }) + blockyield(["a"], &proc { |element, a| assert_equal "a", element }) + blockyield("a", &proc { |element, a| assert_equal "a", element }) + blockyield(["a"], &lambda { |element, a| assert_equal "a", element }) + blockyield("a", &lambda { |element, a| assert_equal "a", element }) + blockarg(["a"]) { |element, a| assert_equal "a", element } + blockarg("a") { |element, a| assert_equal "a", element } + blockarg(["a"], &Proc.new { |element, a| assert_equal "a", element }) + blockarg("a", &Proc.new { |element, a| assert_equal "a", element }) + assert_raises(ArgumentError) { + blockarg(["a"], &proc { |element, a| assert_equal ["a"], element }) + } + assert_raises(ArgumentError) { + blockarg("a", &proc { |element, a| assert_equal "a", element }) + } + assert_raises(ArgumentError) { + blockarg(["a"], &lambda { |element, a| assert_equal ["a"], element }) + } + assert_raises(ArgumentError) { + blockarg("a", &lambda { |element, a| assert_equal "a", element }) + } + end + + def check_all_definemethods(obj) + results = obj.foo1 ["a"] + assert_equal(results[0], results[1]) + results = obj.foo2 "a" + assert_equal(results[0], results[1]) + results = obj.foo3 ["a"] + assert_equal(results[0], results[1]) + results = obj.foo4 "a" + assert_equal(results[0], results[1]) + results = obj.foo5 ["a"] + assert_equal(results[0], results[1]) + results = obj.foo6 "a" + assert_equal(results[0], results[1]) + results = obj.foo7 ["a"] + assert_equal(results[0], results[1]) + results = obj.foo8 "a" + assert_equal(results[0], results[1]) + results = obj.foo9 ["a"] + assert_equal(results[0], results[1]) + results = obj.foo10 "a" + assert_equal(results[0], results[1]) + results = obj.foo11 ["a"] + assert_equal(results[0], results[1]) + results = obj.foo12 "a" + assert_equal(results[0], results[1]) + results = obj.foo13 ["a"] + assert_equal(results[0], results[1]) + results = obj.foo14 "a" + assert_equal(results[0], results[1]) + end + + def check_requiredargs_definemethods(obj) + results = obj.foo1 ["a"] + assert_equal(results[0], results[1]) + results = obj.foo2 "a" + assert_equal(results[0], results[1]) + assert_raises(ArgumentError) { results = obj.foo3 ["a"] } + assert_raises(ArgumentError) { results = obj.foo4 "a" } + assert_raises(ArgumentError) { results = obj.foo5 ["a"] } + assert_raises(ArgumentError) { results = obj.foo6 "a" } + assert_raises(ArgumentError) { results = obj.foo7 ["a"] } + assert_raises(ArgumentError) { results = obj.foo8 "a" } + assert_raises(ArgumentError) { results = obj.foo9 ["a"] } + assert_raises(ArgumentError) { results = obj.foo10 "a" } + assert_raises(ArgumentError) { results = obj.foo11 ["a"] } + assert_raises(ArgumentError) { results = obj.foo12 "a" } + assert_raises(ArgumentError) { results = obj.foo13 ["a"] } + assert_raises(ArgumentError) { results = obj.foo14 "a" } + end + + def test_definemethods + obj = Object.new + + class << obj + define_method :foo1, Proc.new { |*element| [[["a"]], element] } + define_method :foo2, Proc.new { |*element| [["a"], element] } + define_method :foo3, proc { |*element| [[["a"]], element] } + define_method :foo4, proc { |*element| [["a"], element] } + define_method :foo5, lambda { |*element| [[["a"]], element] } + define_method :foo6, lambda { |*element| [["a"], element] } + define_method(:foo7) { |*element| [[["a"]], element] } + define_method(:foo8) { |*element| [["a"], element] } + define_method :foo9, &Proc.new { |*element| [[["a"]], element] } + define_method :foo10, &Proc.new { |*element| [["a"], element] } + define_method :foo11, &proc { |*element| [[["a"]], element] } + define_method :foo12, &proc { |*element| [["a"], element] } + define_method :foo13, &lambda { |*element| [[["a"]], element] } + define_method :foo14, &lambda { |*element| [["a"], element] } + end + + check_all_definemethods(obj) + + class << obj + define_method :foo1, Proc.new { |element| [["a"], element] } + define_method :foo2, Proc.new { |element| ["a", element] } + define_method :foo3, proc { |element| [["a"], element] } + define_method :foo4, proc { |element| ["a", element] } + define_method :foo5, lambda { |element| [["a"], element] } + define_method :foo6, lambda { |element| ["a", element] } + define_method(:foo7) { |element| [["a"], element] } + define_method(:foo8) { |element| ["a", element] } + define_method :foo9, &Proc.new { |element| [["a"], element] } + define_method :foo10, &Proc.new { |element| ["a", element] } + define_method :foo11, &proc { |element| [["a"], element] } + define_method :foo12, &proc { |element| ["a", element] } + define_method :foo13, &lambda { |element| [["a"], element] } + define_method :foo14, &lambda { |element| ["a", element] } + end + + check_all_definemethods(obj) + + class << obj + define_method :foo1, Proc.new { |element, a| ["a", element] } + define_method :foo2, Proc.new { |element, a| ["a", element] } + define_method :foo3, proc { |element, a| [["a"], element] } + define_method :foo4, proc { |element, a| ["a", element] } + define_method :foo5, lambda { |element, a| [["a"], element] } + define_method :foo6, lambda { |element, a| ["a", element] } + define_method(:foo7) { |element, a| [["a"], element] } + define_method(:foo8) { |element, a| ["a", element] } + define_method :foo9, &Proc.new { |element, a| [["a"], element] } + define_method :foo10, &Proc.new { |element, a| ["a", element] } + define_method :foo11, &proc { |element, a| [["a"], element] } + define_method :foo12, &proc { |element, a| ["a", element] } + define_method :foo13, &lambda { |element, a| [["a"], element] } + define_method :foo14, &lambda { |element, a| ["a", element] } + end + + check_requiredargs_definemethods(obj) + end +end + diff --git a/test/test_integer_overflows.rb b/test/test_integer_overflows.rb index 2ef5c60a188..7ee57d71e28 100755 --- a/test/test_integer_overflows.rb +++ b/test/test_integer_overflows.rb @@ -1,668 +1,668 @@ - -# Tests to (a) show issues/bugs, and (b) test patches for these, for jira.codehaus.org. -# In the following: IntMin = -9223372036854775808, which is (-2)**(64 - 1). -# #JRUBY-6612: some problems with JRuby seeming to not detect Java Long arithmetic overflows -# # IntMin * -1 #=> 9223372036854775808; -# # -1 * IntMin #=> -9223372036854775808; -# In the second example JRuby was not detecting the integer overflow. -# The first patch for this fixed the problem in jruby-1.7.0.preview1, -# but created a much less serious problem: -# # IntMin * 1 #=> -9223372036854775808 Fixnum; -# # 1 * IntMin #=> -9223372036854775808 Bignum; -# This problem is fixed in jruby-1.7.0.preview2. -# #JRUBY-6777: RubyFixnum.java - two methods assert false, to detect some long integer overflows -# # IntMin / -1: -9223372036854775808; -# # IntMin.divmod(-1): [-9223372036854775808, 0]; -# Fixed in jruby-1.7.0.preview2. -# #JRUBY-6778: Possible long integer overflow bug in Integer#succ in RubyInteger.java -# # 9223372036854775807.succ #=> -9223372036854775808; -# Fixed in jruby-1.7.0.preview2. - -# VVT.logfile = "path/smalltest-jruby-.txt" -require 'test/unit' - -class VVT < Test::Unit::TestCase - BIT_SIZES = [ 30, 31, 32, 33, 62, 63, 64, 65 ] - - def test_integer_overflows - BIT_SIZES.each do |nbits| - checks_for_integer_overflow(nbits) - end - - end - - def test_integer_iteration_for_overflows - BIT_SIZES.each do |nbits| - checks_for_integer_iteration_overflows(nbits) - end - - end - - def checks_for_integer_overflow(nbits) - reset_subcounts() - return unless nbits >= 6 - nbits_int_min = n_bits_integer_min(nbits) - nbits_int_max = n_bits_integer_max(nbits) - - # (1) Test for whether integer addition and negation seems OK, - # because we need these to be reliable for the remaining tests. - check_integer_add_overflow(nbits_int_max, 1) - check_integer_add_overflow(nbits_int_min, -1) - check_integer_negate_overflow(nbits_int_max) - check_integer_negate_overflow(nbits_int_min) - return if sub_notOK?() # stop here if any of the above tests are failed - - # (2) Test for non-iteration integer overflows. - # The problems for JRuby-1.6.7.2, JRuby-1.7.0.preview1 - # seem to be fixed by patches used in JRuby-1.7.0.preview2. - - # In the following: IntMin = -9223372036854775808, which is -(2**(64 - 1)); - # IntMax = 9223372036854775807, which is 2**(64 - 1) - 1. - - check_integer_succ(nbits_int_max - 1) - #* next line:[JRUBY-6778]: integer overflow: JRuby-1.6.7.2, JRuby-1.7.0.preview1; - # 9223372036854775807.succ #=> -9223372036854775808; - # IntMax.succ #=> IntMin; - check_integer_succ(nbits_int_max) # [JRUBY-6778] - check_integer_succ(nbits_int_max + 1) - - check_integer_multiply_by_0_or_1_or_minus_1(nbits_int_min, 0) # OK - check_integer_multiply_by_0_or_1_or_minus_1(0, nbits_int_min) # OK - check_integer_multiply_by_0_or_1_or_minus_1(nbits_int_min, -1) # OK - #* next line:[JRUBY-6612]: integer overflow: JRuby-1.6.7.2; - # -1 * -9223372036854775808 #=> -9223372036854775808; - # -1 * IntMin #=> IntMin; - # patch for this corrected this bug but created new bug just below - check_integer_multiply_by_0_or_1_or_minus_1(-1, nbits_int_min) # [JRUBY-6612] - #* next line: incorrect class of result: JRuby-1.7.0.preview1; - # patch for [JRUBY-6612] corrected that bug but created this new less serious bug: - # 1 * -9223372036854775808 #=> -9223372036854775808 Bignum; - # 1 * IntMin #=> -9223372036854775808 Bignum; should be Fixnum IntMin - check_integer_multiply_by_0_or_1_or_minus_1( 1, nbits_int_min) # OK in preview2 - check_integer_multiply_by_0_or_1_or_minus_1(nbits_int_min, 1) # OK - - check_integer_divide_by_1_or_minus_1(nbits_int_min, 1) - check_integer_divmod_by_1_or_minus_1(nbits_int_min, 1) - #* next line:[JRUBY-6777]: integer overflow: JRuby-1.6.7.2, JRuby-1.7.0.preview1; - # -9223372036854775808 / -1 #=> -9223372036854775808; - # IntMin / -1 #=> IntMin; - check_integer_divide_by_1_or_minus_1(nbits_int_min, -1) # [JRUBY-6777] - #* next line:[JRUBY-6777]: integer overflow: JRuby-1.6.7.2, JRuby-1.7.0.preview1; - # -9223372036854775808.divmod(-1) #=> [-9223372036854775808, 0]; - # IntMin.divmod(-1) #=> [IntMin, 0]; - check_integer_divmod_by_1_or_minus_1(nbits_int_min, -1) # [JRUBY-6777] - end - - def check_integer_add_overflow(av, bv) - reset_actual_expected_etc() - return unless av.kind_of?(Integer) && bv.kind_of?(Integer) - @expected = vv = vvs = vvv = nil - if av == 0 && bv == 0 then @expected = 0 - elsif av == 0 then @expected = bv - elsif bv == 0 then @expected = av - elsif av == 1 then vv = vvs = 1; vvv = bv - elsif av == -1 then vv = vvs = -1; vvv = bv - elsif bv == 1 then vv = vvs = 1; vvv = av - elsif bv == -1 then vv = vvs = -1; vvv = av - elsif bv > 0 then vv = bv; vvs = 1; vvv = av - elsif bv < 0 then vv = bv; vvs = -1; vvv = av - else return - end - unless @expected then - begin - @expected = vv + vvv - qok = (if vvs == 1 then @expected > vvv else @expected < vvv end) - qok &&= (-vv + @expected) == vvv - @expected = inzpect(@expected) + "_???" unless qok - rescue - @expected = "???_" + inzpect($!) + "_???" - end - end - @text = "#{inzpect(av)} + #{inzpect(bv)}" - begin - @actual = av + bv - rescue - @exception = $! - end - process_test_result() - end - - def check_integer_succ(nv) - reset_actual_expected_etc() - @text = "#{inzpect(nv)}.succ" - begin - @expected = 1 + nv - qok = @expected > nv - qok &&= (-1 + @expected) == nv - @expected = inzpect(@expected) + "_???" unless qok - rescue - @expected = "???_" + inzpect($!) + "_???" - end - begin - @actual = nv.succ - rescue - @exception = $! - end - process_test_result() - end - - def check_integer_negate_overflow(nv) - reset_actual_expected_etc() - return unless nv.kind_of?(Integer) - @text = "negate #{inzpect(nv)}" - begin - # This gets the expected value of negate by using subtract, - # which may be a problem if "a subtract b" is implemented as "a plus negate b", - # or if "negate n" is implemented as "0 subtract n". - @expected = 0 - nv - negexp = 0 - @expected - qok = negexp == nv && negexp.class == nv.class && - if nv > 0 then @expected < 0 && @expected.class == nv.class - elsif nv < 0 then @expected > 0 && (-1 + @expected).class == nv.class - else @expected.zero? && nv.zero? && - @expected == nv && @expected.class == nv.class - end - @expected = inzpect(@expected) + "_???" unless qok - rescue - @expected = "???_" + inzpect($!) + "_???" - end - begin - @actual = -nv - rescue - @exception = $! - end - process_test_result() - end - - def check_integer_multiply_by_0_or_1_or_minus_1(av, bv) - reset_actual_expected_etc() - return unless av.kind_of?(Integer) && bv.kind_of?(Integer) - @expected = if av == 0 || bv == 0 then 0 - elsif av == 1 then bv - elsif bv == 1 then av - elsif av == -1 then - if bv < 0 then -(bv + 1) + 1 else -bv end - elsif bv == -1 then - if bv < 0 then -(av + 1) + 1 else -av end - else nil - end - return unless @expected - @text = "#{inzpect(av)} * #{inzpect(bv)}" - begin - @actual = av * bv - rescue - @exception = $! - end - process_test_result() - end - - def check_integer_divide_by_1_or_minus_1(av, bv) - return unless av.kind_of?(Integer) && bv.kind_of?(Integer) - reset_actual_expected_etc() - @expected = if bv == 1 then av - elsif bv == -1 then -(av + 1) + 1 - else nil - end - return unless @expected - @text = "#{inzpect(av)} / #{inzpect(bv)}" - begin - @actual = av / bv - rescue - @exception = $! - end - process_test_result() - end - - def check_integer_divmod_by_1_or_minus_1(av, bv) - return unless av.kind_of?(Integer) && bv.kind_of?(Integer) - reset_actual_expected_etc() - @expected = if bv == 1 then [av, 0] - elsif bv == -1 then [-(av + 1) + 1, 0] - else nil - end - return unless @expected - @text = "#{inzpect(av)}.divmod(#{inzpect(bv)})" - begin - @actual = av.divmod(bv) - rescue - @exception = $! - end - process_test_result() - end - - def checks_for_integer_iteration_overflows(nbits) - # This mainly tests for incorrect detection of integer overflow in integer iterations. - reset_subcounts() - return unless nbits >= 6 - nbits_int_min = n_bits_integer_min(nbits) - nbits_int_max = n_bits_integer_max(nbits) - - # (1) Test if integer iteration seems OK for some "likely" integer overflows. - # The idea is to "assert false, quickly" if there are "likely" integer overflows. - - #* next lines seem OK in: JRuby-1.6.7.2, JRuby-1.7.0.preview1; - # next line was in [JRUBY-6779] as an example of Range#each working as expected - check_integer_range_each(nbits_int_max - 1...nbits_int_max) # [JRUBY-6779] OK in JRuby-1.6, etc - check_range_step(nbits_int_max - 1...nbits_int_max, 1) - check_range_step(nbits_int_max...nbits_int_max + 1, 1) - - #* next lines: integer overflow: JRuby-1.6.7.2, JRuby-1.7.0.preview1; - - # next three lines are OK in JRuby-1.7.0.preview2 because of [JRUBY-6778] #succ patch - check_integer_range_each(nbits_int_max.. nbits_int_max + 1) # [JRUBY-6779] OK in preview2 - check_integer_range_each(nbits_int_max...nbits_int_max + 1) # [JRUBY-6779] OK in preview2 - check_integer_range_each(nbits_int_max...nbits_int_max + 1) - # but the next two lines seem still notOK in JRuby-1.7.0.preview2 - check_integer_range_each(nbits_int_max ..nbits_int_max) # [JRUBY-6779] - check_integer_range_each(nbits_int_max - 1..nbits_int_max) # [JRUBY-6779] - - check_integer_downto(nbits_int_min, nbits_int_min) - check_integer_upto(nbits_int_max, nbits_int_max) - - check_numeric_step(nbits_int_max - 1, nbits_int_max - 1, 2) # [JRUBY-6790] - check_numeric_step(nbits_int_max, nbits_int_max, 1) # [JRUBY-6790] - check_numeric_step(nbits_int_min, nbits_int_min, -1) - - check_range_step(nbits_int_max..nbits_int_max, 1) - check_range_step(nbits_int_max - 1..nbits_int_max, 2) - check_range_step(nbits_int_max - 1..nbits_int_max - 1, 2) - check_range_step(nbits_int_max - 1...nbits_int_max, 2) - - #* next lines test for plausible but incorrect detection of iteration integer overflow - #* next lines: integer overflow: JRuby-1.6.7.2, JRuby-1.7.0.preview1; - check_numeric_step(nbits_int_min + 1, nbits_int_max - 1, nbits_int_max - 2) - check_numeric_step(nbits_int_max - 1, nbits_int_min + 1, nbits_int_min + 3) - check_range_step(nbits_int_min + 1..nbits_int_max - 1, nbits_int_max - 2) - check_range_step(nbits_int_min + 1...nbits_int_max, nbits_int_max - 2) - - return if sub_notOK?() # stop here if any of the above tests are failed - - # If there aren't any "likely" integer overflows then do many more tests, - # hoping to detect any "unlikely" integer overflows. - - nn0 = nbits_int_max - 7 - nn2 = nbits_int_max + 7 - nn = nn0 - 1 - while (nn += 1) <= nn2 do - nnn = nn0 - 1 - while (nnn += 1) <= nn2 do - check_integer_downto(nn, nnn) - check_integer_upto(nn, nnn) - check_integer_range_each(nn..nnn) - check_integer_range_each(nn...nnn) - - check_numeric_step(nn, nnn, 1) - check_numeric_step(nn, nnn, 2) - - check_range_step(nn..nnn, 1) - check_range_step(nn...nnn, 1) - check_range_step(nn..nnn, 2) - check_range_step(nn...nnn, 2) - end - end - end - - # individual tests - - def check_integer_downto(fromv, tov) - @text = inzpect(fromv) + ".downto(" + inzpect(tov) + ")" - set_numeric_expected_iterations(fromv, tov, -1, false, false) - @expected = fromv - @iterations = [] - begin - @actual = fromv.downto(tov) do |iv| - @iterations << iv - break if @iterations.size >= @max_num_iterations - end - rescue - @exception = $! - end - process_test_result() - end - - def check_integer_upto(fromv, tov) - @text = inzpect(fromv) + ".upto(" + inzpect(tov) + ")" - set_numeric_expected_iterations(fromv, tov, 1, false, false) - @expected = fromv - @iterations = [] - begin - @actual = fromv.upto(tov) do |iv| - @iterations << iv - break if @iterations.size >= @max_num_iterations - end - rescue - @exception = $! - end - process_test_result() - end - - def check_integer_range_each(rangev) - @text = "(" + inzpect(rangev) + ").each" - set_numeric_expected_iterations(rangev.begin, rangev.end, 1, false, rangev.exclude_end?) - @expected = rangev - @iterations = [] - begin - @actual = rangev.each do |iv| - @iterations << iv - break if @iterations.size >= @max_num_iterations - end - rescue - @exception = $! - end - process_test_result() - end - - def check_numeric_step(fromv, tov, stepv) - @text = inzpect(fromv) + ".step(" + inzpect(tov) + ", " + inzpect(stepv) + ")" - efromv = fromv; etov = tov; estepv = stepv - if efromv.kind_of?(Float) || etov.kind_of?(Float) || estepv.kind_of?(Float) then - efromv = efromv.to_f; etov = etov.to_f; estepv = estepv.to_f - end - set_numeric_expected_iterations(efromv, etov, estepv, false, false) - @expected = fromv - if @expected_exception then - @expected_exception = ArgumentError.exception("step can't be 0") - @expected_iterations = [] - @expected = nil - end - @iterations = [] - begin - @actual = fromv.step(tov, stepv) do |iv| - @iterations << iv - break if @iterations.size >= @max_num_iterations - end - rescue - @exception = $! - end - process_test_result() - end - - def check_range_step(rangev, stepv) - @text = "(" + inzpect(rangev) + ").step(" + inzpect(stepv) + ")" - efromv = rangev.begin; etov = rangev.end; estepv = stepv - if efromv.kind_of?(Float) || etov.kind_of?(Float) || estepv.kind_of?(Float) then - efromv = efromv.to_f; etov = etov.to_f; estepv = estepv.to_f - end - set_numeric_expected_iterations(efromv, etov, estepv, false, rangev.exclude_end?) - @expected = rangev - if @expected_exception || stepv < 0 then - @expected_exception = if stepv < 0 then - ArgumentError.exception("step can't be negative") - else - ArgumentError.exception("step can't be 0") - end - @expected_iterations = [] - @expected = nil - end - @iterations = [] - begin - @actual = rangev.step(stepv) do |iv| - @iterations << iv - break if @iterations.size >= @max_num_iterations - end - rescue - @exception = $! - end - process_test_result() - end - - ############################# - # Test support methods follow - ############################# - def ruby_run_info_const(symv, altv = nil) - if Module.const_defined?(symv) then - Module.const_get(symv) - else - altv - end - end - - DEFAULT_RECUR_MAX_DEPTH = 3 - - IS_JRUBY = !! RUBY_PLATFORM.to_s.downcase.index("java") - def JRuby?() - IS_JRUBY - end - - Infinity = 1.0 / 0.0 - - # Min and max values of N-bit signed integers are - # used for tests that integer overflow detection is working. - # 31-bit signed integers: MRI Ruby Fixnum; - # 32-bit signed integers: Java int, C long, etc; - # 63-bit signed integers: MRI Ruby Fixnum; - # 64-bit signed integers: Java long, JRuby Ruby Fixnum; - def n_bits_integer_min(nbits) - return nil if nbits < 1 - # Calculate -(2**(nbits - 1)) using only addition - # to avoid relying on powers (or multiply) being correctly implemented. - # This may be slow but that should not matter for the types of tests that - # this is intended for. (You can "cache" values if speed is a problem.) - min_intv = -1 # starting min value, for a 1_bit signed integer - nbitsi = 0 - while (nbitsi += 1) < nbits do - prev_min_intv = min_intv - unless (min_intv += min_intv) < prev_min_intv then - raise "ERROR overflow calculating -(2**(nbits - 1)) for nbits=#{nbits}" - end - end - return min_intv - end - # - def n_bits_integer_max(nbits) - (minv = n_bits_integer_min(nbits)) && -(minv + 1) - end - - def Rational_loaded?() - return defined?(Rational) - end - - attr_accessor :exclude_tests_level, :normal_tests_level - - def setup() - # initialize test result counts and test controls - @numOK = @numNotOK = @numExceptions = 0 - reset_subcounts() - reset_actual_expected_etc() - @logfile = nil - @exclude_tests_level = nil # controls excluding some tests - @normal_tests_level = 8 - @recur_max_depth = DEFAULT_RECUR_MAX_DEPTH # max depth for #not_equal? - # next instance variable allows you to limit the number of iterations in a test - # in case the actual number of iterations is much larger than expected (or infinite) - @max_num_iterations = nil - # next instance variable is the allowed margin of the actual number of iterations - # over the expected number of iterations - @max_num_iterations_margin = 2 - end - - def reset_actual_expected_etc() - @actual = @iterations = @exception = nil - @expected = @expected_iterations = @expected_exception = nil - @max_num_iterations = nil - end - - def reset_subcounts() - @sub_numOK = @sub_numNotOK = @sub_numExceptions = 0 - end - - def sub_notOK?() - (@sub_numNotOK && @sub_numNotOK != 0) || - (@sub_numExceptions && @sub_numExceptions != 0) - end - - def not_equal?(actualv, expectedv, recur_max_depthv = nil) - return true if actualv.class != expectedv.class - recur_max_depthv ||= @recur_max_depth || DEFAULT_RECUR_MAX_DEPTH - recur_max_depthv -= 1 - case actualv - when Exception then - return actualv.to_s != expectedv.to_s # focus equality on the exception message - when Array then - if recur_max_depthv >= 0 then - ii2 = if actualv.size < expectedv.size then actualv.size else expectedv.size end - iii = vvv = nil - ii = -1 - while (ii += 1) < ii2 do - if (vvv = not_equal?(actualv[ii], expectedv[ii], recur_max_depthv)) then - iii = ii - break - end - end - if iii || actualv.size != expectedv.size then - vvv = [] unless vvv.kind_of?(Array) - vvv << (iii || ii2) - return vvv - end - end - end - return ! (actualv == expectedv) # use normal equality checking - end - - def inzpect(valuev, recur_max_depthv = nil, - first_diff_indexes = nil, first_diff_indexv = nil) - # Similar to "inspect" but has different options for showing arrays. - # And for Bignum values shows class as well as value: for example: -123456789_big; - # the reason for this is that it is possible that a numeric value is correct - # but that the expected value is Fixnum and the actual value is Bignum, - # and we want the output to be clear about the type of value. - recur_max_depthv ||= @recur_max_depth || DEFAULT_RECUR_MAX_DEPTH - recur_max_depthv -= 1 - case valuev - when Array then - if recur_max_depthv >= 0 then - if first_diff_indexes.kind_of?(Array) then - first_diff_indexv ||= first_diff_indexes.size - first_diff_indexv -= 1 - else - first_diff_indexv = nil - end - resultv = "[" - if valuev.size > 0 then - iidiff_indexv = if first_diff_indexes.kind_of?(Array) then - first_diff_indexes[first_diff_indexv] - else - -1 - end - iidiff_indexv = -1 if iidiff_indexv >= valuev.size - ii = 0 - if ii == iidiff_indexv then - iidiff_indexv = -1 - fdixs = first_diff_indexes - fdixv = first_diff_indexv - else - fdixs = fdixv = nil - end - resultv << inzpect(valuev[ii], recur_max_depthv, fdixs, fdixv) - if valuev.size > 1 then - prev_ii = ii - if prev_ii < iidiff_indexv then - if prev_ii < (ii = iidiff_indexv - 1) then - resultv << (if prev_ii + 1 == ii then ", " else ",...@#{ii}:" end) << - inzpect(valuev[ii], recur_max_depthv, nil, nil) - prev_ii = ii - end - ii = iidiff_indexv - iidiff_indexv = -1 - resultv << (if prev_ii + 1 == ii then ", " else ",...@#{ii}:" end) << - inzpect(valuev[ii], recur_max_depthv, - first_diff_indexes, first_diff_indexv) - prev_ii = ii - end - if prev_ii < (ii = valuev.size - 1) then - resultv << (if prev_ii + 1 == ii then ", " else ",...@#{ii}:" end) << - inzpect(valuev[ii], recur_max_depthv, nil, nil) - end - end - end - resultv << "]" - return resultv - end - when Range then - # Note recursive calls in next line!!! - return inzpect(valuev.begin) << - (if valuev.exclude_end? then "..." else ".." end) << - inzpect(valuev.end) - when Exception then - return valuev.class.name + ":" << valuev.to_s.inspect - when Bignum then - return valuev.inspect << "_big" - when Fixnum, Float, NilClass, TrueClass, FalseClass then - return valuev.inspect - else - unless Rational_loaded? && valuev.class == Rational then - return valuev.class.name + ":v:" << valuev.inspect - end - end - valuev.inspect - end - - def process_test_result() - # For readability in making tests, this method relies on instance variables being set. - # It calls "process_test_result_private" which (mostly) does not use instance variables. - process_test_result_private(@actual, @expected, - @iterations, @expected_iterations, - @exception, @expected_exception, - @text) - end - - def process_test_result_private(actual_resultv, expected_resultv, - actual_iterationsv, expected_iterationsv, - actual_exceptionv, expected_exceptionv, - test_textv = nil) - if expected_resultv.kind_of?(Exception) && expected_exceptionv.nil? then - expected_exceptionv = expected_resultv - expected_resultv = nil - end - - msgv = test_textv << " #=>" - msgv << " != " << inzpect(expected_resultv, nil, not_equal?(actual_iterationsv, expected_iterationsv), nil) - assert_equal(actual_resultv, expected_resultv, msgv) - - msgv = test_textv << " #=>" - msgv << " != " << inzpect(expected_iterationsv, nil, not_equal?(actual_resultv, expected_resultv), nil) - assert_equal(actual_iterationsv, expected_iterationsv, msgv) - - msgv = test_textv << " #=>" - msgv << " != " << inzpect(expected_exceptionv, nil, not_equal?(actual_exceptionv, expected_exceptionv), nil) - assert_equal(actual_exceptionv, expected_exceptionv, msgv) - end - - def set_numeric_expected_iterations(fromv, tov, stepv, exclude_fromv, exclude_tov) - # set up expected numeric iterated values - reset_actual_expected_etc() - if stepv == 0 then - @expected_exception = true - return - end - @expected_iterations = [] # store expected iterated values in an array - # next line sets the appropriate check for the end of the iteration - symv = if stepv > 0 then - if exclude_tov then :< else :<= end - else - if exclude_tov then :> else :>= end - end - itvalue = fromv - num_steps = 0 # count the steps from fromv: needed for Float (etc) iterations - if exclude_fromv then - # Depending on the type of iteration, this might need to be changed - # if stepv is a very small Float or BigDecimal, etc. - itvalue += stepv - num_steps += 1 - end - while itvalue.__send__(symv, tov) do - @expected_iterations << itvalue - num_steps += 1 # needed for Float (etc) iterations - if itvalue.kind_of?(Float) || - (defined?(BigDecimal) && itvalue.kind_of?(BigDecimal)) then - itvalue = fromv + stepv * num_steps - else - itvalue += stepv - end - end - # next line anticipates unexpected infinite or very large loops in tests of iterators - @max_num_iterations = @expected_iterations.size + (@max_num_iterations_margin || 2) - return - end - -end + +# Tests to (a) show issues/bugs, and (b) test patches for these, for jira.codehaus.org. +# In the following: IntMin = -9223372036854775808, which is (-2)**(64 - 1). +# #JRUBY-6612: some problems with JRuby seeming to not detect Java Long arithmetic overflows +# # IntMin * -1 #=> 9223372036854775808; +# # -1 * IntMin #=> -9223372036854775808; +# In the second example JRuby was not detecting the integer overflow. +# The first patch for this fixed the problem in jruby-1.7.0.preview1, +# but created a much less serious problem: +# # IntMin * 1 #=> -9223372036854775808 Fixnum; +# # 1 * IntMin #=> -9223372036854775808 Bignum; +# This problem is fixed in jruby-1.7.0.preview2. +# #JRUBY-6777: RubyFixnum.java - two methods assert false, to detect some long integer overflows +# # IntMin / -1: -9223372036854775808; +# # IntMin.divmod(-1): [-9223372036854775808, 0]; +# Fixed in jruby-1.7.0.preview2. +# #JRUBY-6778: Possible long integer overflow bug in Integer#succ in RubyInteger.java +# # 9223372036854775807.succ #=> -9223372036854775808; +# Fixed in jruby-1.7.0.preview2. + +# VVT.logfile = "path/smalltest-jruby-.txt" +require 'test/unit' + +class VVT < Test::Unit::TestCase + BIT_SIZES = [ 30, 31, 32, 33, 62, 63, 64, 65 ] + + def test_integer_overflows + BIT_SIZES.each do |nbits| + checks_for_integer_overflow(nbits) + end + + end + + def test_integer_iteration_for_overflows + BIT_SIZES.each do |nbits| + checks_for_integer_iteration_overflows(nbits) + end + + end + + def checks_for_integer_overflow(nbits) + reset_subcounts() + return unless nbits >= 6 + nbits_int_min = n_bits_integer_min(nbits) + nbits_int_max = n_bits_integer_max(nbits) + + # (1) Test for whether integer addition and negation seems OK, + # because we need these to be reliable for the remaining tests. + check_integer_add_overflow(nbits_int_max, 1) + check_integer_add_overflow(nbits_int_min, -1) + check_integer_negate_overflow(nbits_int_max) + check_integer_negate_overflow(nbits_int_min) + return if sub_notOK?() # stop here if any of the above tests are failed + + # (2) Test for non-iteration integer overflows. + # The problems for JRuby-1.6.7.2, JRuby-1.7.0.preview1 + # seem to be fixed by patches used in JRuby-1.7.0.preview2. + + # In the following: IntMin = -9223372036854775808, which is -(2**(64 - 1)); + # IntMax = 9223372036854775807, which is 2**(64 - 1) - 1. + + check_integer_succ(nbits_int_max - 1) + #* next line:[JRUBY-6778]: integer overflow: JRuby-1.6.7.2, JRuby-1.7.0.preview1; + # 9223372036854775807.succ #=> -9223372036854775808; + # IntMax.succ #=> IntMin; + check_integer_succ(nbits_int_max) # [JRUBY-6778] + check_integer_succ(nbits_int_max + 1) + + check_integer_multiply_by_0_or_1_or_minus_1(nbits_int_min, 0) # OK + check_integer_multiply_by_0_or_1_or_minus_1(0, nbits_int_min) # OK + check_integer_multiply_by_0_or_1_or_minus_1(nbits_int_min, -1) # OK + #* next line:[JRUBY-6612]: integer overflow: JRuby-1.6.7.2; + # -1 * -9223372036854775808 #=> -9223372036854775808; + # -1 * IntMin #=> IntMin; + # patch for this corrected this bug but created new bug just below + check_integer_multiply_by_0_or_1_or_minus_1(-1, nbits_int_min) # [JRUBY-6612] + #* next line: incorrect class of result: JRuby-1.7.0.preview1; + # patch for [JRUBY-6612] corrected that bug but created this new less serious bug: + # 1 * -9223372036854775808 #=> -9223372036854775808 Bignum; + # 1 * IntMin #=> -9223372036854775808 Bignum; should be Fixnum IntMin + check_integer_multiply_by_0_or_1_or_minus_1( 1, nbits_int_min) # OK in preview2 + check_integer_multiply_by_0_or_1_or_minus_1(nbits_int_min, 1) # OK + + check_integer_divide_by_1_or_minus_1(nbits_int_min, 1) + check_integer_divmod_by_1_or_minus_1(nbits_int_min, 1) + #* next line:[JRUBY-6777]: integer overflow: JRuby-1.6.7.2, JRuby-1.7.0.preview1; + # -9223372036854775808 / -1 #=> -9223372036854775808; + # IntMin / -1 #=> IntMin; + check_integer_divide_by_1_or_minus_1(nbits_int_min, -1) # [JRUBY-6777] + #* next line:[JRUBY-6777]: integer overflow: JRuby-1.6.7.2, JRuby-1.7.0.preview1; + # -9223372036854775808.divmod(-1) #=> [-9223372036854775808, 0]; + # IntMin.divmod(-1) #=> [IntMin, 0]; + check_integer_divmod_by_1_or_minus_1(nbits_int_min, -1) # [JRUBY-6777] + end + + def check_integer_add_overflow(av, bv) + reset_actual_expected_etc() + return unless av.kind_of?(Integer) && bv.kind_of?(Integer) + @expected = vv = vvs = vvv = nil + if av == 0 && bv == 0 then @expected = 0 + elsif av == 0 then @expected = bv + elsif bv == 0 then @expected = av + elsif av == 1 then vv = vvs = 1; vvv = bv + elsif av == -1 then vv = vvs = -1; vvv = bv + elsif bv == 1 then vv = vvs = 1; vvv = av + elsif bv == -1 then vv = vvs = -1; vvv = av + elsif bv > 0 then vv = bv; vvs = 1; vvv = av + elsif bv < 0 then vv = bv; vvs = -1; vvv = av + else return + end + unless @expected then + begin + @expected = vv + vvv + qok = (if vvs == 1 then @expected > vvv else @expected < vvv end) + qok &&= (-vv + @expected) == vvv + @expected = inzpect(@expected) + "_???" unless qok + rescue + @expected = "???_" + inzpect($!) + "_???" + end + end + @text = "#{inzpect(av)} + #{inzpect(bv)}" + begin + @actual = av + bv + rescue + @exception = $! + end + process_test_result() + end + + def check_integer_succ(nv) + reset_actual_expected_etc() + @text = "#{inzpect(nv)}.succ" + begin + @expected = 1 + nv + qok = @expected > nv + qok &&= (-1 + @expected) == nv + @expected = inzpect(@expected) + "_???" unless qok + rescue + @expected = "???_" + inzpect($!) + "_???" + end + begin + @actual = nv.succ + rescue + @exception = $! + end + process_test_result() + end + + def check_integer_negate_overflow(nv) + reset_actual_expected_etc() + return unless nv.kind_of?(Integer) + @text = "negate #{inzpect(nv)}" + begin + # This gets the expected value of negate by using subtract, + # which may be a problem if "a subtract b" is implemented as "a plus negate b", + # or if "negate n" is implemented as "0 subtract n". + @expected = 0 - nv + negexp = 0 - @expected + qok = negexp == nv && negexp.class == nv.class && + if nv > 0 then @expected < 0 && @expected.class == nv.class + elsif nv < 0 then @expected > 0 && (-1 + @expected).class == nv.class + else @expected.zero? && nv.zero? && + @expected == nv && @expected.class == nv.class + end + @expected = inzpect(@expected) + "_???" unless qok + rescue + @expected = "???_" + inzpect($!) + "_???" + end + begin + @actual = -nv + rescue + @exception = $! + end + process_test_result() + end + + def check_integer_multiply_by_0_or_1_or_minus_1(av, bv) + reset_actual_expected_etc() + return unless av.kind_of?(Integer) && bv.kind_of?(Integer) + @expected = if av == 0 || bv == 0 then 0 + elsif av == 1 then bv + elsif bv == 1 then av + elsif av == -1 then + if bv < 0 then -(bv + 1) + 1 else -bv end + elsif bv == -1 then + if bv < 0 then -(av + 1) + 1 else -av end + else nil + end + return unless @expected + @text = "#{inzpect(av)} * #{inzpect(bv)}" + begin + @actual = av * bv + rescue + @exception = $! + end + process_test_result() + end + + def check_integer_divide_by_1_or_minus_1(av, bv) + return unless av.kind_of?(Integer) && bv.kind_of?(Integer) + reset_actual_expected_etc() + @expected = if bv == 1 then av + elsif bv == -1 then -(av + 1) + 1 + else nil + end + return unless @expected + @text = "#{inzpect(av)} / #{inzpect(bv)}" + begin + @actual = av / bv + rescue + @exception = $! + end + process_test_result() + end + + def check_integer_divmod_by_1_or_minus_1(av, bv) + return unless av.kind_of?(Integer) && bv.kind_of?(Integer) + reset_actual_expected_etc() + @expected = if bv == 1 then [av, 0] + elsif bv == -1 then [-(av + 1) + 1, 0] + else nil + end + return unless @expected + @text = "#{inzpect(av)}.divmod(#{inzpect(bv)})" + begin + @actual = av.divmod(bv) + rescue + @exception = $! + end + process_test_result() + end + + def checks_for_integer_iteration_overflows(nbits) + # This mainly tests for incorrect detection of integer overflow in integer iterations. + reset_subcounts() + return unless nbits >= 6 + nbits_int_min = n_bits_integer_min(nbits) + nbits_int_max = n_bits_integer_max(nbits) + + # (1) Test if integer iteration seems OK for some "likely" integer overflows. + # The idea is to "assert false, quickly" if there are "likely" integer overflows. + + #* next lines seem OK in: JRuby-1.6.7.2, JRuby-1.7.0.preview1; + # next line was in [JRUBY-6779] as an example of Range#each working as expected + check_integer_range_each(nbits_int_max - 1...nbits_int_max) # [JRUBY-6779] OK in JRuby-1.6, etc + check_range_step(nbits_int_max - 1...nbits_int_max, 1) + check_range_step(nbits_int_max...nbits_int_max + 1, 1) + + #* next lines: integer overflow: JRuby-1.6.7.2, JRuby-1.7.0.preview1; + + # next three lines are OK in JRuby-1.7.0.preview2 because of [JRUBY-6778] #succ patch + check_integer_range_each(nbits_int_max.. nbits_int_max + 1) # [JRUBY-6779] OK in preview2 + check_integer_range_each(nbits_int_max...nbits_int_max + 1) # [JRUBY-6779] OK in preview2 + check_integer_range_each(nbits_int_max...nbits_int_max + 1) + # but the next two lines seem still notOK in JRuby-1.7.0.preview2 + check_integer_range_each(nbits_int_max ..nbits_int_max) # [JRUBY-6779] + check_integer_range_each(nbits_int_max - 1..nbits_int_max) # [JRUBY-6779] + + check_integer_downto(nbits_int_min, nbits_int_min) + check_integer_upto(nbits_int_max, nbits_int_max) + + check_numeric_step(nbits_int_max - 1, nbits_int_max - 1, 2) # [JRUBY-6790] + check_numeric_step(nbits_int_max, nbits_int_max, 1) # [JRUBY-6790] + check_numeric_step(nbits_int_min, nbits_int_min, -1) + + check_range_step(nbits_int_max..nbits_int_max, 1) + check_range_step(nbits_int_max - 1..nbits_int_max, 2) + check_range_step(nbits_int_max - 1..nbits_int_max - 1, 2) + check_range_step(nbits_int_max - 1...nbits_int_max, 2) + + #* next lines test for plausible but incorrect detection of iteration integer overflow + #* next lines: integer overflow: JRuby-1.6.7.2, JRuby-1.7.0.preview1; + check_numeric_step(nbits_int_min + 1, nbits_int_max - 1, nbits_int_max - 2) + check_numeric_step(nbits_int_max - 1, nbits_int_min + 1, nbits_int_min + 3) + check_range_step(nbits_int_min + 1..nbits_int_max - 1, nbits_int_max - 2) + check_range_step(nbits_int_min + 1...nbits_int_max, nbits_int_max - 2) + + return if sub_notOK?() # stop here if any of the above tests are failed + + # If there aren't any "likely" integer overflows then do many more tests, + # hoping to detect any "unlikely" integer overflows. + + nn0 = nbits_int_max - 7 + nn2 = nbits_int_max + 7 + nn = nn0 - 1 + while (nn += 1) <= nn2 do + nnn = nn0 - 1 + while (nnn += 1) <= nn2 do + check_integer_downto(nn, nnn) + check_integer_upto(nn, nnn) + check_integer_range_each(nn..nnn) + check_integer_range_each(nn...nnn) + + check_numeric_step(nn, nnn, 1) + check_numeric_step(nn, nnn, 2) + + check_range_step(nn..nnn, 1) + check_range_step(nn...nnn, 1) + check_range_step(nn..nnn, 2) + check_range_step(nn...nnn, 2) + end + end + end + + # individual tests + + def check_integer_downto(fromv, tov) + @text = inzpect(fromv) + ".downto(" + inzpect(tov) + ")" + set_numeric_expected_iterations(fromv, tov, -1, false, false) + @expected = fromv + @iterations = [] + begin + @actual = fromv.downto(tov) do |iv| + @iterations << iv + break if @iterations.size >= @max_num_iterations + end + rescue + @exception = $! + end + process_test_result() + end + + def check_integer_upto(fromv, tov) + @text = inzpect(fromv) + ".upto(" + inzpect(tov) + ")" + set_numeric_expected_iterations(fromv, tov, 1, false, false) + @expected = fromv + @iterations = [] + begin + @actual = fromv.upto(tov) do |iv| + @iterations << iv + break if @iterations.size >= @max_num_iterations + end + rescue + @exception = $! + end + process_test_result() + end + + def check_integer_range_each(rangev) + @text = "(" + inzpect(rangev) + ").each" + set_numeric_expected_iterations(rangev.begin, rangev.end, 1, false, rangev.exclude_end?) + @expected = rangev + @iterations = [] + begin + @actual = rangev.each do |iv| + @iterations << iv + break if @iterations.size >= @max_num_iterations + end + rescue + @exception = $! + end + process_test_result() + end + + def check_numeric_step(fromv, tov, stepv) + @text = inzpect(fromv) + ".step(" + inzpect(tov) + ", " + inzpect(stepv) + ")" + efromv = fromv; etov = tov; estepv = stepv + if efromv.kind_of?(Float) || etov.kind_of?(Float) || estepv.kind_of?(Float) then + efromv = efromv.to_f; etov = etov.to_f; estepv = estepv.to_f + end + set_numeric_expected_iterations(efromv, etov, estepv, false, false) + @expected = fromv + if @expected_exception then + @expected_exception = ArgumentError.exception("step can't be 0") + @expected_iterations = [] + @expected = nil + end + @iterations = [] + begin + @actual = fromv.step(tov, stepv) do |iv| + @iterations << iv + break if @iterations.size >= @max_num_iterations + end + rescue + @exception = $! + end + process_test_result() + end + + def check_range_step(rangev, stepv) + @text = "(" + inzpect(rangev) + ").step(" + inzpect(stepv) + ")" + efromv = rangev.begin; etov = rangev.end; estepv = stepv + if efromv.kind_of?(Float) || etov.kind_of?(Float) || estepv.kind_of?(Float) then + efromv = efromv.to_f; etov = etov.to_f; estepv = estepv.to_f + end + set_numeric_expected_iterations(efromv, etov, estepv, false, rangev.exclude_end?) + @expected = rangev + if @expected_exception || stepv < 0 then + @expected_exception = if stepv < 0 then + ArgumentError.exception("step can't be negative") + else + ArgumentError.exception("step can't be 0") + end + @expected_iterations = [] + @expected = nil + end + @iterations = [] + begin + @actual = rangev.step(stepv) do |iv| + @iterations << iv + break if @iterations.size >= @max_num_iterations + end + rescue + @exception = $! + end + process_test_result() + end + + ############################# + # Test support methods follow + ############################# + def ruby_run_info_const(symv, altv = nil) + if Module.const_defined?(symv) then + Module.const_get(symv) + else + altv + end + end + + DEFAULT_RECUR_MAX_DEPTH = 3 + + IS_JRUBY = !! RUBY_PLATFORM.to_s.downcase.index("java") + def JRuby?() + IS_JRUBY + end + + Infinity = 1.0 / 0.0 + + # Min and max values of N-bit signed integers are + # used for tests that integer overflow detection is working. + # 31-bit signed integers: MRI Ruby Fixnum; + # 32-bit signed integers: Java int, C long, etc; + # 63-bit signed integers: MRI Ruby Fixnum; + # 64-bit signed integers: Java long, JRuby Ruby Fixnum; + def n_bits_integer_min(nbits) + return nil if nbits < 1 + # Calculate -(2**(nbits - 1)) using only addition + # to avoid relying on powers (or multiply) being correctly implemented. + # This may be slow but that should not matter for the types of tests that + # this is intended for. (You can "cache" values if speed is a problem.) + min_intv = -1 # starting min value, for a 1_bit signed integer + nbitsi = 0 + while (nbitsi += 1) < nbits do + prev_min_intv = min_intv + unless (min_intv += min_intv) < prev_min_intv then + raise "ERROR overflow calculating -(2**(nbits - 1)) for nbits=#{nbits}" + end + end + return min_intv + end + # + def n_bits_integer_max(nbits) + (minv = n_bits_integer_min(nbits)) && -(minv + 1) + end + + def Rational_loaded?() + return defined?(Rational) + end + + attr_accessor :exclude_tests_level, :normal_tests_level + + def setup() + # initialize test result counts and test controls + @numOK = @numNotOK = @numExceptions = 0 + reset_subcounts() + reset_actual_expected_etc() + @logfile = nil + @exclude_tests_level = nil # controls excluding some tests + @normal_tests_level = 8 + @recur_max_depth = DEFAULT_RECUR_MAX_DEPTH # max depth for #not_equal? + # next instance variable allows you to limit the number of iterations in a test + # in case the actual number of iterations is much larger than expected (or infinite) + @max_num_iterations = nil + # next instance variable is the allowed margin of the actual number of iterations + # over the expected number of iterations + @max_num_iterations_margin = 2 + end + + def reset_actual_expected_etc() + @actual = @iterations = @exception = nil + @expected = @expected_iterations = @expected_exception = nil + @max_num_iterations = nil + end + + def reset_subcounts() + @sub_numOK = @sub_numNotOK = @sub_numExceptions = 0 + end + + def sub_notOK?() + (@sub_numNotOK && @sub_numNotOK != 0) || + (@sub_numExceptions && @sub_numExceptions != 0) + end + + def not_equal?(actualv, expectedv, recur_max_depthv = nil) + return true if actualv.class != expectedv.class + recur_max_depthv ||= @recur_max_depth || DEFAULT_RECUR_MAX_DEPTH + recur_max_depthv -= 1 + case actualv + when Exception then + return actualv.to_s != expectedv.to_s # focus equality on the exception message + when Array then + if recur_max_depthv >= 0 then + ii2 = if actualv.size < expectedv.size then actualv.size else expectedv.size end + iii = vvv = nil + ii = -1 + while (ii += 1) < ii2 do + if (vvv = not_equal?(actualv[ii], expectedv[ii], recur_max_depthv)) then + iii = ii + break + end + end + if iii || actualv.size != expectedv.size then + vvv = [] unless vvv.kind_of?(Array) + vvv << (iii || ii2) + return vvv + end + end + end + return ! (actualv == expectedv) # use normal equality checking + end + + def inzpect(valuev, recur_max_depthv = nil, + first_diff_indexes = nil, first_diff_indexv = nil) + # Similar to "inspect" but has different options for showing arrays. + # And for Bignum values shows class as well as value: for example: -123456789_big; + # the reason for this is that it is possible that a numeric value is correct + # but that the expected value is Fixnum and the actual value is Bignum, + # and we want the output to be clear about the type of value. + recur_max_depthv ||= @recur_max_depth || DEFAULT_RECUR_MAX_DEPTH + recur_max_depthv -= 1 + case valuev + when Array then + if recur_max_depthv >= 0 then + if first_diff_indexes.kind_of?(Array) then + first_diff_indexv ||= first_diff_indexes.size + first_diff_indexv -= 1 + else + first_diff_indexv = nil + end + resultv = "[" + if valuev.size > 0 then + iidiff_indexv = if first_diff_indexes.kind_of?(Array) then + first_diff_indexes[first_diff_indexv] + else + -1 + end + iidiff_indexv = -1 if iidiff_indexv >= valuev.size + ii = 0 + if ii == iidiff_indexv then + iidiff_indexv = -1 + fdixs = first_diff_indexes + fdixv = first_diff_indexv + else + fdixs = fdixv = nil + end + resultv << inzpect(valuev[ii], recur_max_depthv, fdixs, fdixv) + if valuev.size > 1 then + prev_ii = ii + if prev_ii < iidiff_indexv then + if prev_ii < (ii = iidiff_indexv - 1) then + resultv << (if prev_ii + 1 == ii then ", " else ",...@#{ii}:" end) << + inzpect(valuev[ii], recur_max_depthv, nil, nil) + prev_ii = ii + end + ii = iidiff_indexv + iidiff_indexv = -1 + resultv << (if prev_ii + 1 == ii then ", " else ",...@#{ii}:" end) << + inzpect(valuev[ii], recur_max_depthv, + first_diff_indexes, first_diff_indexv) + prev_ii = ii + end + if prev_ii < (ii = valuev.size - 1) then + resultv << (if prev_ii + 1 == ii then ", " else ",...@#{ii}:" end) << + inzpect(valuev[ii], recur_max_depthv, nil, nil) + end + end + end + resultv << "]" + return resultv + end + when Range then + # Note recursive calls in next line!!! + return inzpect(valuev.begin) << + (if valuev.exclude_end? then "..." else ".." end) << + inzpect(valuev.end) + when Exception then + return valuev.class.name + ":" << valuev.to_s.inspect + when Bignum then + return valuev.inspect << "_big" + when Fixnum, Float, NilClass, TrueClass, FalseClass then + return valuev.inspect + else + unless Rational_loaded? && valuev.class == Rational then + return valuev.class.name + ":v:" << valuev.inspect + end + end + valuev.inspect + end + + def process_test_result() + # For readability in making tests, this method relies on instance variables being set. + # It calls "process_test_result_private" which (mostly) does not use instance variables. + process_test_result_private(@actual, @expected, + @iterations, @expected_iterations, + @exception, @expected_exception, + @text) + end + + def process_test_result_private(actual_resultv, expected_resultv, + actual_iterationsv, expected_iterationsv, + actual_exceptionv, expected_exceptionv, + test_textv = nil) + if expected_resultv.kind_of?(Exception) && expected_exceptionv.nil? then + expected_exceptionv = expected_resultv + expected_resultv = nil + end + + msgv = test_textv << " #=>" + msgv << " != " << inzpect(expected_resultv, nil, not_equal?(actual_iterationsv, expected_iterationsv), nil) + assert_equal(actual_resultv, expected_resultv, msgv) + + msgv = test_textv << " #=>" + msgv << " != " << inzpect(expected_iterationsv, nil, not_equal?(actual_resultv, expected_resultv), nil) + assert_equal(actual_iterationsv, expected_iterationsv, msgv) + + msgv = test_textv << " #=>" + msgv << " != " << inzpect(expected_exceptionv, nil, not_equal?(actual_exceptionv, expected_exceptionv), nil) + assert_equal(actual_exceptionv, expected_exceptionv, msgv) + end + + def set_numeric_expected_iterations(fromv, tov, stepv, exclude_fromv, exclude_tov) + # set up expected numeric iterated values + reset_actual_expected_etc() + if stepv == 0 then + @expected_exception = true + return + end + @expected_iterations = [] # store expected iterated values in an array + # next line sets the appropriate check for the end of the iteration + symv = if stepv > 0 then + if exclude_tov then :< else :<= end + else + if exclude_tov then :> else :>= end + end + itvalue = fromv + num_steps = 0 # count the steps from fromv: needed for Float (etc) iterations + if exclude_fromv then + # Depending on the type of iteration, this might need to be changed + # if stepv is a very small Float or BigDecimal, etc. + itvalue += stepv + num_steps += 1 + end + while itvalue.__send__(symv, tov) do + @expected_iterations << itvalue + num_steps += 1 # needed for Float (etc) iterations + if itvalue.kind_of?(Float) || + (defined?(BigDecimal) && itvalue.kind_of?(BigDecimal)) then + itvalue = fromv + stepv * num_steps + else + itvalue += stepv + end + end + # next line anticipates unexpected infinite or very large loops in tests of iterators + @max_num_iterations = @expected_iterations.size + (@max_num_iterations_margin || 2) + return + end + +end diff --git a/test/test_line_endings-windows.txt b/test/test_line_endings-windows.txt index d5267d45531..eddcb2281e2 100644 --- a/test/test_line_endings-windows.txt +++ b/test/test_line_endings-windows.txt @@ -1,2 +1,2 @@ -here is line 1 -here is line 2 +here is line 1 +here is line 2 diff --git a/test/test_string_sub.rb b/test/test_string_sub.rb index 9249257f583..19e86aa4ebf 100644 --- a/test/test_string_sub.rb +++ b/test/test_string_sub.rb @@ -1,34 +1,34 @@ -require 'test/unit' - -class UnitTest < Test::Unit::TestCase - - def initialize(test_method_name) - super(test_method_name) - end - - EOL="\r\n" - - def check buf, e1, e2, e3 - - assert_equal e1, buf.size - head = '' - - #from cgi.rb.. - buf = buf.sub(/\A((?:.|\n)*?#{EOL})#{EOL}/n) do - head = $1.dup - "" - end - # ..cgi.rb - - assert_equal e2, head.size - assert_equal e3, buf.size - end - - def test_unit_method - check "a" + EOL + EOL + "a" , 6, 3, 1 # 1byte + 2byte + 2byte + 1byte - check "a" + EOL + EOL + "あ" , 8, 3, 3 # 1byte + 2byte + 2byte + 3byte - check "あ" + EOL + EOL + "a" , 8, 5, 1 # 3byte + 2byte + 2byte + 1byte failure!! - check "あ" + EOL + EOL + "あ" ,10, 5, 3 # 3byte + 2byte + 2byte + 3byte failure!! - end -end - +require 'test/unit' + +class UnitTest < Test::Unit::TestCase + + def initialize(test_method_name) + super(test_method_name) + end + + EOL="\r\n" + + def check buf, e1, e2, e3 + + assert_equal e1, buf.size + head = '' + + #from cgi.rb.. + buf = buf.sub(/\A((?:.|\n)*?#{EOL})#{EOL}/n) do + head = $1.dup + "" + end + # ..cgi.rb + + assert_equal e2, head.size + assert_equal e3, buf.size + end + + def test_unit_method + check "a" + EOL + EOL + "a" , 6, 3, 1 # 1byte + 2byte + 2byte + 1byte + check "a" + EOL + EOL + "あ" , 8, 3, 3 # 1byte + 2byte + 2byte + 3byte + check "あ" + EOL + EOL + "a" , 8, 5, 1 # 3byte + 2byte + 2byte + 1byte failure!! + check "あ" + EOL + EOL + "あ" ,10, 5, 3 # 3byte + 2byte + 2byte + 3byte failure!! + end +end + diff --git a/test/test_string_to_number.rb b/test/test_string_to_number.rb index 814d87f20d5..9376b1e0b59 100644 --- a/test/test_string_to_number.rb +++ b/test/test_string_to_number.rb @@ -1,41 +1,41 @@ -require 'test/unit' - -# Tests for string-to-number conversions (primarily those found -# in org.jruby.util.Convert.java). -# -# TODO Consolidate/merge with tests found in rubicon/test_floats.rb. -# -class TestStringToNumber < Test::Unit::TestCase - - # Test fix for JRUBY-1215 - def test_invalid_float_from_string - for string in [ - "1a", - "a1", - "1.0a", - "10a", - "10.1a", - "0.10a", - "1.1e1a", - "1.1e10a", - "\3 1", - "1 \3", - ] - assert_raises(ArgumentError) { Float(string) } - end - end - - # Test fix for JRUBY-1215-related (unreported) bug - def test_invalid_integer_from_string - for string in [ - "a1", - "1a", - "10a", - "\3 1", - "1 \3", - ] - assert_raises(ArgumentError) { Integer(string) } - end - end - +require 'test/unit' + +# Tests for string-to-number conversions (primarily those found +# in org.jruby.util.Convert.java). +# +# TODO Consolidate/merge with tests found in rubicon/test_floats.rb. +# +class TestStringToNumber < Test::Unit::TestCase + + # Test fix for JRUBY-1215 + def test_invalid_float_from_string + for string in [ + "1a", + "a1", + "1.0a", + "10a", + "10.1a", + "0.10a", + "1.1e1a", + "1.1e10a", + "\3 1", + "1 \3", + ] + assert_raises(ArgumentError) { Float(string) } + end + end + + # Test fix for JRUBY-1215-related (unreported) bug + def test_invalid_integer_from_string + for string in [ + "a1", + "1a", + "10a", + "\3 1", + "1 \3", + ] + assert_raises(ArgumentError) { Integer(string) } + end + end + end \ No newline at end of file diff --git a/test/test_variables.rb b/test/test_variables.rb index 690f997e1f2..848fed18117 100644 --- a/test/test_variables.rb +++ b/test/test_variables.rb @@ -1,50 +1,50 @@ -require 'test/unit' - -class TestVariables < Test::Unit::TestCase - - # - # TODO: test for new variables code will go here as well. - # - - # test fix for JRUBY-1295 (invalid var names permitted in set/get/remove) - def test_instance_variable_validation - assert_raises(NameError) { Object.new.instance_variable_set '@123', 1 } - assert_raises(NameError) { Object.new.instance_variable_set '@$', 1 } - assert_raises(NameError) { Object.new.instance_variable_set '@ a', 1 } - assert_raises(NameError) { Object.new.instance_variable_get '@123' } - assert_raises(NameError) { Object.new.instance_variable_get '@$' } - assert_raises(NameError) { Object.new.instance_variable_get '@ a' } - - # we'll support this MRI behavior, though it seems like a bug (Pickaxe - # says it's illegal): - obj = Object.new - assert_nothing_raised { obj.instance_variable_set('@', 1) } - assert_equal('@', obj.instance_variables[0]) - assert_equal(1, obj.instance_variable_get('@')) - end - - # test fix for JRUBY-1295 (invalid var names permitted in set/get/remove) - def test_class_variable_validation - assert_raises(NameError) { Class.new { class_variable_set '@@123', 1 } } - assert_raises(NameError) { Class.new { class_variable_set '@@$', 1 } } - assert_raises(NameError) { Class.new { class_variable_set '@@ ', 1 } } - assert_raises(NameError) { Class.new { class_variable_get '@@123' } } - assert_raises(NameError) { Class.new { class_variable_get '@@$' } } - assert_raises(NameError) { Class.new { class_variable_get '@@ ' } } - - # we'll support this MRI behavior, though it seems like a bug (Pickaxe - # says it's illegal): - cls = Class.new - assert_nothing_raised { cls.send :class_variable_set, '@@', 1 } - assert_equal('@@', cls.class_variables[0] ) - assert_equal(1, cls.send(:class_variable_get, '@@')) - end - - # test fix for JRUBY-1295 (invalid var names permitted in set/get/remove) - def test_constant_validation - assert_raises(NameError) { Class.new.const_set 'C no evil', 1 } - assert_raises(NameError) { Class.new.const_get "C'est la vie!" } - assert_raises(NameError) { Class.new { remove_const "Ciao, Marcello!" } } - end - -end +require 'test/unit' + +class TestVariables < Test::Unit::TestCase + + # + # TODO: test for new variables code will go here as well. + # + + # test fix for JRUBY-1295 (invalid var names permitted in set/get/remove) + def test_instance_variable_validation + assert_raises(NameError) { Object.new.instance_variable_set '@123', 1 } + assert_raises(NameError) { Object.new.instance_variable_set '@$', 1 } + assert_raises(NameError) { Object.new.instance_variable_set '@ a', 1 } + assert_raises(NameError) { Object.new.instance_variable_get '@123' } + assert_raises(NameError) { Object.new.instance_variable_get '@$' } + assert_raises(NameError) { Object.new.instance_variable_get '@ a' } + + # we'll support this MRI behavior, though it seems like a bug (Pickaxe + # says it's illegal): + obj = Object.new + assert_nothing_raised { obj.instance_variable_set('@', 1) } + assert_equal('@', obj.instance_variables[0]) + assert_equal(1, obj.instance_variable_get('@')) + end + + # test fix for JRUBY-1295 (invalid var names permitted in set/get/remove) + def test_class_variable_validation + assert_raises(NameError) { Class.new { class_variable_set '@@123', 1 } } + assert_raises(NameError) { Class.new { class_variable_set '@@$', 1 } } + assert_raises(NameError) { Class.new { class_variable_set '@@ ', 1 } } + assert_raises(NameError) { Class.new { class_variable_get '@@123' } } + assert_raises(NameError) { Class.new { class_variable_get '@@$' } } + assert_raises(NameError) { Class.new { class_variable_get '@@ ' } } + + # we'll support this MRI behavior, though it seems like a bug (Pickaxe + # says it's illegal): + cls = Class.new + assert_nothing_raised { cls.send :class_variable_set, '@@', 1 } + assert_equal('@@', cls.class_variables[0] ) + assert_equal(1, cls.send(:class_variable_get, '@@')) + end + + # test fix for JRUBY-1295 (invalid var names permitted in set/get/remove) + def test_constant_validation + assert_raises(NameError) { Class.new.const_set 'C no evil', 1 } + assert_raises(NameError) { Class.new.const_get "C'est la vie!" } + assert_raises(NameError) { Class.new { remove_const "Ciao, Marcello!" } } + end + +end diff --git a/test/test_vietnamese_charset.rb b/test/test_vietnamese_charset.rb index 9088528c583..cf890cc9ebe 100644 --- a/test/test_vietnamese_charset.rb +++ b/test/test_vietnamese_charset.rb @@ -1,9 +1,9 @@ -require 'test/unit' -require 'yaml' - -class TestVietnameseCharset < Test::Unit::TestCase - def test_eej - nguyen = "nguy\341\273\205n" - assert_equal nguyen, YAML::load(nguyen.to_yaml) - end -end +require 'test/unit' +require 'yaml' + +class TestVietnameseCharset < Test::Unit::TestCase + def test_eej + nguyen = "nguy\341\273\205n" + assert_equal nguyen, YAML::load(nguyen.to_yaml) + end +end