Sha256: 32e1aee6b42b71bbf772c2a680d5a9e98446016008f57ff9ddb845c74541940f
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
# encoding: UTF-8 # frozen_string_literal: true require_relative "helper" class ArrayTweaksTest < Test::Unit::TestCase def test_drop_last x = [1, 2, 3, 4] y = x.drop_last assert_equal [1, 2, 3], y assert_not_same x, y x = [1, 2, 3, 4] assert_equal 4, x.drop_last! assert_equal [1, 2, 3], x assert_same x, x x = [] assert_equal [], x.drop_last x = [] assert_nil x.drop_last! end def test_each_with_index_and_size x_outer = 1 i_outer = 0 (1..5).to_a.each_with_index_and_size do |x, i, s| assert_equal x_outer, x assert_equal i_outer, i assert_equal 5, s x_outer += 1 i_outer += 1 end end def test_each_after array = [] (1..5).to_a.each_after(3) { |x| array << x } assert_equal [4, 5], array array = [] (1..5).to_a.each_after(0) { |x| array << x } assert_equal [1, 2, 3, 4, 5], array end def test_map_key assert_equal ["a", "b", nil, "c"], [{ k: "a" }, { k: "b" }, {}, { k: "c" }].map_key(:k) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
array-tweaks-1.0.2 | test/test-array-tweaks.rb |