Skip to content

Commit 678e7eb

Browse files
committed
Refactor test
1 parent 6c3faef commit 678e7eb

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

test/mudbrick/drawing_test.exs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,12 @@ defmodule Mudbrick.DrawingTest do
7070
import Path
7171

7272
assert [] =
73-
output(fn ->
73+
operations(fn ->
7474
new()
7575
end)
76-
|> operations()
7776
end
7877

79-
test "can fill a rectangle" do
78+
test "can render a rectangle" do
8079
import Path
8180

8281
assert [
@@ -85,11 +84,10 @@ defmodule Mudbrick.DrawingTest do
8584
"0 0 50 75 re",
8685
"S"
8786
] =
88-
output(fn ->
87+
operations(fn ->
8988
new()
9089
|> rectangle(lower_left: {0, 0}, dimensions: {50, 75})
9190
end)
92-
|> operations()
9391
end
9492

9593
test "can draw one path" do
@@ -102,11 +100,10 @@ defmodule Mudbrick.DrawingTest do
102100
"460 750 l",
103101
"S"
104102
] =
105-
output(fn ->
103+
operations(fn ->
106104
new()
107105
|> straight_line(from: {0, 650}, to: {460, 750})
108106
end)
109-
|> operations()
110107
end
111108

112109
test "can choose line width" do
@@ -119,11 +116,10 @@ defmodule Mudbrick.DrawingTest do
119116
"460 750 l",
120117
"S"
121118
] =
122-
output(fn ->
119+
operations(fn ->
123120
new()
124121
|> straight_line(from: {0, 650}, to: {460, 750}, line_width: 4.0)
125122
end)
126-
|> operations()
127123
end
128124

129125
test "can choose colour" do
@@ -136,11 +132,10 @@ defmodule Mudbrick.DrawingTest do
136132
"460 750 l",
137133
"S"
138134
] =
139-
output(fn ->
135+
operations(fn ->
140136
new()
141137
|> straight_line(from: {0, 650}, to: {460, 750}, colour: {0, 1, 0})
142138
end)
143-
|> operations()
144139
end
145140

146141
property "it's an error to set a colour above 1" do
@@ -158,9 +153,9 @@ defmodule Mudbrick.DrawingTest do
158153
end
159154
end
160155

161-
defp output(f), do: output(fn _ -> f.() end, Mudbrick.Path.Output)
162-
163-
defp operations(ops) do
164-
Enum.map(ops, &Mudbrick.TestHelper.show/1) |> Enum.reverse()
156+
defp operations(f) do
157+
output(fn _ -> f.() end, Mudbrick.Path.Output)
158+
|> Enum.map(&Mudbrick.TestHelper.show/1)
159+
|> Enum.reverse()
165160
end
166161
end

0 commit comments

Comments
 (0)