Skip to content

Commit

Permalink
Changes done for v1.1.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
Senthil Nathan committed Jun 7, 2021
1 parent eb697e7 commit 0b9ca45
Show file tree
Hide file tree
Showing 5 changed files with 234 additions and 43 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes

## v1.1.0
* June/07/2021
* Modified it to support the in operational verb for int32, float64 and rstring based tuple attributes and the inCI operational verb only for rstring based tuple attributes.

## v1.0.9
* June/01/2021
* Added two new operational verbs: in and inCI.
Expand Down
40 changes: 36 additions & 4 deletions com.ibm.streamsx.eval_predicate/EvalPredicateExample.spl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/*
==================================================================
First created on: Mar/05/2021
Last modified on: June/01/2021
Last modified on: June/07/2021

This is an example application that shows how to use the
eval_predicate function to evaluate an SPL expression a.k.a
Expand Down Expand Up @@ -859,13 +859,15 @@ composite EvalPredicateExample {
}

// ============== TESTCASE GROUP 5 ==============
type Role_t = rstring role, int32 x, float64 y;
type Role_t = rstring role, int32 age, float64 salary;
mutable Role_t myRole = {};
myRole.role = "Admin";
myRole.age = 56;
myRole.salary = 10514.00;

//
// 5.1
// Usage of in
// Usage of in for an rstring tuple attribute
// It does case sensitive membership test using a list literal string.
rule = 'role in ["Developer", "Tester", "Admin", "Manager"]';
result = eval_predicate(rule, myRole, error, $EVAL_PREDICATE_TRACING);
Expand All @@ -880,7 +882,7 @@ composite EvalPredicateExample {

//
// 5.2
// Usage of inCI
// Usage of inCI for an rstring tuple attribute
// It does case insensitive membership test using a list literal string.
myRole.role = "mAnAgEr";
rule = 'role inCI ["Developer", "Tester", "Admin", "Manager"]';
Expand All @@ -893,6 +895,36 @@ composite EvalPredicateExample {
} else {
printStringLn("Testcase 5.2: Evaluation execution failed. Error=" + (rstring)error);
}

//
// 5.3
// Usage of in for an int32 tuple attribute
// It does membership test using a list literal string.
rule = 'age in [22, 40, 43, 50, 56, 65]';
result = eval_predicate(rule, myRole, error, $EVAL_PREDICATE_TRACING);

if(result == true) {
printStringLn("Testcase 5.3: Evaluation criteria is met.");
} else if(result == false && error == 0) {
printStringLn("Testcase 5.3: Evaluation criteria is not met.");
} else {
printStringLn("Testcase 5.3: Evaluation execution failed. Error=" + (rstring)error);
}

//
// 5.4
// Usage of in for a float64 tuple attribute
// It does membership test using a list literal string.
rule = 'salary in [68326.45, 92821.87, 10514.00, 120529,32]';
result = eval_predicate(rule, myRole, error, $EVAL_PREDICATE_TRACING);

if(result == true) {
printStringLn("Testcase 5.4: Evaluation criteria is met.");
} else if(result == false && error == 0) {
printStringLn("Testcase 5.4: Evaluation criteria is not met.");
} else {
printStringLn("Testcase 5.4: Evaluation execution failed. Error=" + (rstring)error);
}
} // End of onTuple S
} // End of the Custom operator.
} // End of the main composite.
70 changes: 62 additions & 8 deletions com.ibm.streamsx.eval_predicate/FunctionalTests.spl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/*
==================================================================
First created on: Mar/28/2021
Last modified on: June/01/2021
Last modified on: June/07/2021

This application is meant for doing several hundred
functional tests to provide as much coverage as possible to
Expand Down Expand Up @@ -6768,11 +6768,13 @@ composite FunctionalTests {
}
// -------------------------

// A54.1 (Use of in for membership test.)
// A54.1 (Use of in for rstring membership test.)
// It does case sensitive membership test using a list literal string.
type Role_t = rstring role, int32 x, float64 y;
type Role_t = rstring role, int32 age, float64 salary;
mutable Role_t myRole = {};
myRole.role = "Admin";
myRole.age = 56;
myRole.salary = 10514.00;

_rule = 'role in ["Developer", "Tester", "Admin", "Manager"]';
result = eval_predicate(_rule, myRole, error, $EVAL_PREDICATE_TRACING);
Expand All @@ -6785,11 +6787,10 @@ composite FunctionalTests {
printStringLn("Testcase A54.1: Evaluation execution failed. Error=" + (rstring)error);
}

// A54.2 (Use of inCI for membership test.)
// A54.2 (Use of inCI for rstring membership test.)
// It does case insensitive membership test using a list literal string.
myRole.role = "mAnAgEr";
_rule = 'role inCI ["Developer", "Tester", "Admin", "Manager"]';

result = eval_predicate(_rule, myRole, error, $EVAL_PREDICATE_TRACING);

if(result == true) {
Expand All @@ -6799,6 +6800,58 @@ composite FunctionalTests {
} else {
printStringLn("Testcase A54.2: Evaluation execution failed. Error=" + (rstring)error);
}

// A54.3 (Use of in for int32 membership test.)
// It does membership test using a list literal string.
_rule = 'age in [22, 40, 43, 50, 56, 65]';
result = eval_predicate(_rule, myRole, error, $EVAL_PREDICATE_TRACING);

if(result == true) {
printStringLn("Testcase A54.3: Evaluation criteria is met.");
} else if(result == false && error == 0) {
printStringLn("Testcase A54.3: Evaluation criteria is not met.");
} else {
printStringLn("Testcase A54.3: Evaluation execution failed. Error=" + (rstring)error);
}

// A54.4 (Use of in for float64 membership test.)
// It does membership test using a list literal string.
_rule = 'salary in [68326.45, 92821.87, 10514.00, 120529,32]';
result = eval_predicate(_rule, myRole, error, $EVAL_PREDICATE_TRACING);

if(result == true) {
printStringLn("Testcase A54.4: Evaluation criteria is met.");
} else if(result == false && error == 0) {
printStringLn("Testcase A54.4: Evaluation criteria is not met.");
} else {
printStringLn("Testcase A54.4: Evaluation execution failed. Error=" + (rstring)error);
}

// A54.5 (Use of in for int32 membership test.)
// It does membership test using a list literal string.
_rule = 'age in [22, 40, 43, 50, 58, 65]';
result = eval_predicate(_rule, myRole, error, $EVAL_PREDICATE_TRACING);

if(result == true) {
printStringLn("Testcase A54.5: Evaluation criteria is met.");
} else if(result == false && error == 0) {
printStringLn("Testcase A54.5: Evaluation criteria is not met.");
} else {
printStringLn("Testcase A54.5: Evaluation execution failed. Error=" + (rstring)error);
}

// A54.6 (Use of in for float64 membership test.)
// It does membership test using a list literal string.
_rule = 'salary in [68326.45, 92821.87, 10594.76, 120529,32]';
result = eval_predicate(_rule, myRole, error, $EVAL_PREDICATE_TRACING);

if(result == true) {
printStringLn("Testcase A54.6: Evaluation criteria is met.");
} else if(result == false && error == 0) {
printStringLn("Testcase A54.6: Evaluation criteria is not met.");
} else {
printStringLn("Testcase A54.6: Evaluation execution failed. Error=" + (rstring)error);
}
// -------------------------
} // End of onTuple MTD.
} // End of the HappyPathSink operator.
Expand Down Expand Up @@ -8108,10 +8161,11 @@ composite FunctionalTests {
// -------------------------

// B82.1 (INCOMPATIBLE_IN_OPERATION_FOR_LHS_ATTRIB_TYPE 146)
type Role2_t = rstring role, int32 x, float64 y;
type Role2_t = rstring role, int32 x, float32 y;
mutable Role2_t myRole = {};
myRole.role = "Tester";
_rule = 'x in ["Developer", "Tester", "Admin", "Manager"]';

_rule = 'y in [1.1, 2.2, 3.3, 4.4, 5.5]';
result = eval_predicate(_rule, myRole, error, $EVAL_PREDICATE_TRACING);

if(result == true) {
Expand All @@ -8123,7 +8177,7 @@ composite FunctionalTests {
}

// B82.2 (INCOMPATIBLE_IN_CI_OPERATION_FOR_LHS_ATTRIB_TYPE 147)
_rule = 'x inCI ["Developer", "Tester", "Admin", "Manager"]';
_rule = 'x inCI [1, 2, 3, 4, 5]';
result = eval_predicate(_rule, myRole, error, $EVAL_PREDICATE_TRACING);

if(result == true) {
Expand Down
Loading

0 comments on commit 0b9ca45

Please sign in to comment.