Class: TestArray
- Defined in:
- lib/innate/test/testarray.rb
Instance Method Summary collapse
- #test_array_with_nil ⇒ Object
- #test_columns ⇒ Object
- #test_empty_array ⇒ Object
- #test_long_element ⇒ Object
- #test_match_regexp ⇒ Object
- #test_match_string ⇒ Object
- #test_nil_array ⇒ Object
- #test_one_element ⇒ Object
- #test_rows ⇒ Object
Instance Method Details
#test_array_with_nil ⇒ Object
129 130 131 132 133 |
# File 'lib/innate/test/testarray.rb', line 129 def test_array_with_nil a = [1, nil, 3, nil] assert_equal '1 3', a.columns(80, 2, ' ') assert_equal '1 3', a.rows(80, 2, ' ') end |
#test_columns ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/innate/test/testarray.rb', line 64 def test_columns a = %w{ % & * ** + +@ - -@ / < << <= <=> == === =~ > >= >> [] ^ __id__ __send__ abs between? ceil chr class clone coerce denominator display div divmod downto dup eql? equal? extend floor freeze frozen? gcd gcd2 gcdlcm hash id id2name inspect instance_eval instance_of? instance_variable_get instance_variable_set instance_variables integer? is_a? kind_of? lcm method methods modulo next nil? nonzero? numerator object_id power! prec prec_f prec_i private_methods protected_methods public_methods quo rdiv remainder require require_gem require_gem_with_options respond_to? round rpower send singleton_method_added singleton_methods size step succ taint tainted? times to_a to_bn to_f to_i to_int to_r to_s to_sym truncate type untaint upto zero? | ~} s = ["% === clone gcd kind_of? private_methods singleton_methods to_sym\n", "& =~ coerce gcd2 lcm protected_methods size truncate\n", "* > denominator gcdlcm method public_methods step type\n", "** >= display hash methods quo succ untaint\n", "+ >> div id modulo rdiv taint upto\n", "+@ [] divmod id2name next remainder tainted? zero?\n", "- ^ downto inspect nil? require times |\n", "-@ __id__ dup instance_eval nonzero? require_gem to_a ~\n", "/ __send__ eql? instance_of? numerator require_gem_with_options to_bn\n", "< abs equal? instance_variable_get object_id respond_to? to_f\n", "<< between? extend instance_variable_set power! round to_i\n", "<= ceil floor instance_variables prec rpower to_int\n", "<=> chr freeze integer? prec_f send to_r\n", "== class frozen? is_a? prec_i singleton_method_added to_s"].to_cursor a.columns(130, 2, ' ').each_line do |l| assert_equal s.read1next, l end end |
#test_empty_array ⇒ Object
104 105 106 107 108 |
# File 'lib/innate/test/testarray.rb', line 104 def test_empty_array a = [] assert_equal '', a.columns(80, 2, ' ') assert_equal '', a.rows(80, 2, ' ') end |
#test_long_element ⇒ Object
116 117 118 119 120 |
# File 'lib/innate/test/testarray.rb', line 116 def test_long_element a = ['hello', 'this is a rather long one'] assert_equal "hello\nthis is a rather long one", a.columns(15, 2, ' ') assert_equal "hello\nthis is a rather long one", a.rows(15, 2, ' ') end |
#test_match_regexp ⇒ Object
12 13 14 15 16 17 |
# File 'lib/innate/test/testarray.rb', line 12 def test_match_regexp assert ['aoeu', /z/, /a/].match?('claw') assert [/yes/, 'no', /no/].match?('yes') assert [/yes/, 'no', /no/].match?('no') assert_nil ['aoeu', /z/, /a/].match?('xxxx') end |
#test_match_string ⇒ Object
6 7 8 9 10 |
# File 'lib/innate/test/testarray.rb', line 6 def test_match_string assert ['hello', 'bye'].match?('bye') assert ['something', 'aoeu'].match?('something') assert_nil ['ueao', ';e', 'ueo'].match?('zzzzz') end |
#test_nil_array ⇒ Object
123 124 125 126 127 |
# File 'lib/innate/test/testarray.rb', line 123 def test_nil_array a = [nil] assert_equal '', a.columns(80, 2, ' ') assert_equal '', a.rows(80, 2, ' ') end |
#test_one_element ⇒ Object
110 111 112 113 114 |
# File 'lib/innate/test/testarray.rb', line 110 def test_one_element a = ['hello'] assert_equal 'hello', a.columns(80, 2, ' ') assert_equal 'hello', a.rows(80, 2, ' ') end |
#test_rows ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/innate/test/testarray.rb', line 19 def test_rows a = %w{ % & * ** + +@ - -@ / < << <= <=> == === =~ > >= >> [] ^ __id__ __send__ abs between? ceil chr class clone coerce denominator display div divmod downto dup eql? equal? extend floor freeze frozen? gcd gcd2 gcdlcm hash id id2name inspect instance_eval instance_of? instance_variable_get instance_variable_set instance_variables integer? is_a? kind_of? lcm method methods modulo next nil? nonzero? numerator object_id power! prec prec_f prec_i private_methods protected_methods public_methods quo rdiv remainder require require_gem require_gem_with_options respond_to? round rpower send singleton_method_added singleton_methods size step succ taint tainted? times to_a to_bn to_f to_i to_int to_r to_s to_sym truncate type untaint upto zero? | ~} s = ["% & * ** + +@\n", "- -@ / < << <=\n", "<=> == === =~ > >=\n", ">> [] ^ __id__ __send__ abs\n", "between? ceil chr class clone coerce\n", "denominator display div divmod downto dup\n", "eql? equal? extend floor freeze frozen?\n", "gcd gcd2 gcdlcm hash id id2name\n", "inspect instance_eval instance_of? instance_variable_get instance_variable_set instance_variables\n", "integer? is_a? kind_of? lcm method methods\n", "modulo next nil? nonzero? numerator object_id\n", "power! prec prec_f prec_i private_methods protected_methods\n", "public_methods quo rdiv remainder require require_gem\n", "require_gem_with_options respond_to? round rpower send singleton_method_added\n", "singleton_methods size step succ taint tainted?\n", "times to_a to_bn to_f to_i to_int\n", "to_r to_s to_sym truncate type untaint\n", "upto zero? | ~"].to_cursor a.rows(130, 2, ' ').each_line do |l| assert_equal s.read1next, l end end |