Skip to content

Commit

Permalink
p.151 Remove Assignments to Parameters; Before refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
kono committed May 29, 2010
1 parent 73853fe commit 811e567
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
7 changes: 7 additions & 0 deletions chapter6/Remove_Assignments_to_Parameters.rb
@@ -0,0 +1,7 @@

def discount(input_val, quantity, year_to_date)
input_val -= 2 if input_val > 50
input_val -= 1 if quantity > 100
input_val -= 4 if year_to_date > 10000
input_val
end
23 changes: 23 additions & 0 deletions chapter6/TC_Remove_Assignments_to_Parameters.rb
@@ -0,0 +1,23 @@
require 'rubygems'
require 'test/unit'
require 'must'
require 'kconv'
require 'Remove_Assignments_to_Parameters'

$KCODE="UTF8"
class TC_Remove_Assignments_to_Parameters < Test::Unit::TestCase

def assert(status,msg)
if(RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|cygwin|bccwin/)
msg=Kconv.tosjis(msg)
end
super(status,msg)
end

must "test1" do
assert_equal(50, discount(50,100,1000))
assert_equal(49, discount(51, 100, 1000))
assert_equal(48, discount(51, 101, 1000))
assert_equal(44, discount(51, 101, 10001))
end
end
3 changes: 3 additions & 0 deletions chapter6/TC_Split_Temporary_Variable.rb
Expand Up @@ -5,6 +5,9 @@
require 'Split_Temporary_Variable'

$KCODE="UTF8"
class Array
attr:finish
end
class TC_Split_Temporary_Variable < Test::Unit::TestCase

def assert(status,msg)
Expand Down

0 comments on commit 811e567

Please sign in to comment.