Skip to content

Commit

Permalink
Fix bug introduced in previous bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
jgoizueta committed Mar 3, 2015
1 parent 0059bab commit 2c4ca99
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/flt/num.rb
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ def num_class
def Num(*args)
context = { context: self }
if args.last.kind_of?(Hash)
args = args[0..-1] + [ context.merge(args.last) ]
args = args[0...-1] + [ context.merge(args.last) ]
else
args << context
end
Expand Down
1 change: 1 addition & 0 deletions test/test_basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ def test_context_constructor
DecNum.context.rounding = :half_even
context = DecNum.context[precision: 4]
assert_equal "1000", context.Num('0.1', :fixed).split[1].to_s
assert_equal "1000", context.Num('0.1', :fixed, :base => 10).split[1].to_s
assert_equal "10000000", DecNum('0.1', :fixed).split[1].to_s
end

Expand Down
1 change: 1 addition & 0 deletions test/test_bin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def test_context_constructor
BinNum.context.rounding = :half_even
context = BinNum.context[precision: 8]
assert_equal "11001101", context.Num('0.1', :fixed).split[1].to_s(2)
assert_equal "11001101", context.Num('0.1', :fixed, :base => 10).split[1].to_s(2)
assert_equal "1100110011001101", BinNum('0.1', :fixed).split[1].to_s(2)
end

Expand Down

0 comments on commit 2c4ca99

Please sign in to comment.