Skip to content
Snippets Groups Projects
Commit e5bb6f6b authored by Tomas Stupka's avatar Tomas Stupka
Browse files

[GR-2798] Enable tck tests temporarily disabled in #40bda55e.

PullRequest: fastr/1470
parents 53f5c6c9 c50dc499
No related branches found
No related tags found
No related merge requests found
...@@ -127,12 +127,6 @@ public final class RTCKLanguageProvider implements LanguageProvider { ...@@ -127,12 +127,6 @@ public final class RTCKLanguageProvider implements LanguageProvider {
TypeDescriptor numOrBoolOrNullOrArrNumBool = TypeDescriptor.union(numOrBoolOrNull, arrNumBool); TypeDescriptor numOrBoolOrNullOrArrNumBool = TypeDescriptor.union(numOrBoolOrNull, arrNumBool);
TypeDescriptor boolOrArrBool = TypeDescriptor.union(TypeDescriptor.BOOLEAN, TypeDescriptor.array(TypeDescriptor.BOOLEAN)); TypeDescriptor boolOrArrBool = TypeDescriptor.union(TypeDescriptor.BOOLEAN, TypeDescriptor.array(TypeDescriptor.BOOLEAN));
// TODO cause occasional and more then occasional fails on gate builds
// TypeDescriptor strOrNumOrBool = TypeDescriptor.union(TypeDescriptor.STRING, numOrBool);
// TypeDescriptor arrStrNumBool = TypeDescriptor.array(strOrNumOrBool);
// TypeDescriptor strOrNumOrBoolOrArrStrNumBool = TypeDescriptor.union(strOrNumOrBool,
// arrStrNumBool);
// + // +
ops.add(createBinaryOperator(context, "+", numOrBoolOrArrNumBool, numOrBoolOrNullOrArrNumBool, numOrBoolOrNullOrArrNumBool, ops.add(createBinaryOperator(context, "+", numOrBoolOrArrNumBool, numOrBoolOrNullOrArrNumBool, numOrBoolOrNullOrArrNumBool,
RResultVerifier.newBuilder(numOrBoolOrNullOrArrNumBool, numOrBoolOrNullOrArrNumBool).emptyArrayCheck().build())); RResultVerifier.newBuilder(numOrBoolOrNullOrArrNumBool, numOrBoolOrNullOrArrNumBool).emptyArrayCheck().build()));
...@@ -146,37 +140,24 @@ public final class RTCKLanguageProvider implements LanguageProvider { ...@@ -146,37 +140,24 @@ public final class RTCKLanguageProvider implements LanguageProvider {
ops.add(createBinaryOperator(context, "/", numOrBoolOrArrNumBool, numOrBoolOrNullOrArrNumBool, numOrBoolOrNullOrArrNumBool, ops.add(createBinaryOperator(context, "/", numOrBoolOrArrNumBool, numOrBoolOrNullOrArrNumBool, numOrBoolOrNullOrArrNumBool,
RResultVerifier.newBuilder(numOrBoolOrNullOrArrNumBool, numOrBoolOrNullOrArrNumBool).emptyArrayCheck().build())); RResultVerifier.newBuilder(numOrBoolOrNullOrArrNumBool, numOrBoolOrNullOrArrNumBool).emptyArrayCheck().build()));
// TODO cause occasional and more then occasional fails on gate builds
// < // <
// ops.add(createBinaryOperator(context, "<", boolOrArrBool, strOrNumOrBoolOrArrStrNumBool, ops.add(createBinaryOperator(context, "<", boolOrArrBool, TypeDescriptor.ANY, TypeDescriptor.ANY,
// strOrNumOrBoolOrArrStrNumBool, RResultVerifier.newBuilder(TypeDescriptor.ANY, TypeDescriptor.ANY).compareParametersCheck().build()));
// RResultVerifier.newBuilder(strOrNumOrBoolOrArrStrNumBool, // >
// strOrNumOrBoolOrArrStrNumBool).mixedArraysCheck().emptyArrayCheck().build())); ops.add(createBinaryOperator(context, ">", boolOrArrBool, TypeDescriptor.ANY, TypeDescriptor.ANY,
// // > RResultVerifier.newBuilder(TypeDescriptor.ANY, TypeDescriptor.ANY).compareParametersCheck().build()));
// ops.add(createBinaryOperator(context, ">", boolOrArrBool, strOrNumOrBoolOrArrStrNumBool, // <=
// strOrNumOrBoolOrArrStrNumBool, ops.add(createBinaryOperator(context, "<=", boolOrArrBool, TypeDescriptor.ANY, TypeDescriptor.ANY,
// RResultVerifier.newBuilder(strOrNumOrBoolOrArrStrNumBool, RResultVerifier.newBuilder(TypeDescriptor.ANY, TypeDescriptor.ANY).compareParametersCheck().build()));
// strOrNumOrBoolOrArrStrNumBool).mixedArraysCheck().emptyArrayCheck().build())); // >=
// // <= ops.add(createBinaryOperator(context, ">=", boolOrArrBool, TypeDescriptor.ANY, TypeDescriptor.ANY,
// ops.add(createBinaryOperator(context, "<=", boolOrArrBool, strOrNumOrBoolOrArrStrNumBool, RResultVerifier.newBuilder(TypeDescriptor.ANY, TypeDescriptor.ANY).compareParametersCheck().build()));
// strOrNumOrBoolOrArrStrNumBool, // ==
// RResultVerifier.newBuilder(strOrNumOrBoolOrArrStrNumBool, ops.add(createBinaryOperator(context, "==", boolOrArrBool, TypeDescriptor.ANY, TypeDescriptor.ANY,
// strOrNumOrBoolOrArrStrNumBool).mixedArraysCheck().emptyArrayCheck().build())); RResultVerifier.newBuilder(TypeDescriptor.ANY, TypeDescriptor.ANY).compareParametersCheck().build()));
// // >= // !=
// ops.add(createBinaryOperator(context, ">=", boolOrArrBool, strOrNumOrBoolOrArrStrNumBool, ops.add(createBinaryOperator(context, "!=", boolOrArrBool, TypeDescriptor.ANY, TypeDescriptor.ANY,
// strOrNumOrBoolOrArrStrNumBool, RResultVerifier.newBuilder(TypeDescriptor.ANY, TypeDescriptor.ANY).compareParametersCheck().build()));
// RResultVerifier.newBuilder(strOrNumOrBoolOrArrStrNumBool,
// strOrNumOrBoolOrArrStrNumBool).mixedArraysCheck().emptyArrayCheck().build()));
// // ==
// ops.add(createBinaryOperator(context, "==", boolOrArrBool, strOrNumOrBoolOrArrStrNumBool,
// strOrNumOrBoolOrArrStrNumBool,
// RResultVerifier.newBuilder(strOrNumOrBoolOrArrStrNumBool,
// strOrNumOrBoolOrArrStrNumBool).mixedArraysCheck().emptyArrayCheck().build()));
// // !=
// ops.add(createBinaryOperator(context, "!=", boolOrArrBool, strOrNumOrBoolOrArrStrNumBool,
// strOrNumOrBoolOrArrStrNumBool,
// RResultVerifier.newBuilder(strOrNumOrBoolOrArrStrNumBool,
// strOrNumOrBoolOrArrStrNumBool).mixedArraysCheck().emptyArrayCheck().build()));
// // TODO &, |, &&, || // // TODO &, |, &&, ||
// ! // !
...@@ -485,44 +466,74 @@ public final class RTCKLanguageProvider implements LanguageProvider { ...@@ -485,44 +466,74 @@ public final class RTCKLanguageProvider implements LanguageProvider {
return this; return this;
} }
// TODO cause occasional and more then occasional fails on gate builds // - not empty homogenous number, boolean or string arrays -> vector
// Todo: Is it R bug or should verifier handle this? // - any other array -> list
// [1,"TEST"] < [1,2] works
// [1,"TEST"] < [1,"TEST"] fails
// Builder mixedArraysCheck() {
// chain = new BiFunction<Boolean, SnippetRun, Void>() {
// private final BiFunction<Boolean, SnippetRun, Void> next = chain;
//
// @Override
// public Void apply(Boolean valid, SnippetRun sr) {
// if (valid && sr.getException() != null && areMixedArrays(sr.getParameters())) {
// return null;
// }
// return next.apply(valid, sr);
// }
// //
// private boolean areMixedArrays(List<? extends Value> args) { // comparing:
// for (Value arg : args) { // - null with anything does not fail - logical(0)
// if (!arg.hasArrayElements()) { // - empty list or vector with anything does not fail - logical(0)
// return false; // - atomic vectors does not fail
// } // - a list with an atomic vector does not fail
// boolean str = false; // - a list with another list FAILS
// boolean num = false; // - other kind of object with anything but null or empty list or vector FAILS
// for (int i = 0; i < arg.getArraySize(); i++) { Builder compareParametersCheck() {
// TypeDescriptor td = TypeDescriptor.forValue(arg.getArrayElement(i)); chain = new BiFunction<Boolean, SnippetRun, Void>() {
// str |= TypeDescriptor.STRING.isAssignable(td); private final BiFunction<Boolean, SnippetRun, Void> next = chain;
// num |= TypeDescriptor.NUMBER.isAssignable(td) ||
// TypeDescriptor.BOOLEAN.isAssignable(td); @Override
// } public Void apply(Boolean valid, SnippetRun sr) {
// if ((!str & !num) || (str ^ num)) { if (valid && sr.getException() != null && expectsException(sr.getParameters())) {
// return false; return null;
// } }
// } return next.apply(valid, sr);
// return !args.isEmpty(); }
// }
// }; private boolean expectsException(List<? extends Value> args) {
// return this; boolean parametersValid = false;
// } int mixed = 0;
for (Value arg : args) {
parametersValid = false;
if (arg.isNull()) {
// one of the given parameters is NULL
// this is never expected to fail
return false;
}
if (arg.isNumber() || arg.isString() || arg.isBoolean()) {
parametersValid = true;
} else if (arg.hasArrayElements()) {
if (arg.getArraySize() == 0) {
// one of the given parameters is an emtpy list or vector,
// this is never expected to fail
return false;
} else {
boolean str = false;
boolean num = false;
boolean other = false;
for (int i = 0; i < arg.getArraySize(); i++) {
TypeDescriptor td = TypeDescriptor.forValue(arg.getArrayElement(i));
if (TypeDescriptor.STRING.isAssignable(td)) {
str = true;
} else if (TypeDescriptor.NUMBER.isAssignable(td) || TypeDescriptor.BOOLEAN.isAssignable(td)) {
num = true;
} else {
other = true;
}
}
parametersValid = !other;
if (str && num) {
mixed++;
}
}
}
if (!parametersValid) {
break;
}
}
return !(parametersValid && mixed < args.size());
}
};
return this;
}
RResultVerifier build() { RResultVerifier build() {
return new RResultVerifier(expectedParameterTypes, chain); return new RResultVerifier(expectedParameterTypes, chain);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment