Skip to content

Commit 55a257b

Browse files
committed
Merge pull request #292 from MatthewWest/master
Fix issue #288
2 parents 993f0bf + 103d367 commit 55a257b

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Some planned and implemented features:
3030
make build_with_jit
3131
./pixie-vm
3232

33+
Note: Mac OS X does not come with the build tools required by default. Install the XCode Command Line tools ([Apple Developer Site](http://developer.apple.com)) or install them independently.
34+
3335

3436
## Running the tests
3537

pixie/vm/numbers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ def define_num_ops():
134134
if op == "_div" and c1 == Integer and c2 == Integer:
135135
continue
136136
extend_num_op(op, c1, c2, conv1, sym, conv2)
137-
extend_num_op("_quot", c1, c2, conv1, "/", conv2, wrap_start = "rt.wrap(math.floor(", wrap_end = "))")
138-
extend_num_op("_rem", c1, c2, conv1, ",", conv2, wrap_start = "rt.wrap(math.fmod(", wrap_end = "))")
137+
if c1 != Integer or c2 != Integer:
138+
extend_num_op("_rem", c1, c2, conv1, ",", conv2, wrap_start = "rt.wrap(math.fmod(", wrap_end = "))")
139+
extend_num_op("_quot", c1, c2, conv1, "/", conv2, wrap_start = "rt.wrap(math.floor(", wrap_end = "))")
139140
for (op, sym) in [("_num_eq", "=="), ("_lt", "<"), ("_gt", ">"), ("_lte", "<="), ("_gte", ">=")]:
140141
extend_num_op(op, c1, c2, conv1, sym, conv2,
141142
wrap_start = "true if ", wrap_end = " else false")

tests/pixie/tests/test-numbers.pxi

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,16 @@
4949
(t/deftest test-float
5050
(doseq [[x f] [[1 1.0] [3 3.0] [3.333 3.333] [3/2 1.5] [1/7 (/ 1.0 7.0)]]]
5151
(t/assert= (float x) f)))
52+
53+
(t/deftest rem-types
54+
(t/assert= Integer (type (rem 5 3)))
55+
(t/assert= Float (type (rem 5.0 3)))
56+
(t/assert= Ratio (type (rem 7/2 3)))
57+
(t/assert= Float (type (rem 7/2 3.0))))
58+
59+
(t/deftest quot-types
60+
(t/assert= Integer (type (quot 5 3)))
61+
(t/assert= Float (type (quot 5.0 3)))
62+
(t/assert= Integer (type (quot 7/2 3/7)))
63+
(t/assert= Float (type (quot 7/2 3.0))))
64+

0 commit comments

Comments
 (0)