Skip to content

Commit

Permalink
Add inequality tests from Rudiments
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Jan 26, 2024
1 parent c89047d commit e48f2d3
Showing 1 changed file with 226 additions and 0 deletions.
226 changes: 226 additions & 0 deletions src/test/tests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,231 @@ object Tests extends Suite(t"Hypotenuse tests"):
test(t"Construct an unsigned integer"):
val left: U64 = 123

suite(t"Inequality tests"):
test(t"1.2 < x < 1.4"):
List(1.1, 1.2, 1.3, 1.4, 1.5).filter(1.2 < _ < 1.4)
.assert(_ == List(1.3))

test(t"1.2 < x <= 1.4"):
List(1.1, 1.2, 1.3, 1.4, 1.5).filter(1.2 < _ <= 1.4)
.assert(_ == List(1.3, 1.4))

test(t"1.2 <= x < 1.4"):
List(1.1, 1.2, 1.3, 1.4, 1.5).filter(1.2 <= _ < 1.4)
.assert(_ == List(1.2, 1.3))

test(t"1.2 <= x <= 1.4"):
List(1.1, 1.2, 1.3, 1.4, 1.5).filter(1.2 <= _ <= 1.4)
.assert(_ == List(1.2, 1.3, 1.4))

test(t"2 < x < 4"):
List(1, 2, 3, 4, 5).filter(2 < _ < 4)
.assert(_ == List(3))

test(t"2 < x <= 4"):
List(1, 2, 3, 4, 5).filter(2 < _ <= 4)
.assert(_ == List(3, 4))

test(t"2 <= x < 4"):
List(1, 2, 3, 4, 5).filter(2 <= _ < 4)
.assert(_ == List(2, 3))

test(t"2 <= x <= 4"):
List(1, 2, 3, 4, 5).filter(2 <= _ <= 4)
.assert(_ == List(2, 3, 4))

test(t"2L < x < 4L"):
List(1L, 2L, 3L, 4L, 5L).filter(2L < _ < 4L)
.assert(_ == List(3L))

test(t"2L < x <= 4L"):
List(1L, 2L, 3L, 4L, 5L).filter(2L < _ <= 4L)
.assert(_ == List(3L, 4L))

test(t"2L <= x < 4L"):
List(1L, 2L, 3L, 4L, 5L).filter(2L <= _ < 4L)
.assert(_ == List(2L, 3L))

test(t"2L <= x <= 4L"):
List(1L, 2L, 3L, 4L, 5L).filter(2L <= _ <= 4L)
.assert(_ == List(2L, 3L, 4L))

test(t"2F < x < 4F"):
List(1F, 2F, 3F, 4F, 5F).filter(2F < _ < 4F)
.assert(_ == List(3F))

test(t"2F < x <= 4F"):
List(1F, 2F, 3F, 4F, 5F).filter(2F < _ <= 4F)
.assert(_ == List(3F, 4F))

test(t"2F <= x < 4F"):
List(1F, 2F, 3F, 4F, 5F).filter(2F <= _ < 4F)
.assert(_ == List(2F, 3F))

test(t"2F <= x <= 4F"):
List(1F, 2F, 3F, 4F, 5F).filter(2F <= _ <= 4F)
.assert(_ == List(2F, 3F, 4F))

test(t"'2' < x < '4'"):
List('1', '2', '3', '4', '5').filter('2' < _ < '4')
.assert(_ == List('3'))

test(t"'2' < x <= '4'"):
List('1', '2', '3', '4', '5').filter('2' < _ <= '4')
.assert(_ == List('3', '4'))

test(t"'2' <= x < '4'"):
List('1', '2', '3', '4', '5').filter('2' <= _ < '4')
.assert(_ == List('2', '3'))

test(t"'2' <= x <= '4'"):
List('1', '2', '3', '4', '5').filter('2' <= _ <= '4')
.assert(_ == List('2', '3', '4'))

test(t"2.toByte < x < 4.toByte"):
List(1.toByte, 2.toByte, 3.toByte, 4.toByte, 5.toByte).filter(2.toByte < _ < 4.toByte)
.assert(_ == List(3.toByte))

test(t"2.toByte < x <= 4.toByte"):
List(1.toByte, 2.toByte, 3.toByte, 4.toByte, 5.toByte).filter(2.toByte < _ <= 4.toByte)
.assert(_ == List(3.toByte, 4.toByte))

test(t"2.toByte <= x < 4.toByte"):
List(1.toByte, 2.toByte, 3.toByte, 4.toByte, 5.toByte).filter(2.toByte <= _ < 4.toByte)
.assert(_ == List(2.toByte, 3.toByte))

test(t"2.toByte <= x <= 4.toByte"):
List(1.toByte, 2.toByte, 3.toByte, 4.toByte, 5.toByte).filter(2.toByte <= _ <= 4.toByte)
.assert(_ == List(2.toByte, 3.toByte, 4.toByte))

test(t"2.toShort < x < 4.toShort"):
List(1.toShort, 2.toShort, 3.toShort, 4.toShort, 5.toShort).filter(2.toShort < _ < 4.toShort)
.assert(_ == List(3.toShort))

test(t"2.toShort < x <= 4.toShort"):
List(1.toShort, 2.toShort, 3.toShort, 4.toShort, 5.toShort).filter(2.toShort < _ <= 4.toShort)
.assert(_ == List(3.toShort, 4.toShort))

test(t"2.toShort <= x < 4.toShort"):
List(1.toShort, 2.toShort, 3.toShort, 4.toShort, 5.toShort).filter(2.toShort <= _ < 4.toShort)
.assert(_ == List(2.toShort, 3.toShort))

test(t"2.toShort <= x <= 4.toShort"):
List(1.toShort, 2.toShort, 3.toShort, 4.toShort, 5.toShort).filter(2.toShort <= _ <= 4.toShort)
.assert(_ == List(2.toShort, 3.toShort, 4.toShort))



test(t"1.2 > x > 1.4"):
List(1.1, 1.2, 1.3, 1.4, 1.5).filter(1.4 > _ > 1.2)
.assert(_ == List(1.3))

test(t"1.2 >= x > 1.4"):
List(1.1, 1.2, 1.3, 1.4, 1.5).filter(1.4 >= _ > 1.2)
.assert(_ == List(1.3, 1.4))

test(t"1.2 > x >= 1.4"):
List(1.1, 1.2, 1.3, 1.4, 1.5).filter(1.4 > _ >= 1.2)
.assert(_ == List(1.2, 1.3))

test(t"1.2 >= x >= 1.4"):
List(1.1, 1.2, 1.3, 1.4, 1.5).filter(1.4 >= _ >= 1.2)
.assert(_ == List(1.2, 1.3, 1.4))

test(t"2 > x > 4"):
List(1, 2, 3, 4, 5).filter(4 > _ > 2)
.assert(_ == List(3))

test(t"2 >= x > 4"):
List(1, 2, 3, 4, 5).filter(4 >= _ > 2)
.assert(_ == List(3, 4))

test(t"2 > x >= 4"):
List(1, 2, 3, 4, 5).filter(4 > _ >= 2)
.assert(_ == List(2, 3))

test(t"2 >= x >= 4"):
List(1, 2, 3, 4, 5).filter(4 >= _ >= 2)
.assert(_ == List(2, 3, 4))

test(t"2L > x > 4L"):
List(1L, 2L, 3L, 4L, 5L).filter(4L > _ > 2L)
.assert(_ == List(3L))

test(t"2L >= x > 4L"):
List(1L, 2L, 3L, 4L, 5L).filter(4L >= _ > 2L)
.assert(_ == List(3L, 4L))

test(t"2L > x >= 4L"):
List(1L, 2L, 3L, 4L, 5L).filter(4L > _ >= 2L)
.assert(_ == List(2L, 3L))

test(t"2L >= x >= 4L"):
List(1L, 2L, 3L, 4L, 5L).filter(4L >= _ >= 2L)
.assert(_ == List(2L, 3L, 4L))

test(t"2F > x > 4F"):
List(1F, 2F, 3F, 4F, 5F).filter(4F > _ > 2F)
.assert(_ == List(3F))

test(t"2F >= x > 4F"):
List(1F, 2F, 3F, 4F, 5F).filter(4F >= _ > 2F)
.assert(_ == List(3F, 4F))

test(t"2F > x >= 4F"):
List(1F, 2F, 3F, 4F, 5F).filter(4F > _ >= 2F)
.assert(_ == List(2F, 3F))

test(t"2F >= x >= 4F"):
List(1F, 2F, 3F, 4F, 5F).filter(4F >= _ >= 2F)
.assert(_ == List(2F, 3F, 4F))

test(t"'2' > x > '4'"):
List('1', '2', '3', '4', '5').filter('4' > _ > '2')
.assert(_ == List('3'))

test(t"'2' >= x > '4'"):
List('1', '2', '3', '4', '5').filter('4' >=_ > '2')
.assert(_ == List('3', '4'))

test(t"'2' > x >= '4'"):
List('1', '2', '3', '4', '5').filter('4' > _ >= '2')
.assert(_ == List('2', '3'))

test(t"'2' >= x >= '4'"):
List('1', '2', '3', '4', '5').filter('4' >= _ >= '2')
.assert(_ == List('2', '3', '4'))

test(t"2.toByte > x > 4.toByte"):
List(1.toByte, 2.toByte, 3.toByte, 4.toByte, 5.toByte).filter(4.toByte > _ > 2.toByte)
.assert(_ == List(3.toByte))

test(t"2.toByte >= x > 4.toByte"):
List(1.toByte, 2.toByte, 3.toByte, 4.toByte, 5.toByte).filter(4.toByte >= _ > 2.toByte)
.assert(_ == List(3.toByte, 4.toByte))

test(t"2.toByte > x >= 4.toByte"):
List(1.toByte, 2.toByte, 3.toByte, 4.toByte, 5.toByte).filter(4.toByte > _ >= 2.toByte)
.assert(_ == List(2.toByte, 3.toByte))

test(t"2.toByte >= x >= 4.toByte"):
List(1.toByte, 2.toByte, 3.toByte, 4.toByte, 5.toByte).filter(4.toByte >= _ >= 2.toByte)
.assert(_ == List(2.toByte, 3.toByte, 4.toByte))

test(t"2.toShort > x > 4.toShort"):
List(1.toShort, 2.toShort, 3.toShort, 4.toShort, 5.toShort).filter(4.toShort > _ > 2.toShort)
.assert(_ == List(3.toShort))

test(t"2.toShort >= x > 4.toShort"):
List(1.toShort, 2.toShort, 3.toShort, 4.toShort, 5.toShort).filter(4.toShort >= _ > 2.toShort)
.assert(_ == List(3.toShort, 4.toShort))

test(t"2.toShort > x >= 4.toShort"):
List(1.toShort, 2.toShort, 3.toShort, 4.toShort, 5.toShort).filter(4.toShort > _ >= 2.toShort)
.assert(_ == List(2.toShort, 3.toShort))

test(t"2.toShort >= x >= 4.toShort"):
List(1.toShort, 2.toShort, 3.toShort, 4.toShort, 5.toShort).filter(4.toShort >= _ >= 2.toShort)
.assert(_ == List(2.toShort, 3.toShort, 4.toShort))


0 comments on commit e48f2d3

Please sign in to comment.