Skip to content

Commit

Permalink
Merge pull request beeware#544 from njvrzm/divmod_complex
Browse files Browse the repository at this point in the history
divmod() support for complex args and wrong number of args
  • Loading branch information
freakboy3742 committed May 25, 2017
2 parents de0fb49 + 12008dd commit c5f6965
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 55 deletions.
5 changes: 4 additions & 1 deletion batavia/builtins/divmod.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ function divmod(args, kwargs) {
throw new exceptions.TypeError.$pyclass("divmod() doesn't accept keyword arguments")
}
if (!args || args.length !== 2) {
throw new exceptions.TypeError.$pyclass('divmod() expected exactly 2 argument (' + args.length + ' given)')
throw new exceptions.TypeError.$pyclass('divmod expected 2 arguments, got ' + args.length)
}
if (types.isinstance(args[0], types.Complex) || types.isinstance(args[1], types.Complex)) {
throw new exceptions.TypeError.$pyclass("can't take floor or mod of complex number.")
}

var div = Math.floor(args[0] / args[1])
Expand Down
54 changes: 0 additions & 54 deletions tests/builtins/test_divmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,6 @@ class DivmodTests(TranspileTestCase):
class BuiltinDivmodFunctionTests(BuiltinFunctionTestCase, TranspileTestCase):
functions = ["divmod"]

not_implemented = [
'test_noargs',
'test_bool',
'test_bytearray',
'test_bytes',
'test_class',
'test_complex',
'test_dict',
'test_float',
'test_frozenset',
'test_int',
'test_list',
'test_None',
'test_NotImplemented',
'test_range',
'test_set',
'test_slice',
'test_str',
'test_tuple',
]


class BuiltinTwoargDivmodFunctionTests(BuiltinTwoargFunctionTestCase, TranspileTestCase):
functions = ["divmod"]
Expand All @@ -38,7 +17,6 @@ class BuiltinTwoargDivmodFunctionTests(BuiltinTwoargFunctionTestCase, TranspileT
'test_bool_bytearray',
'test_bool_bytes',
'test_bool_class',
'test_bool_complex',
'test_bool_dict',
'test_bool_float',
'test_bool_frozenset',
Expand All @@ -56,7 +34,6 @@ class BuiltinTwoargDivmodFunctionTests(BuiltinTwoargFunctionTestCase, TranspileT
'test_bytearray_bytearray',
'test_bytearray_bytes',
'test_bytearray_class',
'test_bytearray_complex',
'test_bytearray_dict',
'test_bytearray_float',
'test_bytearray_frozenset',
Expand All @@ -74,7 +51,6 @@ class BuiltinTwoargDivmodFunctionTests(BuiltinTwoargFunctionTestCase, TranspileT
'test_bytes_bytearray',
'test_bytes_bytes',
'test_bytes_class',
'test_bytes_complex',
'test_bytes_dict',
'test_bytes_float',
'test_bytes_frozenset',
Expand All @@ -92,7 +68,6 @@ class BuiltinTwoargDivmodFunctionTests(BuiltinTwoargFunctionTestCase, TranspileT
'test_class_bytearray',
'test_class_bytes',
'test_class_class',
'test_class_complex',
'test_class_dict',
'test_class_float',
'test_class_frozenset',
Expand All @@ -106,29 +81,11 @@ class BuiltinTwoargDivmodFunctionTests(BuiltinTwoargFunctionTestCase, TranspileT
'test_class_str',
'test_class_tuple',

'test_complex_bool',
'test_complex_bytearray',
'test_complex_bytes',
'test_complex_class',
'test_complex_complex',
'test_complex_dict',
'test_complex_float',
'test_complex_frozenset',
'test_complex_int',
'test_complex_list',
'test_complex_None',
'test_complex_NotImplemented',
'test_complex_range',
'test_complex_set',
'test_complex_slice',
'test_complex_str',
'test_complex_tuple',

'test_dict_bool',
'test_dict_bytearray',
'test_dict_bytes',
'test_dict_class',
'test_dict_complex',
'test_dict_dict',
'test_dict_float',
'test_dict_frozenset',
Expand All @@ -146,7 +103,6 @@ class BuiltinTwoargDivmodFunctionTests(BuiltinTwoargFunctionTestCase, TranspileT
'test_float_bytearray',
'test_float_bytes',
'test_float_class',
'test_float_complex',
'test_float_dict',
'test_float_float',
'test_float_frozenset',
Expand All @@ -164,7 +120,6 @@ class BuiltinTwoargDivmodFunctionTests(BuiltinTwoargFunctionTestCase, TranspileT
'test_frozenset_bytearray',
'test_frozenset_bytes',
'test_frozenset_class',
'test_frozenset_complex',
'test_frozenset_dict',
'test_frozenset_float',
'test_frozenset_frozenset',
Expand All @@ -182,7 +137,6 @@ class BuiltinTwoargDivmodFunctionTests(BuiltinTwoargFunctionTestCase, TranspileT
'test_int_bytearray',
'test_int_bytes',
'test_int_class',
'test_int_complex',
'test_int_dict',
'test_int_float',
'test_int_frozenset',
Expand All @@ -200,7 +154,6 @@ class BuiltinTwoargDivmodFunctionTests(BuiltinTwoargFunctionTestCase, TranspileT
'test_list_bytearray',
'test_list_bytes',
'test_list_class',
'test_list_complex',
'test_list_dict',
'test_list_float',
'test_list_frozenset',
Expand All @@ -218,7 +171,6 @@ class BuiltinTwoargDivmodFunctionTests(BuiltinTwoargFunctionTestCase, TranspileT
'test_None_bytearray',
'test_None_bytes',
'test_None_class',
'test_None_complex',
'test_None_dict',
'test_None_float',
'test_None_frozenset',
Expand All @@ -236,7 +188,6 @@ class BuiltinTwoargDivmodFunctionTests(BuiltinTwoargFunctionTestCase, TranspileT
'test_NotImplemented_bytearray',
'test_NotImplemented_bytes',
'test_NotImplemented_class',
'test_NotImplemented_complex',
'test_NotImplemented_dict',
'test_NotImplemented_float',
'test_NotImplemented_frozenset',
Expand All @@ -254,7 +205,6 @@ class BuiltinTwoargDivmodFunctionTests(BuiltinTwoargFunctionTestCase, TranspileT
'test_range_bytearray',
'test_range_bytes',
'test_range_class',
'test_range_complex',
'test_range_dict',
'test_range_float',
'test_range_frozenset',
Expand All @@ -272,7 +222,6 @@ class BuiltinTwoargDivmodFunctionTests(BuiltinTwoargFunctionTestCase, TranspileT
'test_set_bytearray',
'test_set_bytes',
'test_set_class',
'test_set_complex',
'test_set_dict',
'test_set_float',
'test_set_frozenset',
Expand All @@ -290,7 +239,6 @@ class BuiltinTwoargDivmodFunctionTests(BuiltinTwoargFunctionTestCase, TranspileT
'test_slice_bytearray',
'test_slice_bytes',
'test_slice_class',
'test_slice_complex',
'test_slice_dict',
'test_slice_float',
'test_slice_frozenset',
Expand All @@ -308,7 +256,6 @@ class BuiltinTwoargDivmodFunctionTests(BuiltinTwoargFunctionTestCase, TranspileT
'test_str_bytearray',
'test_str_bytes',
'test_str_class',
'test_str_complex',
'test_str_dict',
'test_str_float',
'test_str_frozenset',
Expand All @@ -326,7 +273,6 @@ class BuiltinTwoargDivmodFunctionTests(BuiltinTwoargFunctionTestCase, TranspileT
'test_tuple_bytearray',
'test_tuple_bytes',
'test_tuple_class',
'test_tuple_complex',
'test_tuple_dict',
'test_tuple_float',
'test_tuple_frozenset',
Expand Down

0 comments on commit c5f6965

Please sign in to comment.