test/console.rb in console-0.1 vs test/console.rb in console-0.2

- old
+ new

@@ -12,79 +12,79 @@ def setup @s = "能吞aê" end def test_slice_of_zero_width_is_empty_string - assert_equal "", Console.slice(@s, 0, 0) - assert_equal "", Console.slice(@s, 1, 0) + assert_equal "", Console.display_slice(@s, 0, 0) + assert_equal "", Console.display_slice(@s, 1, 0) end def test_slice_out_of_bounds_is_nil - assert_equal nil, Console.slice(@s, 100, 3) - assert_equal nil, Console.slice(@s, -100, 3) + assert_equal nil, Console.display_slice(@s, 100, 3) + assert_equal nil, Console.display_slice(@s, -100, 3) end def test_slice_with_negative_offset - assert_equal "ê", Console.slice(@s, -1, 1) - assert_equal "aê", Console.slice(@s, -2, 2) - assert_equal "a", Console.slice(@s, -2, 1) + assert_equal "ê", Console.display_slice(@s, -1, 1) + assert_equal "aê", Console.display_slice(@s, -2, 2) + assert_equal "a", Console.display_slice(@s, -2, 1) end def test_slice_width_argument_defaults_to_1 - assert_equal "ê", Console.slice(@s, -1) - assert_equal "a", Console.slice(@s, -2) + assert_equal "ê", Console.display_slice(@s, -1) + assert_equal "a", Console.display_slice(@s, -2) end def test_slice_works_on_chinese_characters - assert_equal "能", Console.slice(@s, 0, 2); - assert_equal "能吞", Console.slice(@s, 0, 4); - assert_equal "能吞a", Console.slice(@s, 0, 5); - assert_equal "能吞aê", Console.slice(@s, 0, 6); + assert_equal "能", Console.display_slice(@s, 0, 2); + assert_equal "能吞", Console.display_slice(@s, 0, 4); + assert_equal "能吞a", Console.display_slice(@s, 0, 5); + assert_equal "能吞aê", Console.display_slice(@s, 0, 6); end def test_slice_with_excessive_width_is_still_cool - assert_equal "能吞aê", Console.slice(@s, 0, 100); - assert_equal "吞aê", Console.slice(@s, 2, 100); - assert_equal "aê", Console.slice(@s, 4, 100); - assert_equal "ê", Console.slice(@s, 5, 100); - assert_equal "", Console.slice(@s, 6, 100); # yep, we get a non-nil at this value - assert_equal nil, Console.slice(@s, 7, 100); + assert_equal "能吞aê", Console.display_slice(@s, 0, 100); + assert_equal "吞aê", Console.display_slice(@s, 2, 100); + assert_equal "aê", Console.display_slice(@s, 4, 100); + assert_equal "ê", Console.display_slice(@s, 5, 100); + assert_equal "", Console.display_slice(@s, 6, 100); # yep, we get a non-nil at this value + assert_equal nil, Console.display_slice(@s, 7, 100); end def test_slice_with_the_biggest_valid_start_offset_behaves_like_String_slice_does - assert_equal "", Console.slice(@s, 6, 100); - assert_equal "", Console.slice(@s, 6, 0); - assert_equal nil, Console.slice(@s, 6, -1); + assert_equal "", Console.display_slice(@s, 6, 100); + assert_equal "", Console.display_slice(@s, 6, 0); + assert_equal nil, Console.display_slice(@s, 6, -1); end def test_slice_misaligned_start_offsets_get_padded s = "能吞aê" - assert_equal "", Console.slice(@s, 0, 0) - assert_equal " ", Console.slice(@s, 0, 1) - assert_equal "能", Console.slice(@s, 0, 2) - assert_equal "能 ", Console.slice(@s, 0, 3) + assert_equal "", Console.display_slice(@s, 0, 0) + assert_equal " ", Console.display_slice(@s, 0, 1) + assert_equal "能", Console.display_slice(@s, 0, 2) + assert_equal "能 ", Console.display_slice(@s, 0, 3) - assert_equal "", Console.slice(@s, 1, 0) - assert_equal " ", Console.slice(@s, 1, 1) - assert_equal " ", Console.slice(@s, 1, 2) - assert_equal " 吞", Console.slice(@s, 1, 3) + assert_equal "", Console.display_slice(@s, 1, 0) + assert_equal " ", Console.display_slice(@s, 1, 1) + assert_equal " ", Console.display_slice(@s, 1, 2) + assert_equal " 吞", Console.display_slice(@s, 1, 3) - assert_equal "", Console.slice(@s, 3, 0); - assert_equal " ", Console.slice(@s, 3, 1); - assert_equal " a", Console.slice(@s, 3, 2); - assert_equal " aê", Console.slice(@s, 3, 3); + assert_equal "", Console.display_slice(@s, 3, 0); + assert_equal " ", Console.display_slice(@s, 3, 1); + assert_equal " a", Console.display_slice(@s, 3, 2); + assert_equal " aê", Console.display_slice(@s, 3, 3); end def test_slice_misaligned_start_offsets_get_padded_with_specified_character - assert_equal "", Console.slice(@s, 0, 0, "X") - assert_equal "X", Console.slice(@s, 0, 1, "X") - assert_equal "XX", Console.slice(@s, 1, 2, "X") + assert_equal "", Console.display_slice(@s, 0, 0, "X") + assert_equal "X", Console.display_slice(@s, 0, 1, "X") + assert_equal "XX", Console.display_slice(@s, 1, 2, "X") end def test_slice_fails_on_nonstrings - assert_raises(TypeError) { Console.slice :potato, 1, 1 } - assert_raises(TypeError) { Console.slice 3, 1, 1 } + assert_raises(TypeError) { Console.display_slice :potato, 1, 1 } + assert_raises(TypeError) { Console.display_slice 3, 1, 1 } end def test_display_width_empty_string_is_zero assert_equal 0, Console.display_width("") end