Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
p.151 Remove Assignments to Parameters; Before refactoring.
- Loading branch information
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters