1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Test CE Demo Rules
// Demonstrates CLIPS-inspired Test CE feature
// Rule 1: Simple email validation using test CE
rule "ValidateEmail" salience 10 {
when
test(is_valid_email(User.email))
then
User.status = "valid";
Log("Email validation passed");
}
// Rule 2: Price range check with multiple arguments
rule "CheckPriceRange" salience 5 {
when
test(in_range(Product.price, 100, 1000))
then
Product.category = "mid-range";
Log("Product categorized as mid-range");
}
// Rule 3: Combined conditions - regular AND test CE
rule "ApproveOrder" salience 15 {
when
Order.amount > 100 &&
test(is_valid_email(Customer.email))
then
Order.status = "approved";
Order.discount = 50.0;
Log("Order approved with discount");
}
// Rule 4: Multiple test CEs combined
rule "PremiumCustomer" {
when
test(is_valid_email(Customer.email)) &&
test(in_range(Customer.age, 25, 65)) &&
Customer.spending > 1000
then
Customer.tier = "premium";
Log("Customer upgraded to premium");
}
// Rule 5: Negated test CE (using NOT operator)
rule "BlockInvalidEmail" {
when
User.checkEmail == true &&
!test(is_valid_email(User.email))
then
User.status = "blocked";
Log("Invalid email blocked");
}