| 51 | using ::testing::Truly; |
| 52 | |
| 53 | TEST(CompilerFactoryTest, Works) { |
| 54 | ASSERT_OK_AND_ASSIGN( |
| 55 | auto builder, |
| 56 | NewCompilerBuilder(cel::internal::GetSharedTestingDescriptorPool())); |
| 57 | |
| 58 | ASSERT_THAT(builder->AddLibrary(StandardCompilerLibrary()), IsOk()); |
| 59 | ASSERT_OK_AND_ASSIGN(auto compiler, builder->Build()); |
| 60 | |
| 61 | ASSERT_OK_AND_ASSIGN( |
| 62 | ValidationResult result, |
| 63 | compiler->Compile("['a', 'b', 'c'].exists(x, x in ['c', 'd', 'e']) && 10 " |
| 64 | "< (5 % 3 * 2 + 1 - 2)")); |
| 65 | |
| 66 | ASSERT_TRUE(result.IsValid()); |
| 67 | |
| 68 | EXPECT_EQ(FormatBaselineAst(*result.GetAst()), |
| 69 | R"(_&&_( |
| 70 | __comprehension__( |
| 71 | // Variable |
| 72 | x, |
| 73 | // Target |
| 74 | [ |
| 75 | "a"~string, |
| 76 | "b"~string, |
| 77 | "c"~string |
| 78 | ]~list(string), |
| 79 | // Accumulator |
| 80 | @result, |
| 81 | // Init |
| 82 | false~bool, |
| 83 | // LoopCondition |
| 84 | @not_strictly_false( |
| 85 | !_( |
| 86 | @result~bool^@result |
| 87 | )~bool^logical_not |
| 88 | )~bool^not_strictly_false, |
| 89 | // LoopStep |
| 90 | _||_( |
| 91 | @result~bool^@result, |
| 92 | @in( |
| 93 | x~string^x, |
| 94 | [ |
| 95 | "c"~string, |
| 96 | "d"~string, |
| 97 | "e"~string |
| 98 | ]~list(string) |
| 99 | )~bool^in_list |
| 100 | )~bool^logical_or, |
| 101 | // Result |
| 102 | @result~bool^@result)~bool, |
| 103 | _<_( |
| 104 | 10~int, |
| 105 | _-_( |
| 106 | _+_( |
| 107 | _*_( |
| 108 | _%_( |
| 109 | 5~int, |
| 110 | 3~int |
nothing calls this directly
no test coverage detected