kagemusha 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+
2
+ == 0.0.2 2007-08-27
3
+
4
+ ...
5
+
1
6
  == 0.0.1 2007-08-15
2
7
 
3
8
  * 1 major enhancement:
data/Manifest.txt CHANGED
@@ -8,6 +8,7 @@ examples/date.rb
8
8
  examples/datetime.rb
9
9
  examples/first.rb
10
10
  examples/rand.rb
11
+ examples/style.rb
11
12
  examples/time.rb
12
13
  lib/kagemusha.rb
13
14
  lib/kagemusha/core.rb
data/examples/date.rb CHANGED
@@ -1,19 +1,22 @@
1
1
 
2
- # $Id: date.rb 26 2007-08-15 14:22:25Z yuyakato $
2
+ # $Id: date.rb 40 2007-08-27 13:21:13Z yuyakato $
3
3
 
4
4
  require "rubygems"
5
5
  require "kagemusha/date"
6
6
 
7
- musha = Kagemusha::Date.on(2007, 1, 1)
8
-
9
- p Date.today.strftime("%Y-%m-%d")
10
-
11
- puts "---"
7
+ p Date.today.strftime("%Y-%m-%d") #=> today
12
8
 
9
+ # Normal Style.
10
+ musha = Kagemusha::Date.on(2007, 1, 1)
13
11
  musha.swap {
14
- p Date.today.strftime("%Y-%m-%d")
12
+ p Date.today.strftime("%Y-%m-%d") #=> 2007-01-01
15
13
  }
16
14
 
17
- puts "---"
15
+ p Date.today.strftime("%Y-%m-%d") #=> today
16
+
17
+ # Block Style.
18
+ Kagemusha::Date.on(2007, 1, 1) {
19
+ p Date.today.strftime("%Y-%m-%d") #=> 2007-01-01
20
+ }
18
21
 
19
- p Date.today.strftime("%Y-%m-%d")
22
+ p Date.today.strftime("%Y-%m-%d") #=> today
data/examples/datetime.rb CHANGED
@@ -1,22 +1,32 @@
1
1
 
2
- # $Id: datetime.rb 26 2007-08-15 14:22:25Z yuyakato $
2
+ # $Id: datetime.rb 40 2007-08-27 13:21:13Z yuyakato $
3
3
 
4
4
  require "rubygems"
5
5
  require "kagemusha/datetime"
6
6
 
7
- musha = Kagemusha::DateTime.at(1984, 5, 11, 5, 15, 30)
8
-
9
- p Date.today.strftime("%Y-%m-%d")
10
- p Time.now
11
-
7
+ p Date.today.strftime("%Y-%m-%d") #=> today
8
+ p Time.now #=> now
12
9
  puts "---"
13
10
 
11
+ # Normal Style.
12
+ musha = Kagemusha::DateTime.at(1984, 5, 11, 5, 15, 30)
14
13
  musha.swap {
15
- p Date.today.strftime("%Y-%m-%d")
16
- p Time.now
14
+ p Date.today.strftime("%Y-%m-%d") #=> 1984-05-11
15
+ p Time.now #=> 1984-05-11 05:15:30
16
+ puts "---"
17
17
  }
18
18
 
19
+ p Date.today.strftime("%Y-%m-%d") #=> today
20
+ p Time.now #=> now
19
21
  puts "---"
20
22
 
21
- p Date.today.strftime("%Y-%m-%d")
22
- p Time.now
23
+ # Block Style.
24
+ Kagemusha::DateTime.at(1984, 5, 11, 5, 15, 30) {
25
+ p Date.today.strftime("%Y-%m-%d") #=> 1984-05-11
26
+ p Time.now #=> 1984-05-11 05:15:30
27
+ puts "---"
28
+ }
29
+
30
+ p Date.today.strftime("%Y-%m-%d") #=> today
31
+ p Time.now #=> now
32
+ puts "---"
data/examples/first.rb CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- # $Id: first.rb 25 2007-08-15 14:18:09Z yuyakato $
2
+ # $Id: first.rb 40 2007-08-27 13:21:13Z yuyakato $
3
3
 
4
4
  require "rubygems"
5
5
  require "kagemusha"
@@ -8,17 +8,16 @@ musha = Kagemusha.new(Time)
8
8
  musha.defs(:now) { self.local(1984, 5, 11) }
9
9
  musha.def(:+) { |other| other }
10
10
 
11
- p Time.now
12
- p Time.now + 60 * 60 * 24
13
-
11
+ p Time.now #=> now
12
+ p Time.now + 60 * 60 * 24 #=> now + 24 hours
14
13
  puts "---"
15
14
 
16
15
  musha.swap {
17
- p Time.now
18
- p Time.now + 60 * 60 * 24
16
+ p Time.now #=> 1984-05-11 00:00:00
17
+ p Time.now + 60 * 60 * 24 #=> 86400
18
+ puts "---"
19
19
  }
20
20
 
21
+ p Time.now #=> now
22
+ p Time.now + 60 * 60 * 24 #=> now + 24 hours
21
23
  puts "---"
22
-
23
- p Time.now
24
- p Time.now + 60 * 60 * 24
data/examples/rand.rb CHANGED
@@ -1,22 +1,32 @@
1
1
 
2
- # $Id: rand.rb 26 2007-08-15 14:22:25Z yuyakato $
2
+ # $Id: rand.rb 40 2007-08-27 13:21:13Z yuyakato $
3
3
 
4
4
  require "rubygems"
5
5
  require "kagemusha/rand"
6
6
 
7
- musha = Kagemusha::Rand.always(1)
8
-
9
- p rand(5)
10
- p rand(5)
11
-
7
+ p rand(100) #=> rand
8
+ p rand(100) #=> rand
12
9
  puts "---"
13
10
 
11
+ # Normal Style.
12
+ musha = Kagemusha::Rand.always(1)
14
13
  musha.swap {
15
- p rand(5)
16
- p rand(5)
14
+ p rand(100) #=> 1
15
+ p rand(100) #=> 1
16
+ puts "---"
17
17
  }
18
18
 
19
+ p rand(100) #=> rand
20
+ p rand(100) #=> rand
19
21
  puts "---"
20
22
 
21
- p rand(5)
22
- p rand(5)
23
+ # Block Style.
24
+ Kagemusha::Rand.always(1) {
25
+ p rand(100) #=> 1
26
+ p rand(100) #=> 1
27
+ puts "---"
28
+ }
29
+
30
+ p rand(100) #=> rand
31
+ p rand(100) #=> rand
32
+ puts "---"
data/examples/style.rb ADDED
@@ -0,0 +1,39 @@
1
+
2
+ # $Id: style.rb 38 2007-08-27 13:03:39Z yuyakato $
3
+
4
+ require "rubygems"
5
+ require "kagemusha"
6
+
7
+ def one_plus_one
8
+ return 1 + 1
9
+ end
10
+
11
+ p one_plus_one #=> 2
12
+
13
+ # Normal Style.
14
+ musha = Kagemusha.new(Fixnum)
15
+ musha.def(:+) { 1 }
16
+ musha.swap {
17
+ p one_plus_one #=> 1
18
+ }
19
+
20
+ p one_plus_one #=> 2
21
+
22
+ # Block Style.
23
+ Kagemusha.new(Fixnum) { |m|
24
+ m.def(:+) { 1 }
25
+ m.swap {
26
+ p one_plus_one #=> 1
27
+ }
28
+ }
29
+
30
+ p one_plus_one #=> 2
31
+
32
+ # Chain Style.
33
+ Kagemusha.new(Fixnum).
34
+ def(:+) { 1 }.
35
+ swap {
36
+ p one_plus_one #=> 1
37
+ }
38
+
39
+ p one_plus_one #=> 2
data/examples/time.rb CHANGED
@@ -1,19 +1,22 @@
1
1
 
2
- # $Id: time.rb 26 2007-08-15 14:22:25Z yuyakato $
2
+ # $Id: time.rb 40 2007-08-27 13:21:13Z yuyakato $
3
3
 
4
4
  require "rubygems"
5
5
  require "kagemusha/time"
6
6
 
7
- musha = Kagemusha::Time.at(2007, 1, 1)
8
-
9
- p Time.now
10
-
11
- puts "---"
7
+ p Time.now #=> now
12
8
 
9
+ # Normal Style.
10
+ musha = Kagemusha::Time.at(2007, 1, 1)
13
11
  musha.swap {
14
- p Time.now
12
+ p Time.now #=> 2007-01-01 00:00:00
15
13
  }
16
14
 
17
- puts "---"
15
+ p Time.now #=> now
16
+
17
+ # Block Style.
18
+ Kagemusha::Time.at(2007, 1, 1) {
19
+ p Time.now #=> 2007-01-01 00:00:00
20
+ }
18
21
 
19
- p Time.now
22
+ p Time.now #=> now
@@ -1,6 +1,6 @@
1
1
 
2
2
  #==============================================================================#
3
- # $Id: core.rb 27 2007-08-15 14:35:31Z yuyakato $
3
+ # $Id: core.rb 35 2007-08-27 12:59:31Z yuyakato $
4
4
  #==============================================================================#
5
5
 
6
6
  class Kagemusha #:nodoc:
@@ -9,25 +9,33 @@ class Kagemusha #:nodoc:
9
9
  @meta = class << @klass; self; end
10
10
  @class_methods = {}
11
11
  @instance_methods = {}
12
+
13
+ if block_given?
14
+ yield(self)
15
+ end
12
16
  end
13
17
 
14
18
  def define_class_method(name, &block) #:nodoc:
15
19
  @class_methods[name.to_s.intern] = block
20
+ return self
16
21
  end
17
22
  alias :defs :define_class_method
18
23
 
19
24
  def undefine_class_method(name) #:nodoc:
20
25
  @class_methods.delete(name.to_s.intern)
26
+ return self
21
27
  end
22
28
  alias :undefs :undefine_class_method
23
29
 
24
30
  def define_instance_method(name, &block) #:nodoc:
25
31
  @instance_methods[name.to_s.intern] = block
32
+ return self
26
33
  end
27
34
  alias :def :define_instance_method
28
35
 
29
36
  def undefine_instance_method(name) #:nodoc:
30
37
  @instance_methods.delete(name.to_s.intern)
38
+ return self
31
39
  end
32
40
  alias :undef :undefine_instance_method
33
41
 
@@ -47,7 +55,7 @@ class Kagemusha #:nodoc:
47
55
  original_instance_methods[name] = method
48
56
  }
49
57
 
50
- yield
58
+ return yield
51
59
  ensure
52
60
  original_class_methods.each { |name, method|
53
61
  @meta.instance_eval { define_method(name, method) }
@@ -1,6 +1,6 @@
1
1
 
2
2
  #==============================================================================#
3
- # $Id: date.rb 27 2007-08-15 14:35:31Z yuyakato $
3
+ # $Id: date.rb 37 2007-08-27 13:02:39Z yuyakato $
4
4
  #==============================================================================#
5
5
 
6
6
  require "kagemusha"
@@ -10,7 +10,11 @@ require "date"
10
10
 
11
11
  class Kagemusha #:nodoc:
12
12
  module Date #:nodoc:
13
- def self.on(date_or_year, mon = 1, mday = 1) #:nodoc:
13
+ def self.on(date_or_year, mon = 1, mday = 1, &block) #:nodoc:
14
+ if block_given?
15
+ return self.on(date_or_year, mon, mday).swap(&block)
16
+ end
17
+
14
18
  date =
15
19
  case date_or_year
16
20
  when ::Date then date_or_year
@@ -1,6 +1,6 @@
1
1
 
2
2
  #==============================================================================#
3
- # $Id: datetime.rb 22 2007-08-15 12:34:58Z yuyakato $
3
+ # $Id: datetime.rb 37 2007-08-27 13:02:39Z yuyakato $
4
4
  #==============================================================================#
5
5
 
6
6
  require "kagemusha/date"
@@ -14,7 +14,11 @@ class Kagemusha #:nodoc:
14
14
  @mock1, @mock2 = mock1, mock2
15
15
  end
16
16
 
17
- def self.at(time_or_year, mon = 1, mday = 1, hour = 0, min = 0, sec = 0)
17
+ def self.at(time_or_year, mon = 1, mday = 1, hour = 0, min = 0, sec = 0, &block)
18
+ if block_given?
19
+ return self.at(time_or_year, mon, mday, hour, min, sec).swap(&block)
20
+ end
21
+
18
22
  case time_or_year
19
23
  when ::Time
20
24
  time = time_or_year
@@ -30,7 +34,7 @@ class Kagemusha #:nodoc:
30
34
 
31
35
  datemusha = Kagemusha::Date.on(date)
32
36
  timemusha = Kagemusha::Time.at(time)
33
-
37
+
34
38
  return self.new(datemusha, timemusha)
35
39
  end
36
40
 
@@ -1,6 +1,6 @@
1
1
 
2
2
  #==============================================================================#
3
- # $Id: rand.rb 22 2007-08-15 12:34:58Z yuyakato $
3
+ # $Id: rand.rb 33 2007-08-27 12:25:50Z yuyakato $
4
4
  #==============================================================================#
5
5
 
6
6
  require "kagemusha"
@@ -9,7 +9,11 @@ require "kagemusha"
9
9
 
10
10
  class Kagemusha #:nodoc:
11
11
  module Rand
12
- def self.always(num)
12
+ def self.always(num, &block)
13
+ if block_given?
14
+ return self.always(num).swap(&block)
15
+ end
16
+
13
17
  musha = Kagemusha.new(Kernel)
14
18
  musha.def(:rand) { num }
15
19
 
@@ -1,6 +1,6 @@
1
1
 
2
2
  #==============================================================================#
3
- # $Id: time.rb 27 2007-08-15 14:35:31Z yuyakato $
3
+ # $Id: time.rb 33 2007-08-27 12:25:50Z yuyakato $
4
4
  #==============================================================================#
5
5
 
6
6
  require "kagemusha"
@@ -9,7 +9,11 @@ require "kagemusha"
9
9
 
10
10
  class Kagemusha #:nodoc:
11
11
  module Time #:nodoc:
12
- def self.at(time_or_year, mon = 1, mday = 1, hour = 0, min = 0, sec = 0)
12
+ def self.at(time_or_year, mon = 1, mday = 1, hour = 0, min = 0, sec = 0, &block)
13
+ if block_given?
14
+ return self.at(time_or_year, mon, mday, hour, min, sec).swap(&block)
15
+ end
16
+
13
17
  time =
14
18
  case time_or_year
15
19
  when ::Time then time_or_year
@@ -1,13 +1,13 @@
1
1
 
2
2
  #==============================================================================#
3
- # $Id: version.rb 6 2007-08-15 08:47:26Z yuyakato $
3
+ # $Id: version.rb 33 2007-08-27 12:25:50Z yuyakato $
4
4
  #==============================================================================#
5
5
 
6
6
  class Kagemusha #:nodoc:
7
7
  module VERSION #:nodoc:
8
8
  MAJOR = 0
9
9
  MINOR = 0
10
- TINY = 1
10
+ TINY = 2
11
11
 
12
12
  STRING = [MAJOR, MINOR, TINY].join('.')
13
13
  end
data/test/test_date.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  #==============================================================================#
3
- # $Id: test_date.rb 27 2007-08-15 14:35:31Z yuyakato $
3
+ # $Id: test_date.rb 37 2007-08-27 13:02:39Z yuyakato $
4
4
  #==============================================================================#
5
5
 
6
6
  require File.dirname(__FILE__) + "/test_helper.rb"
@@ -28,6 +28,15 @@ class TestKagemushaDate < Test::Unit::TestCase
28
28
  Kagemusha::Date.on(:symbol)
29
29
  }
30
30
  end
31
+
32
+ def test_on_with_block
33
+ ret = Kagemusha::Date.on(2007, 1, 2) {
34
+ assert_equal(Date.new(2007, 1, 2), Date.today)
35
+ 1
36
+ }
37
+
38
+ assert_equal(1, ret)
39
+ end
31
40
  end
32
41
 
33
42
  #==============================================================================#
@@ -1,6 +1,6 @@
1
1
 
2
2
  #==============================================================================#
3
- # $Id: test_datetime.rb 27 2007-08-15 14:35:31Z yuyakato $
3
+ # $Id: test_datetime.rb 37 2007-08-27 13:02:39Z yuyakato $
4
4
  #==============================================================================#
5
5
 
6
6
  require File.dirname(__FILE__) + "/test_helper.rb"
@@ -37,6 +37,16 @@ class TestKagemushaDateTime < Test::Unit::TestCase
37
37
  Kagemusha::DateTime.at(:symbol)
38
38
  }
39
39
  end
40
+
41
+ def test_at_with_block
42
+ ret = Kagemusha::DateTime.at(2007, 1, 2, 3, 4, 5) {
43
+ assert_equal(Date.new(2007, 1, 2), Date.today)
44
+ assert_equal(Time.local(2007, 1, 2, 3, 4, 5), Time.now)
45
+ 1
46
+ }
47
+
48
+ assert_equal(1, ret)
49
+ end
40
50
  end
41
51
 
42
52
  #==============================================================================#
@@ -1,6 +1,6 @@
1
1
 
2
2
  #==============================================================================#
3
- # $Id: test_kagemusha.rb 27 2007-08-15 14:35:31Z yuyakato $
3
+ # $Id: test_kagemusha.rb 35 2007-08-27 12:59:31Z yuyakato $
4
4
  #==============================================================================#
5
5
 
6
6
  require File.dirname(__FILE__) + "/test_helper.rb"
@@ -16,12 +16,24 @@ class TestKagemusha < Test::Unit::TestCase
16
16
  klass = String
17
17
  meta = class << klass; self; end
18
18
 
19
+ assert_kind_of(Kagemusha, @musha)
19
20
  assert_equal(klass, @musha.instance_eval { @klass })
20
21
  assert_equal(meta, @musha.instance_eval { @meta })
21
22
  assert_equal({}, @musha.instance_eval { @class_methods })
22
23
  assert_equal({}, @musha.instance_eval { @instance_methods })
23
24
  end
24
25
 
26
+ def test_initialize_with_block
27
+ arg = nil
28
+
29
+ ret = Kagemusha.new(String) { |x|
30
+ arg = x
31
+ }
32
+
33
+ assert_kind_of(Kagemusha, ret)
34
+ assert_same(ret, arg)
35
+ end
36
+
25
37
  def test_define_class_method_and_undefine
26
38
  block1 = proc { 1 }
27
39
  block2 = proc { 2 }
@@ -29,23 +41,27 @@ class TestKagemusha < Test::Unit::TestCase
29
41
  assert_equal(nil, @musha.instance_eval { @class_methods[:foo] })
30
42
  assert_equal(nil, @musha.instance_eval { @class_methods[:bar] })
31
43
 
32
- @musha.define_class_method(:foo, &block1)
44
+ ret = @musha.define_class_method(:foo, &block1)
33
45
 
46
+ assert_same(ret, @musha)
34
47
  assert_equal(block1, @musha.instance_eval { @class_methods[:foo] })
35
48
  assert_equal(nil, @musha.instance_eval { @class_methods[:bar] })
36
49
 
37
- @musha.define_class_method("bar", &block2)
50
+ ret = @musha.define_class_method("bar", &block2)
38
51
 
52
+ assert_same(ret, @musha)
39
53
  assert_equal(block1, @musha.instance_eval { @class_methods[:foo] })
40
54
  assert_equal(block2, @musha.instance_eval { @class_methods[:bar] })
41
55
 
42
- @musha.undefine_class_method("foo")
56
+ ret = @musha.undefine_class_method("foo")
43
57
 
58
+ assert_same(ret, @musha)
44
59
  assert_equal(nil, @musha.instance_eval { @class_methods[:foo] })
45
60
  assert_equal(block2, @musha.instance_eval { @class_methods[:bar] })
46
61
 
47
- @musha.undefine_class_method(:bar)
62
+ ret = @musha.undefine_class_method(:bar)
48
63
 
64
+ assert_same(ret, @musha)
49
65
  assert_equal(nil, @musha.instance_eval { @class_methods[:foo] })
50
66
  assert_equal(nil, @musha.instance_eval { @class_methods[:bar] })
51
67
  end
@@ -55,12 +71,14 @@ class TestKagemusha < Test::Unit::TestCase
55
71
 
56
72
  assert_equal(nil, @musha.instance_eval { @class_methods[:foo] })
57
73
 
58
- @musha.defs(:foo, &block)
74
+ ret = @musha.defs(:foo, &block)
59
75
 
76
+ assert_same(ret, @musha)
60
77
  assert_equal(block, @musha.instance_eval { @class_methods[:foo] })
61
78
 
62
- @musha.undefs(:foo)
79
+ ret = @musha.undefs(:foo)
63
80
 
81
+ assert_same(ret, @musha)
64
82
  assert_equal(nil, @musha.instance_eval { @class_methods[:foo] })
65
83
  end
66
84
 
@@ -71,23 +89,27 @@ class TestKagemusha < Test::Unit::TestCase
71
89
  assert_equal(nil, @musha.instance_eval { @instance_methods[:foo] })
72
90
  assert_equal(nil, @musha.instance_eval { @instance_methods[:bar] })
73
91
 
74
- @musha.define_instance_method(:foo, &block1)
92
+ ret = @musha.define_instance_method(:foo, &block1)
75
93
 
94
+ assert_same(ret, @musha)
76
95
  assert_equal(block1, @musha.instance_eval { @instance_methods[:foo] })
77
96
  assert_equal(nil, @musha.instance_eval { @instance_methods[:bar] })
78
97
 
79
- @musha.define_instance_method("bar", &block2)
98
+ ret = @musha.define_instance_method("bar", &block2)
80
99
 
100
+ assert_same(ret, @musha)
81
101
  assert_equal(block1, @musha.instance_eval { @instance_methods[:foo] })
82
102
  assert_equal(block2, @musha.instance_eval { @instance_methods[:bar] })
83
103
 
84
- @musha.undefine_instance_method("foo")
104
+ ret = @musha.undefine_instance_method("foo")
85
105
 
106
+ assert_same(ret, @musha)
86
107
  assert_equal(nil, @musha.instance_eval { @instance_methods[:foo] })
87
108
  assert_equal(block2, @musha.instance_eval { @instance_methods[:bar] })
88
109
 
89
- @musha.undefine_instance_method(:bar)
110
+ ret = @musha.undefine_instance_method(:bar)
90
111
 
112
+ assert_same(ret, @musha)
91
113
  assert_equal(nil, @musha.instance_eval { @instance_methods[:foo] })
92
114
  assert_equal(nil, @musha.instance_eval { @instance_methods[:bar] })
93
115
  end
@@ -97,12 +119,14 @@ class TestKagemusha < Test::Unit::TestCase
97
119
 
98
120
  assert_equal(nil, @musha.instance_eval { @instance_methods[:foo] })
99
121
 
100
- @musha.def(:foo, &block)
122
+ ret = @musha.def(:foo, &block)
101
123
 
124
+ assert_same(ret, @musha)
102
125
  assert_equal(block, @musha.instance_eval { @instance_methods[:foo] })
103
126
 
104
- @musha.undef(:foo)
127
+ ret = @musha.undef(:foo)
105
128
 
129
+ assert_same(ret, @musha)
106
130
  assert_equal(nil, @musha.instance_eval { @instance_methods[:foo] })
107
131
  end
108
132
 
@@ -112,10 +136,12 @@ class TestKagemusha < Test::Unit::TestCase
112
136
 
113
137
  assert_equal(/foo/, Regexp.compile("foo"))
114
138
 
115
- @musha.swap {
139
+ ret = @musha.swap {
116
140
  assert_equal(/bar/, Regexp.compile("foo"))
141
+ 1
117
142
  }
118
143
 
144
+ assert_equal(1, ret)
119
145
  assert_equal(/foo/, Regexp.compile("foo"))
120
146
  end
121
147
 
@@ -125,10 +151,12 @@ class TestKagemusha < Test::Unit::TestCase
125
151
 
126
152
  assert_equal("foo", target.to_s)
127
153
 
128
- @musha.swap {
154
+ ret = @musha.swap {
129
155
  assert_equal("bar", target.to_s)
156
+ 1
130
157
  }
131
158
 
159
+ assert_equal(1, ret)
132
160
  assert_equal("foo", target.to_s)
133
161
  end
134
162
  end
data/test/test_rand.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  #==============================================================================#
3
- # $Id: test_rand.rb 27 2007-08-15 14:35:31Z yuyakato $
3
+ # $Id: test_rand.rb 37 2007-08-27 13:02:39Z yuyakato $
4
4
  #==============================================================================#
5
5
 
6
6
  require File.dirname(__FILE__) + "/test_helper.rb"
@@ -23,6 +23,19 @@ class TestKagemushaRand < Test::Unit::TestCase
23
23
  assert_equal(1, rand(5))
24
24
  }
25
25
  end
26
+
27
+ def test_always_with_block
28
+ ret = Kagemusha::Rand.always(1) {
29
+ assert_equal(1, rand)
30
+ assert_equal(1, rand(2))
31
+ assert_equal(1, rand(3))
32
+ assert_equal(1, rand(4))
33
+ assert_equal(1, rand(5))
34
+ 1
35
+ }
36
+
37
+ assert_equal(1, ret)
38
+ end
26
39
  end
27
40
 
28
41
  #==============================================================================#
data/test/test_time.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  #==============================================================================#
3
- # $Id: test_time.rb 27 2007-08-15 14:35:31Z yuyakato $
3
+ # $Id: test_time.rb 37 2007-08-27 13:02:39Z yuyakato $
4
4
  #==============================================================================#
5
5
 
6
6
  require File.dirname(__FILE__) + "/test_helper.rb"
@@ -28,6 +28,15 @@ class TestKagemushaTime < Test::Unit::TestCase
28
28
  Kagemusha::Time.at(:symbol)
29
29
  }
30
30
  end
31
+
32
+ def test_at_with_block
33
+ ret = Kagemusha::Time.at(2007, 1, 2, 3, 4, 5) {
34
+ assert_equal(Time.local(2007, 1, 2, 3, 4, 5), Time.now)
35
+ 1
36
+ }
37
+
38
+ assert_equal(1, ret)
39
+ end
31
40
  end
32
41
 
33
42
  #==============================================================================#
data/website/index.html CHANGED
@@ -33,7 +33,7 @@
33
33
  <h1>Kagemusha &#8211; 影武者</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/kagemusha"; return false'>
35
35
  <p>Get Version</p>
36
- <a href="http://rubyforge.org/projects/kagemusha" class="numbers">0.0.1</a>
36
+ <a href="http://rubyforge.org/projects/kagemusha" class="numbers">0.0.2</a>
37
37
  </div>
38
38
  <h2>What</h2>
39
39
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: kagemusha
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.1
7
- date: 2007-08-16 00:00:00 +09:00
6
+ version: 0.0.2
7
+ date: 2007-08-27 00:00:00 +09:00
8
8
  summary: Kagemusha is a library of helper functions for testing Ruby scripts.
9
9
  require_paths:
10
10
  - lib
@@ -39,6 +39,7 @@ files:
39
39
  - examples/datetime.rb
40
40
  - examples/first.rb
41
41
  - examples/rand.rb
42
+ - examples/style.rb
42
43
  - examples/time.rb
43
44
  - lib/kagemusha.rb
44
45
  - lib/kagemusha/core.rb