Skip to content

Commit

Permalink
Tests for formatting of floats as mentioned in topazproject#779. Also…
Browse files Browse the repository at this point in the history
… includes tests for floats < 0 which are also formatted incorrectly
  • Loading branch information
codeZeilen committed Aug 12, 2014
1 parent b95c858 commit 2df69c0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/objects/test_floatobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def test_hashability(self, space):
assert w_res is space.w_true

def test_to_s(self, space):
w_res = space.execute("return 0.0.to_s")
assert space.str_w(w_res) == "0.0"
w_res = space.execute("return 1.5.to_s")
assert space.str_w(w_res) == "1.5"
w_res = space.execute("return (0.0 / 0.0).to_s")
Expand All @@ -68,6 +70,21 @@ def test_to_s(self, space):
assert space.str_w(w_res) == "Infinity"
w_res = space.execute("return (-1.0 / 0.0).to_s")
assert space.str_w(w_res) == "-Infinity"
w_res = space.execute("return 2585201673888528.0.to_s")
assert space.str_w(w_res) == "2585201673888528.0"
w_res = space.execute("return 25852016738885287.0.to_s")
assert space.str_w(w_res) == "25852016738885290.0"
w_res = space.execute("return -25852016738885287.0.to_s")
assert space.str_w(w_res) == "-25852016738885290.0"
w_res = space.execute("return 100000000000000111.0.to_s")
assert space.str_w(w_res) == "100000000000000110.0"
w_res = space.execute("return 0.0001.to_s")
assert space.str_w(w_res) == "0.0001"
w_res = space.execute("return 0.00001.to_s")
assert space.str_w(w_res) == "1.0e-05"


w_res = space.execute

def test_to_i(self, space):
w_res = space.execute("return [1.1.to_i, 1.1.to_int]")
Expand Down

0 comments on commit 2df69c0

Please sign in to comment.