Skip to content

Commit

Permalink
Merge pull request beeware#462 from memo330179/bool_mod
Browse files Browse the repository at this point in the history
Implemented Bool.__mod__(bool) part of issue beeware#46
  • Loading branch information
freakboy3742 authored Mar 14, 2017
2 parents 8acc93c + 5a75e23 commit 24a604b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 15 additions & 0 deletions batavia/types/Bool.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,21 @@ Bool.prototype.__mul__ = function(other) {
} }

Bool.prototype.__mod__ = function(other) {
var types = require('../types')
var result
if (types.isinstance(other, types.Bool)) {
if (this.valueOf()) {
result = 0
} else {
result = new types.Bool(0)
}
if (other.valueOf()) {
return result
} else {
throw new exceptions.ZeroDivisionError.$pyclass('integer division or modulo by zero')
}
}

throw new exceptions.TypeError.$pyclass("unsupported operand type(s) for %: 'bool' and '" + type_name(other) + "'")
}

Expand Down
1 change: 0 additions & 1 deletion tests/datatypes/test_bool.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class BinaryBoolOperationTests(BinaryOperationTestCase, TranspileTestCase):

'test_lshift_int',

'test_modulo_bool',
'test_modulo_complex',
'test_modulo_float',
'test_modulo_int',
Expand Down

0 comments on commit 24a604b

Please sign in to comment.