Skip to content

Commit

Permalink
Pull in and wire up Ruby 2.0 tests + excludes.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Mar 12, 2013
1 parent 322103a commit dfd22f3
Show file tree
Hide file tree
Showing 1,211 changed files with 237,273 additions and 1 deletion.
67 changes: 66 additions & 1 deletion rakelib/test.rake
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ namespace :test do

short_tests_18 = ['jruby', 'mri', 'rubicon']
short_tests_19 = short_tests_18.map {|test| test + "19"}
short_tests_20 = short_tests_18.map {|test| test + "20"}
short_tests = short_tests_18 + short_tests_19
long_tests_18 = short_tests_18 + ['spec:ji', 'spec:compiler', 'spec:ffi', 'spec:regression']
long_tests_19 = long_tests_18.map {|test| test + "19"}
long_tests_20 = long_tests_18.map {|test| test + "20"}
slow_tests = ['test:slow', 'test:objectspace', 'test:tracing']
long_tests = long_tests_18 + long_tests_19 + slow_tests
all_tests_18 = long_tests_18.map {|test| test + ':all'}
all_tests_19 = long_tests_19.map {|test| test + ':all'}
all_tests_20 = long_tests_20.map {|test| test + ':all'}
all_tests = all_tests_18 + all_tests_19 + slow_tests

desc "Run the short suite: #{short_tests.inspect}"
Expand All @@ -35,6 +38,9 @@ namespace :test do
desc "Run the short 1.9 suite: #{short_tests_19.inspect}"
task :short19 => [:compile, *short_tests_19]

desc "Run the short 2.0 suite: #{short_tests_20.inspect}"
task :short19 => [:compile, *short_tests_20]

desc "Run the short 1.8 suite: #{short_tests_18.inspect}"
task :short18 => [:compile, *short_tests_18]

Expand All @@ -44,6 +50,9 @@ namespace :test do
desc "Run the long 1.9 suite: #{long_tests_19.inspect}"
task :long19 => [:compile, *long_tests_19]

desc "Run the long 2.0 suite: #{long_tests_20.inspect}"
task :long19 => [:compile, *long_tests_20]

desc "Run the long 1.8 suite: #{long_tests_18.inspect}"
task :long18 => [:compile, *long_tests_18]

Expand All @@ -53,6 +62,9 @@ namespace :test do
desc "Run the comprehensive 1.9 suite: #{all_tests_19}"
task :all19 => [:compile, *all_tests_19]

desc "Run the comprehensive 2.0 suite: #{all_tests_20}"
task :all19 => [:compile, *all_tests_20]

desc "Run the comprehensive 1.8 suite: #{all_tests_18}"
task :all18 => [:compile, *all_tests_18]

Expand Down Expand Up @@ -94,6 +106,27 @@ namespace :test do
t.ruby_opts << '--1.9'
t.ruby_opts << '-I test/externals/ruby1.9'
t.ruby_opts << '-I test/externals/ruby1.9/ruby'
t.ruby_opts << '-r ./test/ruby19_env.rb'
t.ruby_opts << '-r minitest/excludes'
end

permute_tests(:mri20, compile_flags, :install_dev_gems) do |t|
files = []
File.open('test/mri.2.0.index') do |f|
f.lines.each do |line|
filename = "test/#{line.chomp}.rb"
next unless File.exist? filename
files << filename
end
end
t.test_files = files
t.verbose = true
ENV['EXCLUDE_DIR'] = 'test/externals/ruby2.0/excludes'
t.ruby_opts << '-J-ea'
t.ruby_opts << '--2.0'
t.ruby_opts << '-I test/externals/ruby2.0'
t.ruby_opts << '-I test/externals/ruby2.0/ruby'
t.ruby_opts << '-r ./test/ruby20_env.rb'
t.ruby_opts << '-r minitest/excludes'
end

Expand All @@ -108,7 +141,6 @@ namespace :test do
end
t.test_files = files
t.verbose = true
ENV['EXCLUDE_DIR'] = 'test/externals/ruby1.9/excludes'
t.ruby_opts << '-J-ea'
t.ruby_opts << '--1.8'
end
Expand All @@ -129,6 +161,22 @@ namespace :test do
t.ruby_opts << '--1.9'
end

permute_tests(:jruby20, compile_flags, 'test:compile') do |t|
files = []
File.open('test/jruby.1.9.index') do |f|
f.lines.each do |line|
filename = "test/#{line.chomp}.rb"
next unless File.exist? filename
files << filename
end
end
t.test_files = files
t.verbose = true
t.ruby_opts << '-J-ea'
t.ruby_opts << '-J-cp build/classes/test'
t.ruby_opts << '--2.0'
end

permute_tests(:jruby, compile_flags, 'test:compile') do |t|
files = []
File.open('test/jruby.1.8.index') do |f|
Expand Down Expand Up @@ -162,6 +210,23 @@ namespace :test do
t.ruby_opts << '-X+O'
end

permute_tests(:rubicon20, compile_flags) do |t|
files = []
File.open('test/rubicon.1.9.index') do |f|
f.lines.each do |line|
filename = "test/#{line.chomp}.rb"
next unless File.exist? filename
files << filename
end
end
t.test_files = files
t.verbose = true
t.ruby_opts << '-J-ea'
t.ruby_opts << '-J-cp build/classes/test'
t.ruby_opts << '--2.0'
t.ruby_opts << '-X+O'
end

permute_tests(:rubicon, compile_flags) do |t|
files = []
File.open('test/rubicon.1.8.index') do |f|
Expand Down
10 changes: 10 additions & 0 deletions src/org/jruby/ext/readline/Readline.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import jline.console.completer.FileNameCompleter;
import jline.console.history.History;
import jline.console.history.MemoryHistory;
import org.jruby.CompatVersion;
import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.RubyModule;
Expand Down Expand Up @@ -472,6 +473,15 @@ public static IRubyObject s_hist_each(IRubyObject recv, Block block) {
}
return recv;
}

@JRubyMethod(name = "clear", compat = CompatVersion.RUBY1_9)
public static IRubyObject clear(ThreadContext context, IRubyObject recv, Block block) {
ConsoleHolder holder = getHolder(context.runtime);

holder.history.clear();

return context.nil;
}
}

// Complete using a Proc object
Expand Down
29 changes: 29 additions & 0 deletions test/externals/ruby2.0/array/test_resize.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'test/unit'
require '-test-/array/resize'

class TestArray < Test::Unit::TestCase
class TestResize < Test::Unit::TestCase
def test_expand
feature = '[ruby-dev:42912]'
ary = [*1..10]
ary.__resize__(10)
assert_equal(10, ary.size, feature)
assert_equal([*1..10], ary, feature)
ary.__resize__(100)
assert_equal(100, ary.size, feature)
assert_equal([*1..10]+[nil]*90, ary, feature)
ary.__resize__(20)
assert_equal(20, ary.size, feature)
assert_equal([*1..10]+[nil]*10, ary, feature)
ary.__resize__(2)
assert_equal(2, ary.size, feature)
assert_equal([1,2], ary, feature)
ary.__resize__(3)
assert_equal(3, ary.size, feature)
assert_equal([1,2,nil], ary, feature)
ary.__resize__(10)
assert_equal(10, ary.size, feature)
assert_equal([1,2]+[nil]*8, ary, feature)
end
end
end
100 changes: 100 additions & 0 deletions test/externals/ruby2.0/base64/test_base64.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# coding: US-ASCII
require "test/unit"
require "base64"

class TestBase64 < Test::Unit::TestCase
def test_sample
assert_equal("U2VuZCByZWluZm9yY2VtZW50cw==\n", Base64.encode64('Send reinforcements'))
assert_equal('Send reinforcements', Base64.decode64("U2VuZCByZWluZm9yY2VtZW50cw==\n"))
assert_equal(
"Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g\nUnVieQ==\n",
Base64.encode64("Now is the time for all good coders\nto learn Ruby"))
assert_equal(
"Now is the time for all good coders\nto learn Ruby",
Base64.decode64("Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g\nUnVieQ==\n"))
assert_equal(
"VGhpcyBpcyBsaW5lIG9uZQpUaGlzIGlzIGxpbmUgdHdvClRoaXMgaXMgbGlu\nZSB0aHJlZQpBbmQgc28gb24uLi4K\n",
Base64.encode64("This is line one\nThis is line two\nThis is line three\nAnd so on...\n"))
assert_equal(
"This is line one\nThis is line two\nThis is line three\nAnd so on...\n",
Base64.decode64("VGhpcyBpcyBsaW5lIG9uZQpUaGlzIGlzIGxpbmUgdHdvClRoaXMgaXMgbGluZSB0aHJlZQpBbmQgc28gb24uLi4K"))
end

def test_encode64
assert_equal("", Base64.encode64(""))
assert_equal("AA==\n", Base64.encode64("\0"))
assert_equal("AAA=\n", Base64.encode64("\0\0"))
assert_equal("AAAA\n", Base64.encode64("\0\0\0"))
assert_equal("/w==\n", Base64.encode64("\377"))
assert_equal("//8=\n", Base64.encode64("\377\377"))
assert_equal("////\n", Base64.encode64("\377\377\377"))
assert_equal("/+8=\n", Base64.encode64("\xff\xef"))
end

def test_decode64
assert_equal("", Base64.decode64(""))
assert_equal("\0", Base64.decode64("AA==\n"))
assert_equal("\0\0", Base64.decode64("AAA=\n"))
assert_equal("\0\0\0", Base64.decode64("AAAA\n"))
assert_equal("\377", Base64.decode64("/w==\n"))
assert_equal("\377\377", Base64.decode64("//8=\n"))
assert_equal("\377\377\377", Base64.decode64("////\n"))
assert_equal("\xff\xef", Base64.decode64("/+8=\n"))
end

def test_strict_encode64
assert_equal("", Base64.strict_encode64(""))
assert_equal("AA==", Base64.strict_encode64("\0"))
assert_equal("AAA=", Base64.strict_encode64("\0\0"))
assert_equal("AAAA", Base64.strict_encode64("\0\0\0"))
assert_equal("/w==", Base64.strict_encode64("\377"))
assert_equal("//8=", Base64.strict_encode64("\377\377"))
assert_equal("////", Base64.strict_encode64("\377\377\377"))
assert_equal("/+8=", Base64.strict_encode64("\xff\xef"))
end

def test_strict_decode64
assert_equal("", Base64.strict_decode64(""))
assert_equal("\0", Base64.strict_decode64("AA=="))
assert_equal("\0\0", Base64.strict_decode64("AAA="))
assert_equal("\0\0\0", Base64.strict_decode64("AAAA"))
assert_equal("\377", Base64.strict_decode64("/w=="))
assert_equal("\377\377", Base64.strict_decode64("//8="))
assert_equal("\377\377\377", Base64.strict_decode64("////"))
assert_equal("\xff\xef", Base64.strict_decode64("/+8="))

assert_raise(ArgumentError) { Base64.strict_decode64("^") }
assert_raise(ArgumentError) { Base64.strict_decode64("A") }
assert_raise(ArgumentError) { Base64.strict_decode64("A^") }
assert_raise(ArgumentError) { Base64.strict_decode64("AA") }
assert_raise(ArgumentError) { Base64.strict_decode64("AA=") }
assert_raise(ArgumentError) { Base64.strict_decode64("AA===") }
assert_raise(ArgumentError) { Base64.strict_decode64("AA=x") }
assert_raise(ArgumentError) { Base64.strict_decode64("AAA") }
assert_raise(ArgumentError) { Base64.strict_decode64("AAA^") }
assert_raise(ArgumentError) { Base64.strict_decode64("AB==") }
assert_raise(ArgumentError) { Base64.strict_decode64("AAB=") }
end

def test_urlsafe_encode64
assert_equal("", Base64.urlsafe_encode64(""))
assert_equal("AA==", Base64.urlsafe_encode64("\0"))
assert_equal("AAA=", Base64.urlsafe_encode64("\0\0"))
assert_equal("AAAA", Base64.urlsafe_encode64("\0\0\0"))
assert_equal("_w==", Base64.urlsafe_encode64("\377"))
assert_equal("__8=", Base64.urlsafe_encode64("\377\377"))
assert_equal("____", Base64.urlsafe_encode64("\377\377\377"))
assert_equal("_-8=", Base64.urlsafe_encode64("\xff\xef"))
end

def test_urlsafe_decode64
assert_equal("", Base64.urlsafe_decode64(""))
assert_equal("\0", Base64.urlsafe_decode64("AA=="))
assert_equal("\0\0", Base64.urlsafe_decode64("AAA="))
assert_equal("\0\0\0", Base64.urlsafe_decode64("AAAA"))
assert_equal("\377", Base64.urlsafe_decode64("_w=="))
assert_equal("\377\377", Base64.urlsafe_decode64("__8="))
assert_equal("\377\377\377", Base64.urlsafe_decode64("____"))
assert_equal("\xff\xef", Base64.urlsafe_decode64("_+8="))
end
end
Loading

0 comments on commit dfd22f3

Please sign in to comment.