Skip to content

Commit 207c072

Browse files
Merge pull request #87 from logicalmechanism/adding-additional-moment-tests
many moment tests added because of aipoph
2 parents 7c66144 + b543bd0 commit 207c072

File tree

1 file changed

+114
-2
lines changed

1 file changed

+114
-2
lines changed

lib/assist/types/moment.ak

Lines changed: 114 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,18 @@ test an_empty_moment() {
5858
is_logical(m) == True
5959
}
6060

61+
test a_singular_moment() {
62+
let m: Moment = Moment { start: 10, end: 10 }
63+
is_logical(m) == True
64+
}
65+
6166
test a_nonvalid_moment() {
6267
let m: Moment = Moment { start: 10, end: 0 }
6368
is_logical(m) == False
6469
}
6570

6671
test a_valid_moment() {
67-
let m: Moment = Moment { start: 10, end: 11230 }
72+
let m: Moment = Moment { start: 1, end: 15 }
6873
is_logical(m) == True
6974
}
7075

@@ -117,6 +122,23 @@ test infinite_bounds_not_allowed() {
117122
is_contained(m, vr) == False
118123
}
119124

125+
test infinite_bounds_not_allowed2() {
126+
let vr: ValidityRange =
127+
Interval {
128+
lower_bound: IntervalBound {
129+
bound_type: NegativeInfinity,
130+
is_inclusive: True,
131+
},
132+
upper_bound: IntervalBound {
133+
bound_type: PositiveInfinity,
134+
is_inclusive: True,
135+
},
136+
}
137+
let m: Moment = Moment { start: 1, end: 10 }
138+
// the bounds can not be infinite
139+
is_contained(m, vr) == False
140+
}
141+
120142
test an_empty_validity_range_inside_a_moment() {
121143
let vr: ValidityRange =
122144
Interval {
@@ -157,6 +179,16 @@ test a_validity_range_outside_a_moment() {
157179
is_contained(m, vr) == False
158180
}
159181

182+
test a_validity_range_outside_a_moment2() {
183+
let vr: ValidityRange =
184+
Interval {
185+
lower_bound: IntervalBound { bound_type: Finite(3), is_inclusive: True },
186+
upper_bound: IntervalBound { bound_type: Finite(5), is_inclusive: True },
187+
}
188+
let m: Moment = Moment { start: 6, end: 17 }
189+
is_contained(m, vr) == False
190+
}
191+
160192
/// Check if a validity range of a tx is after a moment.
161193
/// This assumes exclusivity.
162194
///
@@ -186,6 +218,26 @@ test a_validity_range_is_after_a_moment() {
186218
is_after(m, vr) == True
187219
}
188220

221+
test a_validity_range_start_at_the_end_of_a_moment() {
222+
let vr: ValidityRange =
223+
Interval {
224+
lower_bound: IntervalBound { bound_type: Finite(4), is_inclusive: True },
225+
upper_bound: IntervalBound { bound_type: Finite(10), is_inclusive: True },
226+
}
227+
let m: Moment = Moment { start: 1, end: 4 }
228+
is_after(m, vr) == False
229+
}
230+
231+
test a_validity_range_start_at_the_end_of_a_moment2() {
232+
let vr: ValidityRange =
233+
Interval {
234+
lower_bound: IntervalBound { bound_type: Finite(4), is_inclusive: False },
235+
upper_bound: IntervalBound { bound_type: Finite(10), is_inclusive: True },
236+
}
237+
let m: Moment = Moment { start: 1, end: 4 }
238+
is_after(m, vr) == False
239+
}
240+
189241
test a_validity_range_is_not_after_a_moment() {
190242
let vr: ValidityRange =
191243
Interval {
@@ -196,6 +248,26 @@ test a_validity_range_is_not_after_a_moment() {
196248
is_after(m, vr) == False
197249
}
198250

251+
test a_validity_range_is_not_after_a_moment2() {
252+
let vr: ValidityRange =
253+
Interval {
254+
lower_bound: IntervalBound { bound_type: Finite(0), is_inclusive: True },
255+
upper_bound: IntervalBound { bound_type: Finite(4), is_inclusive: True },
256+
}
257+
let m: Moment = Moment { start: 4, end: 12 }
258+
is_after(m, vr) == False
259+
}
260+
261+
test a_validity_range_is_not_after_a_moment3() {
262+
let vr: ValidityRange =
263+
Interval {
264+
lower_bound: IntervalBound { bound_type: Finite(8), is_inclusive: True },
265+
upper_bound: IntervalBound { bound_type: Finite(14), is_inclusive: True },
266+
}
267+
let m: Moment = Moment { start: 4, end: 12 }
268+
is_after(m, vr) == False
269+
}
270+
199271
/// Check if a validity range of a tx is before a moment.
200272
/// This assumes exclusivity.
201273
///
@@ -231,6 +303,46 @@ test a_validity_range_is_not_before_a_moment() {
231303
lower_bound: IntervalBound { bound_type: Finite(10), is_inclusive: True },
232304
upper_bound: IntervalBound { bound_type: Finite(12), is_inclusive: True },
233305
}
234-
let m: Moment = Moment { start: 11, end: 13 }
306+
let m: Moment = Moment { start: 5, end: 13 }
307+
is_before(m, vr) == False
308+
}
309+
310+
test a_validity_range_is_not_before_a_moment2() {
311+
let vr: ValidityRange =
312+
Interval {
313+
lower_bound: IntervalBound { bound_type: Finite(10), is_inclusive: True },
314+
upper_bound: IntervalBound { bound_type: Finite(16), is_inclusive: True },
315+
}
316+
let m: Moment = Moment { start: 5, end: 13 }
317+
is_before(m, vr) == False
318+
}
319+
320+
test a_validity_range_is_not_before_a_moment3() {
321+
let vr: ValidityRange =
322+
Interval {
323+
lower_bound: IntervalBound { bound_type: Finite(15), is_inclusive: True },
324+
upper_bound: IntervalBound { bound_type: Finite(17), is_inclusive: True },
325+
}
326+
let m: Moment = Moment { start: 5, end: 13 }
327+
is_before(m, vr) == False
328+
}
329+
330+
test a_validity_range_is_not_before_a_moment4() {
331+
let vr: ValidityRange =
332+
Interval {
333+
lower_bound: IntervalBound { bound_type: Finite(1), is_inclusive: True },
334+
upper_bound: IntervalBound { bound_type: Finite(7), is_inclusive: True },
335+
}
336+
let m: Moment = Moment { start: 5, end: 13 }
337+
is_before(m, vr) == False
338+
}
339+
340+
test a_validity_range_is_not_before_a_moment5() {
341+
let vr: ValidityRange =
342+
Interval {
343+
lower_bound: IntervalBound { bound_type: Finite(1), is_inclusive: True },
344+
upper_bound: IntervalBound { bound_type: Finite(5), is_inclusive: True },
345+
}
346+
let m: Moment = Moment { start: 5, end: 13 }
235347
is_before(m, vr) == False
236348
}

0 commit comments

Comments
 (0)