This class checks only the translate_sql_to_code method
Methods
- setup
- test_array_sort_by
- test_array_sort_by!
- test_array_stable_sort
- test_array_stable_sort_by
- test_object_in
Public Instance methods
[ show source ]
# File test/kb_stdlib_extensions_test.rb, line 6
6: def setup
7: @num_array = [2,4,6,3,5,1]
8: @string_array = ['az', 'cx', 'by', 'dw']
9: @rec_array = [['c', 2], ['a', 2], ['d', 1], ['b', 1]]
10: end
[ show source ]
# File test/kb_stdlib_extensions_test.rb, line 12
12: def test_array_sort_by
13: assert_equal [1,2,3,4,5,6], @num_array.sort_by(:to_i)
14: assert_equal [1,2,3,4,5,6], @num_array.sort_by{|x| x.to_i}
15: assert_equal ['dw', 'cx', 'by', 'az'], @string_array.sort_by(:reverse)
16: assert_equal ['az', 'by', 'cx', 'dw'], @string_array.sort_by{|x| x[0..0]}
17: end
[ show source ]
# File test/kb_stdlib_extensions_test.rb, line 19
19: def test_array_sort_by!
20: @num_array.sort_by!(:to_i)
21: assert_equal [1,2,3,4,5,6], @num_array
22: end
[ show source ]
# File test/kb_stdlib_extensions_test.rb, line 24
24: def test_array_stable_sort
25: assert_equal [['a', 2], ['b', 1], ['c', 2], ['d', 1]], @rec_array.stable_sort
26: end
[ show source ]
# File test/kb_stdlib_extensions_test.rb, line 28
28: def test_array_stable_sort_by
29: assert_equal [['d', 1], ['b', 1], ['c', 2], ['a', 2]], @rec_array.stable_sort_by(:last)
30: end
[ show source ]
# File test/kb_stdlib_extensions_test.rb, line 32
32: def test_object_in
33: assert 1.in(@num_array)
34: assert !1.in(@string_array)
35: assert 1.in(1)
36: assert 1.in(1,2,3)
37: end