Skip to content

Commit

Permalink
[GR-21744] Enable additional assertions for tck tests.
Browse files Browse the repository at this point in the history
PullRequest: graal/9545
  • Loading branch information
timfel committed Aug 13, 2021
2 parents b0a2522 + 2135557 commit 3ecf62b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,7 @@ public static void assertUnsupported(Value value, Trait... supported) {
break;
case INSTANTIABLE:
assertFalse(value.canInstantiate());
// TODO remove PolyglotException if GR-21743 and GR-21744 is fixed.
// assertFails(() -> value.newInstance(), UnsupportedOperationException.class);
assertFails(() -> value.newInstance(), UnsupportedOperationException.class);
if (value.isNull()) {
assertNull(value.as(Function.class));
assertNull(value.as(IsFunctionalInterfaceVarArgs.class));
Expand All @@ -326,12 +325,9 @@ public static void assertUnsupported(Value value, Trait... supported) {
break;
case ARRAY_ELEMENTS:
assertFalse(value.hasArrayElements());
// temporary workaround for GR-21744
// assertFails(() -> value.getArrayElement(0),
// UnsupportedOperationException.class);
// assertFails(() -> value.setArrayElement(0, null),
// UnsupportedOperationException.class);
// assertFails(() -> value.getArraySize(), UnsupportedOperationException.class);
assertFails(() -> value.getArrayElement(0), UnsupportedOperationException.class);
assertFails(() -> value.setArrayElement(0, null), UnsupportedOperationException.class);
assertFails(() -> value.getArraySize(), UnsupportedOperationException.class);
if (!value.isNull()) {
if ((!value.isHostObject() || (!(value.asHostObject() instanceof List) && !(value.asHostObject() instanceof Object[])))) {
assertFails(() -> value.as(List.class), ClassCastException.class);
Expand Down Expand Up @@ -972,24 +968,21 @@ private static void assertValueNumber(Value value) {
if (value.fitsInByte()) {
value.asByte();
} else {
// TODO expecting PolyglotException is a temporary workaround GR-21744
assertFails(() -> value.asByte(), ClassCastException.class, PolyglotException.class);
assertFails(() -> value.asByte(), ClassCastException.class);
}
if (value.fitsInShort()) {
short shortValue = value.asShort();
assertEquals((byte) shortValue == shortValue, value.fitsInByte());
} else {
// TODO expecting PolyglotException is a temporary workaround GR-21744
assertFails(() -> value.asShort(), ClassCastException.class, PolyglotException.class);
assertFails(() -> value.asShort(), ClassCastException.class);
}

if (value.fitsInInt()) {
int intValue = value.asInt();
assertEquals((byte) intValue == intValue, value.fitsInByte());
assertEquals((short) intValue == intValue, value.fitsInShort());
} else {
// TODO expecting PolyglotException is a temporary workaround GR-21744
assertFails(() -> value.asInt(), ClassCastException.class, PolyglotException.class);
assertFails(() -> value.asInt(), ClassCastException.class);
}

if (value.fitsInLong()) {
Expand All @@ -998,22 +991,19 @@ private static void assertValueNumber(Value value) {
assertEquals((short) longValue == longValue, value.fitsInShort());
assertEquals((int) longValue == longValue, value.fitsInInt());
} else {
// TODO expecting PolyglotException is a temporary workaround GR-21744
assertFails(() -> value.asLong(), ClassCastException.class, PolyglotException.class);
assertFails(() -> value.asLong(), ClassCastException.class);
}

if (value.fitsInFloat()) {
value.asFloat();
} else {
// TODO expecting PolyglotException is a temporary workaround GR-21744
assertFails(() -> value.asFloat(), ClassCastException.class, PolyglotException.class);
assertFails(() -> value.asFloat(), ClassCastException.class);
}

if (value.fitsInDouble()) {
value.asDouble();
} else {
// TODO expecting PolyglotException is a temporary workaround GR-21744
assertFails(() -> value.asDouble(), ClassCastException.class, PolyglotException.class);
assertFails(() -> value.asDouble(), ClassCastException.class);
}
}

Expand Down
2 changes: 1 addition & 1 deletion vm/mx.vm/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
},
{
"name": "graalpython",
"version": "afa50aa6925f16fd671e1077c322220e38c4cb90",
"version": "4003cf5c2b79653485052209659e94f2c0c0991c",
"dynamic": True,
"urls": [
{"url": "https://github.com/graalvm/graalpython.git", "kind": "git"},
Expand Down

0 comments on commit 3ecf62b

Please sign in to comment.