Skip to content

Commit

Permalink
Merge branch 'notimplemented-tests' of https://github.com/cflee/voc i…
Browse files Browse the repository at this point in the history
…nto notimplemented

Conflicts:
	tests/datatypes/test_float.py
  • Loading branch information
freakboy3742 committed Apr 5, 2016
2 parents cc2053a + 34f2fc1 commit ac769f0
Show file tree
Hide file tree
Showing 14 changed files with 421 additions and 369 deletions.
7 changes: 7 additions & 0 deletions python/common/org/python/Object.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ public interface Object {
public void __itruediv__(org.python.Object other);
public void __ifloordiv__(org.python.Object other);
public void __imod__(org.python.Object other);
public void __idivmod__(org.python.Object other);
public void __ipow__(org.python.Object other);
public void __ilshift__(org.python.Object other);
public void __irshift__(org.python.Object other);
public void __iand__(org.python.Object other);
public void __ixor__(org.python.Object other);
public void __ior__(org.python.Object other);

public org.python.Object __neg__();
public org.python.Object __pos__();
Expand Down
30 changes: 29 additions & 1 deletion python/common/org/python/exceptions/BaseException.java
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,35 @@ public void __ifloordiv__(org.python.Object other) {
}

public void __imod__(org.python.Object other) {
throw new org.python.exceptions.AttributeError(this, "__im__");
throw new org.python.exceptions.AttributeError(this, "__imod__");
}

public void __idivmod__(org.python.Object other) {
throw new org.python.exceptions.AttributeError(this, "__idivmod__");
}

public void __ipow__(org.python.Object other) {
throw new org.python.exceptions.AttributeError(this, "__ipow__");
}

public void __ilshift__(org.python.Object other) {
throw new org.python.exceptions.AttributeError(this, "__ilshift__");
}

public void __irshift__(org.python.Object other) {
throw new org.python.exceptions.AttributeError(this, "__irshift__");
}

public void __iand__(org.python.Object other) {
throw new org.python.exceptions.AttributeError(this, "__iand__");
}

public void __ixor__(org.python.Object other) {
throw new org.python.exceptions.AttributeError(this, "__ixor__");
}

public void __ior__(org.python.Object other) {
throw new org.python.exceptions.AttributeError(this, "__ior__");
}


Expand Down
86 changes: 86 additions & 0 deletions python/common/org/python/types/NotImplementedType.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,90 @@ public org.python.types.Str __repr__() {
public boolean __setattr_null(java.lang.String name, org.python.Object value) {
return false;
}

@org.python.Method(
__doc__ = ""
)
public org.python.Object __invert__() {
throw new org.python.exceptions.TypeError("bad operand type for unary ~: 'NotImplementedType'");
}

@org.python.Method(
__doc__ = ""
)
public org.python.Object __pos__() {
throw new org.python.exceptions.TypeError("bad operand type for unary +: 'NotImplementedType'");
}

@org.python.Method(
__doc__ = ""
)
public org.python.Object __neg__() {
throw new org.python.exceptions.TypeError("bad operand type for unary -: 'NotImplementedType'");
}

@org.python.Method(
__doc__ = ""
)
public org.python.types.Bool __bool__() {
return new org.python.types.Bool(true);
}

@org.python.Method(
__doc__ = ""
)
public org.python.Object __ge__(org.python.Object other) {
throw new org.python.exceptions.TypeError(
String.format("unorderable types: NotImplementedType() >= %s()", other.typeName())
);
}

@org.python.Method(
__doc__ = ""
)
public org.python.Object __gt__(org.python.Object other) {
throw new org.python.exceptions.TypeError(
String.format("unorderable types: NotImplementedType() > %s()", other.typeName())
);
}

@org.python.Method(
__doc__ = ""
)
public org.python.Object __lt__(org.python.Object other) {
throw new org.python.exceptions.TypeError(
String.format("unorderable types: NotImplementedType() < %s()", other.typeName())
);
}

@org.python.Method(
__doc__ = ""
)
public org.python.Object __le__(org.python.Object other) {
throw new org.python.exceptions.TypeError(
String.format("unorderable types: NotImplementedType() <= %s()", other.typeName())
);
}

@org.python.Method(
__doc__ = ""
)
public org.python.Object __mul__(org.python.Object other) {
if (other instanceof org.python.types.Str || other instanceof org.python.types.List || other instanceof org.python.types.Tuple) {
throw new org.python.exceptions.TypeError("can't multiply sequence by non-int of type 'NotImplementedType'");
} else {
throw new org.python.exceptions.TypeError(
String.format("unsupported operand type(s) for *: 'NotImplementedType' and '%s'",
other.typeName())
);
}
}

@org.python.Method(
__doc__ = ""
)
public org.python.Object __getitem__(org.python.Object other) {
throw new org.python.exceptions.TypeError("'NotImplementedType' object is not subscriptable");
}

}
13 changes: 13 additions & 0 deletions python/common/org/python/types/Object.java
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,19 @@ public void __imod__(org.python.Object other) {
}


@org.python.Method(
__doc__ = "",
args = {"other"}
)
public void __idivmod__(org.python.Object other) {
try {
this.setValue(this.__pow__(other, null));
} catch (org.python.exceptions.TypeError e) {
throw new org.python.exceptions.TypeError("unsupported operand type(s) for //=: '" + this.typeName() + "' and '" + other.typeName() + "'");
}
}


@org.python.Method(
__doc__ = "",
args = {"other"}
Expand Down
13 changes: 13 additions & 0 deletions python/common/org/python/types/Super.java
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,19 @@ public void __imod__(org.python.Object other) {
}


@org.python.Method(
__doc__ = "",
args = {"other"}
)
public void __idivmod__(org.python.Object other) {
try {
this.setValue(this.__pow__(other, null));
} catch (org.python.exceptions.TypeError e) {
throw new org.python.exceptions.TypeError("unsupported operand type(s) for //=: '" + this.typeName() + "' and '" + other.typeName() + "'");
}
}


@org.python.Method(
__doc__ = "",
args = {"other"}
Expand Down
45 changes: 0 additions & 45 deletions tests/datatypes/test_NoneType.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,41 +153,23 @@ class InplaceNoneTypeOperationTests(InplaceOperationTestCase, TranspileTestCase)
'test_add_complex',
'test_add_frozenset',

'test_and_bool',
'test_and_bytearray',
'test_and_bytes',
'test_and_class',
'test_and_complex',
'test_and_dict',
'test_and_float',
'test_and_frozenset',
'test_and_int',
'test_and_list',
'test_and_none',
'test_and_set',
'test_and_str',
'test_and_tuple',

'test_floor_divide_bytearray',
'test_floor_divide_bytes',
'test_floor_divide_class',
'test_floor_divide_complex',
'test_floor_divide_frozenset',

'test_lshift_bool',
'test_lshift_bytearray',
'test_lshift_bytes',
'test_lshift_class',
'test_lshift_complex',
'test_lshift_dict',
'test_lshift_float',
'test_lshift_frozenset',
'test_lshift_int',
'test_lshift_list',
'test_lshift_none',
'test_lshift_set',
'test_lshift_str',
'test_lshift_tuple',

'test_modulo_bytearray',
'test_modulo_bytes',
Expand All @@ -204,20 +186,11 @@ class InplaceNoneTypeOperationTests(InplaceOperationTestCase, TranspileTestCase)
'test_multiply_str',
'test_multiply_tuple',

'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_set',
'test_or_str',
'test_or_tuple',

'test_power_bool',
'test_power_bytearray',
Expand All @@ -234,20 +207,11 @@ class InplaceNoneTypeOperationTests(InplaceOperationTestCase, TranspileTestCase)
'test_power_str',
'test_power_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_set',
'test_rshift_str',
'test_rshift_tuple',

'test_subtract_bytearray',
'test_subtract_bytes',
Expand All @@ -261,18 +225,9 @@ class InplaceNoneTypeOperationTests(InplaceOperationTestCase, TranspileTestCase)
'test_true_divide_complex',
'test_true_divide_frozenset',

'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_set',
'test_xor_str',
'test_xor_tuple',
]
Loading

0 comments on commit ac769f0

Please sign in to comment.