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.
- data/AUTHORS +3 -3
- data/README +6 -7
- data/lib/core/facets.rb +1 -46
- data/lib/core/facets/array.rb +3 -0
- data/lib/core/facets/array/indexable.rb +6 -1
- data/lib/core/facets/array/only.rb +20 -0
- data/lib/core/facets/dir/multiglob.rb +12 -1
- data/lib/core/facets/enumerable.rb +0 -1
- data/lib/core/facets/enumerable/collect.rb +1 -0
- data/lib/core/facets/enumerable/combination.rb +44 -90
- data/lib/core/facets/facets.rb +46 -0
- data/lib/core/facets/file/write.rb +46 -58
- data/lib/core/facets/hash.rb +2 -0
- data/lib/core/facets/hash/select.rb +14 -0
- data/lib/core/facets/integer/multiples.rb +12 -55
- data/lib/core/facets/kernel/val.rb +14 -0
- data/lib/core/facets/module/alias.rb +28 -9
- data/lib/core/facets/module/methods.rb +18 -0
- data/lib/core/facets/module/traits.rb +65 -70
- data/lib/core/facets/proc/compose.rb +15 -12
- data/lib/core/facets/stackable.rb +3 -2
- data/lib/core/facets/string/format.rb +4 -6
- data/lib/core/facets/string/tabs.rb +34 -0
- data/lib/core/facets/symbol.rb +1 -0
- data/lib/core/facets/symbol/succ.rb +1 -42
- data/lib/core/facets/symbol/to_proc.rb +34 -0
- data/lib/methods/facets/array/contains.rb +1 -0
- data/lib/methods/facets/facets/require_core.rb +1 -0
- data/lib/methods/facets/file/writelines.rb +1 -0
- data/lib/methods/facets/io/writelines.rb +1 -0
- data/lib/methods/facets/kernel/not_nil.rb +1 -0
- data/lib/methods/facets/module/conflict.rb +1 -0
- data/lib/methods/facets/module/instance_method_defined.rb +1 -0
- data/lib/methods/facets/module/module_method_defined.rb +1 -0
- data/lib/methods/facets/module/private_conflict.rb +1 -0
- data/lib/methods/facets/module/protected_conflict.rb +1 -0
- data/lib/methods/facets/module/public_conflict.rb +1 -0
- data/lib/methods/facets/string/expand_tabs.rb +1 -0
- data/lib/methods/facets/string/outdent.rb +1 -0
- data/lib/methods/facets/string/taballto.rb +1 -0
- data/lib/more/facets/arguments.rb +1 -1
- data/lib/more/facets/association.rb +0 -46
- data/lib/more/facets/autoarray.rb +0 -28
- data/lib/more/facets/command.rb +341 -8
- data/lib/more/facets/dictionary.rb +25 -131
- data/lib/more/facets/downloader.rb +1 -1
- data/lib/more/facets/infinity.rb +3 -3
- data/lib/more/facets/interval.rb +0 -161
- data/lib/more/facets/multiton.rb +16 -12
- data/lib/more/facets/namespace.rb +1 -1
- data/lib/more/facets/ostruct.rb +46 -10
- data/lib/more/facets/overload.rb +0 -51
- data/lib/more/facets/paramix.rb +0 -97
- data/lib/more/facets/pp_s.rb +30 -0
- data/lib/more/facets/progressbar.rb +18 -10
- data/lib/more/facets/prototype.rb +1 -40
- data/lib/more/facets/random.rb +1 -0
- data/lib/more/facets/rbsystem.rb +4 -1
- data/lib/more/facets/snapshot.rb +8 -1
- data/lib/more/facets/stylize.rb +2 -0
- data/meta/{project.yaml → facets-2.0.3.roll} +22 -14
- data/meta/manifest.txt +38 -8
- data/task/{config.yaml → config/general.yaml} +7 -2
- data/task/{rdoc.yaml → config/rdoc.yaml} +1 -1
- data/task/crosstest +309 -0
- data/task/isotest +293 -0
- data/task/loadtest +28 -0
- data/task/methods +4 -4
- data/task/prepare +5 -0
- data/task/publish +2 -2
- data/task/rdoc +1 -0
- data/task/syntax +29 -0
- data/task/test +0 -1
- data/task/testeach +42 -0
- data/task/testpairs +50 -0
- data/test/lib/rq.rb +15 -0
- data/test/unit/array/test_merge.rb +21 -43
- data/test/unit/array/test_only.rb +21 -0
- data/test/unit/enumerable/test_collect.rb +1 -21
- data/test/unit/enumerable/test_combination.rb +50 -44
- data/test/unit/file/test_topath.rb +48 -57
- data/test/unit/file/test_write.rb +82 -0
- data/test/unit/hash/test_select.rb +43 -0
- data/test/unit/integer/test_multiples.rb +28 -32
- data/test/unit/kernel/test_report.rb +9 -12
- data/test/unit/kernel/test_val.rb +50 -45
- data/test/unit/module/test_include.rb +56 -57
- data/test/unit/module/test_name.rb +42 -55
- data/test/unit/module/test_traits.rb +46 -47
- data/test/unit/string/test_filter.rb +19 -34
- data/test/unit/string/test_format.rb +87 -96
- data/test/unit/string/test_regesc.rb +18 -26
- data/test/unit/string/test_tabs.rb +226 -119
- data/test/unit/symbol/test_succ.rb +14 -23
- data/test/unit/symbol/test_to_proc.rb +41 -0
- data/test/unit/test_association.rb +38 -47
- data/test/unit/test_attributes.rb +24 -33
- data/test/unit/test_autoarray.rb +23 -32
- data/test/unit/test_command.rb +26 -0
- data/test/unit/test_dictionary.rb +123 -117
- data/test/unit/test_infinity.rb +41 -47
- data/test/unit/test_inheritor.rb +133 -142
- data/test/unit/test_interval.rb +129 -93
- data/test/unit/test_ostruct.rb +148 -101
- data/test/unit/test_overload.rb +8 -15
- data/test/unit/test_paramix.rb +67 -73
- data/test/unit/test_pp_s.rb +23 -0
- data/test/unit/test_prototype.rb +28 -38
- metadata +47 -11
- data/lib/core/facets/enumerable/instance_map.rb +0 -0
- data/lib/more/facets/command_options.rb +0 -328
- data/meta/version.txt +0 -1
- data/task/load +0 -39
- data/test/unit/test_command_options.rb +0 -29
data/task/testpairs
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/usr/bin/env ratch
|
2
|
+
|
3
|
+
# cross-run unit tests
|
4
|
+
#
|
5
|
+
# This tool runs all tests against each other in pairs
|
6
|
+
# to ensure across the board compatibility.
|
7
|
+
|
8
|
+
abort "Not working correctly. Fix me."
|
9
|
+
|
10
|
+
require "./lib/more/facets/progressbar"
|
11
|
+
|
12
|
+
main :test do
|
13
|
+
output = "doc/log/crosstest.txt"
|
14
|
+
|
15
|
+
live = ARGV.delete('--live')
|
16
|
+
|
17
|
+
find = 'test/**/test_*.rb'
|
18
|
+
|
19
|
+
tests = Dir.glob(find).reject{ |f| dir?(f) }.sort
|
20
|
+
tests = tests.sort{ |a,b| File.basename(a) <=> File.basename(b) }
|
21
|
+
|
22
|
+
File.open(output, 'w'){ |f|
|
23
|
+
f << "= CROSS TESTING\n#{Time.now}"
|
24
|
+
}
|
25
|
+
|
26
|
+
total = tests.size * tests.size
|
27
|
+
|
28
|
+
pbar = Console::ProgressBar.new("CrossTest", total+1)
|
29
|
+
pbar.inc
|
30
|
+
|
31
|
+
tests.each do |file1|
|
32
|
+
tests.each do |file2|
|
33
|
+
next if file1 == file2
|
34
|
+
|
35
|
+
sh %{echo "\n\n#{file1} & #{file2}" >> #{output}}
|
36
|
+
|
37
|
+
pbar.title = File.basename(file1)
|
38
|
+
pbar.inc
|
39
|
+
pbar.flush
|
40
|
+
|
41
|
+
if live
|
42
|
+
sh %{ruby -r#{file2} #{file1} >> #{output}}
|
43
|
+
else
|
44
|
+
sh %{ruby -Ilib/more -Ilib/core -Ilib/methods -r#{file2} #{file1} >> #{output}}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
pbar.finish
|
50
|
+
end
|
data/test/lib/rq.rb
ADDED
@@ -1,51 +1,29 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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 facets/array/merge.rb
|
12
8
|
|
13
|
-
|
9
|
+
require 'facets/array/merge.rb'
|
14
10
|
|
11
|
+
require 'test/unit'
|
15
12
|
|
13
|
+
class TestArray < Test::Unit::TestCase
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
def test_merge
|
22
|
-
a = [1,2,3]
|
23
|
-
b = [3,4,5]
|
24
|
-
assert_equal( [1,2,3,4,5], a.merge(b) )
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_merge!
|
28
|
-
a = [1,2,3]
|
29
|
-
b = [3,4,5]
|
30
|
-
a.merge!(b)
|
31
|
-
assert_equal( [1,2,3,4,5], a )
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_rotate
|
35
|
-
a = [1,2,3]
|
36
|
-
assert_equal( [3,1,2], a.rotate, 'clockwise' )
|
37
|
-
assert_equal( [2,3,1], a.rotate(-1), 'counter-clockwise' )
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_rotate!
|
41
|
-
a = [1,2,3]
|
42
|
-
a.rotate!
|
43
|
-
assert_equal( [3,1,2], a, 'clockwise' )
|
44
|
-
a.rotate!(-1)
|
45
|
-
assert_equal( [1,2,3], a, 'counter-clockwise' )
|
46
|
-
end
|
47
|
-
|
15
|
+
def test_merge
|
16
|
+
a = [1,2,3]
|
17
|
+
b = [3,4,5]
|
18
|
+
assert_equal( [1,2,3,4,5], a.merge(b) )
|
48
19
|
end
|
49
20
|
|
21
|
+
def test_merge!
|
22
|
+
a = [1,2,3]
|
23
|
+
b = [3,4,5]
|
24
|
+
a.merge!(b)
|
25
|
+
assert_equal( [1,2,3,4,5], a )
|
26
|
+
end
|
50
27
|
|
28
|
+
end
|
51
29
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# _____ _
|
2
|
+
# |_ _|__ ___| |_
|
3
|
+
# | |/ _ \/ __| __|
|
4
|
+
# | | __/\__ \ |
|
5
|
+
# |_|\___||___/\__|
|
6
|
+
#
|
7
|
+
require 'facets/array/only.rb'
|
8
|
+
|
9
|
+
require 'test/unit'
|
10
|
+
|
11
|
+
class TestArrayOnly < Test::Unit::TestCase
|
12
|
+
|
13
|
+
def test_only
|
14
|
+
assert_equal(5, [5].only)
|
15
|
+
assert_equal(nil, [nil].only)
|
16
|
+
assert_raise(IndexError) { [].only }
|
17
|
+
assert_raise(IndexError) { [1,2,3].only }
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
@@ -4,14 +4,9 @@
|
|
4
4
|
# | | __/\__ \ |
|
5
5
|
# |_|\___||___/\__|
|
6
6
|
#
|
7
|
-
# for
|
8
|
-
#
|
9
|
-
# Extracted Mon Sep 03 16:23:07 -0700 2007
|
10
|
-
# w/ Test Extraction Ratchet
|
11
|
-
#
|
7
|
+
# for facets/enumerable/collect.rb
|
12
8
|
|
13
9
|
require 'facets/enumerable/collect.rb'
|
14
|
-
|
15
10
|
require 'test/unit'
|
16
11
|
require 'set'
|
17
12
|
|
@@ -140,13 +135,6 @@ class TestEnumerable < Test::Unit::TestCase
|
|
140
135
|
assert_equal( [[1,2],[3,4]], r )
|
141
136
|
end
|
142
137
|
|
143
|
-
def test_each_unique_pair
|
144
|
-
r = []
|
145
|
-
a = [1,2,3,4]
|
146
|
-
a.each_unique_pair{ |a,b| r << [a,b] }
|
147
|
-
assert_equal( [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]], r )
|
148
|
-
end
|
149
|
-
|
150
138
|
def test_eachn
|
151
139
|
x = []
|
152
140
|
[1,2,3,4].eachn{ |a,b| x << [a,b] }
|
@@ -159,14 +147,6 @@ class TestEnumerable < Test::Unit::TestCase
|
|
159
147
|
assert_equal( o, x )
|
160
148
|
end
|
161
149
|
|
162
|
-
def test_each_combination
|
163
|
-
r = []
|
164
|
-
a = [1,2,3,4]
|
165
|
-
a.each_combination(2){ |a,b| r << [a,b] }
|
166
|
-
assert_equal( [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]], r )
|
167
|
-
end
|
168
|
-
|
169
|
-
|
170
150
|
def test_collect_with_index
|
171
151
|
a = [1,2,3].collect_with_index{ |e,i| e*i }
|
172
152
|
assert_equal( [0,2,6], a )
|
@@ -1,49 +1,55 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
["a", "x", "y"],
|
39
|
-
["b", "a", "x"],
|
40
|
-
["b", "a", "y"],
|
41
|
-
["b", "x", "x"],
|
42
|
-
["b", "x", "y"] ]
|
43
|
-
assert_equal( r, z )
|
44
|
-
end
|
1
|
+
# _____ _
|
2
|
+
# |_ _|__ ___| |_
|
3
|
+
# | |/ _ \/ __| __|
|
4
|
+
# | | __/\__ \ |
|
5
|
+
# |_|\___||___/\__|
|
6
|
+
#
|
7
|
+
# for lib/facets/enumerable/combination.rb
|
8
|
+
|
9
|
+
require 'facets/enumerable/combination.rb'
|
10
|
+
require 'test/unit'
|
11
|
+
require 'set'
|
12
|
+
|
13
|
+
class TestEnumerableCombination < Test::Unit::TestCase
|
14
|
+
|
15
|
+
def test_combinations
|
16
|
+
a = [1,2]
|
17
|
+
b = [3,4]
|
18
|
+
z = Enumerable.combinations(a,b)
|
19
|
+
r = [[1,3],[1,4],[2,3],[2,4]]
|
20
|
+
assert_equal( r, z )
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_combinations_of_three
|
24
|
+
a = %w|a b|
|
25
|
+
b = %w|a x|
|
26
|
+
c = %w|x y|
|
27
|
+
z = Enumerable.combinations(a, b, c)
|
28
|
+
r = [ ["a", "a", "x"],
|
29
|
+
["a", "a", "y"],
|
30
|
+
["a", "x", "x"],
|
31
|
+
["a", "x", "y"],
|
32
|
+
["b", "a", "x"],
|
33
|
+
["b", "a", "y"],
|
34
|
+
["b", "x", "x"],
|
35
|
+
["b", "x", "y"] ]
|
36
|
+
assert_equal( r, z )
|
37
|
+
end
|
45
38
|
|
39
|
+
def test_each_combination
|
40
|
+
r = []
|
41
|
+
a = [1,2,3,4]
|
42
|
+
a.each_combination(2){ |a,b| r << [a,b] }
|
43
|
+
assert_equal( [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]], r )
|
46
44
|
end
|
47
45
|
|
46
|
+
# DEPRECATED
|
47
|
+
# def test_each_unique_pair
|
48
|
+
# r = []
|
49
|
+
# a = [1,2,3,4]
|
50
|
+
# a.each_unique_pair{ |a,b| r << [a,b] }
|
51
|
+
# assert_equal( [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]], r )
|
52
|
+
# end
|
48
53
|
|
54
|
+
end
|
49
55
|
|
@@ -1,74 +1,65 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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 facets/file/topath.rb
|
12
8
|
|
13
|
-
|
9
|
+
require 'facets/file/topath.rb'
|
14
10
|
|
11
|
+
require 'test/unit'
|
15
12
|
|
13
|
+
# mock file
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
class File
|
22
|
-
def self.open( fname, mode, &blk )
|
23
|
-
blk.call(self)
|
24
|
-
end
|
25
|
-
def self.read( fname=nil )
|
26
|
-
@mock_content.clone
|
27
|
-
end
|
28
|
-
def self.write( str )
|
29
|
-
@mock_content = str
|
30
|
-
end
|
31
|
-
def self.<<( str )
|
32
|
-
(@mock_content ||="") << str
|
33
|
-
end
|
15
|
+
class MockFile < File
|
16
|
+
def self.open( fname, mode, &blk )
|
17
|
+
blk.call(self)
|
34
18
|
end
|
19
|
+
def self.read( fname=nil )
|
20
|
+
@mock_content.clone
|
21
|
+
end
|
22
|
+
def self.write( str )
|
23
|
+
@mock_content = str
|
24
|
+
end
|
25
|
+
def self.<<( str )
|
26
|
+
(@mock_content ||="") << str
|
27
|
+
end
|
28
|
+
end
|
35
29
|
|
36
|
-
|
37
|
-
|
38
|
-
class TestFile < Test::Unit::TestCase
|
39
|
-
|
40
|
-
# TODO Write file identity tests.
|
41
|
-
|
42
|
-
def test_sanitize_01
|
43
|
-
assert_equal( "This_is_a_test", File.sanitize('This is a test') )
|
44
|
-
end
|
30
|
+
# tests
|
45
31
|
|
46
|
-
|
47
|
-
assert_equal( "test", File.sanitize('This\is\test') )
|
48
|
-
end
|
32
|
+
class TestFile < Test::Unit::TestCase
|
49
33
|
|
50
|
-
|
51
|
-
assert_equal( "test", File.sanitize('This/is/test') )
|
52
|
-
end
|
34
|
+
# TODO Write file identity tests.
|
53
35
|
|
54
|
-
|
55
|
-
|
56
|
-
|
36
|
+
def test_sanitize_01
|
37
|
+
assert_equal( "This_is_a_test", MockFile.sanitize('This is a test') )
|
38
|
+
end
|
57
39
|
|
58
|
-
|
59
|
-
|
60
|
-
|
40
|
+
def test_sanitize_02
|
41
|
+
assert_equal( "test", MockFile.sanitize('This\is\test') )
|
42
|
+
end
|
61
43
|
|
62
|
-
|
63
|
-
|
64
|
-
|
44
|
+
def test_sanitize_03
|
45
|
+
assert_equal( "test", MockFile.sanitize('This/is/test') )
|
46
|
+
end
|
65
47
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
48
|
+
def test_sanitize_04
|
49
|
+
assert_equal( "te_____st", MockFile.sanitize('This/te#$#@!st') )
|
50
|
+
end
|
70
51
|
|
52
|
+
def test_sanitize_05
|
53
|
+
assert_equal( "_.", MockFile.sanitize('.') )
|
71
54
|
end
|
72
55
|
|
56
|
+
def test_sanitize_06
|
57
|
+
assert_equal( "_....", MockFile.sanitize('....') )
|
58
|
+
end
|
73
59
|
|
60
|
+
def test_split_all
|
61
|
+
fp = "this/is/test"
|
62
|
+
assert_equal( ['this', 'is', 'test'], MockFile.split_all(fp) )
|
63
|
+
end
|
74
64
|
|
65
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# _____ _
|
2
|
+
# |_ _|__ ___| |_
|
3
|
+
# | |/ _ \/ __| __|
|
4
|
+
# | | __/\__ \ |
|
5
|
+
# |_|\___||___/\__|
|
6
|
+
#
|
7
|
+
# for facets/file/write.rb
|
8
|
+
|
9
|
+
# TODO Needs a file mock.
|
10
|
+
|
11
|
+
require 'facets/file/write.rb'
|
12
|
+
require 'test/unit'
|
13
|
+
require 'tempfile'
|
14
|
+
|
15
|
+
class TC_FileWrite < Test::Unit::TestCase
|
16
|
+
|
17
|
+
def setup
|
18
|
+
tmp_dir = Dir::tmpdir # ENV["TMP"] || ENV["TEMP"] || "/tmp"
|
19
|
+
raise "Can't find temporary directory" unless File.directory?(tmp_dir)
|
20
|
+
@path = File.join(tmp_dir, "ruby_io_test")
|
21
|
+
end
|
22
|
+
|
23
|
+
# Test File.write
|
24
|
+
def test_file_write
|
25
|
+
data_in = "Test data\n"
|
26
|
+
nbytes = File.write(@path, data_in)
|
27
|
+
data_out = File.read(@path) # This is standard class method.
|
28
|
+
assert_equal(data_in, data_out)
|
29
|
+
assert_equal(data_out.size, nbytes)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Test File.writelines
|
33
|
+
def test_file_writelines
|
34
|
+
data_in = %w[one two three four five]
|
35
|
+
File.writelines(@path, data_in)
|
36
|
+
data_out = File.readlines(@path) # This is standard class method.
|
37
|
+
assert_equal(data_in, data_out.map { |l| l.chomp })
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
# TODO This isn't right, and I'm concerned about acidentally writing a real file.
|
44
|
+
|
45
|
+
# class TestFileWrite < Test::Unit::TestCase
|
46
|
+
#
|
47
|
+
# class MockFile < ::File
|
48
|
+
# def open( fname, mode, &blk )
|
49
|
+
# blk.call(self)
|
50
|
+
# end
|
51
|
+
# def ead( fname=nil )
|
52
|
+
# @mrock_content.clone
|
53
|
+
# end
|
54
|
+
# def write( str )
|
55
|
+
# @mock_content = str
|
56
|
+
# end
|
57
|
+
# def <<( str )
|
58
|
+
# (@mock_content ||="") << str
|
59
|
+
# end
|
60
|
+
# end
|
61
|
+
#
|
62
|
+
# File = MockFile.new
|
63
|
+
#
|
64
|
+
# def test_create
|
65
|
+
# f = "not a real file"
|
66
|
+
# t = 'This is a test'
|
67
|
+
# File.create( f, t )
|
68
|
+
# s = File.read( f )
|
69
|
+
# assert_equal( t, s )
|
70
|
+
# end
|
71
|
+
#
|
72
|
+
# def test_rewrite
|
73
|
+
# f = "not a real file"
|
74
|
+
# t = 'This is a test'
|
75
|
+
# File.write( t )
|
76
|
+
# File.rewrite(f) { |s| s.reverse! }
|
77
|
+
# s = File.read(f)
|
78
|
+
# assert_equal( t.reverse, s )
|
79
|
+
# end
|
80
|
+
#
|
81
|
+
# end
|
82
|
+
|