4 assert('Range', '15.2.14') do
5 assert_equal Class, Range.class
8 assert('Range#==', '15.2.14.4.1') do
9 assert_true (1..10) == (1..10)
10 assert_false (1..10) == (1..100)
11 skip unless Object.const_defined?(:Float)
12 assert_true (1..10) == Range.new(1.0, 10.0)
15 assert('Range#===', '15.2.14.4.2') do
22 assert('Range#begin', '15.2.14.4.3') do
23 assert_equal 1, (1..10).begin
26 assert('Range#each', '15.2.14.4.4') do
33 assert('Range#end', '15.2.14.4.5') do
34 assert_equal 10, (1..10).end
37 assert('Range#exclude_end?', '15.2.14.4.6') do
38 assert_true (1...10).exclude_end?
39 assert_false (1..10).exclude_end?
42 assert('Range#first', '15.2.14.4.7') do
43 assert_equal 1, (1..10).first
46 assert('Range#include?', '15.2.14.4.8') do
47 assert_true (1..10).include?(10)
48 assert_false (1..10).include?(11)
50 assert_true (1...10).include?(9)
51 assert_false (1...10).include?(10)
54 assert('Range#initialize', '15.2.14.4.9') do
55 a = Range.new(1, 10, true)
56 b = Range.new(1, 10, false)
58 assert_equal (1...10), a
59 assert_true a.exclude_end?
60 assert_equal (1..10), b
61 assert_false b.exclude_end?
63 assert_raise(NameError) { (0..1).__send__(:initialize, 1, 3) }
66 assert('Range#last', '15.2.14.4.10') do
67 assert_equal 10, (1..10).last
70 assert('Range#member?', '15.2.14.4.11') do
73 assert_true a.member?(5)
74 assert_false a.member?(20)
77 assert('Range#to_s', '15.2.14.4.12') do
78 assert_equal "0..1", (0..1).to_s
79 assert_equal "0...1", (0...1).to_s
80 assert_equal "a..b", ("a".."b").to_s
81 assert_equal "a...b", ("a"..."b").to_s
84 assert('Range#inspect', '15.2.14.4.13') do
85 assert_equal "0..1", (0..1).inspect
86 assert_equal "0...1", (0...1).inspect
87 assert_equal "\"a\"..\"b\"", ("a".."b").inspect
88 assert_equal "\"a\"...\"b\"", ("a"..."b").inspect
91 assert('Range#eql?', '15.2.14.4.14') do
92 assert_true (1..10).eql? (1..10)
93 assert_false (1..10).eql? (1..100)
94 assert_false (1..10).eql? (Range.new(1.0, 10.0))
95 assert_false (1..10).eql? "1..10"
98 assert('Range#initialize_copy', '15.2.14.4.15') do
99 assert_raise(NameError) { (0..1).__send__(:initialize_copy, 1..3) }
102 assert('Range#dup') do
104 assert_equal 1, r.begin
105 assert_equal 3, r.end
106 assert_false r.exclude_end?
109 assert_equal "a", r.begin
110 assert_equal "z", r.end
111 assert_true r.exclude_end?