Skip to content

Commit

Permalink
Address review suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
HindujaB committed Oct 6, 2023
1 parent 7fa7796 commit bcbf2b7
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import io.ballerina.runtime.internal.types.BTupleType;
import io.ballerina.runtime.internal.values.ReadOnlyUtils;
import org.jetbrains.annotations.Nullable;
import org.testng.Assert;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -186,7 +187,7 @@ public static BString getParamTypesString(BFunctionPointer func) {

public static BArray getConstituentTypes(BArray array) {
Optional<IntersectionType> arrayType = ((IntersectableReferenceType) array.getType()).getIntersectionType();
assert arrayType.isPresent();
Assert.assertTrue(arrayType.isPresent());
List<Type> constituentTypes = arrayType.get().getConstituentTypes();
int size = constituentTypes.size();
BArray arrayValue =
Expand Down Expand Up @@ -396,12 +397,12 @@ public static Object validateFunctionParameterExtern(BFunctionPointer fpValue) {
@Nullable
private static BError validateFunctionType(FunctionType functionType) {
Parameter[] parameters = functionType.getParameters();
assert parameters[0].type.getTag() == TypeTags.TYPE_REFERENCED_TYPE_TAG;
Assert.assertEquals(parameters[0].type.getTag(), TypeTags.TYPE_REFERENCED_TYPE_TAG);
AnnotatableType annotatableType = (AnnotatableType) parameters[0].type;
if (annotatableType.getAnnotation(intAnnotation) == null) {
return constraintError;
}
assert parameters[1].type.getTag() == TypeTags.TYPE_REFERENCED_TYPE_TAG;
Assert.assertEquals(parameters[1].type.getTag(), TypeTags.TYPE_REFERENCED_TYPE_TAG);
annotatableType = (AnnotatableType) parameters[1].type;
if (annotatableType.getAnnotation(intAnnotation) == null) {
return constraintError;
Expand Down Expand Up @@ -500,7 +501,7 @@ public static BError getErrorValue(BString errorTypeName) {
BString errorMsg = StringUtils.fromString("error message!");
BError bError = ErrorCreator.createError(errorModule, errorTypeName.getValue(), errorTypeName,
ErrorCreator.createError(errorMsg), ValueCreator.createMapValue());
assert bError.getType().getName().equals(errorTypeName.getValue());
Assert.assertEquals(bError.getType().getName(), errorTypeName.getValue());
return bError;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.ballerina.runtime.api.async.Callback;
import io.ballerina.runtime.api.values.BError;
import io.ballerina.runtime.internal.values.ObjectValue;
import org.testng.Assert;

/**
* This class is used for Java interoperability tests.
Expand All @@ -39,7 +40,7 @@ public class Accumulator {
public static void accumulate(Environment env, ObjectValue intFunction, long from, long to) {
Runtime runtime = env.getRuntime();
Future future = env.markAsync();
assert from <= to;
Assert.assertTrue(from <= to);
accumulateI(intFunction, from, to, runtime, future, new long[1]);
}

Expand All @@ -59,8 +60,8 @@ public void notifySuccess(Object result) {

@Override
public void notifyFailure(BError error) {
assert error == null;
assert false;
Assert.assertNull(error);
Assert.fail();
}
}, null, PredefinedTypes.TYPE_NULL, i, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.ballerina.runtime.api.Environment;
import io.ballerina.runtime.api.Future;
import io.ballerina.runtime.internal.scheduling.AsyncUtils;
import org.testng.Assert;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -59,7 +60,7 @@ private static void sleep() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
assert false;
Assert.fail(e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import io.ballerina.runtime.internal.values.TableValue;
import io.ballerina.runtime.internal.values.TupleValueImpl;
import io.ballerina.runtime.internal.values.TypedescValue;
import org.testng.Assert;

import java.io.IOException;
import java.math.BigDecimal;
Expand Down Expand Up @@ -597,7 +598,7 @@ private static void sleep() {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
assert false;
Assert.fail(e.getMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.ballerina.runtime.api.PredefinedTypes;
import io.ballerina.runtime.api.Runtime;
import io.ballerina.runtime.internal.values.ObjectValue;
import org.testng.Assert;

/**
* This class is used for Java interoperability tests.
Expand All @@ -47,7 +48,7 @@ public static void sleep(int millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
assert false;
Assert.fail(e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import io.ballerina.runtime.internal.values.ObjectValue;
import io.ballerina.runtime.internal.values.TableValue;
import io.ballerina.runtime.internal.values.TupleValueImpl;
import org.testng.Assert;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -152,7 +153,7 @@ public static MapValue query(BString query, BTypedesc typedesc) {

public static BStream getStreamOfRecords(ObjectValue objectValue, BStream strm, BTypedesc typedesc) {
RecordType streamConstraint = (RecordType) typedesc.getDescribingType();
assert streamConstraint == TypeUtils.getImpliedType(strm.getConstraintType());
Assert.assertSame(streamConstraint, TypeUtils.getImpliedType(strm.getConstraintType()));
return strm;
}

Expand Down Expand Up @@ -253,7 +254,7 @@ public static Object getInvalidValue(BTypedesc td1, BTypedesc td2) {
return getRecord(td2);
}

assert tag == RECORD_TYPE_TAG;
Assert.assertEquals(tag, RECORD_TYPE_TAG);
return 200;
}

Expand Down Expand Up @@ -428,8 +429,8 @@ public static Object getResource(BObject client, BArray path, BTypedesc targetTy
if (targetTypeTag == STRING_TAG) {
return StringUtils.fromString(path.toString());
}
assert targetTypeTag == INT_TAG;

Assert.assertEquals(targetTypeTag, INT_TAG);
return 0;
}

Expand Down Expand Up @@ -477,7 +478,7 @@ public static BArray funcWithMultipleArgs(long i, BTypedesc td, BArray arr) {
return arr;
}

assert td.getDescribingType().getTag() == INT_TAG;
Assert.assertEquals(td.getDescribingType().getTag(), INT_TAG);
return ValueCreator.createArrayValue(new long[]{arr.getLength(), i});
}

Expand All @@ -488,7 +489,7 @@ public static Object funcReturningUnionWithBuiltInRefType(Object strm, BTypedesc
return strm;
}

assert tag == BYTE_TAG;
Assert.assertEquals(tag, BYTE_TAG);
if (strm == null) {
return 100L;
}
Expand All @@ -501,22 +502,22 @@ public static Object getValueWithUnionReturnType(Object val, BTypedesc td) {

Type describingType = td.getDescribingType();
if (tag == RECORD_TYPE_TAG) {
assert describingType.getTag() == INT_TAG;
Assert.assertEquals(describingType.getTag(), INT_TAG);
return 101L;
}

if (tag == OBJECT_TYPE_TAG) {
assert describingType.getTag() == ARRAY_TAG &&
((BArrayType) describingType).getElementType().getTag() == STRING_TAG;
Assert.assertEquals(describingType.getTag(), ARRAY_TAG);
Assert.assertEquals(((BArrayType) describingType).getElementType().getTag(), STRING_TAG);
return val;
}

assert describingType.getTag() == BOOLEAN_TAG;
Assert.assertEquals(describingType.getTag(), BOOLEAN_TAG);
return !((boolean) val);
}

public static BFunctionPointer getFunctionWithAnyFunctionParamType(BFunctionPointer x, BTypedesc td) {
assert td.getDescribingType().getTag() == INT_TAG;
Assert.assertEquals(td.getDescribingType().getTag(), INT_TAG);
return x;
}

Expand All @@ -529,7 +530,7 @@ public static Object functionWithInferredArgForParamOfTypeReferenceType(BTypedes
return 9876L;
}

assert tag == STRING_TAG;
Assert.assertEquals(tag, STRING_TAG);
return StringUtils.fromString("hello!");
}
}

0 comments on commit bcbf2b7

Please sign in to comment.