Skip to content

Commit 0b9ca45

Browse files
author
Senthil Nathan
committed
Changes done for v1.1.0.
1 parent eb697e7 commit 0b9ca45

File tree

5 files changed

+234
-43
lines changed

5 files changed

+234
-43
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changes
22

3+
## v1.1.0
4+
* June/07/2021
5+
* 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.
6+
37
## v1.0.9
48
* June/01/2021
59
* Added two new operational verbs: in and inCI.

com.ibm.streamsx.eval_predicate/EvalPredicateExample.spl

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/*
99
==================================================================
1010
First created on: Mar/05/2021
11-
Last modified on: June/01/2021
11+
Last modified on: June/07/2021
1212

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

861861
// ============== TESTCASE GROUP 5 ==============
862-
type Role_t = rstring role, int32 x, float64 y;
862+
type Role_t = rstring role, int32 age, float64 salary;
863863
mutable Role_t myRole = {};
864864
myRole.role = "Admin";
865+
myRole.age = 56;
866+
myRole.salary = 10514.00;
865867

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

881883
//
882884
// 5.2
883-
// Usage of inCI
885+
// Usage of inCI for an rstring tuple attribute
884886
// It does case insensitive membership test using a list literal string.
885887
myRole.role = "mAnAgEr";
886888
rule = 'role inCI ["Developer", "Tester", "Admin", "Manager"]';
@@ -893,6 +895,36 @@ composite EvalPredicateExample {
893895
} else {
894896
printStringLn("Testcase 5.2: Evaluation execution failed. Error=" + (rstring)error);
895897
}
898+
899+
//
900+
// 5.3
901+
// Usage of in for an int32 tuple attribute
902+
// It does membership test using a list literal string.
903+
rule = 'age in [22, 40, 43, 50, 56, 65]';
904+
result = eval_predicate(rule, myRole, error, $EVAL_PREDICATE_TRACING);
905+
906+
if(result == true) {
907+
printStringLn("Testcase 5.3: Evaluation criteria is met.");
908+
} else if(result == false && error == 0) {
909+
printStringLn("Testcase 5.3: Evaluation criteria is not met.");
910+
} else {
911+
printStringLn("Testcase 5.3: Evaluation execution failed. Error=" + (rstring)error);
912+
}
913+
914+
//
915+
// 5.4
916+
// Usage of in for a float64 tuple attribute
917+
// It does membership test using a list literal string.
918+
rule = 'salary in [68326.45, 92821.87, 10514.00, 120529,32]';
919+
result = eval_predicate(rule, myRole, error, $EVAL_PREDICATE_TRACING);
920+
921+
if(result == true) {
922+
printStringLn("Testcase 5.4: Evaluation criteria is met.");
923+
} else if(result == false && error == 0) {
924+
printStringLn("Testcase 5.4: Evaluation criteria is not met.");
925+
} else {
926+
printStringLn("Testcase 5.4: Evaluation execution failed. Error=" + (rstring)error);
927+
}
896928
} // End of onTuple S
897929
} // End of the Custom operator.
898930
} // End of the main composite.

com.ibm.streamsx.eval_predicate/FunctionalTests.spl

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/*
99
==================================================================
1010
First created on: Mar/28/2021
11-
Last modified on: June/01/2021
11+
Last modified on: June/07/2021
1212

1313
This application is meant for doing several hundred
1414
functional tests to provide as much coverage as possible to
@@ -6768,11 +6768,13 @@ composite FunctionalTests {
67686768
}
67696769
// -------------------------
67706770

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

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

6788-
// A54.2 (Use of inCI for membership test.)
6790+
// A54.2 (Use of inCI for rstring membership test.)
67896791
// It does case insensitive membership test using a list literal string.
67906792
myRole.role = "mAnAgEr";
67916793
_rule = 'role inCI ["Developer", "Tester", "Admin", "Manager"]';
6792-
67936794
result = eval_predicate(_rule, myRole, error, $EVAL_PREDICATE_TRACING);
67946795

67956796
if(result == true) {
@@ -6799,6 +6800,58 @@ composite FunctionalTests {
67996800
} else {
68006801
printStringLn("Testcase A54.2: Evaluation execution failed. Error=" + (rstring)error);
68016802
}
6803+
6804+
// A54.3 (Use of in for int32 membership test.)
6805+
// It does membership test using a list literal string.
6806+
_rule = 'age in [22, 40, 43, 50, 56, 65]';
6807+
result = eval_predicate(_rule, myRole, error, $EVAL_PREDICATE_TRACING);
6808+
6809+
if(result == true) {
6810+
printStringLn("Testcase A54.3: Evaluation criteria is met.");
6811+
} else if(result == false && error == 0) {
6812+
printStringLn("Testcase A54.3: Evaluation criteria is not met.");
6813+
} else {
6814+
printStringLn("Testcase A54.3: Evaluation execution failed. Error=" + (rstring)error);
6815+
}
6816+
6817+
// A54.4 (Use of in for float64 membership test.)
6818+
// It does membership test using a list literal string.
6819+
_rule = 'salary in [68326.45, 92821.87, 10514.00, 120529,32]';
6820+
result = eval_predicate(_rule, myRole, error, $EVAL_PREDICATE_TRACING);
6821+
6822+
if(result == true) {
6823+
printStringLn("Testcase A54.4: Evaluation criteria is met.");
6824+
} else if(result == false && error == 0) {
6825+
printStringLn("Testcase A54.4: Evaluation criteria is not met.");
6826+
} else {
6827+
printStringLn("Testcase A54.4: Evaluation execution failed. Error=" + (rstring)error);
6828+
}
6829+
6830+
// A54.5 (Use of in for int32 membership test.)
6831+
// It does membership test using a list literal string.
6832+
_rule = 'age in [22, 40, 43, 50, 58, 65]';
6833+
result = eval_predicate(_rule, myRole, error, $EVAL_PREDICATE_TRACING);
6834+
6835+
if(result == true) {
6836+
printStringLn("Testcase A54.5: Evaluation criteria is met.");
6837+
} else if(result == false && error == 0) {
6838+
printStringLn("Testcase A54.5: Evaluation criteria is not met.");
6839+
} else {
6840+
printStringLn("Testcase A54.5: Evaluation execution failed. Error=" + (rstring)error);
6841+
}
6842+
6843+
// A54.6 (Use of in for float64 membership test.)
6844+
// It does membership test using a list literal string.
6845+
_rule = 'salary in [68326.45, 92821.87, 10594.76, 120529,32]';
6846+
result = eval_predicate(_rule, myRole, error, $EVAL_PREDICATE_TRACING);
6847+
6848+
if(result == true) {
6849+
printStringLn("Testcase A54.6: Evaluation criteria is met.");
6850+
} else if(result == false && error == 0) {
6851+
printStringLn("Testcase A54.6: Evaluation criteria is not met.");
6852+
} else {
6853+
printStringLn("Testcase A54.6: Evaluation execution failed. Error=" + (rstring)error);
6854+
}
68026855
// -------------------------
68036856
} // End of onTuple MTD.
68046857
} // End of the HappyPathSink operator.
@@ -8108,10 +8161,11 @@ composite FunctionalTests {
81088161
// -------------------------
81098162

81108163
// B82.1 (INCOMPATIBLE_IN_OPERATION_FOR_LHS_ATTRIB_TYPE 146)
8111-
type Role2_t = rstring role, int32 x, float64 y;
8164+
type Role2_t = rstring role, int32 x, float32 y;
81128165
mutable Role2_t myRole = {};
81138166
myRole.role = "Tester";
8114-
_rule = 'x in ["Developer", "Tester", "Admin", "Manager"]';
8167+
8168+
_rule = 'y in [1.1, 2.2, 3.3, 4.4, 5.5]';
81158169
result = eval_predicate(_rule, myRole, error, $EVAL_PREDICATE_TRACING);
81168170

81178171
if(result == true) {
@@ -8123,7 +8177,7 @@ composite FunctionalTests {
81238177
}
81248178

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

81298183
if(result == true) {

0 commit comments

Comments
 (0)