Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
trs
Commits
f39fc1f5
Commit
f39fc1f5
authored
Feb 28, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for recently added numeric division rules.
parent
e20e1936
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
src/rules/numerics.py
src/rules/numerics.py
+3
-2
No files found.
src/rules/numerics.py
View file @
f39fc1f5
...
@@ -93,7 +93,7 @@ def match_divide_numerics(node):
...
@@ -93,7 +93,7 @@ def match_divide_numerics(node):
3.0 / 2.0 -> 1.5
3.0 / 2.0 -> 1.5
3 / 1.0 -> 3 # Exceptional case: division of integer by 1.0
3 / 1.0 -> 3 # Exceptional case: division of integer by 1.0
# keeps integer precision
# keeps integer precision
2 / 4 -> 1 / 2 #
denominator % nominator == 0
2 / 4 -> 1 / 2 #
1 < greatest common divisor <= nominator
4 / 3 -> 1 + 1 / 3 # nominator > denominator
4 / 3 -> 1 + 1 / 3 # nominator > denominator
"""
"""
assert
node
.
is_op
(
OP_DIV
)
assert
node
.
is_op
(
OP_DIV
)
...
@@ -182,7 +182,8 @@ def fraction_to_int_fraction(root, args):
...
@@ -182,7 +182,8 @@ def fraction_to_int_fraction(root, args):
return
integer
+
nominator
/
denominator
return
integer
+
nominator
/
denominator
MESSAGES
[
divide_numerics
]
=
_
(
'Divide constant {1} by constant {2}.'
)
MESSAGES
[
fraction_to_int_fraction
]
=
_
(
'Expand fraction with nominator greater'
' than denominator {0} to an integer plus a fraction.'
)
def
match_multiply_zero
(
node
):
def
match_multiply_zero
(
node
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment