(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestTemporalValidation(t *testing.T) { |
| 12 | tests := []struct { |
| 13 | name string |
| 14 | program string |
| 15 | wantErr bool |
| 16 | err string |
| 17 | }{ |
| 18 | { |
| 19 | name: "valid temporal predicate", |
| 20 | program: ` |
| 21 | Decl p(X) temporal bound [/any]. |
| 22 | p(1) @[2020-01-01, 2021-01-01]. |
| 23 | `, |
| 24 | wantErr: false, |
| 25 | }, |
| 26 | { |
| 27 | name: "valid synthetic temporal predicate", |
| 28 | program: ` |
| 29 | p(1) @[2020-01-01, 2021-01-01]. |
| 30 | p(2) @[2021-01-01, 2022-01-01]. |
| 31 | `, |
| 32 | wantErr: false, |
| 33 | }, |
| 34 | { |
| 35 | name: "invalid non-temporal predicate with annotation", |
| 36 | program: ` |
| 37 | Decl p(X) bound [/any]. |
| 38 | p(1) @[2020-01-01, 2021-01-01]. |
| 39 | `, |
| 40 | wantErr: true, |
| 41 | err: "predicate p(A0) is not declared temporal", |
| 42 | }, |
| 43 | { |
| 44 | name: "invalid eternal fact for temporal predicate", |
| 45 | program: ` |
| 46 | Decl p(X) temporal bound [/any]. |
| 47 | p(1). |
| 48 | `, |
| 49 | wantErr: true, |
| 50 | err: "defined without temporal annotation", |
| 51 | }, |
| 52 | { |
| 53 | name: "valid annotated fact for temporal predicate", |
| 54 | program: ` |
| 55 | Decl p(X) temporal bound [/any]. |
| 56 | p(1) @[2020-01-01, 2021-01-01]. |
| 57 | `, |
| 58 | wantErr: false, |
| 59 | }, |
| 60 | { |
| 61 | name: "mixed usage synthetic (invalid)", |
| 62 | program: ` |
| 63 | p(1) @[2020-01-01, 2021-01-01]. |
| 64 | p(2). |
| 65 | `, |
| 66 | wantErr: true, |
| 67 | err: "defined without temporal annotation", |
| 68 | }, |
nothing calls this directly
no test coverage detected