@@ -59,10 +59,10 @@ testIsoURIRef = testIso URIRef.parser URIRef.print
59
59
testRunParseURIRefParses :: forall a . String -> Either URI RelativeRef -> TestSuite a
60
60
testRunParseURIRefParses = testRunParseSuccess URIRef .parser
61
61
62
- testRunParseURIRefFailes :: forall a . String -> TestSuite a
63
- testRunParseURIRefFailes uri =
62
+ testRunParseURIRefFails :: forall a . String -> TestSuite a
63
+ testRunParseURIRefFails uri =
64
64
test
65
- (" failes to parse: " <> uri)
65
+ (" fails to parse: " <> uri)
66
66
(assert (" parse should fail for: " <> uri) <<< isLeft <<< URIRef .parse $ uri)
67
67
68
68
testPrintQuerySerializes :: forall a . Query -> String -> TestSuite a
@@ -110,8 +110,8 @@ main = runTest $ suite "Data.URI" do
110
110
isLeft $ runParser Host .ipv4AddressParser " 192.168.001.1"
111
111
112
112
suite " Scheme parser" do
113
- testRunParseSuccess Scheme .parser " http" (Scheme " http" )
114
- testRunParseSuccess Scheme .parser " git+ssh" (Scheme " git+ssh" )
113
+ testRunParseSuccess Scheme .parser " http: " (Scheme " http" )
114
+ testRunParseSuccess Scheme .parser " git+ssh: " (Scheme " git+ssh" )
115
115
116
116
suite " UserInfo parser" do
117
117
testRunParseSuccess UserInfo .parser " user" (UserInfo " user" )
@@ -132,8 +132,14 @@ main = runTest $ suite "Data.URI" do
132
132
testRunParseSuccess Port .parser " 63174" (Port 63174 )
133
133
134
134
suite " Authority parser" do
135
- testRunParseSuccess Authority .parser " localhost" (Authority Nothing [Tuple (NameAddress " localhost" ) Nothing ])
136
- testRunParseSuccess Authority .parser " localhost:3000" (Authority Nothing [Tuple (NameAddress " localhost" ) (Just (Port 3000 ))] )
135
+ testRunParseSuccess
136
+ Authority .parser
137
+ " //localhost"
138
+ (Authority Nothing [Tuple (NameAddress " localhost" ) Nothing ])
139
+ testRunParseSuccess
140
+ Authority .parser
141
+ " //localhost:3000"
142
+ (Authority Nothing [Tuple (NameAddress " localhost" ) (Just (Port 3000 ))] )
137
143
138
144
suite " URIRef.parse" do
139
145
testIsoURIRef
@@ -321,6 +327,14 @@ main = runTest $ suite "Data.URI" do
321
327
(HierarchicalPart (Just (Authority Nothing [(Tuple (NameAddress " example.com" ) (Just (Port 8042 )))] )) (Just (Right ((rootDir </> dir " over" ) </> file " there" ))))
322
328
(Just (Query (singleton (Tuple " name" (Just " ferret" )))))
323
329
(Just (Fragment " nose" ))))
330
+ testIsoURIRef
331
+ " foo://example.com:8042/over/there?name=ferret#"
332
+ (Left
333
+ (URI
334
+ (Just (Scheme " foo" ))
335
+ (HierarchicalPart (Just (Authority Nothing [(Tuple (NameAddress " example.com" ) (Just (Port 8042 )))] )) (Just (Right ((rootDir </> dir " over" ) </> file " there" ))))
336
+ (Just (Query (singleton (Tuple " name" (Just " ferret" )))))
337
+ (Just (Fragment " " ))))
324
338
testIsoURIRef
325
339
" foo://info.example.com?fred"
326
340
(Left
@@ -408,6 +422,25 @@ main = runTest $ suite "Data.URI" do
408
422
((Just (Right (rootDir </> dir " metadata" </> dir " fs" </> dir " test" </> file " Пациенты# #" )))))
409
423
(Just mempty)
410
424
Nothing ))
425
+ testIsoURIRef
426
+ " /top_story.htm"
427
+ (Left
428
+ (URI
429
+ Nothing
430
+ (HierarchicalPart
431
+ Nothing
432
+ (Just (Right (rootDir </> file " top_story.htm" ))))
433
+ Nothing
434
+ Nothing ))
435
+ testIsoURIRef
436
+ " ../top_story.htm"
437
+ (Right
438
+ (RelativeRef
439
+ (RelativePart
440
+ Nothing
441
+ (Just (Right (parentDir' currentDir </> file " top_story.htm" ))))
442
+ Nothing
443
+ Nothing ))
411
444
412
445
-- Not an iso in this case as the printed path is normalised
413
446
testRunParseURIRefParses
@@ -432,12 +465,11 @@ main = runTest $ suite "Data.URI" do
432
465
((Just mempty))
433
466
((Just (Fragment " ?sort=asc&q=path:/&salt=1177214" )))))
434
467
435
- testRunParseURIRefFailes " news:comp.infosystems.www.servers.unix"
436
- testRunParseURIRefFailes " tel:+1-816-555-1212"
437
- testRunParseURIRefFailes " urn:oasis:names:specification:docbook:dtd:xml:4.1.2"
438
- testRunParseURIRefFailes
" mailto:[email protected] "
439
- testRunParseURIRefFailes
" mailto:[email protected] "
440
- testRunParseURIRefFailes " /top_story.htm"
468
+ testRunParseURIRefFails " news:comp.infosystems.www.servers.unix"
469
+ testRunParseURIRefFails " tel:+1-816-555-1212"
470
+ testRunParseURIRefFails " urn:oasis:names:specification:docbook:dtd:xml:4.1.2"
471
+ testRunParseURIRefFails
" mailto:[email protected] "
472
+ testRunParseURIRefFails
" mailto:[email protected] "
441
473
442
474
suite " Query.print" do
443
475
testPrintQuerySerializes
@@ -456,16 +488,16 @@ main = runTest $ suite "Data.URI" do
456
488
457
489
suite " Query.parser" do
458
490
testParseQueryParses
459
- " key1=value1&key2=value2&key1=value3"
491
+ " ? key1=value1&key2=value2&key1=value3"
460
492
(Query (Tuple " key1" (Just " value1" ) : Tuple " key2" (Just " value2" ) : Tuple " key1" (Just " value3" ) : Nil ))
461
493
testParseQueryParses
462
- " key1&key2"
494
+ " ? key1&key2"
463
495
(Query (Tuple " key1" Nothing : Tuple " key2" Nothing : Nil ))
464
496
testParseQueryParses
465
- " key1=&key2="
497
+ " ? key1=&key2="
466
498
(Query (Tuple " key1" (Just " " ) : Tuple " key2" (Just " " ) : Nil ))
467
499
testParseQueryParses
468
- " key1=foo%3Bbar"
500
+ " ? key1=foo%3Bbar"
469
501
(Query (Tuple " key1" (Just " foo;bar" ) : Nil ))
470
502
471
503
suite " Common.match1From" do
0 commit comments