Skip to content

Commit

Permalink
Improve test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
PetroZarytskyi committed Jan 22, 2024
1 parent 4db4d8e commit a94a447
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/Gradient/Assignments.C
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,43 @@ double f21 (double x, double y) {
//CHECK-NEXT: }
//CHECK-NEXT: }

double f22(double x, double y) {
if (x > 0) {
double& ref = x;
ref *= y;
}
return x;
}

//CHECK: void f22_grad(double x, double y, clad::array_ref<double> _d_x, clad::array_ref<double> _d_y) {
//CHECK-NEXT: bool _cond0;
//CHECK-NEXT: double *_d_ref = 0;
//CHECK-NEXT: double _t0;
//CHECK-NEXT: double *_t1;
//CHECK-NEXT: _cond0 = x > 0;
//CHECK-NEXT: if (_cond0) {
//CHECK-NEXT: _d_ref = &* _d_x;
//CHECK-NEXT: double &ref = x;
//CHECK-NEXT: _t0 = ref;
//CHECK-NEXT: ref *= y;
//CHECK-NEXT: _t1 = &ref;
//CHECK-NEXT: }
//CHECK-NEXT: goto _label0;
//CHECK-NEXT: _label0:
//CHECK-NEXT: ;
//CHECK-NEXT: * _d_x += 1;
//CHECK-NEXT: if (_cond0) {
//CHECK-NEXT: double &ref = *_t1;
//CHECK-NEXT: {
//CHECK-NEXT: ref = _t0;
//CHECK-NEXT: double _r_d0 = *_d_ref;
//CHECK-NEXT: *_d_ref += _r_d0 * y;
//CHECK-NEXT: * _d_y += ref * _r_d0;
//CHECK-NEXT: *_d_ref -= _r_d0;
//CHECK-NEXT: }
//CHECK-NEXT: }
//CHECK-NEXT: }

#define TEST(F, x, y) \
{ \
result[0] = 0; \
Expand Down Expand Up @@ -973,4 +1010,5 @@ int main() {
TEST(f19, 1, 2); // CHECK-EXEC: {2.00, 2.00}
TEST(f20, 1, 2); // CHECK-EXEC: {0.00, 3.00}
TEST(f21, 6, 4); // CHECK-EXEC: {1.00, 0.00}
TEST(f22, 1, 2); // CHECK-EXEC: {2.00, 1.00}
}

0 comments on commit a94a447

Please sign in to comment.