diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 02:57:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 02:57:58 +0000 |
commit | be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97 (patch) | |
tree | 9754ff1ca740f6346cf8483ec915d4054bc5da2d /web/server/h2o/libh2o/deps/mruby/test/t/range.rb | |
parent | Initial commit. (diff) | |
download | netdata-be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97.tar.xz netdata-be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97.zip |
Adding upstream version 1.44.3.upstream/1.44.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/server/h2o/libh2o/deps/mruby/test/t/range.rb')
-rw-r--r-- | web/server/h2o/libh2o/deps/mruby/test/t/range.rb | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/web/server/h2o/libh2o/deps/mruby/test/t/range.rb b/web/server/h2o/libh2o/deps/mruby/test/t/range.rb new file mode 100644 index 00000000..5391369d --- /dev/null +++ b/web/server/h2o/libh2o/deps/mruby/test/t/range.rb @@ -0,0 +1,95 @@ +## +# Range ISO Test + +assert('Range', '15.2.14') do + assert_equal Class, Range.class +end + +assert('Range#==', '15.2.14.4.1') do + assert_true (1..10) == (1..10) + assert_false (1..10) == (1..100) + assert_true (1..10) == Range.new(1.0, 10.0) +end + +assert('Range#===', '15.2.14.4.2') do + a = (1..10) + + assert_true a === 5 + assert_false a === 20 +end + +assert('Range#begin', '15.2.14.4.3') do + assert_equal 1, (1..10).begin +end + +assert('Range#each', '15.2.14.4.4') do + a = (1..3) + b = 0 + a.each {|i| b += i} + assert_equal 6, b +end + +assert('Range#end', '15.2.14.4.5') do + assert_equal 10, (1..10).end +end + +assert('Range#exclude_end?', '15.2.14.4.6') do + assert_true (1...10).exclude_end? + assert_false (1..10).exclude_end? +end + +assert('Range#first', '15.2.14.4.7') do + assert_equal 1, (1..10).first +end + +assert('Range#include?', '15.2.14.4.8') do + assert_true (1..10).include?(10) + assert_false (1..10).include?(11) + + assert_true (1...10).include?(9) + assert_false (1...10).include?(10) +end + +assert('Range#initialize', '15.2.14.4.9') do + a = Range.new(1, 10, true) + b = Range.new(1, 10, false) + + assert_equal (1...10), a + assert_true a.exclude_end? + assert_equal (1..10), b + assert_false b.exclude_end? + + assert_raise(NameError) { (0..1).send(:initialize, 1, 3) } +end + +assert('Range#last', '15.2.14.4.10') do + assert_equal 10, (1..10).last +end + +assert('Range#member?', '15.2.14.4.11') do + a = (1..10) + + assert_true a.member?(5) + assert_false a.member?(20) +end + +assert('Range#to_s', '15.2.14.4.12') do + assert_equal "0..1", (0..1).to_s + assert_equal "0...1", (0...1).to_s + assert_equal "a..b", ("a".."b").to_s + assert_equal "a...b", ("a"..."b").to_s +end + +assert('Range#inspect', '15.2.14.4.13') do + assert_equal "0..1", (0..1).inspect + assert_equal "0...1", (0...1).inspect + assert_equal "\"a\"..\"b\"", ("a".."b").inspect + assert_equal "\"a\"...\"b\"", ("a"..."b").inspect +end + +assert('Range#eql?', '15.2.14.4.14') do + assert_true (1..10).eql? (1..10) + assert_false (1..10).eql? (1..100) + assert_false (1..10).eql? (Range.new(1.0, 10.0)) + assert_false (1..10).eql? "1..10" +end |