Skip to content

Commit b5344ea

Browse files
test: Rounding test for positions
Floats and irrational roots can create interesting test failures
1 parent f68863f commit b5344ea

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Turtle.tests.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ describe Turtle {
3636
$turtle = $turtle.Rotate($turtle.Towards(1,1))
3737
$turtle = $turtle.Forward($turtle.Distance(1,1))
3838
$turtle.Heading | Should -be 45
39-
$turtle.Position.X | Should -be 1
40-
$turtle.Position.Y | Should -be 1
39+
[Math]::Round($turtle.Position.X,10) | Should -be 1
40+
[Math]::Round($turtle.Position.Y,10) | Should -be 1
4141
$turtle = $turtle.Rotate($turtle.Towards(2,2))
4242
$turtle = $turtle.Forward($turtle.Distance(2,2))
4343
$turtle.Heading | Should -be 45
44-
$turtle.Position.X | Should -be 2
45-
$turtle.Position.Y | Should -be 2
44+
[Math]::Round($turtle.Position.Y,10) | Should -be 2
45+
[Math]::Round($turtle.Position.Y,10) | Should -be 2
4646
}
4747
}
4848

0 commit comments

Comments
 (0)