elm-pages 3.0.0-beta.10 → 3.0.0-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateData.elmo +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/i.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/o.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm.json +1 -1
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +1326 -121
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Runner.elm.js +15156 -13244
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
- package/generator/dead-code-review/elm.json +6 -5
- package/generator/dead-code-review/src/Pages/Review/DeadCodeEliminateData.elm +1 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/i.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/o.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm.json +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +1326 -121
- package/generator/review/elm-stuff/tests-0.19.1/js/Runner.elm.js +14574 -12631
- package/generator/review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
- package/generator/review/elm.json +6 -6
- package/generator/src/build.js +6 -9
- package/generator/src/cli.js +120 -42
- package/generator/src/codegen.js +11 -10
- package/generator/src/compatibility-key.js +1 -1
- package/generator/src/elm-codegen.js +3 -0
- package/generator/src/render-worker.js +1 -1
- package/generator/src/render.js +222 -37
- package/generator/src/request-cache.js +1 -0
- package/generator/src/rewrite-elm-json.js +3 -3
- package/package.json +12 -12
- package/src/ApiRoute.elm +147 -9
- package/src/DataSource/Env.elm +27 -3
- package/src/DataSource.elm +11 -22
- package/src/Form.elm +32 -32
- package/src/Head.elm +112 -8
- package/src/MultiDict.elm +49 -0
- package/src/Pages/Generate.elm +4 -1
- package/src/Pages/GeneratorProgramConfig.elm +15 -0
- package/src/Pages/Internal/Platform/CompatibilityKey.elm +1 -1
- package/src/Pages/Internal/Platform/GeneratorApplication.elm +455 -0
- package/src/Pages/Manifest.elm +24 -0
- package/src/Pages/Script.elm +100 -0
- package/src/PairingHeap.elm +137 -0
- package/src/Parser/Extra/String.elm +33 -0
- package/src/Parser/Extra.elm +69 -0
- package/src/ProgramTest/ComplexQuery.elm +360 -0
- package/src/ProgramTest/EffectSimulation.elm +122 -0
- package/src/ProgramTest/Failure.elm +367 -0
- package/src/ProgramTest/HtmlHighlighter.elm +116 -0
- package/src/ProgramTest/HtmlParserHacks.elm +58 -0
- package/src/ProgramTest/HtmlRenderer.elm +73 -0
- package/src/ProgramTest/Program.elm +30 -0
- package/src/ProgramTest/StringLines.elm +26 -0
- package/src/ProgramTest/TestHtmlHacks.elm +132 -0
- package/src/ProgramTest/TestHtmlParser.elm +201 -0
- package/src/ProgramTest.elm +2339 -0
- package/src/Query/Extra.elm +55 -0
- package/src/Result/Extra.elm +21 -0
- package/src/Server/Request.elm +2 -2
- package/src/SimulatedEffect/Cmd.elm +69 -0
- package/src/SimulatedEffect/Http.elm +330 -0
- package/src/SimulatedEffect/Navigation.elm +69 -0
- package/src/SimulatedEffect/Ports.elm +62 -0
- package/src/SimulatedEffect/Process.elm +24 -0
- package/src/SimulatedEffect/Sub.elm +48 -0
- package/src/SimulatedEffect/Task.elm +252 -0
- package/src/SimulatedEffect/Time.elm +25 -0
- package/src/SimulatedEffect.elm +42 -0
- package/src/String/Extra.elm +6 -0
- package/src/Test/Http.elm +145 -0
- package/src/TestResult.elm +35 -0
- package/src/TestState.elm +305 -0
- package/src/Url/Extra.elm +100 -0
- package/src/Vendored/Diff.elm +321 -0
- package/src/Vendored/Failure.elm +217 -0
- package/src/Vendored/FormatMonochrome.elm +44 -0
- package/src/Vendored/Highlightable.elm +53 -0
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
-- NOTE: This is copy/pasted from https://github.com/jinjor/elm-diff
|
|
2
|
+
-- License:
|
|
3
|
+
{-
|
|
4
|
+
Copyright (c) 2016, Yosuke Torii
|
|
5
|
+
All rights reserved.
|
|
6
|
+
|
|
7
|
+
Redistribution and use in source and binary forms, with or without
|
|
8
|
+
modification, are permitted provided that the following conditions are met:
|
|
9
|
+
|
|
10
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
11
|
+
list of conditions and the following disclaimer.
|
|
12
|
+
|
|
13
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
14
|
+
this list of conditions and the following disclaimer in the documentation
|
|
15
|
+
and/or other materials provided with the distribution.
|
|
16
|
+
|
|
17
|
+
* Neither the name of elm-diff nor the names of its
|
|
18
|
+
contributors may be used to endorse or promote products derived from
|
|
19
|
+
this software without specific prior written permission.
|
|
20
|
+
|
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
22
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
23
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
24
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
25
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
26
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
27
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
28
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
29
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
30
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
31
|
+
|
|
32
|
+
-}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
module Vendored.Diff exposing
|
|
36
|
+
( Change(..)
|
|
37
|
+
, diff
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
{-| Compares two list and returns how they have changed.
|
|
41
|
+
Each function internally uses Wu's [O(NP) algorithm](http://myerslab.mpi-cbg.de/wp-content/uploads/2014/06/np_diff.pdf).
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# Types
|
|
45
|
+
|
|
46
|
+
@docs Change
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# Diffing
|
|
50
|
+
|
|
51
|
+
@docs diff, diffLines
|
|
52
|
+
|
|
53
|
+
-}
|
|
54
|
+
|
|
55
|
+
import Array exposing (Array)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
{-| This describes how each line has changed and also contains its value.
|
|
59
|
+
-}
|
|
60
|
+
type Change a
|
|
61
|
+
= Added a
|
|
62
|
+
| Removed a
|
|
63
|
+
| NoChange a
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
type StepResult
|
|
67
|
+
= Continue (Array (List ( Int, Int )))
|
|
68
|
+
| Found (List ( Int, Int ))
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
type BugReport
|
|
72
|
+
= CannotGetA Int
|
|
73
|
+
| CannotGetB Int
|
|
74
|
+
| UnexpectedPath ( Int, Int ) (List ( Int, Int ))
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
{-| Compares general lists.
|
|
78
|
+
|
|
79
|
+
diff [ 1, 3 ] [ 2, 3 ] == [ Removed 1, Added 2, NoChange 3 ] -- True
|
|
80
|
+
|
|
81
|
+
-}
|
|
82
|
+
diff : List a -> List a -> List (Change a)
|
|
83
|
+
diff a b =
|
|
84
|
+
case testDiff a b of
|
|
85
|
+
Ok changes ->
|
|
86
|
+
changes
|
|
87
|
+
|
|
88
|
+
Err _ ->
|
|
89
|
+
[]
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
{-| Test the algolithm itself.
|
|
93
|
+
If it returns Err, it should be a bug.
|
|
94
|
+
-}
|
|
95
|
+
testDiff : List a -> List a -> Result BugReport (List (Change a))
|
|
96
|
+
testDiff a b =
|
|
97
|
+
let
|
|
98
|
+
arrA =
|
|
99
|
+
Array.fromList a
|
|
100
|
+
|
|
101
|
+
arrB =
|
|
102
|
+
Array.fromList b
|
|
103
|
+
|
|
104
|
+
m =
|
|
105
|
+
Array.length arrA
|
|
106
|
+
|
|
107
|
+
n =
|
|
108
|
+
Array.length arrB
|
|
109
|
+
|
|
110
|
+
-- Elm's Array doesn't allow null element,
|
|
111
|
+
-- so we'll use shifted index to access source.
|
|
112
|
+
getA =
|
|
113
|
+
\x -> Array.get (x - 1) arrA
|
|
114
|
+
|
|
115
|
+
getB =
|
|
116
|
+
\y -> Array.get (y - 1) arrB
|
|
117
|
+
|
|
118
|
+
path =
|
|
119
|
+
-- Is there any case ond is needed?
|
|
120
|
+
-- ond getA getB m n
|
|
121
|
+
onp getA getB m n
|
|
122
|
+
in
|
|
123
|
+
makeChanges getA getB path
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
makeChanges :
|
|
127
|
+
(Int -> Maybe a)
|
|
128
|
+
-> (Int -> Maybe a)
|
|
129
|
+
-> List ( Int, Int )
|
|
130
|
+
-> Result BugReport (List (Change a))
|
|
131
|
+
makeChanges getA getB path =
|
|
132
|
+
case path of
|
|
133
|
+
[] ->
|
|
134
|
+
Ok []
|
|
135
|
+
|
|
136
|
+
latest :: tail ->
|
|
137
|
+
makeChangesHelp [] getA getB latest tail
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
makeChangesHelp :
|
|
141
|
+
List (Change a)
|
|
142
|
+
-> (Int -> Maybe a)
|
|
143
|
+
-> (Int -> Maybe a)
|
|
144
|
+
-> ( Int, Int )
|
|
145
|
+
-> List ( Int, Int )
|
|
146
|
+
-> Result BugReport (List (Change a))
|
|
147
|
+
makeChangesHelp changes getA getB ( x, y ) path =
|
|
148
|
+
case path of
|
|
149
|
+
[] ->
|
|
150
|
+
Ok changes
|
|
151
|
+
|
|
152
|
+
( prevX, prevY ) :: tail ->
|
|
153
|
+
let
|
|
154
|
+
change =
|
|
155
|
+
if x - 1 == prevX && y - 1 == prevY then
|
|
156
|
+
case getA x of
|
|
157
|
+
Just a ->
|
|
158
|
+
Ok (NoChange a)
|
|
159
|
+
|
|
160
|
+
Nothing ->
|
|
161
|
+
Err (CannotGetA x)
|
|
162
|
+
|
|
163
|
+
else if x == prevX then
|
|
164
|
+
case getB y of
|
|
165
|
+
Just b ->
|
|
166
|
+
Ok (Added b)
|
|
167
|
+
|
|
168
|
+
Nothing ->
|
|
169
|
+
Err (CannotGetB y)
|
|
170
|
+
|
|
171
|
+
else if y == prevY then
|
|
172
|
+
case getA x of
|
|
173
|
+
Just a ->
|
|
174
|
+
Ok (Removed a)
|
|
175
|
+
|
|
176
|
+
Nothing ->
|
|
177
|
+
Err (CannotGetA x)
|
|
178
|
+
|
|
179
|
+
else
|
|
180
|
+
Err (UnexpectedPath ( x, y ) path)
|
|
181
|
+
in
|
|
182
|
+
case change of
|
|
183
|
+
Err err ->
|
|
184
|
+
Err err
|
|
185
|
+
|
|
186
|
+
Ok c ->
|
|
187
|
+
makeChangesHelp (c :: changes) getA getB ( prevX, prevY ) tail
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
-- Wu's O(NP) algorithm (http://myerslab.mpi-cbg.de/wp-content/uploads/2014/06/np_diff.pdf)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
onp : (Int -> Maybe a) -> (Int -> Maybe a) -> Int -> Int -> List ( Int, Int )
|
|
195
|
+
onp getA getB m n =
|
|
196
|
+
let
|
|
197
|
+
v =
|
|
198
|
+
Array.initialize (m + n + 1) (always [])
|
|
199
|
+
|
|
200
|
+
delta =
|
|
201
|
+
n - m
|
|
202
|
+
in
|
|
203
|
+
onpLoopP (snake getA getB) delta m 0 v
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
onpLoopP :
|
|
207
|
+
(Int -> Int -> List ( Int, Int ) -> ( List ( Int, Int ), Bool ))
|
|
208
|
+
-> Int
|
|
209
|
+
-> Int
|
|
210
|
+
-> Int
|
|
211
|
+
-> Array (List ( Int, Int ))
|
|
212
|
+
-> List ( Int, Int )
|
|
213
|
+
onpLoopP snake_ delta offset p v =
|
|
214
|
+
let
|
|
215
|
+
ks =
|
|
216
|
+
if delta > 0 then
|
|
217
|
+
List.reverse (List.range (delta + 1) (delta + p))
|
|
218
|
+
++ List.range -p delta
|
|
219
|
+
|
|
220
|
+
else
|
|
221
|
+
List.reverse (List.range (delta + 1) p)
|
|
222
|
+
++ List.range (-p + delta) delta
|
|
223
|
+
in
|
|
224
|
+
case onpLoopK snake_ offset ks v of
|
|
225
|
+
Found path ->
|
|
226
|
+
path
|
|
227
|
+
|
|
228
|
+
Continue v_ ->
|
|
229
|
+
onpLoopP snake_ delta offset (p + 1) v_
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
onpLoopK :
|
|
233
|
+
(Int -> Int -> List ( Int, Int ) -> ( List ( Int, Int ), Bool ))
|
|
234
|
+
-> Int
|
|
235
|
+
-> List Int
|
|
236
|
+
-> Array (List ( Int, Int ))
|
|
237
|
+
-> StepResult
|
|
238
|
+
onpLoopK snake_ offset ks v =
|
|
239
|
+
case ks of
|
|
240
|
+
[] ->
|
|
241
|
+
Continue v
|
|
242
|
+
|
|
243
|
+
k :: ks_ ->
|
|
244
|
+
case step snake_ offset k v of
|
|
245
|
+
Found path ->
|
|
246
|
+
Found path
|
|
247
|
+
|
|
248
|
+
Continue v_ ->
|
|
249
|
+
onpLoopK snake_ offset ks_ v_
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
step :
|
|
253
|
+
(Int -> Int -> List ( Int, Int ) -> ( List ( Int, Int ), Bool ))
|
|
254
|
+
-> Int
|
|
255
|
+
-> Int
|
|
256
|
+
-> Array (List ( Int, Int ))
|
|
257
|
+
-> StepResult
|
|
258
|
+
step snake_ offset k v =
|
|
259
|
+
let
|
|
260
|
+
fromLeft =
|
|
261
|
+
Maybe.withDefault [] (Array.get (k - 1 + offset) v)
|
|
262
|
+
|
|
263
|
+
fromTop =
|
|
264
|
+
Maybe.withDefault [] (Array.get (k + 1 + offset) v)
|
|
265
|
+
|
|
266
|
+
( path, ( x, y ) ) =
|
|
267
|
+
case ( fromLeft, fromTop ) of
|
|
268
|
+
( [], [] ) ->
|
|
269
|
+
( [], ( 0, 0 ) )
|
|
270
|
+
|
|
271
|
+
( [], ( topX, topY ) :: _ ) ->
|
|
272
|
+
( fromTop, ( topX + 1, topY ) )
|
|
273
|
+
|
|
274
|
+
( ( leftX, leftY ) :: _, [] ) ->
|
|
275
|
+
( fromLeft, ( leftX, leftY + 1 ) )
|
|
276
|
+
|
|
277
|
+
( ( leftX, leftY ) :: _, ( topX, topY ) :: _ ) ->
|
|
278
|
+
-- this implies "remove" comes always earlier than "add"
|
|
279
|
+
if leftY + 1 >= topY then
|
|
280
|
+
( fromLeft, ( leftX, leftY + 1 ) )
|
|
281
|
+
|
|
282
|
+
else
|
|
283
|
+
( fromTop, ( topX + 1, topY ) )
|
|
284
|
+
|
|
285
|
+
( newPath, goal ) =
|
|
286
|
+
snake_ (x + 1) (y + 1) (( x, y ) :: path)
|
|
287
|
+
in
|
|
288
|
+
if goal then
|
|
289
|
+
Found newPath
|
|
290
|
+
|
|
291
|
+
else
|
|
292
|
+
Continue (Array.set (k + offset) newPath v)
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
snake :
|
|
296
|
+
(Int -> Maybe a)
|
|
297
|
+
-> (Int -> Maybe a)
|
|
298
|
+
-> Int
|
|
299
|
+
-> Int
|
|
300
|
+
-> List ( Int, Int )
|
|
301
|
+
-> ( List ( Int, Int ), Bool )
|
|
302
|
+
snake getA getB nextX nextY path =
|
|
303
|
+
case ( getA nextX, getB nextY ) of
|
|
304
|
+
( Just a, Just b ) ->
|
|
305
|
+
if a == b then
|
|
306
|
+
snake
|
|
307
|
+
getA
|
|
308
|
+
getB
|
|
309
|
+
(nextX + 1)
|
|
310
|
+
(nextY + 1)
|
|
311
|
+
(( nextX, nextY ) :: path)
|
|
312
|
+
|
|
313
|
+
else
|
|
314
|
+
( path, False )
|
|
315
|
+
|
|
316
|
+
-- reached bottom-right corner
|
|
317
|
+
( Nothing, Nothing ) ->
|
|
318
|
+
( path, True )
|
|
319
|
+
|
|
320
|
+
_ ->
|
|
321
|
+
( path, False )
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
-- Copied from rtfeldman/node-test-runner : elm/src/Test/Reporter/Console/Format.elm
|
|
2
|
+
-- https://github.com/rtfeldman/node-test-runner/blob/master/elm/src/Test/Reporter/Console/Format.elm
|
|
3
|
+
-- Published under BSD-3-Clause license, see LICENSE_node-test-runner
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
module Vendored.Failure exposing (format)
|
|
7
|
+
|
|
8
|
+
import Test.Runner.Failure exposing (InvalidReason(..), Reason(..))
|
|
9
|
+
import Vendored.Highlightable as Highlightable exposing (Highlightable)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
format :
|
|
13
|
+
(List (Highlightable String) -> List (Highlightable String) -> ( String, String ))
|
|
14
|
+
-> String
|
|
15
|
+
-> Reason
|
|
16
|
+
-> String
|
|
17
|
+
format formatEquality description reason =
|
|
18
|
+
case reason of
|
|
19
|
+
Custom ->
|
|
20
|
+
description
|
|
21
|
+
|
|
22
|
+
Equality expected actual ->
|
|
23
|
+
case highlightEqual expected actual of
|
|
24
|
+
Nothing ->
|
|
25
|
+
verticalBar description expected actual
|
|
26
|
+
|
|
27
|
+
Just ( highlightedExpected, highlightedActual ) ->
|
|
28
|
+
let
|
|
29
|
+
( formattedExpected, formattedActual ) =
|
|
30
|
+
formatEquality highlightedExpected highlightedActual
|
|
31
|
+
in
|
|
32
|
+
verticalBar description formattedExpected formattedActual
|
|
33
|
+
|
|
34
|
+
Comparison first second ->
|
|
35
|
+
verticalBar description first second
|
|
36
|
+
|
|
37
|
+
TODO ->
|
|
38
|
+
description
|
|
39
|
+
|
|
40
|
+
Invalid BadDescription ->
|
|
41
|
+
if description == "" then
|
|
42
|
+
"The empty string is not a valid test description."
|
|
43
|
+
|
|
44
|
+
else
|
|
45
|
+
"This is an invalid test description: " ++ description
|
|
46
|
+
|
|
47
|
+
Invalid _ ->
|
|
48
|
+
description
|
|
49
|
+
|
|
50
|
+
ListDiff expected actual ->
|
|
51
|
+
listDiffToString 0
|
|
52
|
+
description
|
|
53
|
+
{ expected = expected
|
|
54
|
+
, actual = actual
|
|
55
|
+
}
|
|
56
|
+
{ originalExpected = expected
|
|
57
|
+
, originalActual = actual
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
CollectionDiff { expected, actual, extra, missing } ->
|
|
61
|
+
let
|
|
62
|
+
extraStr =
|
|
63
|
+
if List.isEmpty extra then
|
|
64
|
+
""
|
|
65
|
+
|
|
66
|
+
else
|
|
67
|
+
"\nThese keys are extra: "
|
|
68
|
+
++ (extra |> String.join ", " |> (\d -> "[ " ++ d ++ " ]"))
|
|
69
|
+
|
|
70
|
+
missingStr =
|
|
71
|
+
if List.isEmpty missing then
|
|
72
|
+
""
|
|
73
|
+
|
|
74
|
+
else
|
|
75
|
+
"\nThese keys are missing: "
|
|
76
|
+
++ (missing |> String.join ", " |> (\d -> "[ " ++ d ++ " ]"))
|
|
77
|
+
in
|
|
78
|
+
String.join ""
|
|
79
|
+
[ verticalBar description expected actual
|
|
80
|
+
, "\n"
|
|
81
|
+
, extraStr
|
|
82
|
+
, missingStr
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
highlightEqual : String -> String -> Maybe ( List (Highlightable String), List (Highlightable String) )
|
|
87
|
+
highlightEqual expected actual =
|
|
88
|
+
if expected == "\"\"" || actual == "\"\"" then
|
|
89
|
+
-- Diffing when one is the empty string looks silly. Don't bother.
|
|
90
|
+
Nothing
|
|
91
|
+
|
|
92
|
+
else if isFloat expected && isFloat actual then
|
|
93
|
+
-- Diffing numbers looks silly. Don't bother.
|
|
94
|
+
Nothing
|
|
95
|
+
|
|
96
|
+
else
|
|
97
|
+
let
|
|
98
|
+
isHighlighted =
|
|
99
|
+
Highlightable.resolve
|
|
100
|
+
{ fromHighlighted = always True
|
|
101
|
+
, fromPlain = always False
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
edgeCount highlightedString =
|
|
105
|
+
let
|
|
106
|
+
highlights =
|
|
107
|
+
List.map isHighlighted highlightedString
|
|
108
|
+
in
|
|
109
|
+
highlights
|
|
110
|
+
|> List.map2 Tuple.pair (List.drop 1 highlights)
|
|
111
|
+
|> List.filter (\( lhs, rhs ) -> lhs /= rhs)
|
|
112
|
+
|> List.length
|
|
113
|
+
|
|
114
|
+
expectedChars =
|
|
115
|
+
String.toList expected
|
|
116
|
+
|
|
117
|
+
actualChars =
|
|
118
|
+
String.toList actual
|
|
119
|
+
|
|
120
|
+
highlightedExpected =
|
|
121
|
+
Highlightable.diffLists expectedChars actualChars
|
|
122
|
+
|> List.map (Highlightable.map String.fromChar)
|
|
123
|
+
|
|
124
|
+
highlightedActual =
|
|
125
|
+
Highlightable.diffLists actualChars expectedChars
|
|
126
|
+
|> List.map (Highlightable.map String.fromChar)
|
|
127
|
+
|
|
128
|
+
plainCharCount =
|
|
129
|
+
highlightedExpected
|
|
130
|
+
|> List.filter (not << isHighlighted)
|
|
131
|
+
|> List.length
|
|
132
|
+
in
|
|
133
|
+
if edgeCount highlightedActual > plainCharCount || edgeCount highlightedExpected > plainCharCount then
|
|
134
|
+
-- Large number of small highlighted blocks. Diff is too messy to be useful.
|
|
135
|
+
Nothing
|
|
136
|
+
|
|
137
|
+
else
|
|
138
|
+
Just
|
|
139
|
+
( highlightedExpected
|
|
140
|
+
, highlightedActual
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
isFloat : String -> Bool
|
|
145
|
+
isFloat str =
|
|
146
|
+
case String.toFloat str of
|
|
147
|
+
Just _ ->
|
|
148
|
+
True
|
|
149
|
+
|
|
150
|
+
Nothing ->
|
|
151
|
+
False
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
listDiffToString :
|
|
155
|
+
Int
|
|
156
|
+
-> String
|
|
157
|
+
-> { expected : List String, actual : List String }
|
|
158
|
+
-> { originalExpected : List String, originalActual : List String }
|
|
159
|
+
-> String
|
|
160
|
+
listDiffToString index description { expected, actual } originals =
|
|
161
|
+
case ( expected, actual ) of
|
|
162
|
+
( [], [] ) ->
|
|
163
|
+
[ "Two lists were unequal previously, yet ended up equal later."
|
|
164
|
+
, "This should never happen!"
|
|
165
|
+
, "Please report this bug to https://github.com/elm-community/elm-test/issues - and include these lists: "
|
|
166
|
+
, "\n"
|
|
167
|
+
, String.join ", " originals.originalExpected
|
|
168
|
+
, "\n"
|
|
169
|
+
, String.join ", " originals.originalActual
|
|
170
|
+
]
|
|
171
|
+
|> String.join ""
|
|
172
|
+
|
|
173
|
+
( _ :: _, [] ) ->
|
|
174
|
+
verticalBar (description ++ " was shorter than")
|
|
175
|
+
(String.join ", " originals.originalExpected)
|
|
176
|
+
(String.join ", " originals.originalActual)
|
|
177
|
+
|
|
178
|
+
( [], _ :: _ ) ->
|
|
179
|
+
verticalBar (description ++ " was longer than")
|
|
180
|
+
(String.join ", " originals.originalExpected)
|
|
181
|
+
(String.join ", " originals.originalActual)
|
|
182
|
+
|
|
183
|
+
( firstExpected :: restExpected, firstActual :: restActual ) ->
|
|
184
|
+
if firstExpected == firstActual then
|
|
185
|
+
-- They're still the same so far; keep going.
|
|
186
|
+
listDiffToString (index + 1)
|
|
187
|
+
description
|
|
188
|
+
{ expected = restExpected
|
|
189
|
+
, actual = restActual
|
|
190
|
+
}
|
|
191
|
+
originals
|
|
192
|
+
|
|
193
|
+
else
|
|
194
|
+
-- We found elements that differ; fail!
|
|
195
|
+
String.join ""
|
|
196
|
+
[ verticalBar description
|
|
197
|
+
(String.join ", " originals.originalExpected)
|
|
198
|
+
(String.join ", " originals.originalActual)
|
|
199
|
+
, "\n\nThe first diff is at index "
|
|
200
|
+
, String.fromInt index
|
|
201
|
+
, ": it was `"
|
|
202
|
+
, firstActual
|
|
203
|
+
, "`, but `"
|
|
204
|
+
, firstExpected
|
|
205
|
+
, "` was expected."
|
|
206
|
+
]
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
verticalBar : String -> String -> String -> String
|
|
210
|
+
verticalBar comparison expected actual =
|
|
211
|
+
[ actual
|
|
212
|
+
, "╷"
|
|
213
|
+
, "│ " ++ comparison
|
|
214
|
+
, "╵"
|
|
215
|
+
, expected
|
|
216
|
+
]
|
|
217
|
+
|> String.join "\n"
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
-- Copied from rtfeldman/node-test-runner : elm/src/Test/Reporter/Console/Format/Monochrome.elm
|
|
2
|
+
-- https://github.com/rtfeldman/node-test-runner/blob/master/elm/src/Test/Reporter/Console/Format/Monochrome.elm
|
|
3
|
+
-- Published under BSD-3-Clause license, see LICENSE_node-test-runner
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
module Vendored.FormatMonochrome exposing (formatEquality)
|
|
7
|
+
|
|
8
|
+
import Vendored.Highlightable as Highlightable exposing (Highlightable(..))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
formatEquality : List (Highlightable String) -> List (Highlightable String) -> ( String, String )
|
|
12
|
+
formatEquality highlightedExpected highlightedActual =
|
|
13
|
+
let
|
|
14
|
+
( formattedExpected, expectedIndicators ) =
|
|
15
|
+
highlightedExpected
|
|
16
|
+
|> List.map (fromHighlightable "▲")
|
|
17
|
+
|> List.unzip
|
|
18
|
+
|
|
19
|
+
( formattedActual, actualIndicators ) =
|
|
20
|
+
highlightedActual
|
|
21
|
+
|> List.map (fromHighlightable "▼")
|
|
22
|
+
|> List.unzip
|
|
23
|
+
|
|
24
|
+
combinedExpected =
|
|
25
|
+
String.join "\n"
|
|
26
|
+
[ String.join "" formattedExpected
|
|
27
|
+
, String.join "" expectedIndicators
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
combinedActual =
|
|
31
|
+
String.join "\n"
|
|
32
|
+
[ String.join "" actualIndicators
|
|
33
|
+
, String.join "" formattedActual
|
|
34
|
+
]
|
|
35
|
+
in
|
|
36
|
+
( combinedExpected, combinedActual )
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
fromHighlightable : String -> Highlightable String -> ( String, String )
|
|
40
|
+
fromHighlightable indicator =
|
|
41
|
+
Highlightable.resolve
|
|
42
|
+
{ fromHighlighted = \char -> ( char, indicator )
|
|
43
|
+
, fromPlain = \char -> ( char, " " )
|
|
44
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
-- Copied from rtfeldman/node-test-runner : elm/src/Test/Reporter/Highlightable.elm
|
|
2
|
+
-- https://github.com/rtfeldman/node-test-runner/blob/master/elm/src/Test/Reporter/Highlightable.elm
|
|
3
|
+
-- Published under BSD-3-Clause license, see LICENSE_node-test-runner
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
module Vendored.Highlightable exposing (Highlightable, diffLists, map, resolve)
|
|
7
|
+
|
|
8
|
+
import Vendored.Diff as Diff exposing (Change(..))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
type Highlightable a
|
|
12
|
+
= Highlighted a
|
|
13
|
+
| Plain a
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
resolve : { fromHighlighted : a -> b, fromPlain : a -> b } -> Highlightable a -> b
|
|
17
|
+
resolve { fromHighlighted, fromPlain } highlightable =
|
|
18
|
+
case highlightable of
|
|
19
|
+
Highlighted val ->
|
|
20
|
+
fromHighlighted val
|
|
21
|
+
|
|
22
|
+
Plain val ->
|
|
23
|
+
fromPlain val
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
diffLists : List a -> List a -> List (Highlightable a)
|
|
27
|
+
diffLists expected actual =
|
|
28
|
+
-- TODO make sure this looks reasonable for multiline strings
|
|
29
|
+
Diff.diff expected actual
|
|
30
|
+
|> List.concatMap fromDiff
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
map : (a -> b) -> Highlightable a -> Highlightable b
|
|
34
|
+
map transform highlightable =
|
|
35
|
+
case highlightable of
|
|
36
|
+
Highlighted val ->
|
|
37
|
+
Highlighted (transform val)
|
|
38
|
+
|
|
39
|
+
Plain val ->
|
|
40
|
+
Plain (transform val)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
fromDiff : Change a -> List (Highlightable a)
|
|
44
|
+
fromDiff diff =
|
|
45
|
+
case diff of
|
|
46
|
+
Added _ ->
|
|
47
|
+
[]
|
|
48
|
+
|
|
49
|
+
Removed char ->
|
|
50
|
+
[ Highlighted char ]
|
|
51
|
+
|
|
52
|
+
NoChange char ->
|
|
53
|
+
[ Plain char ]
|