Skip to content

Commit 90031bd

Browse files
LostKobrakaiBenjamin Milde
andauthored
Fix math tests (#48)
Co-authored-by: Benjamin Milde <[email protected]>
1 parent 51b4645 commit 90031bd

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

test/ecto/integration/math_test.exs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ defmodule Ecto.Integration.MathTest do
8989

9090
query = from(p in Product, select: fragment("acos(?)", p.price))
9191

92-
[nil] = TestRepo.all(query)
92+
assert [nil] = TestRepo.all(query)
9393
end
9494

9595
test "decimal below -1.0" do
@@ -98,7 +98,7 @@ defmodule Ecto.Integration.MathTest do
9898

9999
query = from(p in Product, select: fragment("acos(?)", p.price))
100100

101-
[nil] = TestRepo.all(query)
101+
assert [nil] = TestRepo.all(query)
102102
end
103103

104104
test "decimal at 0.3" do
@@ -108,31 +108,34 @@ defmodule Ecto.Integration.MathTest do
108108
query = from(p in Product, select: fragment("acos(?)", p.price))
109109

110110
# Right now, sqlite will return the acos function as an IEEE float
111-
[1.2661036727794992] = TestRepo.all(query)
111+
[num] = TestRepo.all(query)
112+
assert_in_delta num, 1.266103672779499, 0.000000000000001
112113
end
113114

114115
test "float above 1.0" do
115116
TestRepo.insert!(%Vec3f{x: 1.1, y: 1.2, z: 1.3})
116117

117118
query = from(v in Vec3f, select: fragment("acos(?)", v.x))
118119

119-
[nil] = TestRepo.all(query)
120+
assert [nil] = TestRepo.all(query)
120121
end
121122

122123
test "float below -1.0" do
123124
TestRepo.insert!(%Vec3f{x: -1.1, y: 1.2, z: 1.3})
124125

125126
query = from(v in Vec3f, select: fragment("acos(?)", v.x))
126127

127-
[nil] = TestRepo.all(query)
128+
assert [nil] = TestRepo.all(query)
128129
end
129130

130131
test "float at 0.3" do
131132
TestRepo.insert!(%Vec3f{x: 0.3, y: 1.2, z: 1.3})
132133

133134
query = from(v in Vec3f, select: fragment("acos(?)", v.x))
134135

135-
[1.2661036727794992] = TestRepo.all(query)
136+
[num] = TestRepo.all(query)
137+
138+
assert_in_delta num, 1.266103672779499, 0.000000000000001
136139
end
137140
end
138141
end

0 commit comments

Comments
 (0)