Class: TestArray

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/innate/test/testarray.rb

Instance Method Summary collapse

Instance Method Details

#test_columnsObject



60
61
62
63
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
# File 'lib/innate/test/testarray.rb', line 60

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                       "

  assert_equal s, a.columns(130, 2, ' ')
end

#test_match_regexpObject



11
12
13
14
15
16
# File 'lib/innate/test/testarray.rb', line 11

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_stringObject



5
6
7
8
9
# File 'lib/innate/test/testarray.rb', line 5

def test_match_string
  assert ['hello', 'bye'].match?('bye')
  assert ['something', 'aoeu'].match?('something')
  assert_nil ['ueao', ';e', 'ueo'].match?('zzzzz')
end

#test_rowsObject



18
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
# File 'lib/innate/test/testarray.rb', line 18

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?          |             ~                                                                   "

  assert_equal s, a.rows(130, 2, ' ')
end