facets 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. data/AUTHORS +3 -3
  2. data/README +6 -7
  3. data/lib/core/facets.rb +1 -46
  4. data/lib/core/facets/array.rb +3 -0
  5. data/lib/core/facets/array/indexable.rb +6 -1
  6. data/lib/core/facets/array/only.rb +20 -0
  7. data/lib/core/facets/dir/multiglob.rb +12 -1
  8. data/lib/core/facets/enumerable.rb +0 -1
  9. data/lib/core/facets/enumerable/collect.rb +1 -0
  10. data/lib/core/facets/enumerable/combination.rb +44 -90
  11. data/lib/core/facets/facets.rb +46 -0
  12. data/lib/core/facets/file/write.rb +46 -58
  13. data/lib/core/facets/hash.rb +2 -0
  14. data/lib/core/facets/hash/select.rb +14 -0
  15. data/lib/core/facets/integer/multiples.rb +12 -55
  16. data/lib/core/facets/kernel/val.rb +14 -0
  17. data/lib/core/facets/module/alias.rb +28 -9
  18. data/lib/core/facets/module/methods.rb +18 -0
  19. data/lib/core/facets/module/traits.rb +65 -70
  20. data/lib/core/facets/proc/compose.rb +15 -12
  21. data/lib/core/facets/stackable.rb +3 -2
  22. data/lib/core/facets/string/format.rb +4 -6
  23. data/lib/core/facets/string/tabs.rb +34 -0
  24. data/lib/core/facets/symbol.rb +1 -0
  25. data/lib/core/facets/symbol/succ.rb +1 -42
  26. data/lib/core/facets/symbol/to_proc.rb +34 -0
  27. data/lib/methods/facets/array/contains.rb +1 -0
  28. data/lib/methods/facets/facets/require_core.rb +1 -0
  29. data/lib/methods/facets/file/writelines.rb +1 -0
  30. data/lib/methods/facets/io/writelines.rb +1 -0
  31. data/lib/methods/facets/kernel/not_nil.rb +1 -0
  32. data/lib/methods/facets/module/conflict.rb +1 -0
  33. data/lib/methods/facets/module/instance_method_defined.rb +1 -0
  34. data/lib/methods/facets/module/module_method_defined.rb +1 -0
  35. data/lib/methods/facets/module/private_conflict.rb +1 -0
  36. data/lib/methods/facets/module/protected_conflict.rb +1 -0
  37. data/lib/methods/facets/module/public_conflict.rb +1 -0
  38. data/lib/methods/facets/string/expand_tabs.rb +1 -0
  39. data/lib/methods/facets/string/outdent.rb +1 -0
  40. data/lib/methods/facets/string/taballto.rb +1 -0
  41. data/lib/more/facets/arguments.rb +1 -1
  42. data/lib/more/facets/association.rb +0 -46
  43. data/lib/more/facets/autoarray.rb +0 -28
  44. data/lib/more/facets/command.rb +341 -8
  45. data/lib/more/facets/dictionary.rb +25 -131
  46. data/lib/more/facets/downloader.rb +1 -1
  47. data/lib/more/facets/infinity.rb +3 -3
  48. data/lib/more/facets/interval.rb +0 -161
  49. data/lib/more/facets/multiton.rb +16 -12
  50. data/lib/more/facets/namespace.rb +1 -1
  51. data/lib/more/facets/ostruct.rb +46 -10
  52. data/lib/more/facets/overload.rb +0 -51
  53. data/lib/more/facets/paramix.rb +0 -97
  54. data/lib/more/facets/pp_s.rb +30 -0
  55. data/lib/more/facets/progressbar.rb +18 -10
  56. data/lib/more/facets/prototype.rb +1 -40
  57. data/lib/more/facets/random.rb +1 -0
  58. data/lib/more/facets/rbsystem.rb +4 -1
  59. data/lib/more/facets/snapshot.rb +8 -1
  60. data/lib/more/facets/stylize.rb +2 -0
  61. data/meta/{project.yaml → facets-2.0.3.roll} +22 -14
  62. data/meta/manifest.txt +38 -8
  63. data/task/{config.yaml → config/general.yaml} +7 -2
  64. data/task/{rdoc.yaml → config/rdoc.yaml} +1 -1
  65. data/task/crosstest +309 -0
  66. data/task/isotest +293 -0
  67. data/task/loadtest +28 -0
  68. data/task/methods +4 -4
  69. data/task/prepare +5 -0
  70. data/task/publish +2 -2
  71. data/task/rdoc +1 -0
  72. data/task/syntax +29 -0
  73. data/task/test +0 -1
  74. data/task/testeach +42 -0
  75. data/task/testpairs +50 -0
  76. data/test/lib/rq.rb +15 -0
  77. data/test/unit/array/test_merge.rb +21 -43
  78. data/test/unit/array/test_only.rb +21 -0
  79. data/test/unit/enumerable/test_collect.rb +1 -21
  80. data/test/unit/enumerable/test_combination.rb +50 -44
  81. data/test/unit/file/test_topath.rb +48 -57
  82. data/test/unit/file/test_write.rb +82 -0
  83. data/test/unit/hash/test_select.rb +43 -0
  84. data/test/unit/integer/test_multiples.rb +28 -32
  85. data/test/unit/kernel/test_report.rb +9 -12
  86. data/test/unit/kernel/test_val.rb +50 -45
  87. data/test/unit/module/test_include.rb +56 -57
  88. data/test/unit/module/test_name.rb +42 -55
  89. data/test/unit/module/test_traits.rb +46 -47
  90. data/test/unit/string/test_filter.rb +19 -34
  91. data/test/unit/string/test_format.rb +87 -96
  92. data/test/unit/string/test_regesc.rb +18 -26
  93. data/test/unit/string/test_tabs.rb +226 -119
  94. data/test/unit/symbol/test_succ.rb +14 -23
  95. data/test/unit/symbol/test_to_proc.rb +41 -0
  96. data/test/unit/test_association.rb +38 -47
  97. data/test/unit/test_attributes.rb +24 -33
  98. data/test/unit/test_autoarray.rb +23 -32
  99. data/test/unit/test_command.rb +26 -0
  100. data/test/unit/test_dictionary.rb +123 -117
  101. data/test/unit/test_infinity.rb +41 -47
  102. data/test/unit/test_inheritor.rb +133 -142
  103. data/test/unit/test_interval.rb +129 -93
  104. data/test/unit/test_ostruct.rb +148 -101
  105. data/test/unit/test_overload.rb +8 -15
  106. data/test/unit/test_paramix.rb +67 -73
  107. data/test/unit/test_pp_s.rb +23 -0
  108. data/test/unit/test_prototype.rb +28 -38
  109. metadata +47 -11
  110. data/lib/core/facets/enumerable/instance_map.rb +0 -0
  111. data/lib/more/facets/command_options.rb +0 -328
  112. data/meta/version.txt +0 -1
  113. data/task/load +0 -39
  114. data/test/unit/test_command_options.rb +0 -29
@@ -1,52 +1,51 @@
1
- # _____ _
2
- # |_ _|__ ___| |_
3
- # | |/ _ \/ __| __|
4
- # | | __/\__ \ |
5
- # |_|\___||___/\__|
6
- #
7
- # for lib/facets/module/traits.rb
8
- #
9
- # Extracted Mon Sep 03 16:23:07 -0700 2007
10
- # w/ Test Extraction Ratchet
11
- #
12
-
13
- require 'facets/module/traits.rb'
14
-
15
-
16
-
17
- require 'test/unit'
18
-
19
- class TestModuleTraits < Test::Unit::TestCase
20
-
21
- module A
22
- def x; "x"; end
23
- def z; "zA"; end
24
- end
25
-
26
- module B
27
- def y; "y"; end
28
- def z; "zB"; end
29
- end
30
-
31
- Q = A + B
32
- R = A - B
33
-
34
- def test_add
35
- assert(Q)
36
- Q.extend Q
37
- assert_equal( "x", Q.x )
38
- assert_equal( "y", Q.y )
39
- assert_equal( "zB", Q.z )
40
- end
41
-
42
- def test_minus
43
- assert(R)
44
- R.extend R
45
- assert_equal( "x", R.x )
46
- assert_raises( NoMethodError ){ R.z }
47
- end
1
+ # _____ _
2
+ # |_ _|__ ___| |_
3
+ # | |/ _ \/ __| __|
4
+ # | | __/\__ \ |
5
+ # |_|\___||___/\__|
6
+ #
48
7
 
8
+ require 'facets/module/traits.rb'
9
+
10
+ require 'test/unit'
11
+
12
+ class TestModuleTraits < Test::Unit::TestCase
13
+
14
+ module A
15
+ def x; "x"; end
16
+ def z; "zA"; end
17
+ end
18
+
19
+ module B
20
+ def y; "y"; end
21
+ def z; "zB"; end
49
22
  end
50
23
 
24
+ Q = A + B
25
+ R = A - B
26
+ Z = A * { :x => :y }
51
27
 
28
+ def test_add
29
+ assert(Q)
30
+ Q.extend Q
31
+ assert_equal( "x", Q.x )
32
+ assert_equal( "y", Q.y )
33
+ assert_equal( "zB", Q.z )
34
+ end
35
+
36
+ def test_minus
37
+ assert(R)
38
+ R.extend R
39
+ assert_equal( "x", R.x )
40
+ assert_raises(NoMethodError){ R.z }
41
+ end
42
+
43
+ def test_rename
44
+ assert(Z)
45
+ Z.extend Z
46
+ assert_raise(NoMethodError){ Z.x }
47
+ assert_equal( "x", Z.y )
48
+ assert_equal( "zA", Z.z )
49
+ end
52
50
 
51
+ end
@@ -1,42 +1,27 @@
1
- # _____ _
2
- # |_ _|__ ___| |_
3
- # | |/ _ \/ __| __|
4
- # | | __/\__ \ |
5
- # |_|\___||___/\__|
6
- #
7
- # for lib/facets/string/filter.rb
8
- #
9
- # Extracted Mon Sep 03 16:23:07 -0700 2007
10
- # w/ Test Extraction Ratchet
11
- #
1
+ # _____ _
2
+ # |_ _|__ ___| |_
3
+ # | |/ _ \/ __| __|
4
+ # | | __/\__ \ |
5
+ # |_|\___||___/\__|
6
+ #
12
7
 
13
- require 'facets/string/filter.rb'
8
+ require 'facets/string/filter.rb'
14
9
 
10
+ require 'test/unit'
15
11
 
12
+ class TestStringFilter < Test::Unit::TestCase
16
13
 
17
- require 'test/unit'
18
-
19
- class TestStringFilter < Test::Unit::TestCase
20
-
21
- def test_regesc
22
- a = "?"
23
- b = /#{a.regesc}/
24
- assert( b =~ "?" )
25
- end
26
-
27
- def test_word_filter
28
- s = "this is a test"
29
- n = s.word_filter{ |w| "#{w}1" }
30
- assert_equal( 'this1 is1 a1 test1', n )
31
- end
32
-
33
- def test_word_filter!
34
- s = "this is a test"
35
- s.word_filter!{ |w| "#{w}1" }
36
- assert_equal( 'this1 is1 a1 test1', s )
37
- end
38
-
14
+ def test_word_filter
15
+ s = "this is a test"
16
+ n = s.word_filter{ |w| "#{w}1" }
17
+ assert_equal( 'this1 is1 a1 test1', n )
39
18
  end
40
19
 
20
+ def test_word_filter!
21
+ s = "this is a test"
22
+ s.word_filter!{ |w| "#{w}1" }
23
+ assert_equal( 'this1 is1 a1 test1', s )
24
+ end
41
25
 
26
+ end
42
27
 
@@ -1,96 +1,87 @@
1
- # _____ _
2
- # |_ _|__ ___| |_
3
- # | |/ _ \/ __| __|
4
- # | | __/\__ \ |
5
- # |_|\___||___/\__|
6
- #
7
- # for lib/facets/string/format.rb
8
- #
9
- # Extracted Mon Sep 03 16:23:07 -0700 2007
10
- # w/ Test Extraction Ratchet
11
- #
12
-
13
- require 'facets/string/format.rb'
14
-
15
-
16
-
17
- require 'test/unit'
18
-
19
- class TestStringFormat < Test::Unit::TestCase
20
-
21
- def test_fold_1
22
- s = "This is\na test.\n\nIt clumps\nlines of text."
23
- o = "This is a test.\n\nIt clumps lines of text."
24
- assert_equal( o, s.fold )
25
- end
26
-
27
- def test_fold_2
28
- s = "This is\na test.\n\n This is pre.\n Leave alone.\n\nIt clumps\nlines of text."
29
- o = "This is a test.\n\n This is pre.\n Leave alone.\n\nIt clumps lines of text."
30
- assert_equal( o, s.fold(true) )
31
- end
32
-
33
- def test_line_wrap
34
- assert_equal "abc\n123\n", "abc123".line_wrap(3)
35
- assert_equal "abcd\n123\n", "abcd123".line_wrap(4)
36
- end
37
-
38
- def test_word_wrap
39
- assert_equal "abcde\n12345\nxyzwu\n", "abcde 12345 xyzwu".word_wrap(5)
40
- assert_equal "abcd\n1234\nxyzw\n", "abcd 1234 xyzw".word_wrap(4)
41
- assert_equal "abc\n123\n", "abc 123".word_wrap(4)
42
- assert_equal "abc \n123\n", "abc 123".word_wrap(4)
43
- assert_equal "abc \n123\n", "abc 123".word_wrap(4)
44
- end
45
-
46
- def test_word_wrap!
47
- w = "abcde 12345 xyzwu" ; w.word_wrap!(5)
48
- assert_equal("abcde\n12345\nxyzwu\n", w)
49
- w = "abcd 1234 xyzw" ; w.word_wrap!(4)
50
- assert_equal("abcd\n1234\nxyzw\n", w)
51
- w = "abc 123" ; w.word_wrap!(4)
52
- assert_equal "abc\n123\n", w
53
- w = "abc 123" ; w.word_wrap!(4)
54
- assert_equal("abc \n123\n", w)
55
- w = "abc 123" ; w.word_wrap!(4)
56
- assert_equal("abc \n123\n", w)
57
- end
58
-
59
- # def test_word_wrap
60
- # assert_equal "abcde-\n12345-\nxyzwu\n", "abcde12345xyzwu".word_wrap(6,2)
61
- # assert_equal "abcd-\n1234-\nxyzw\n", "abcd1234xyzw".word_wrap(5,2)
62
- # assert_equal "abc \n123\n", "abc 123".word_wrap(4,2)
63
- # assert_equal "abc \n123\n", "abc 123".word_wrap(4,2)
64
- # assert_equal "abc \n123\n", "abc 123".word_wrap(4,2)
65
- # end
66
-
67
- def test_cleave_nospaces
68
- assert_equal [ 'whole', '' ], 'whole'.cleave
69
- assert_equal [ 'Supercalifragilisticexpialidocious', '' ],
70
- 'Supercalifragilisticexpialidocious'.cleave
71
- end
72
-
73
- def test_cleave_exact_middle
74
- assert_equal [ 'fancy', 'split' ], 'fancy split'.cleave
75
- assert_equal [ 'All good Rubyists', 'know how to party' ],
76
- 'All good Rubyists know how to party'.cleave
77
- end
78
-
79
- def test_cleave_closer_to_start
80
- assert_equal [ 'short', 'splitter' ], 'short splitter'.cleave
81
- assert_equal [ 'Four score and', 'seven years ago...' ],
82
- 'Four score and seven years ago...'.cleave
83
- assert_equal [ 'abc def', 'ghijklm nop' ],
84
- 'abc def ghijklm nop'.cleave
85
- end
86
-
87
- def test_cleave_closer_to_end
88
- assert_equal [ 'extended', 'split' ], 'extended split'.cleave
89
- assert_equal [ 'abc defghi', 'jklm nop' ],
90
- 'abc defghi jklm nop'.cleave
91
- end
92
-
93
- end
94
-
95
-
96
-
1
+ # _____ _
2
+ # |_ _|__ ___| |_
3
+ # | |/ _ \/ __| __|
4
+ # | | __/\__ \ |
5
+ # |_|\___||___/\__|
6
+ #
7
+ # for facets/string/format.rb
8
+
9
+ require 'facets/string/format.rb'
10
+
11
+ require 'test/unit'
12
+
13
+ class TestStringFormat < Test::Unit::TestCase
14
+
15
+ def test_fold_1
16
+ s = "This is\na test.\n\nIt clumps\nlines of text."
17
+ o = "This is a test.\n\nIt clumps lines of text."
18
+ assert_equal( o, s.fold )
19
+ end
20
+
21
+ def test_fold_2
22
+ s = "This is\na test.\n\n This is pre.\n Leave alone.\n\nIt clumps\nlines of text."
23
+ o = "This is a test.\n\n This is pre.\n Leave alone.\n\nIt clumps lines of text."
24
+ assert_equal( o, s.fold(true) )
25
+ end
26
+
27
+ def test_line_wrap
28
+ assert_equal "abc\n123\n", "abc123".line_wrap(3)
29
+ assert_equal "abcd\n123\n", "abcd123".line_wrap(4)
30
+ end
31
+
32
+ def test_word_wrap
33
+ assert_equal "abcde\n12345\nxyzwu\n", "abcde 12345 xyzwu".word_wrap(5)
34
+ assert_equal "abcd\n1234\nxyzw\n", "abcd 1234 xyzw".word_wrap(4)
35
+ assert_equal "abc\n123\n", "abc 123".word_wrap(4)
36
+ assert_equal "abc \n123\n", "abc 123".word_wrap(4)
37
+ assert_equal "abc \n123\n", "abc 123".word_wrap(4)
38
+ end
39
+
40
+ def test_word_wrap!
41
+ w = "abcde 12345 xyzwu" ; w.word_wrap!(5)
42
+ assert_equal("abcde\n12345\nxyzwu\n", w)
43
+ w = "abcd 1234 xyzw" ; w.word_wrap!(4)
44
+ assert_equal("abcd\n1234\nxyzw\n", w)
45
+ w = "abc 123" ; w.word_wrap!(4)
46
+ assert_equal "abc\n123\n", w
47
+ w = "abc 123" ; w.word_wrap!(4)
48
+ assert_equal("abc \n123\n", w)
49
+ w = "abc 123" ; w.word_wrap!(4)
50
+ assert_equal("abc \n123\n", w)
51
+ end
52
+
53
+ # def test_word_wrap
54
+ # assert_equal "abcde-\n12345-\nxyzwu\n", "abcde12345xyzwu".word_wrap(6,2)
55
+ # assert_equal "abcd-\n1234-\nxyzw\n", "abcd1234xyzw".word_wrap(5,2)
56
+ # assert_equal "abc \n123\n", "abc 123".word_wrap(4,2)
57
+ # assert_equal "abc \n123\n", "abc 123".word_wrap(4,2)
58
+ # assert_equal "abc \n123\n", "abc 123".word_wrap(4,2)
59
+ # end
60
+
61
+ def test_cleave_nospaces
62
+ assert_equal [ 'whole', '' ], 'whole'.cleave
63
+ assert_equal [ 'Supercalifragilisticexpialidocious', '' ],
64
+ 'Supercalifragilisticexpialidocious'.cleave
65
+ end
66
+
67
+ def test_cleave_exact_middle
68
+ assert_equal [ 'fancy', 'split' ], 'fancy split'.cleave
69
+ assert_equal [ 'All good Rubyists', 'know how to party' ],
70
+ 'All good Rubyists know how to party'.cleave
71
+ end
72
+
73
+ def test_cleave_closer_to_start
74
+ assert_equal [ 'short', 'splitter' ], 'short splitter'.cleave
75
+ assert_equal [ 'Four score and', 'seven years ago...' ],
76
+ 'Four score and seven years ago...'.cleave
77
+ assert_equal [ 'abc def', 'ghijklm nop' ],
78
+ 'abc def ghijklm nop'.cleave
79
+ end
80
+
81
+ def test_cleave_closer_to_end
82
+ assert_equal [ 'extended', 'split' ], 'extended split'.cleave
83
+ assert_equal [ 'abc defghi', 'jklm nop' ],
84
+ 'abc defghi jklm nop'.cleave
85
+ end
86
+
87
+ end
@@ -1,35 +1,27 @@
1
- # _____ _
2
- # |_ _|__ ___| |_
3
- # | |/ _ \/ __| __|
4
- # | | __/\__ \ |
5
- # |_|\___||___/\__|
6
- #
7
- # for lib/facets/string/regesc.rb
8
- #
9
- # Extracted Mon Sep 03 16:23:07 -0700 2007
10
- # w/ Test Extraction Ratchet
11
- #
1
+ # _____ _
2
+ # |_ _|__ ___| |_
3
+ # | |/ _ \/ __| __|
4
+ # | | __/\__ \ |
5
+ # |_|\___||___/\__|
6
+ #
12
7
 
13
- require 'facets/string/regesc.rb'
8
+ require 'facets/string/regesc.rb'
14
9
 
10
+ require 'test/unit'
15
11
 
12
+ class TestStringRegesc < Test::Unit::TestCase
16
13
 
17
- require 'test/unit'
18
-
19
- class TestStringRegesc < Test::Unit::TestCase
20
-
21
- def test_regesc
22
- a = "?"
23
- b = /#{a.regesc}/
24
- assert( b =~ "?" )
25
- end
26
-
27
- def test_resc
28
- assert_equal( Regexp.escape("'jfiw0[]4"), resc("'jfiw0[]4") )
29
- assert_equal( Regexp.escape("/////"), resc("/////") )
30
- end
14
+ def test_regesc
15
+ a = "?"
16
+ b = /#{a.regesc}/
17
+ assert( b =~ "?" )
18
+ end
31
19
 
20
+ def test_resc
21
+ assert_equal( Regexp.escape("'jfiw0[]4"), resc("'jfiw0[]4") )
22
+ assert_equal( Regexp.escape("/////"), resc("/////") )
32
23
  end
33
24
 
25
+ end
34
26
 
35
27
 
@@ -1,135 +1,242 @@
1
- # _____ _
2
- # |_ _|__ ___| |_
3
- # | |/ _ \/ __| __|
4
- # | | __/\__ \ |
5
- # |_|\___||___/\__|
6
- #
7
- # for lib/facets/string/tabs.rb
8
- #
9
- # Extracted Mon Sep 03 16:23:07 -0700 2007
10
- # w/ Test Extraction Ratchet
11
- #
1
+ # _____ _
2
+ # |_ _|__ ___| |_
3
+ # | |/ _ \/ __| __|
4
+ # | | __/\__ \ |
5
+ # |_|\___||___/\__|
6
+ #
7
+ # for lib/facets/string/tabs.rb
8
+
9
+ require 'facets/string/tabs.rb'
10
+ require 'test/unit'
11
+
12
+ class TestStringTabs < Test::Unit::TestCase
13
+
14
+ def setup
15
+ @tabs = <<-EOF
16
+
17
+ \tOne tab
18
+ \tOne space and one tab
19
+ \t Six spaces, a tab, and a space
20
+ EOF
21
+
22
+ @poem1 = <<-EOF
23
+ I must go down to the seas again
24
+ The lonely sea and the sky
25
+ And all I want is a tall ship
26
+ And a star to steer her by
27
+ EOF
28
+
29
+ @poem2 = <<-EOF
30
+ "Eek!"
31
+ She cried
32
+ As the mouse quietly scurried
33
+ by.
34
+ EOF
35
+ end # def setup
36
+
37
+ def test_tab
38
+ a = "xyz".tab(4)
39
+ assert_equal( ' ', a[0..3] )
40
+ # Need to expand on this
41
+ end
12
42
 
13
- require 'facets/string/tabs.rb'
43
+ def test_expand_tabs_1
44
+ expected = <<-EOF
14
45
 
46
+ One tab
47
+ One space and one tab
48
+ Six spaces, a tab, and a space
49
+ EOF
50
+ assert_equal(expected, @tabs.expand_tabs)
51
+ assert_equal(expected, @tabs.expand_tabs(8))
52
+ end
15
53
 
54
+ def test_expand_tabs_2
55
+ expected = <<-EOF
16
56
 
17
- require 'test/unit'
57
+ One tab
58
+ One space and one tab
59
+ Six spaces, a tab, and a space
60
+ EOF
61
+ assert_equal(expected, @tabs.expand_tabs(4))
62
+ end
18
63
 
19
- class TestStringTabs < Test::Unit::TestCase
64
+ def test_expand_tabs_3
65
+ expected = <<-EOF
20
66
 
21
- def test_tab
22
- a = "xyz".tab(4)
23
- assert_equal( ' ', a[0..3] )
24
- # Need to expand on this
25
- end
67
+ One tab
68
+ One space and one tab
69
+ Six spaces, a tab, and a space
70
+ EOF
71
+ assert_equal(expected, @tabs.expand_tabs(16))
72
+ end
26
73
 
27
- def test_tabto
28
- a = "xyz".tabto(4)
29
- assert_equal( ' ', a[0..3] )
30
- # Need to expand on this
31
- end
74
+ def test_expand_tabs_4
75
+ expected = <<-EOF
32
76
 
33
- def test_indent
34
- a = "xyz".indent(4)
35
- assert_equal( ' ', a[0..3] )
36
- # Need to expand on this
37
- end
77
+ One tab
78
+ One space and one tab
79
+ Six spaces, a tab, and a space
80
+ EOF
81
+ assert_equal(expected, @tabs.expand_tabs(1))
82
+ end
38
83
 
39
- def test_margin
40
- s = %q{
41
- |ABC
42
- |123
43
- |TEST
44
- }.margin
45
- assert_equal( "ABC\n123\nTEST", s )
46
-
47
- s = %q{
48
- |ABC
49
- |123
50
- |TEST
51
- }.margin
52
- assert_equal( "ABC\n123\nTEST", s )
53
-
54
- s = %q{|ABC
55
- |123
56
- |TEST
57
- }.margin
58
- assert_equal( "ABC\n123\nTEST", s )
59
-
60
- s = %q{
61
- |ABC
62
- |123
63
- |TEST}.margin
64
- assert_equal( "ABC\n123\nTEST", s )
65
-
66
- s = %q{|ABC
67
- |123
68
- |TEST}.margin
69
- assert_equal( "ABC\n123\nTEST", s )
70
-
71
- s = %q{ |ABC
72
- |123
73
- |TEST}.margin
74
- assert_equal( "ABC\n123\nTEST", s )
75
-
76
- s = %q{ABC
77
- |123
78
- |TEST
79
- }.margin
80
- assert_equal( "ABC\n123\nTEST", s )
81
- end
82
-
83
- #
84
-
85
- def test_spacing
86
- s = %q{
87
- | ABC
88
- | 123
89
- | TEST
90
- }.margin
91
- assert_equal( " ABC\n 123\n TEST", s )
92
-
93
- s = %q{
94
- |ABC
95
- |123
96
- |TEST
97
- }.margin(1)
98
- assert_equal( " ABC\n 123\n TEST", s )
84
+ def test_expand_tabs_5
85
+ expected = <<-EOF
99
86
 
100
- s = %q{
87
+ One tab
88
+ One space and one tab
89
+ Six spaces, a tab, and a space
90
+ EOF
91
+ assert_equal(expected, @tabs.expand_tabs(0))
92
+ end
93
+
94
+ def test_tabto
95
+ a = "xyz".tabto(4)
96
+ assert_equal( ' ', a[0..3] )
97
+ # Need to expand on this
98
+ end
99
+
100
+ def test_indent
101
+ a = "xyz".indent(4)
102
+ assert_equal( ' ', a[0..3] )
103
+ # Need to expand on this
104
+ end
105
+
106
+ def test_outdent_0
107
+ assert_equal(" xyz", " xyz".outdent(-1))
108
+ assert_equal(" xyz", " xyz".outdent(0))
109
+ assert_equal(" xyz", " xyz".outdent(1))
110
+ assert_equal(" xyz", " xyz".outdent(2))
111
+ assert_equal("xyz", " xyz".outdent(3))
112
+ assert_equal("xyz", " xyz".outdent(4))
113
+ end
114
+
115
+ def test_outdent_1
116
+ expected = <<-EOF
117
+ I must go down to the seas again
118
+ The lonely sea and the sky
119
+ And all I want is a tall ship
120
+ And a star to steer her by
121
+ EOF
122
+ actual = @poem1.outdent(1)
123
+ assert_equal(expected, actual)
124
+ end
125
+
126
+ def test_outdent_2
127
+ expected = <<-EOF
128
+ I must go down to the seas again
129
+ The lonely sea and the sky
130
+ And all I want is a tall ship
131
+ And a star to steer her by
132
+ EOF
133
+ actual = @poem1.outdent(4)
134
+ assert_equal(expected, actual)
135
+ end
136
+
137
+ def test_outdent_3
138
+ expected = <<-EOF
139
+ "Eek!"
140
+ She cried
141
+ As the mouse quietly scurried
142
+ by.
143
+ EOF
144
+ actual = @poem2.outdent(100)
145
+ assert_equal(expected, actual)
146
+ end
147
+
148
+ def test_margin
149
+ s = %q{
150
+ |ABC
151
+ |123
152
+ |TEST
153
+ }.margin
154
+ assert_equal( "ABC\n123\nTEST", s )
155
+
156
+ s = %q{
101
157
  |ABC
102
- |123
103
- |TEST
104
- }.margin(2)
105
- assert_equal( " ABC\n 123\n TEST", s )
106
-
107
- s = %q{ ABC
108
- - 123
109
- - TEST
110
- }.margin
111
- assert_equal( " ABC\n 123\n TEST", s )
112
- end
113
-
114
- #
115
-
116
- def test_random_placement
117
- @volly = {}
118
- 100.times{ |n|
119
- k = []
120
- a = []
121
- 5.times{ |i|
122
- k << ( ( ' ' * Integer(rand*10) ) + '|' + i.to_s )
123
- a << ( i.to_s )
124
- }
125
- @volly[k.join("\n")] = a.join("\n")
126
- }
127
- @volly.each{ |k,v|
128
- assert_equal( v, k.margin )
129
- }
130
- end
158
+ |123
159
+ |TEST
160
+ }.margin
161
+ assert_equal( "ABC\n123\nTEST", s )
162
+
163
+ s = %q{|ABC
164
+ |123
165
+ |TEST
166
+ }.margin
167
+ assert_equal( "ABC\n123\nTEST", s )
168
+
169
+ s = %q{
170
+ |ABC
171
+ |123
172
+ |TEST}.margin
173
+ assert_equal( "ABC\n123\nTEST", s )
174
+
175
+ s = %q{|ABC
176
+ |123
177
+ |TEST}.margin
178
+ assert_equal( "ABC\n123\nTEST", s )
179
+
180
+ s = %q{ |ABC
181
+ |123
182
+ |TEST}.margin
183
+ assert_equal( "ABC\n123\nTEST", s )
184
+
185
+ s = %q{ABC
186
+ |123
187
+ |TEST
188
+ }.margin
189
+ assert_equal( "ABC\n123\nTEST", s )
190
+ end
191
+
192
+ #
131
193
 
194
+ def test_spacing
195
+ s = %q{
196
+ | ABC
197
+ | 123
198
+ | TEST
199
+ }.margin
200
+ assert_equal( " ABC\n 123\n TEST", s )
201
+
202
+ s = %q{
203
+ |ABC
204
+ |123
205
+ |TEST
206
+ }.margin(1)
207
+ assert_equal( " ABC\n 123\n TEST", s )
208
+
209
+ s = %q{
210
+ |ABC
211
+ |123
212
+ |TEST
213
+ }.margin(2)
214
+ assert_equal( " ABC\n 123\n TEST", s )
215
+
216
+ s = %q{ ABC
217
+ - 123
218
+ - TEST
219
+ }.margin
220
+ assert_equal( " ABC\n 123\n TEST", s )
132
221
  end
133
222
 
223
+ #
224
+
225
+ def test_random_placement
226
+ @volly = {}
227
+ 100.times{ |n|
228
+ k = []
229
+ a = []
230
+ 5.times{ |i|
231
+ k << ( ( ' ' * Integer(rand*10) ) + '|' + i.to_s )
232
+ a << ( i.to_s )
233
+ }
234
+ @volly[k.join("\n")] = a.join("\n")
235
+ }
236
+ @volly.each{ |k,v|
237
+ assert_equal( v, k.margin )
238
+ }
239
+ end
134
240
 
241
+ end
135
242