Permalink
Browse files

Flip some 1.8.7/1.9 features to 1.9 only, since we're backing off 1.8…

….7 support. Move tests to 1_9 variants so we don't lose them.

git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@7852 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
headius committed Oct 9, 2008
1 parent 3e71aee commit 40a73091ffd8be3351f74b958559030402e2b543
View
@@ -1264,12 +1264,13 @@ public void load(Ruby runtime, boolean wrap) throws IOException {
for (String library : builtins) {
addBuiltinIfAllowed(library + ".rb", new BuiltinScript(library));
}
-
- getLoadService().require("builtin/core_ext/symbol");
RubyKernel.autoload(topSelf, newSymbol("Java"), newString("java"));
- getLoadService().require("enumerator");
+ if (config.getCompatVersion() == CompatVersion.RUBY1_9) {
+ getLoadService().require("builtin/core_ext/symbol");
+ getLoadService().require("enumerator");
+ }
}
private void addLazyBuiltin(String name, String shortName, String className) {
@@ -418,23 +418,23 @@ public IRubyObject op_div(ThreadContext context, IRubyObject other) {
return idiv(context, other, "/");
}
- @JRubyMethod(name = {"odd?"})
+ @JRubyMethod(name = {"odd?"}, compat = CompatVersion.RUBY1_9)
public RubyBoolean odd_p() {
if(value%2 != 0) {
return getRuntime().getTrue();
}
return getRuntime().getFalse();
}
- @JRubyMethod(name = {"even?"})
+ @JRubyMethod(name = {"even?"}, compat = CompatVersion.RUBY1_9)
public RubyBoolean even_p() {
if(value%2 == 0) {
return getRuntime().getTrue();
}
return getRuntime().getFalse();
}
- @JRubyMethod
+ @JRubyMethod(compat = CompatVersion.RUBY1_9)
public IRubyObject pred() {
return getRuntime().newFixnum(value-1);
}
@@ -267,7 +267,7 @@ public IRubyObject to_r(ThreadContext context) {
}
- @JRubyMethod(name = "odd?")
+ @JRubyMethod(name = "odd?", compat = CompatVersion.RUBY1_9)
public static RubyBoolean odd_p(ThreadContext context, IRubyObject recv) {
Ruby runtime = context.getRuntime();
if (recv.callMethod(context, "%", RubyFixnum.two(runtime)) != RubyFixnum.zero(runtime)) {
@@ -276,7 +276,7 @@ public static RubyBoolean odd_p(ThreadContext context, IRubyObject recv) {
return runtime.getFalse();
}
- @JRubyMethod(name = "even?")
+ @JRubyMethod(name = "even?", compat = CompatVersion.RUBY1_9)
public static RubyBoolean even_p(ThreadContext context, IRubyObject recv) {
Ruby runtime = context.getRuntime();
if (recv.callMethod(context, "%", RubyFixnum.two(runtime)) == RubyFixnum.zero(runtime)) {
@@ -285,7 +285,7 @@ public static RubyBoolean even_p(ThreadContext context, IRubyObject recv) {
return runtime.getFalse();
}
- @JRubyMethod(name = "pred")
+ @JRubyMethod(name = "pred", compat = CompatVersion.RUBY1_9)
public static IRubyObject pred(ThreadContext context, IRubyObject recv) {
return recv.callMethod(context, "-", RubyFixnum.one(context.getRuntime()));
}
@@ -1294,7 +1294,7 @@ public static IRubyObject fork(ThreadContext context, IRubyObject recv, Block bl
}
}
- @JRubyMethod(frame = true, module = true)
+ @JRubyMethod(frame = true, module = true, compat = CompatVersion.RUBY1_9)
public static IRubyObject tap(ThreadContext context, IRubyObject recv, Block block) {
block.yield(context, recv);
return recv;
View
@@ -2,4 +2,8 @@
# compat mode is working.
test_loading_builtin_libraries_1_9
test_kernel_1_9_features
+test_fixnum_1_9
+test_integer_1_9
+test_object_1_9
+test_symbol_1_9
externals/mri/ruby/test_fiber
View
@@ -1,4 +1,5 @@
require 'test/minirunit'
+require 'enumerator'
test_ok defined?(Enumerable::Enumerator)
View
@@ -61,8 +61,3 @@
h = 2
test_equal(3, h +1)
-
-test_ok 0.even?
-test_ok 1.odd?
-test_ok -1.odd?
-test_ok 2.even?
View
@@ -78,11 +78,3 @@ def to_i
end
test_exception(TypeError){Integer(Foo.new)}
-
-test_ok 1000000000000000000000000000000.even?
-test_ok 1000000000000000000000000000001.odd?
-
-test_equal 10000000000000000000000000000000, 10000000000000000000000000000001.pred
-test_equal 1, 2.pred
-test_equal 0, 1.pred
-test_equal -1, 0.pred
View
@@ -166,27 +166,6 @@ def initialize_copy
test_ok c1.private_methods.include?("initialize")
test_ok c1.private_methods.include?("initialize_copy")
-# Test tap
-value = nil
-1.tap { |v| value = v }
-test_equal 1, value
-
-[].tap { |v| value = v }
-test_equal [], value
-
-test_equal 1, 1.tap { }
-
-obj = Object.new
-
-test_equal obj, obj.tap { }
-
-test_equal "str", "str".tap { value = "foo" }
-test_equal "foo", value
-
-test_exception(LocalJumpError) do
- "str".tap
-end
-
# JRUBY-2247
test_equal ['now'], Time.methods.grep('now')
test_equal ["_load", "at", "gm", "local", "mktime", "now", "utc"], Time.methods(false).sort
View
@@ -132,19 +132,3 @@ def x.foo(other)
#Creating a singleton from Symbol should yield: "TypeError: no virtual class for Symbol"
test_exception(TypeError) { class << :abc ; end }
-
-test_ok Symbol.instance_methods.include?('to_proc')
-class SymTest
- attr_accessor :call_parameters
- def call(*args)
- self.call_parameters = args
- end
-end
-
-s = SymTest.new
-[s].each &:call
-test_equal [], s.call_parameters
-
-#test_exception ArgumentError, &:call
-
-test_equal 3, (:+).to_proc.call(1,2)
View
@@ -0,0 +1,19 @@
+require 'test/unit'
+
+class TestFixnum19 < Test::Unit::TestCase
+ def test_even?
+ assert 0.even?
+ assert 2.even?
+ end
+
+ def test_odd?
+ assert 1.odd?
+ assert -1.odd?
+ end
+
+ def test_pred
+ assert_equal 1, 2.pred
+ assert_equal 0, 1.pred
+ assert_equal -1, 0.pred
+ end
+end
View
@@ -0,0 +1,17 @@
+require 'test/unit'
+
+class TestInteger19 < Test::Unit::TestCase
+ def test_even?
+ assert 1000000000000000000000000000000.even?
+ end
+
+ def test_odd?
+ 1000000000000000000000000000001.odd?
+ end
+
+ def test_pred
+ assert_equal 10000000000000000000000000000001, 10000000000000000000000000000002.pred
+ assert_equal 10000000000000000000000000000000, 10000000000000000000000000000001.pred
+ assert_equal 9999999999999999999999999999999, 10000000000000000000000000000000.pred
+ end
+end
View
@@ -471,7 +471,7 @@ def test_null_open_windows
def test_file_constants_included
assert IO.include?(File::Constants)
- assert_equal ["APPEND", "BINARY", "CREAT", "EXCL", "Enumerator", "FNM_CASEFOLD",
+ assert_equal ["APPEND", "BINARY", "CREAT", "EXCL", "FNM_CASEFOLD",
"FNM_DOTMATCH", "FNM_NOESCAPE", "FNM_PATHNAME", "FNM_SYSCASE",
"LOCK_EX", "LOCK_NB", "LOCK_SH", "LOCK_UN", "NOCTTY", "NONBLOCK",
"RDONLY", "RDWR", "SEEK_CUR", "SEEK_END", "SEEK_SET", "SYNC", "TRUNC",
View
@@ -0,0 +1,25 @@
+require 'test/unit'
+
+class TestObject19 < Test::Unit::TestCase
+ def test_tap
+ value = nil
+ 1.tap { |v| value = v }
+ assert_equal 1, value
+
+ [].tap { |v| value = v }
+ assert_equal [], value
+
+ assert_equal 1, 1.tap { }
+
+ obj = Object.new
+
+ assert_equal obj, obj.tap { }
+
+ assert_equal "str", "str".tap { value = "foo" }
+ assert_equal "foo", value
+
+ assert_raises(LocalJumpError) do
+ "str".tap
+ end
+ end
+end
View
@@ -0,0 +1,20 @@
+require 'test/unit'
+
+class TestSymbol19 < Test::Unit::TestCase
+ class SymTest
+ attr_accessor :call_parameters
+ def call(*args)
+ self.call_parameters = args
+ end
+ end
+
+ def test_to_proc
+ assert Symbol.instance_methods.include?('to_proc')
+
+ s = SymTest.new
+ [s].each &:call
+ assert_equal [], s.call_parameters
+
+ assert_equal 3, (:+).to_proc.call(1,2)
+ end
+end

0 comments on commit 40a7309

Please sign in to comment.