summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--enumerator.c2
-rw-r--r--test/ruby/test_arithmetic_sequence.rb8
2 files changed, 10 insertions, 0 deletions
diff --git a/enumerator.c b/enumerator.c
index 66c126d409..9e48fddae3 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -2844,6 +2844,8 @@ InitVM_Enumerator(void)
/* ArithmeticSequence */
rb_cArithSeq = rb_define_class_under(rb_cEnumerator, "ArithmeticSequence", rb_cEnumerator);
+ rb_undef_alloc_func(rb_cArithSeq);
+ rb_undef_method(CLASS_OF(rb_cArithSeq), "new");
rb_define_method(rb_cArithSeq, "begin", arith_seq_begin, 0);
rb_define_method(rb_cArithSeq, "end", arith_seq_end, 0);
rb_define_method(rb_cArithSeq, "exclude_end?", arith_seq_exclude_end, 0);
diff --git a/test/ruby/test_arithmetic_sequence.rb b/test/ruby/test_arithmetic_sequence.rb
index fe1af362f4..fcabc8a8c7 100644
--- a/test/ruby/test_arithmetic_sequence.rb
+++ b/test/ruby/test_arithmetic_sequence.rb
@@ -2,6 +2,14 @@
require 'test/unit'
class TestArithmeticSequence < Test::Unit::TestCase
+ def test_new
+ assert_raise(NoMethodError) { Enumerator::ArithmeticSequence.new }
+ end
+
+ def test_allocate
+ assert_raise(TypeError) { Enumerator::ArithmeticSequence.allocate }
+ end
+
def test_begin
assert_equal(1, 1.step.begin)
assert_equal(1, 1.step(10).begin)