Skip to content

Commit

Permalink
Merge pull request beeware#559 from skierchic/master
Browse files Browse the repository at this point in the history
Fix mod error and implement or, xor, and rightshift in-place operators for tuples
  • Loading branch information
freakboy3742 committed May 30, 2017
2 parents e56c62e + d3a8d12 commit 1e377c6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 66 deletions.
20 changes: 15 additions & 5 deletions batavia/types/Tuple.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,12 @@ Tuple.prototype.__or__ = function(other) {
**************************************************/

Tuple.prototype.__ifloordiv__ = function(other) {
throw new exceptions.TypeError.$pyclass("unsupported operand type(s) for //=: 'tuple' and '" + type_name(other) + "'")
var types = require('../types')
if (types.isinstance(other, types.Complex)) {
throw new exceptions.TypeError.$pyclass("can't take floor of complex number.")
} else {
throw new exceptions.TypeError.$pyclass("unsupported operand type(s) for //=: 'tuple' and '" + type_name(other) + "'")
}
}

Tuple.prototype.__itruediv__ = function(other) {
Expand Down Expand Up @@ -489,7 +494,12 @@ Tuple.prototype.__imul__ = function(other) {
}

Tuple.prototype.__imod__ = function(other) {
throw new exceptions.TypeError.$pyclass("unsupported operand type(s) for %=: 'tuple' and '" + type_name(other) + "'")
var types = require('../types')
if (types.isinstance(other, types.Complex)) {
throw new exceptions.TypeError.$pyclass("can't mod complex numbers.")
} else {
throw new exceptions.TypeError.$pyclass("unsupported operand type(s) for %=: 'tuple' and '" + type_name(other) + "'")
}
}

Tuple.prototype.__ipow__ = function(other) {
Expand All @@ -501,19 +511,19 @@ Tuple.prototype.__ilshift__ = function(other) {
}

Tuple.prototype.__irshift__ = function(other) {
throw new exceptions.NotImplementedError.$pyclass('Tuple.__irshift__ has not been implemented')
throw new exceptions.TypeError.$pyclass("unsupported operand type(s) for >>=: 'tuple' and '" + type_name(other) + "'")
}

Tuple.prototype.__iand__ = function(other) {
throw new exceptions.TypeError.$pyclass("unsupported operand type(s) for &=: 'tuple' and '" + type_name(other) + "'")
}

Tuple.prototype.__ixor__ = function(other) {
throw new exceptions.NotImplementedError.$pyclass('Tuple.__ixor__ has not been implemented')
throw new exceptions.TypeError.$pyclass("unsupported operand type(s) for ^=: 'tuple' and '" + type_name(other) + "'")
}

Tuple.prototype.__ior__ = function(other) {
throw new exceptions.NotImplementedError.$pyclass('Tuple.__ior__ has not been implemented')
throw new exceptions.TypeError.$pyclass("unsupported operand type(s) for |=: 'tuple' and '" + type_name(other) + "'")
}

/**************************************************
Expand Down
61 changes: 0 additions & 61 deletions tests/datatypes/test_tuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,64 +182,3 @@ class BinaryTupleOperationTests(BinaryOperationTestCase, TranspileTestCase):

class InplaceTupleOperationTests(InplaceOperationTestCase, TranspileTestCase):
data_type = 'tuple'

not_implemented = [

'test_floor_divide_complex',

'test_modulo_complex',

'test_or_bool',
'test_or_bytearray',
'test_or_bytes',
'test_or_class',
'test_or_complex',
'test_or_dict',
'test_or_float',
'test_or_frozenset',
'test_or_int',
'test_or_list',
'test_or_None',
'test_or_NotImplemented',
'test_or_range',
'test_or_set',
'test_or_slice',
'test_or_str',
'test_or_tuple',

'test_rshift_bool',
'test_rshift_bytearray',
'test_rshift_bytes',
'test_rshift_class',
'test_rshift_complex',
'test_rshift_dict',
'test_rshift_float',
'test_rshift_frozenset',
'test_rshift_int',
'test_rshift_list',
'test_rshift_None',
'test_rshift_NotImplemented',
'test_rshift_range',
'test_rshift_set',
'test_rshift_slice',
'test_rshift_str',
'test_rshift_tuple',

'test_xor_bool',
'test_xor_bytearray',
'test_xor_bytes',
'test_xor_class',
'test_xor_complex',
'test_xor_dict',
'test_xor_float',
'test_xor_frozenset',
'test_xor_int',
'test_xor_list',
'test_xor_None',
'test_xor_NotImplemented',
'test_xor_range',
'test_xor_set',
'test_xor_slice',
'test_xor_str',
'test_xor_tuple',
]

0 comments on commit 1e377c6

Please sign in to comment.